babylon.module.d.ts 6.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696
  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. * Restricts the camera to viewing objects with the same layerMask.
  10228. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10229. */
  10230. layerMask: number;
  10231. /**
  10232. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10233. */
  10234. isPickable: boolean;
  10235. /**
  10236. * Gets the hosting scene
  10237. */
  10238. scene: Scene;
  10239. /**
  10240. * Specifies the rendering group id for this mesh (0 by default)
  10241. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10242. */
  10243. renderingGroupId: number;
  10244. /**
  10245. * Defines the list of sprites managed by the manager.
  10246. */
  10247. sprites: Array<Sprite>;
  10248. /**
  10249. * Tests the intersection of a sprite with a specific ray.
  10250. * @param ray The ray we are sending to test the collision
  10251. * @param camera The camera space we are sending rays in
  10252. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10253. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10254. * @returns picking info or null.
  10255. */
  10256. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10257. /**
  10258. * Intersects the sprites with a ray
  10259. * @param ray defines the ray to intersect with
  10260. * @param camera defines the current active camera
  10261. * @param predicate defines a predicate used to select candidate sprites
  10262. * @returns null if no hit or a PickingInfo array
  10263. */
  10264. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10265. /**
  10266. * Renders the list of sprites on screen.
  10267. */
  10268. render(): void;
  10269. }
  10270. /**
  10271. * Class used to manage multiple sprites on the same spritesheet
  10272. * @see http://doc.babylonjs.com/babylon101/sprites
  10273. */
  10274. export class SpriteManager implements ISpriteManager {
  10275. /** defines the manager's name */
  10276. name: string;
  10277. /** Gets the list of sprites */
  10278. sprites: Sprite[];
  10279. /** Gets or sets the rendering group id (0 by default) */
  10280. renderingGroupId: number;
  10281. /** Gets or sets camera layer mask */
  10282. layerMask: number;
  10283. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10284. fogEnabled: boolean;
  10285. /** Gets or sets a boolean indicating if the sprites are pickable */
  10286. isPickable: boolean;
  10287. /** Defines the default width of a cell in the spritesheet */
  10288. cellWidth: number;
  10289. /** Defines the default height of a cell in the spritesheet */
  10290. cellHeight: number;
  10291. /** Associative array from JSON sprite data file */
  10292. private _cellData;
  10293. /** Array of sprite names from JSON sprite data file */
  10294. private _spriteMap;
  10295. /** True when packed cell data from JSON file is ready*/
  10296. private _packedAndReady;
  10297. private _textureContent;
  10298. /**
  10299. * An event triggered when the manager is disposed.
  10300. */
  10301. onDisposeObservable: Observable<SpriteManager>;
  10302. private _onDisposeObserver;
  10303. /**
  10304. * Callback called when the manager is disposed
  10305. */
  10306. set onDispose(callback: () => void);
  10307. private _capacity;
  10308. private _fromPacked;
  10309. private _spriteTexture;
  10310. private _epsilon;
  10311. private _scene;
  10312. private _vertexData;
  10313. private _buffer;
  10314. private _vertexBuffers;
  10315. private _indexBuffer;
  10316. private _effectBase;
  10317. private _effectFog;
  10318. /**
  10319. * Gets or sets the unique id of the sprite
  10320. */
  10321. uniqueId: number;
  10322. /**
  10323. * Gets the array of sprites
  10324. */
  10325. get children(): Sprite[];
  10326. /**
  10327. * Gets the hosting scene
  10328. */
  10329. get scene(): Scene;
  10330. /**
  10331. * Gets or sets the spritesheet texture
  10332. */
  10333. get texture(): Texture;
  10334. set texture(value: Texture);
  10335. private _blendMode;
  10336. /**
  10337. * Blend mode use to render the particle, it can be any of
  10338. * the static Constants.ALPHA_x properties provided in this class.
  10339. * Default value is Constants.ALPHA_COMBINE
  10340. */
  10341. get blendMode(): number;
  10342. set blendMode(blendMode: number);
  10343. /** Disables writing to the depth buffer when rendering the sprites.
  10344. * It can be handy to disable depth writing when using textures without alpha channel
  10345. * and setting some specific blend modes.
  10346. */
  10347. disableDepthWrite: boolean;
  10348. /**
  10349. * Creates a new sprite manager
  10350. * @param name defines the manager's name
  10351. * @param imgUrl defines the sprite sheet url
  10352. * @param capacity defines the maximum allowed number of sprites
  10353. * @param cellSize defines the size of a sprite cell
  10354. * @param scene defines the hosting scene
  10355. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10356. * @param samplingMode defines the smapling mode to use with spritesheet
  10357. * @param fromPacked set to false; do not alter
  10358. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10359. */
  10360. constructor(
  10361. /** defines the manager's name */
  10362. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10363. /**
  10364. * Returns the string "SpriteManager"
  10365. * @returns "SpriteManager"
  10366. */
  10367. getClassName(): string;
  10368. private _makePacked;
  10369. private _appendSpriteVertex;
  10370. private _checkTextureAlpha;
  10371. /**
  10372. * Intersects the sprites with a ray
  10373. * @param ray defines the ray to intersect with
  10374. * @param camera defines the current active camera
  10375. * @param predicate defines a predicate used to select candidate sprites
  10376. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10377. * @returns null if no hit or a PickingInfo
  10378. */
  10379. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10380. /**
  10381. * Intersects the sprites with a ray
  10382. * @param ray defines the ray to intersect with
  10383. * @param camera defines the current active camera
  10384. * @param predicate defines a predicate used to select candidate sprites
  10385. * @returns null if no hit or a PickingInfo array
  10386. */
  10387. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10388. /**
  10389. * Render all child sprites
  10390. */
  10391. render(): void;
  10392. /**
  10393. * Release associated resources
  10394. */
  10395. dispose(): void;
  10396. }
  10397. }
  10398. declare module "babylonjs/Misc/gradients" {
  10399. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10400. /** Interface used by value gradients (color, factor, ...) */
  10401. export interface IValueGradient {
  10402. /**
  10403. * Gets or sets the gradient value (between 0 and 1)
  10404. */
  10405. gradient: number;
  10406. }
  10407. /** Class used to store color4 gradient */
  10408. export class ColorGradient implements IValueGradient {
  10409. /**
  10410. * Gets or sets the gradient value (between 0 and 1)
  10411. */
  10412. gradient: number;
  10413. /**
  10414. * Gets or sets first associated color
  10415. */
  10416. color1: Color4;
  10417. /**
  10418. * Gets or sets second associated color
  10419. */
  10420. color2?: Color4 | undefined;
  10421. /**
  10422. * Creates a new color4 gradient
  10423. * @param gradient gets or sets the gradient value (between 0 and 1)
  10424. * @param color1 gets or sets first associated color
  10425. * @param color2 gets or sets first second color
  10426. */
  10427. constructor(
  10428. /**
  10429. * Gets or sets the gradient value (between 0 and 1)
  10430. */
  10431. gradient: number,
  10432. /**
  10433. * Gets or sets first associated color
  10434. */
  10435. color1: Color4,
  10436. /**
  10437. * Gets or sets second associated color
  10438. */
  10439. color2?: Color4 | undefined);
  10440. /**
  10441. * Will get a color picked randomly between color1 and color2.
  10442. * If color2 is undefined then color1 will be used
  10443. * @param result defines the target Color4 to store the result in
  10444. */
  10445. getColorToRef(result: Color4): void;
  10446. }
  10447. /** Class used to store color 3 gradient */
  10448. export class Color3Gradient implements IValueGradient {
  10449. /**
  10450. * Gets or sets the gradient value (between 0 and 1)
  10451. */
  10452. gradient: number;
  10453. /**
  10454. * Gets or sets the associated color
  10455. */
  10456. color: Color3;
  10457. /**
  10458. * Creates a new color3 gradient
  10459. * @param gradient gets or sets the gradient value (between 0 and 1)
  10460. * @param color gets or sets associated color
  10461. */
  10462. constructor(
  10463. /**
  10464. * Gets or sets the gradient value (between 0 and 1)
  10465. */
  10466. gradient: number,
  10467. /**
  10468. * Gets or sets the associated color
  10469. */
  10470. color: Color3);
  10471. }
  10472. /** Class used to store factor gradient */
  10473. export class FactorGradient implements IValueGradient {
  10474. /**
  10475. * Gets or sets the gradient value (between 0 and 1)
  10476. */
  10477. gradient: number;
  10478. /**
  10479. * Gets or sets first associated factor
  10480. */
  10481. factor1: number;
  10482. /**
  10483. * Gets or sets second associated factor
  10484. */
  10485. factor2?: number | undefined;
  10486. /**
  10487. * Creates a new factor gradient
  10488. * @param gradient gets or sets the gradient value (between 0 and 1)
  10489. * @param factor1 gets or sets first associated factor
  10490. * @param factor2 gets or sets second associated factor
  10491. */
  10492. constructor(
  10493. /**
  10494. * Gets or sets the gradient value (between 0 and 1)
  10495. */
  10496. gradient: number,
  10497. /**
  10498. * Gets or sets first associated factor
  10499. */
  10500. factor1: number,
  10501. /**
  10502. * Gets or sets second associated factor
  10503. */
  10504. factor2?: number | undefined);
  10505. /**
  10506. * Will get a number picked randomly between factor1 and factor2.
  10507. * If factor2 is undefined then factor1 will be used
  10508. * @returns the picked number
  10509. */
  10510. getFactor(): number;
  10511. }
  10512. /**
  10513. * Helper used to simplify some generic gradient tasks
  10514. */
  10515. export class GradientHelper {
  10516. /**
  10517. * Gets the current gradient from an array of IValueGradient
  10518. * @param ratio defines the current ratio to get
  10519. * @param gradients defines the array of IValueGradient
  10520. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10521. */
  10522. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10523. }
  10524. }
  10525. declare module "babylonjs/Maths/math.size" {
  10526. /**
  10527. * Interface for the size containing width and height
  10528. */
  10529. export interface ISize {
  10530. /**
  10531. * Width
  10532. */
  10533. width: number;
  10534. /**
  10535. * Heighht
  10536. */
  10537. height: number;
  10538. }
  10539. /**
  10540. * Size containing widht and height
  10541. */
  10542. export class Size implements ISize {
  10543. /**
  10544. * Width
  10545. */
  10546. width: number;
  10547. /**
  10548. * Height
  10549. */
  10550. height: number;
  10551. /**
  10552. * Creates a Size object from the given width and height (floats).
  10553. * @param width width of the new size
  10554. * @param height height of the new size
  10555. */
  10556. constructor(width: number, height: number);
  10557. /**
  10558. * Returns a string with the Size width and height
  10559. * @returns a string with the Size width and height
  10560. */
  10561. toString(): string;
  10562. /**
  10563. * "Size"
  10564. * @returns the string "Size"
  10565. */
  10566. getClassName(): string;
  10567. /**
  10568. * Returns the Size hash code.
  10569. * @returns a hash code for a unique width and height
  10570. */
  10571. getHashCode(): number;
  10572. /**
  10573. * Updates the current size from the given one.
  10574. * @param src the given size
  10575. */
  10576. copyFrom(src: Size): void;
  10577. /**
  10578. * Updates in place the current Size from the given floats.
  10579. * @param width width of the new size
  10580. * @param height height of the new size
  10581. * @returns the updated Size.
  10582. */
  10583. copyFromFloats(width: number, height: number): Size;
  10584. /**
  10585. * Updates in place the current Size from the given floats.
  10586. * @param width width to set
  10587. * @param height height to set
  10588. * @returns the updated Size.
  10589. */
  10590. set(width: number, height: number): Size;
  10591. /**
  10592. * Multiplies the width and height by numbers
  10593. * @param w factor to multiple the width by
  10594. * @param h factor to multiple the height by
  10595. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10596. */
  10597. multiplyByFloats(w: number, h: number): Size;
  10598. /**
  10599. * Clones the size
  10600. * @returns a new Size copied from the given one.
  10601. */
  10602. clone(): Size;
  10603. /**
  10604. * True if the current Size and the given one width and height are strictly equal.
  10605. * @param other the other size to compare against
  10606. * @returns True if the current Size and the given one width and height are strictly equal.
  10607. */
  10608. equals(other: Size): boolean;
  10609. /**
  10610. * The surface of the Size : width * height (float).
  10611. */
  10612. get surface(): number;
  10613. /**
  10614. * Create a new size of zero
  10615. * @returns a new Size set to (0.0, 0.0)
  10616. */
  10617. static Zero(): Size;
  10618. /**
  10619. * Sums the width and height of two sizes
  10620. * @param otherSize size to add to this size
  10621. * @returns a new Size set as the addition result of the current Size and the given one.
  10622. */
  10623. add(otherSize: Size): Size;
  10624. /**
  10625. * Subtracts the width and height of two
  10626. * @param otherSize size to subtract to this size
  10627. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10628. */
  10629. subtract(otherSize: Size): Size;
  10630. /**
  10631. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10632. * @param start starting size to lerp between
  10633. * @param end end size to lerp between
  10634. * @param amount amount to lerp between the start and end values
  10635. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10636. */
  10637. static Lerp(start: Size, end: Size, amount: number): Size;
  10638. }
  10639. }
  10640. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10642. import { Nullable } from "babylonjs/types";
  10643. module "babylonjs/Engines/thinEngine" {
  10644. interface ThinEngine {
  10645. /**
  10646. * Creates a dynamic texture
  10647. * @param width defines the width of the texture
  10648. * @param height defines the height of the texture
  10649. * @param generateMipMaps defines if the engine should generate the mip levels
  10650. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10651. * @returns the dynamic texture inside an InternalTexture
  10652. */
  10653. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10654. /**
  10655. * Update the content of a dynamic texture
  10656. * @param texture defines the texture to update
  10657. * @param canvas defines the canvas containing the source
  10658. * @param invertY defines if data must be stored with Y axis inverted
  10659. * @param premulAlpha defines if alpha is stored as premultiplied
  10660. * @param format defines the format of the data
  10661. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10662. */
  10663. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10664. }
  10665. }
  10666. }
  10667. declare module "babylonjs/Misc/canvasGenerator" {
  10668. /**
  10669. * Helper class used to generate a canvas to manipulate images
  10670. */
  10671. export class CanvasGenerator {
  10672. /**
  10673. * Create a new canvas (or offscreen canvas depending on the context)
  10674. * @param width defines the expected width
  10675. * @param height defines the expected height
  10676. * @return a new canvas or offscreen canvas
  10677. */
  10678. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10679. }
  10680. }
  10681. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10682. import { Scene } from "babylonjs/scene";
  10683. import { Texture } from "babylonjs/Materials/Textures/texture";
  10684. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10685. /**
  10686. * A class extending Texture allowing drawing on a texture
  10687. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10688. */
  10689. export class DynamicTexture extends Texture {
  10690. private _generateMipMaps;
  10691. private _canvas;
  10692. private _context;
  10693. /**
  10694. * Creates a DynamicTexture
  10695. * @param name defines the name of the texture
  10696. * @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
  10697. * @param scene defines the scene where you want the texture
  10698. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10699. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10700. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10701. */
  10702. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10703. /**
  10704. * Get the current class name of the texture useful for serialization or dynamic coding.
  10705. * @returns "DynamicTexture"
  10706. */
  10707. getClassName(): string;
  10708. /**
  10709. * Gets the current state of canRescale
  10710. */
  10711. get canRescale(): boolean;
  10712. private _recreate;
  10713. /**
  10714. * Scales the texture
  10715. * @param ratio the scale factor to apply to both width and height
  10716. */
  10717. scale(ratio: number): void;
  10718. /**
  10719. * Resizes the texture
  10720. * @param width the new width
  10721. * @param height the new height
  10722. */
  10723. scaleTo(width: number, height: number): void;
  10724. /**
  10725. * Gets the context of the canvas used by the texture
  10726. * @returns the canvas context of the dynamic texture
  10727. */
  10728. getContext(): CanvasRenderingContext2D;
  10729. /**
  10730. * Clears the texture
  10731. */
  10732. clear(): void;
  10733. /**
  10734. * Updates the texture
  10735. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10736. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10737. */
  10738. update(invertY?: boolean, premulAlpha?: boolean): void;
  10739. /**
  10740. * Draws text onto the texture
  10741. * @param text defines the text to be drawn
  10742. * @param x defines the placement of the text from the left
  10743. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10744. * @param font defines the font to be used with font-style, font-size, font-name
  10745. * @param color defines the color used for the text
  10746. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10747. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10748. * @param update defines whether texture is immediately update (default is true)
  10749. */
  10750. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10751. /**
  10752. * Clones the texture
  10753. * @returns the clone of the texture.
  10754. */
  10755. clone(): DynamicTexture;
  10756. /**
  10757. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10758. * @returns a serialized dynamic texture object
  10759. */
  10760. serialize(): any;
  10761. /** @hidden */
  10762. _rebuild(): void;
  10763. }
  10764. }
  10765. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10766. import { Nullable } from "babylonjs/types";
  10767. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10768. import { Scene } from "babylonjs/scene";
  10769. module "babylonjs/Engines/thinEngine" {
  10770. interface ThinEngine {
  10771. /**
  10772. * Creates a raw texture
  10773. * @param data defines the data to store in the texture
  10774. * @param width defines the width of the texture
  10775. * @param height defines the height of the texture
  10776. * @param format defines the format of the data
  10777. * @param generateMipMaps defines if the engine should generate the mip levels
  10778. * @param invertY defines if data must be stored with Y axis inverted
  10779. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10780. * @param compression defines the compression used (null by default)
  10781. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10782. * @returns the raw texture inside an InternalTexture
  10783. */
  10784. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10785. /**
  10786. * Update a raw texture
  10787. * @param texture defines the texture to update
  10788. * @param data defines the data to store in the texture
  10789. * @param format defines the format of the data
  10790. * @param invertY defines if data must be stored with Y axis inverted
  10791. */
  10792. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10793. /**
  10794. * Update a raw texture
  10795. * @param texture defines the texture to update
  10796. * @param data defines the data to store in the texture
  10797. * @param format defines the format of the data
  10798. * @param invertY defines if data must be stored with Y axis inverted
  10799. * @param compression defines the compression used (null by default)
  10800. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10801. */
  10802. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10803. /**
  10804. * Creates a new raw cube texture
  10805. * @param data defines the array of data to use to create each face
  10806. * @param size defines the size of the textures
  10807. * @param format defines the format of the data
  10808. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10809. * @param generateMipMaps defines if the engine should generate the mip levels
  10810. * @param invertY defines if data must be stored with Y axis inverted
  10811. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10812. * @param compression defines the compression used (null by default)
  10813. * @returns the cube texture as an InternalTexture
  10814. */
  10815. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10816. /**
  10817. * Update a raw cube texture
  10818. * @param texture defines the texture to udpdate
  10819. * @param data defines the data to store
  10820. * @param format defines the data format
  10821. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10822. * @param invertY defines if data must be stored with Y axis inverted
  10823. */
  10824. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10825. /**
  10826. * Update a raw cube texture
  10827. * @param texture defines the texture to udpdate
  10828. * @param data defines the data to store
  10829. * @param format defines the data format
  10830. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10831. * @param invertY defines if data must be stored with Y axis inverted
  10832. * @param compression defines the compression used (null by default)
  10833. */
  10834. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10835. /**
  10836. * Update a raw cube texture
  10837. * @param texture defines the texture to udpdate
  10838. * @param data defines the data to store
  10839. * @param format defines the data format
  10840. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10841. * @param invertY defines if data must be stored with Y axis inverted
  10842. * @param compression defines the compression used (null by default)
  10843. * @param level defines which level of the texture to update
  10844. */
  10845. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10846. /**
  10847. * Creates a new raw cube texture from a specified url
  10848. * @param url defines the url where the data is located
  10849. * @param scene defines the current scene
  10850. * @param size defines the size of the textures
  10851. * @param format defines the format of the data
  10852. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10853. * @param noMipmap defines if the engine should avoid generating the mip levels
  10854. * @param callback defines a callback used to extract texture data from loaded data
  10855. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10856. * @param onLoad defines a callback called when texture is loaded
  10857. * @param onError defines a callback called if there is an error
  10858. * @returns the cube texture as an InternalTexture
  10859. */
  10860. 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;
  10861. /**
  10862. * Creates a new raw cube texture from a specified url
  10863. * @param url defines the url where the data is located
  10864. * @param scene defines the current scene
  10865. * @param size defines the size of the textures
  10866. * @param format defines the format of the data
  10867. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10868. * @param noMipmap defines if the engine should avoid generating the mip levels
  10869. * @param callback defines a callback used to extract texture data from loaded data
  10870. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10871. * @param onLoad defines a callback called when texture is loaded
  10872. * @param onError defines a callback called if there is an error
  10873. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10874. * @param invertY defines if data must be stored with Y axis inverted
  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>, samplingMode: number, invertY: boolean): InternalTexture;
  10878. /**
  10879. * Creates a new raw 3D texture
  10880. * @param data defines the data used to create the texture
  10881. * @param width defines the width of the texture
  10882. * @param height defines the height of the texture
  10883. * @param depth defines the depth of the texture
  10884. * @param format defines the format of the texture
  10885. * @param generateMipMaps defines if the engine must generate mip levels
  10886. * @param invertY defines if data must be stored with Y axis inverted
  10887. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10888. * @param compression defines the compressed used (can be null)
  10889. * @param textureType defines the compressed used (can be null)
  10890. * @returns a new raw 3D texture (stored in an InternalTexture)
  10891. */
  10892. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10893. /**
  10894. * Update a raw 3D texture
  10895. * @param texture defines the texture to update
  10896. * @param data defines the data to store
  10897. * @param format defines the data format
  10898. * @param invertY defines if data must be stored with Y axis inverted
  10899. */
  10900. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10901. /**
  10902. * Update a raw 3D texture
  10903. * @param texture defines the texture to update
  10904. * @param data defines the data to store
  10905. * @param format defines the data format
  10906. * @param invertY defines if data must be stored with Y axis inverted
  10907. * @param compression defines the used compression (can be null)
  10908. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10909. */
  10910. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10911. /**
  10912. * Creates a new raw 2D array texture
  10913. * @param data defines the data used to create the texture
  10914. * @param width defines the width of the texture
  10915. * @param height defines the height of the texture
  10916. * @param depth defines the number of layers of the texture
  10917. * @param format defines the format of the texture
  10918. * @param generateMipMaps defines if the engine must generate mip levels
  10919. * @param invertY defines if data must be stored with Y axis inverted
  10920. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10921. * @param compression defines the compressed used (can be null)
  10922. * @param textureType defines the compressed used (can be null)
  10923. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10924. */
  10925. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10926. /**
  10927. * Update a raw 2D array texture
  10928. * @param texture defines the texture to update
  10929. * @param data defines the data to store
  10930. * @param format defines the data format
  10931. * @param invertY defines if data must be stored with Y axis inverted
  10932. */
  10933. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10934. /**
  10935. * Update a raw 2D array texture
  10936. * @param texture defines the texture to update
  10937. * @param data defines the data to store
  10938. * @param format defines the data format
  10939. * @param invertY defines if data must be stored with Y axis inverted
  10940. * @param compression defines the used compression (can be null)
  10941. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10942. */
  10943. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10944. }
  10945. }
  10946. }
  10947. declare module "babylonjs/Materials/Textures/rawTexture" {
  10948. import { Scene } from "babylonjs/scene";
  10949. import { Texture } from "babylonjs/Materials/Textures/texture";
  10950. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10951. /**
  10952. * Raw texture can help creating a texture directly from an array of data.
  10953. * This can be super useful if you either get the data from an uncompressed source or
  10954. * if you wish to create your texture pixel by pixel.
  10955. */
  10956. export class RawTexture extends Texture {
  10957. /**
  10958. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10959. */
  10960. format: number;
  10961. /**
  10962. * Instantiates a new RawTexture.
  10963. * Raw texture can help creating a texture directly from an array of data.
  10964. * This can be super useful if you either get the data from an uncompressed source or
  10965. * if you wish to create your texture pixel by pixel.
  10966. * @param data define the array of data to use to create the texture
  10967. * @param width define the width of the texture
  10968. * @param height define the height of the texture
  10969. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10970. * @param scene define the scene the texture belongs to
  10971. * @param generateMipMaps define whether mip maps should be generated or not
  10972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10975. */
  10976. constructor(data: ArrayBufferView, width: number, height: number,
  10977. /**
  10978. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10979. */
  10980. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10981. /**
  10982. * Updates the texture underlying data.
  10983. * @param data Define the new data of the texture
  10984. */
  10985. update(data: ArrayBufferView): void;
  10986. /**
  10987. * Creates a luminance texture from some data.
  10988. * @param data Define the texture data
  10989. * @param width Define the width of the texture
  10990. * @param height Define the height of the texture
  10991. * @param scene Define the scene the texture belongs to
  10992. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10993. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10994. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10995. * @returns the luminance texture
  10996. */
  10997. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10998. /**
  10999. * Creates a luminance alpha texture from some data.
  11000. * @param data Define the texture data
  11001. * @param width Define the width of the texture
  11002. * @param height Define the height of the texture
  11003. * @param scene Define the scene the texture belongs to
  11004. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11005. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11006. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11007. * @returns the luminance alpha texture
  11008. */
  11009. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11010. /**
  11011. * Creates an alpha texture from some data.
  11012. * @param data Define the texture data
  11013. * @param width Define the width of the texture
  11014. * @param height Define the height of the texture
  11015. * @param scene Define the scene the texture belongs to
  11016. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11017. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11018. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11019. * @returns the alpha texture
  11020. */
  11021. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11022. /**
  11023. * Creates a RGB texture from some data.
  11024. * @param data Define the texture data
  11025. * @param width Define the width of the texture
  11026. * @param height Define the height of the texture
  11027. * @param scene Define the scene the texture belongs to
  11028. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11029. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11030. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11031. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11032. * @returns the RGB alpha texture
  11033. */
  11034. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11035. /**
  11036. * Creates a RGBA texture from some data.
  11037. * @param data Define the texture data
  11038. * @param width Define the width of the texture
  11039. * @param height Define the height of the texture
  11040. * @param scene Define the scene the texture belongs to
  11041. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11042. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11043. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11044. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11045. * @returns the RGBA texture
  11046. */
  11047. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11048. /**
  11049. * Creates a R texture from some data.
  11050. * @param data Define the texture data
  11051. * @param width Define the width of the texture
  11052. * @param height Define the height of the texture
  11053. * @param scene Define the scene the texture belongs to
  11054. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11055. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11056. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11057. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11058. * @returns the R texture
  11059. */
  11060. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11061. }
  11062. }
  11063. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11064. import { Scene } from "babylonjs/scene";
  11065. import { ISceneComponent } from "babylonjs/sceneComponent";
  11066. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11067. module "babylonjs/abstractScene" {
  11068. interface AbstractScene {
  11069. /**
  11070. * The list of procedural textures added to the scene
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11072. */
  11073. proceduralTextures: Array<ProceduralTexture>;
  11074. }
  11075. }
  11076. /**
  11077. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11078. * in a given scene.
  11079. */
  11080. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11081. /**
  11082. * The component name helpfull to identify the component in the list of scene components.
  11083. */
  11084. readonly name: string;
  11085. /**
  11086. * The scene the component belongs to.
  11087. */
  11088. scene: Scene;
  11089. /**
  11090. * Creates a new instance of the component for the given scene
  11091. * @param scene Defines the scene to register the component in
  11092. */
  11093. constructor(scene: Scene);
  11094. /**
  11095. * Registers the component in a given scene
  11096. */
  11097. register(): void;
  11098. /**
  11099. * Rebuilds the elements related to this component in case of
  11100. * context lost for instance.
  11101. */
  11102. rebuild(): void;
  11103. /**
  11104. * Disposes the component and the associated ressources.
  11105. */
  11106. dispose(): void;
  11107. private _beforeClear;
  11108. }
  11109. }
  11110. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11111. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11112. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11113. module "babylonjs/Engines/thinEngine" {
  11114. interface ThinEngine {
  11115. /**
  11116. * Creates a new render target cube texture
  11117. * @param size defines the size of the texture
  11118. * @param options defines the options used to create the texture
  11119. * @returns a new render target cube texture stored in an InternalTexture
  11120. */
  11121. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11122. }
  11123. }
  11124. }
  11125. declare module "babylonjs/Shaders/procedural.vertex" {
  11126. /** @hidden */
  11127. export var proceduralVertexShader: {
  11128. name: string;
  11129. shader: string;
  11130. };
  11131. }
  11132. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11133. import { Observable } from "babylonjs/Misc/observable";
  11134. import { Nullable } from "babylonjs/types";
  11135. import { Scene } from "babylonjs/scene";
  11136. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11137. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11138. import { Effect } from "babylonjs/Materials/effect";
  11139. import { Texture } from "babylonjs/Materials/Textures/texture";
  11140. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11141. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11142. import "babylonjs/Shaders/procedural.vertex";
  11143. /**
  11144. * 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.
  11145. * This is the base class of any Procedural texture and contains most of the shareable code.
  11146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11147. */
  11148. export class ProceduralTexture extends Texture {
  11149. isCube: boolean;
  11150. /**
  11151. * Define if the texture is enabled or not (disabled texture will not render)
  11152. */
  11153. isEnabled: boolean;
  11154. /**
  11155. * Define if the texture must be cleared before rendering (default is true)
  11156. */
  11157. autoClear: boolean;
  11158. /**
  11159. * Callback called when the texture is generated
  11160. */
  11161. onGenerated: () => void;
  11162. /**
  11163. * Event raised when the texture is generated
  11164. */
  11165. onGeneratedObservable: Observable<ProceduralTexture>;
  11166. /** @hidden */
  11167. _generateMipMaps: boolean;
  11168. /** @hidden **/
  11169. _effect: Effect;
  11170. /** @hidden */
  11171. _textures: {
  11172. [key: string]: Texture;
  11173. };
  11174. /** @hidden */
  11175. protected _fallbackTexture: Nullable<Texture>;
  11176. private _size;
  11177. private _currentRefreshId;
  11178. private _frameId;
  11179. private _refreshRate;
  11180. private _vertexBuffers;
  11181. private _indexBuffer;
  11182. private _uniforms;
  11183. private _samplers;
  11184. private _fragment;
  11185. private _floats;
  11186. private _ints;
  11187. private _floatsArrays;
  11188. private _colors3;
  11189. private _colors4;
  11190. private _vectors2;
  11191. private _vectors3;
  11192. private _matrices;
  11193. private _fallbackTextureUsed;
  11194. private _fullEngine;
  11195. private _cachedDefines;
  11196. private _contentUpdateId;
  11197. private _contentData;
  11198. /**
  11199. * Instantiates a new procedural texture.
  11200. * 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.
  11201. * This is the base class of any Procedural texture and contains most of the shareable code.
  11202. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11203. * @param name Define the name of the texture
  11204. * @param size Define the size of the texture to create
  11205. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11206. * @param scene Define the scene the texture belongs to
  11207. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11208. * @param generateMipMaps Define if the texture should creates mip maps or not
  11209. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11210. */
  11211. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11212. /**
  11213. * The effect that is created when initializing the post process.
  11214. * @returns The created effect corresponding the the postprocess.
  11215. */
  11216. getEffect(): Effect;
  11217. /**
  11218. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11219. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11220. */
  11221. getContent(): Nullable<ArrayBufferView>;
  11222. private _createIndexBuffer;
  11223. /** @hidden */
  11224. _rebuild(): void;
  11225. /**
  11226. * Resets the texture in order to recreate its associated resources.
  11227. * This can be called in case of context loss
  11228. */
  11229. reset(): void;
  11230. protected _getDefines(): string;
  11231. /**
  11232. * Is the texture ready to be used ? (rendered at least once)
  11233. * @returns true if ready, otherwise, false.
  11234. */
  11235. isReady(): boolean;
  11236. /**
  11237. * Resets the refresh counter of the texture and start bak from scratch.
  11238. * Could be useful to regenerate the texture if it is setup to render only once.
  11239. */
  11240. resetRefreshCounter(): void;
  11241. /**
  11242. * Set the fragment shader to use in order to render the texture.
  11243. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11244. */
  11245. setFragment(fragment: any): void;
  11246. /**
  11247. * Define the refresh rate of the texture or the rendering frequency.
  11248. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11249. */
  11250. get refreshRate(): number;
  11251. set refreshRate(value: number);
  11252. /** @hidden */
  11253. _shouldRender(): boolean;
  11254. /**
  11255. * Get the size the texture is rendering at.
  11256. * @returns the size (texture is always squared)
  11257. */
  11258. getRenderSize(): number;
  11259. /**
  11260. * Resize the texture to new value.
  11261. * @param size Define the new size the texture should have
  11262. * @param generateMipMaps Define whether the new texture should create mip maps
  11263. */
  11264. resize(size: number, generateMipMaps: boolean): void;
  11265. private _checkUniform;
  11266. /**
  11267. * Set a texture in the shader program used to render.
  11268. * @param name Define the name of the uniform samplers as defined in the shader
  11269. * @param texture Define the texture to bind to this sampler
  11270. * @return the texture itself allowing "fluent" like uniform updates
  11271. */
  11272. setTexture(name: string, texture: Texture): ProceduralTexture;
  11273. /**
  11274. * Set a float in the shader.
  11275. * @param name Define the name of the uniform as defined in the shader
  11276. * @param value Define the value to give to the uniform
  11277. * @return the texture itself allowing "fluent" like uniform updates
  11278. */
  11279. setFloat(name: string, value: number): ProceduralTexture;
  11280. /**
  11281. * Set a int in the shader.
  11282. * @param name Define the name of the uniform as defined in the shader
  11283. * @param value Define the value to give to the uniform
  11284. * @return the texture itself allowing "fluent" like uniform updates
  11285. */
  11286. setInt(name: string, value: number): ProceduralTexture;
  11287. /**
  11288. * Set an array of floats in the shader.
  11289. * @param name Define the name of the uniform as defined in the shader
  11290. * @param value Define the value to give to the uniform
  11291. * @return the texture itself allowing "fluent" like uniform updates
  11292. */
  11293. setFloats(name: string, value: number[]): ProceduralTexture;
  11294. /**
  11295. * Set a vec3 in the shader from a Color3.
  11296. * @param name Define the name of the uniform as defined in the shader
  11297. * @param value Define the value to give to the uniform
  11298. * @return the texture itself allowing "fluent" like uniform updates
  11299. */
  11300. setColor3(name: string, value: Color3): ProceduralTexture;
  11301. /**
  11302. * Set a vec4 in the shader from a Color4.
  11303. * @param name Define the name of the uniform as defined in the shader
  11304. * @param value Define the value to give to the uniform
  11305. * @return the texture itself allowing "fluent" like uniform updates
  11306. */
  11307. setColor4(name: string, value: Color4): ProceduralTexture;
  11308. /**
  11309. * Set a vec2 in the shader from a Vector2.
  11310. * @param name Define the name of the uniform as defined in the shader
  11311. * @param value Define the value to give to the uniform
  11312. * @return the texture itself allowing "fluent" like uniform updates
  11313. */
  11314. setVector2(name: string, value: Vector2): ProceduralTexture;
  11315. /**
  11316. * Set a vec3 in the shader from a Vector3.
  11317. * @param name Define the name of the uniform as defined in the shader
  11318. * @param value Define the value to give to the uniform
  11319. * @return the texture itself allowing "fluent" like uniform updates
  11320. */
  11321. setVector3(name: string, value: Vector3): ProceduralTexture;
  11322. /**
  11323. * Set a mat4 in the shader from a MAtrix.
  11324. * @param name Define the name of the uniform as defined in the shader
  11325. * @param value Define the value to give to the uniform
  11326. * @return the texture itself allowing "fluent" like uniform updates
  11327. */
  11328. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11329. /**
  11330. * Render the texture to its associated render target.
  11331. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11332. */
  11333. render(useCameraPostProcess?: boolean): void;
  11334. /**
  11335. * Clone the texture.
  11336. * @returns the cloned texture
  11337. */
  11338. clone(): ProceduralTexture;
  11339. /**
  11340. * Dispose the texture and release its asoociated resources.
  11341. */
  11342. dispose(): void;
  11343. }
  11344. }
  11345. declare module "babylonjs/Particles/baseParticleSystem" {
  11346. import { Nullable } from "babylonjs/types";
  11347. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11349. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11350. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11351. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11354. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11355. import { Texture } from "babylonjs/Materials/Textures/texture";
  11356. import { Color4 } from "babylonjs/Maths/math.color";
  11357. import { Animation } from "babylonjs/Animations/animation";
  11358. /**
  11359. * This represents the base class for particle system in Babylon.
  11360. * 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.
  11361. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11362. * @example https://doc.babylonjs.com/babylon101/particles
  11363. */
  11364. export class BaseParticleSystem {
  11365. /**
  11366. * Source color is added to the destination color without alpha affecting the result
  11367. */
  11368. static BLENDMODE_ONEONE: number;
  11369. /**
  11370. * Blend current color and particle color using particle’s alpha
  11371. */
  11372. static BLENDMODE_STANDARD: number;
  11373. /**
  11374. * Add current color and particle color multiplied by particle’s alpha
  11375. */
  11376. static BLENDMODE_ADD: number;
  11377. /**
  11378. * Multiply current color with particle color
  11379. */
  11380. static BLENDMODE_MULTIPLY: number;
  11381. /**
  11382. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11383. */
  11384. static BLENDMODE_MULTIPLYADD: number;
  11385. /**
  11386. * List of animations used by the particle system.
  11387. */
  11388. animations: Animation[];
  11389. /**
  11390. * Gets or sets the unique id of the particle system
  11391. */
  11392. uniqueId: number;
  11393. /**
  11394. * The id of the Particle system.
  11395. */
  11396. id: string;
  11397. /**
  11398. * The friendly name of the Particle system.
  11399. */
  11400. name: string;
  11401. /**
  11402. * Snippet ID if the particle system was created from the snippet server
  11403. */
  11404. snippetId: string;
  11405. /**
  11406. * The rendering group used by the Particle system to chose when to render.
  11407. */
  11408. renderingGroupId: number;
  11409. /**
  11410. * The emitter represents the Mesh or position we are attaching the particle system to.
  11411. */
  11412. emitter: Nullable<AbstractMesh | Vector3>;
  11413. /**
  11414. * The maximum number of particles to emit per frame
  11415. */
  11416. emitRate: number;
  11417. /**
  11418. * If you want to launch only a few particles at once, that can be done, as well.
  11419. */
  11420. manualEmitCount: number;
  11421. /**
  11422. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11423. */
  11424. updateSpeed: number;
  11425. /**
  11426. * The amount of time the particle system is running (depends of the overall update speed).
  11427. */
  11428. targetStopDuration: number;
  11429. /**
  11430. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11431. */
  11432. disposeOnStop: boolean;
  11433. /**
  11434. * Minimum power of emitting particles.
  11435. */
  11436. minEmitPower: number;
  11437. /**
  11438. * Maximum power of emitting particles.
  11439. */
  11440. maxEmitPower: number;
  11441. /**
  11442. * Minimum life time of emitting particles.
  11443. */
  11444. minLifeTime: number;
  11445. /**
  11446. * Maximum life time of emitting particles.
  11447. */
  11448. maxLifeTime: number;
  11449. /**
  11450. * Minimum Size of emitting particles.
  11451. */
  11452. minSize: number;
  11453. /**
  11454. * Maximum Size of emitting particles.
  11455. */
  11456. maxSize: number;
  11457. /**
  11458. * Minimum scale of emitting particles on X axis.
  11459. */
  11460. minScaleX: number;
  11461. /**
  11462. * Maximum scale of emitting particles on X axis.
  11463. */
  11464. maxScaleX: number;
  11465. /**
  11466. * Minimum scale of emitting particles on Y axis.
  11467. */
  11468. minScaleY: number;
  11469. /**
  11470. * Maximum scale of emitting particles on Y axis.
  11471. */
  11472. maxScaleY: number;
  11473. /**
  11474. * Gets or sets the minimal initial rotation in radians.
  11475. */
  11476. minInitialRotation: number;
  11477. /**
  11478. * Gets or sets the maximal initial rotation in radians.
  11479. */
  11480. maxInitialRotation: number;
  11481. /**
  11482. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11483. */
  11484. minAngularSpeed: number;
  11485. /**
  11486. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11487. */
  11488. maxAngularSpeed: number;
  11489. /**
  11490. * The texture used to render each particle. (this can be a spritesheet)
  11491. */
  11492. particleTexture: Nullable<Texture>;
  11493. /**
  11494. * The layer mask we are rendering the particles through.
  11495. */
  11496. layerMask: number;
  11497. /**
  11498. * This can help using your own shader to render the particle system.
  11499. * The according effect will be created
  11500. */
  11501. customShader: any;
  11502. /**
  11503. * By default particle system starts as soon as they are created. This prevents the
  11504. * automatic start to happen and let you decide when to start emitting particles.
  11505. */
  11506. preventAutoStart: boolean;
  11507. private _noiseTexture;
  11508. /**
  11509. * Gets or sets a texture used to add random noise to particle positions
  11510. */
  11511. get noiseTexture(): Nullable<ProceduralTexture>;
  11512. set noiseTexture(value: Nullable<ProceduralTexture>);
  11513. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11514. noiseStrength: Vector3;
  11515. /**
  11516. * Callback triggered when the particle animation is ending.
  11517. */
  11518. onAnimationEnd: Nullable<() => void>;
  11519. /**
  11520. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11521. */
  11522. blendMode: number;
  11523. /**
  11524. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11525. * to override the particles.
  11526. */
  11527. forceDepthWrite: boolean;
  11528. /** 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 */
  11529. preWarmCycles: number;
  11530. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11531. preWarmStepOffset: number;
  11532. /**
  11533. * 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)
  11534. */
  11535. spriteCellChangeSpeed: number;
  11536. /**
  11537. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11538. */
  11539. startSpriteCellID: number;
  11540. /**
  11541. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11542. */
  11543. endSpriteCellID: number;
  11544. /**
  11545. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11546. */
  11547. spriteCellWidth: number;
  11548. /**
  11549. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11550. */
  11551. spriteCellHeight: number;
  11552. /**
  11553. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11554. */
  11555. spriteRandomStartCell: boolean;
  11556. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11557. translationPivot: Vector2;
  11558. /** @hidden */
  11559. protected _isAnimationSheetEnabled: boolean;
  11560. /**
  11561. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11562. */
  11563. beginAnimationOnStart: boolean;
  11564. /**
  11565. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11566. */
  11567. beginAnimationFrom: number;
  11568. /**
  11569. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11570. */
  11571. beginAnimationTo: number;
  11572. /**
  11573. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11574. */
  11575. beginAnimationLoop: boolean;
  11576. /**
  11577. * Gets or sets a world offset applied to all particles
  11578. */
  11579. worldOffset: Vector3;
  11580. /**
  11581. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11582. */
  11583. get isAnimationSheetEnabled(): boolean;
  11584. set isAnimationSheetEnabled(value: boolean);
  11585. /**
  11586. * Get hosting scene
  11587. * @returns the scene
  11588. */
  11589. getScene(): Scene;
  11590. /**
  11591. * You can use gravity if you want to give an orientation to your particles.
  11592. */
  11593. gravity: Vector3;
  11594. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11595. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11596. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11597. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11598. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11599. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11600. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11601. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11602. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11603. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11604. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11605. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11606. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11607. /**
  11608. * Defines the delay in milliseconds before starting the system (0 by default)
  11609. */
  11610. startDelay: number;
  11611. /**
  11612. * Gets the current list of drag gradients.
  11613. * You must use addDragGradient and removeDragGradient to udpate this list
  11614. * @returns the list of drag gradients
  11615. */
  11616. getDragGradients(): Nullable<Array<FactorGradient>>;
  11617. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11618. limitVelocityDamping: number;
  11619. /**
  11620. * Gets the current list of limit velocity gradients.
  11621. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11622. * @returns the list of limit velocity gradients
  11623. */
  11624. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11625. /**
  11626. * Gets the current list of color gradients.
  11627. * You must use addColorGradient and removeColorGradient to udpate this list
  11628. * @returns the list of color gradients
  11629. */
  11630. getColorGradients(): Nullable<Array<ColorGradient>>;
  11631. /**
  11632. * Gets the current list of size gradients.
  11633. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11634. * @returns the list of size gradients
  11635. */
  11636. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11637. /**
  11638. * Gets the current list of color remap gradients.
  11639. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11640. * @returns the list of color remap gradients
  11641. */
  11642. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11643. /**
  11644. * Gets the current list of alpha remap gradients.
  11645. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11646. * @returns the list of alpha remap gradients
  11647. */
  11648. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11649. /**
  11650. * Gets the current list of life time gradients.
  11651. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11652. * @returns the list of life time gradients
  11653. */
  11654. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11655. /**
  11656. * Gets the current list of angular speed gradients.
  11657. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11658. * @returns the list of angular speed gradients
  11659. */
  11660. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11661. /**
  11662. * Gets the current list of velocity gradients.
  11663. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11664. * @returns the list of velocity gradients
  11665. */
  11666. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11667. /**
  11668. * Gets the current list of start size gradients.
  11669. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11670. * @returns the list of start size gradients
  11671. */
  11672. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11673. /**
  11674. * Gets the current list of emit rate gradients.
  11675. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11676. * @returns the list of emit rate gradients
  11677. */
  11678. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11679. /**
  11680. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11681. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11682. */
  11683. get direction1(): Vector3;
  11684. set direction1(value: Vector3);
  11685. /**
  11686. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11687. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11688. */
  11689. get direction2(): Vector3;
  11690. set direction2(value: Vector3);
  11691. /**
  11692. * 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.
  11693. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11694. */
  11695. get minEmitBox(): Vector3;
  11696. set minEmitBox(value: Vector3);
  11697. /**
  11698. * 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.
  11699. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11700. */
  11701. get maxEmitBox(): Vector3;
  11702. set maxEmitBox(value: Vector3);
  11703. /**
  11704. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11705. */
  11706. color1: Color4;
  11707. /**
  11708. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11709. */
  11710. color2: Color4;
  11711. /**
  11712. * Color the particle will have at the end of its lifetime
  11713. */
  11714. colorDead: Color4;
  11715. /**
  11716. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11717. */
  11718. textureMask: Color4;
  11719. /**
  11720. * The particle emitter type defines the emitter used by the particle system.
  11721. * It can be for example box, sphere, or cone...
  11722. */
  11723. particleEmitterType: IParticleEmitterType;
  11724. /** @hidden */
  11725. _isSubEmitter: boolean;
  11726. /**
  11727. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11728. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11729. */
  11730. billboardMode: number;
  11731. protected _isBillboardBased: boolean;
  11732. /**
  11733. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11734. */
  11735. get isBillboardBased(): boolean;
  11736. set isBillboardBased(value: boolean);
  11737. /**
  11738. * The scene the particle system belongs to.
  11739. */
  11740. protected _scene: Scene;
  11741. /**
  11742. * Local cache of defines for image processing.
  11743. */
  11744. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11745. /**
  11746. * Default configuration related to image processing available in the standard Material.
  11747. */
  11748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11749. /**
  11750. * Gets the image processing configuration used either in this material.
  11751. */
  11752. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11753. /**
  11754. * Sets the Default image processing configuration used either in the this material.
  11755. *
  11756. * If sets to null, the scene one is in use.
  11757. */
  11758. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11759. /**
  11760. * Attaches a new image processing configuration to the Standard Material.
  11761. * @param configuration
  11762. */
  11763. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11764. /** @hidden */
  11765. protected _reset(): void;
  11766. /** @hidden */
  11767. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11768. /**
  11769. * Instantiates a particle system.
  11770. * 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.
  11771. * @param name The name of the particle system
  11772. */
  11773. constructor(name: string);
  11774. /**
  11775. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11776. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11777. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11778. * @returns the emitter
  11779. */
  11780. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11781. /**
  11782. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11783. * @param radius The radius of the hemisphere to emit from
  11784. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11785. * @returns the emitter
  11786. */
  11787. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11788. /**
  11789. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11790. * @param radius The radius of the sphere to emit from
  11791. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11792. * @returns the emitter
  11793. */
  11794. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11795. /**
  11796. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11797. * @param radius The radius of the sphere to emit from
  11798. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11799. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11800. * @returns the emitter
  11801. */
  11802. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11803. /**
  11804. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11805. * @param radius The radius of the emission cylinder
  11806. * @param height The height of the emission cylinder
  11807. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11808. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11809. * @returns the emitter
  11810. */
  11811. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11812. /**
  11813. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11814. * @param radius The radius of the cylinder to emit from
  11815. * @param height The height of the emission cylinder
  11816. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11817. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11818. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11819. * @returns the emitter
  11820. */
  11821. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11822. /**
  11823. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11824. * @param radius The radius of the cone to emit from
  11825. * @param angle The base angle of the cone
  11826. * @returns the emitter
  11827. */
  11828. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11829. /**
  11830. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11831. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11832. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11833. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11834. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11835. * @returns the emitter
  11836. */
  11837. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11838. }
  11839. }
  11840. declare module "babylonjs/Particles/subEmitter" {
  11841. import { Scene } from "babylonjs/scene";
  11842. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11843. /**
  11844. * Type of sub emitter
  11845. */
  11846. export enum SubEmitterType {
  11847. /**
  11848. * Attached to the particle over it's lifetime
  11849. */
  11850. ATTACHED = 0,
  11851. /**
  11852. * Created when the particle dies
  11853. */
  11854. END = 1
  11855. }
  11856. /**
  11857. * Sub emitter class used to emit particles from an existing particle
  11858. */
  11859. export class SubEmitter {
  11860. /**
  11861. * the particle system to be used by the sub emitter
  11862. */
  11863. particleSystem: ParticleSystem;
  11864. /**
  11865. * Type of the submitter (Default: END)
  11866. */
  11867. type: SubEmitterType;
  11868. /**
  11869. * 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)
  11870. * Note: This only is supported when using an emitter of type Mesh
  11871. */
  11872. inheritDirection: boolean;
  11873. /**
  11874. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11875. */
  11876. inheritedVelocityAmount: number;
  11877. /**
  11878. * Creates a sub emitter
  11879. * @param particleSystem the particle system to be used by the sub emitter
  11880. */
  11881. constructor(
  11882. /**
  11883. * the particle system to be used by the sub emitter
  11884. */
  11885. particleSystem: ParticleSystem);
  11886. /**
  11887. * Clones the sub emitter
  11888. * @returns the cloned sub emitter
  11889. */
  11890. clone(): SubEmitter;
  11891. /**
  11892. * Serialize current object to a JSON object
  11893. * @returns the serialized object
  11894. */
  11895. serialize(): any;
  11896. /** @hidden */
  11897. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11898. /**
  11899. * Creates a new SubEmitter from a serialized JSON version
  11900. * @param serializationObject defines the JSON object to read from
  11901. * @param scene defines the hosting scene
  11902. * @param rootUrl defines the rootUrl for data loading
  11903. * @returns a new SubEmitter
  11904. */
  11905. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11906. /** Release associated resources */
  11907. dispose(): void;
  11908. }
  11909. }
  11910. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11911. /** @hidden */
  11912. export var imageProcessingDeclaration: {
  11913. name: string;
  11914. shader: string;
  11915. };
  11916. }
  11917. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11918. /** @hidden */
  11919. export var imageProcessingFunctions: {
  11920. name: string;
  11921. shader: string;
  11922. };
  11923. }
  11924. declare module "babylonjs/Shaders/particles.fragment" {
  11925. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11926. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11927. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11928. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11929. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11930. /** @hidden */
  11931. export var particlesPixelShader: {
  11932. name: string;
  11933. shader: string;
  11934. };
  11935. }
  11936. declare module "babylonjs/Shaders/particles.vertex" {
  11937. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11938. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11939. /** @hidden */
  11940. export var particlesVertexShader: {
  11941. name: string;
  11942. shader: string;
  11943. };
  11944. }
  11945. declare module "babylonjs/Particles/particleSystem" {
  11946. import { Nullable } from "babylonjs/types";
  11947. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11948. import { Observable } from "babylonjs/Misc/observable";
  11949. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11950. import { Effect } from "babylonjs/Materials/effect";
  11951. import { Scene, IDisposable } from "babylonjs/scene";
  11952. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11953. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11954. import { Particle } from "babylonjs/Particles/particle";
  11955. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11956. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11957. import "babylonjs/Shaders/particles.fragment";
  11958. import "babylonjs/Shaders/particles.vertex";
  11959. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11960. /**
  11961. * This represents a particle system in Babylon.
  11962. * 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.
  11963. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11964. * @example https://doc.babylonjs.com/babylon101/particles
  11965. */
  11966. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11967. /**
  11968. * Billboard mode will only apply to Y axis
  11969. */
  11970. static readonly BILLBOARDMODE_Y: number;
  11971. /**
  11972. * Billboard mode will apply to all axes
  11973. */
  11974. static readonly BILLBOARDMODE_ALL: number;
  11975. /**
  11976. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11977. */
  11978. static readonly BILLBOARDMODE_STRETCHED: number;
  11979. /**
  11980. * This function can be defined to provide custom update for active particles.
  11981. * This function will be called instead of regular update (age, position, color, etc.).
  11982. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11983. */
  11984. updateFunction: (particles: Particle[]) => void;
  11985. private _emitterWorldMatrix;
  11986. /**
  11987. * This function can be defined to specify initial direction for every new particle.
  11988. * It by default use the emitterType defined function
  11989. */
  11990. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11991. /**
  11992. * This function can be defined to specify initial position for every new particle.
  11993. * It by default use the emitterType defined function
  11994. */
  11995. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11996. /**
  11997. * @hidden
  11998. */
  11999. _inheritedVelocityOffset: Vector3;
  12000. /**
  12001. * An event triggered when the system is disposed
  12002. */
  12003. onDisposeObservable: Observable<ParticleSystem>;
  12004. private _onDisposeObserver;
  12005. /**
  12006. * Sets a callback that will be triggered when the system is disposed
  12007. */
  12008. set onDispose(callback: () => void);
  12009. private _particles;
  12010. private _epsilon;
  12011. private _capacity;
  12012. private _stockParticles;
  12013. private _newPartsExcess;
  12014. private _vertexData;
  12015. private _vertexBuffer;
  12016. private _vertexBuffers;
  12017. private _spriteBuffer;
  12018. private _indexBuffer;
  12019. private _effect;
  12020. private _customEffect;
  12021. private _cachedDefines;
  12022. private _scaledColorStep;
  12023. private _colorDiff;
  12024. private _scaledDirection;
  12025. private _scaledGravity;
  12026. private _currentRenderId;
  12027. private _alive;
  12028. private _useInstancing;
  12029. private _started;
  12030. private _stopped;
  12031. private _actualFrame;
  12032. private _scaledUpdateSpeed;
  12033. private _vertexBufferSize;
  12034. /** @hidden */
  12035. _currentEmitRateGradient: Nullable<FactorGradient>;
  12036. /** @hidden */
  12037. _currentEmitRate1: number;
  12038. /** @hidden */
  12039. _currentEmitRate2: number;
  12040. /** @hidden */
  12041. _currentStartSizeGradient: Nullable<FactorGradient>;
  12042. /** @hidden */
  12043. _currentStartSize1: number;
  12044. /** @hidden */
  12045. _currentStartSize2: number;
  12046. private readonly _rawTextureWidth;
  12047. private _rampGradientsTexture;
  12048. private _useRampGradients;
  12049. /** Gets or sets a boolean indicating that ramp gradients must be used
  12050. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12051. */
  12052. get useRampGradients(): boolean;
  12053. set useRampGradients(value: boolean);
  12054. /**
  12055. * 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.
  12056. * 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: [])
  12057. */
  12058. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12059. private _subEmitters;
  12060. /**
  12061. * @hidden
  12062. * If the particle systems emitter should be disposed when the particle system is disposed
  12063. */
  12064. _disposeEmitterOnDispose: boolean;
  12065. /**
  12066. * The current active Sub-systems, this property is used by the root particle system only.
  12067. */
  12068. activeSubSystems: Array<ParticleSystem>;
  12069. /**
  12070. * Specifies if the particles are updated in emitter local space or world space
  12071. */
  12072. isLocal: boolean;
  12073. private _rootParticleSystem;
  12074. /**
  12075. * Gets the current list of active particles
  12076. */
  12077. get particles(): Particle[];
  12078. /**
  12079. * Gets the number of particles active at the same time.
  12080. * @returns The number of active particles.
  12081. */
  12082. getActiveCount(): number;
  12083. /**
  12084. * Returns the string "ParticleSystem"
  12085. * @returns a string containing the class name
  12086. */
  12087. getClassName(): string;
  12088. /**
  12089. * Gets a boolean indicating that the system is stopping
  12090. * @returns true if the system is currently stopping
  12091. */
  12092. isStopping(): boolean;
  12093. /**
  12094. * Instantiates a particle system.
  12095. * 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.
  12096. * @param name The name of the particle system
  12097. * @param capacity The max number of particles alive at the same time
  12098. * @param scene The scene the particle system belongs to
  12099. * @param customEffect a custom effect used to change the way particles are rendered by default
  12100. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12101. * @param epsilon Offset used to render the particles
  12102. */
  12103. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12104. private _addFactorGradient;
  12105. private _removeFactorGradient;
  12106. /**
  12107. * Adds a new life time gradient
  12108. * @param gradient defines the gradient to use (between 0 and 1)
  12109. * @param factor defines the life time factor to affect to the specified gradient
  12110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12111. * @returns the current particle system
  12112. */
  12113. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12114. /**
  12115. * Remove a specific life time gradient
  12116. * @param gradient defines the gradient to remove
  12117. * @returns the current particle system
  12118. */
  12119. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12120. /**
  12121. * Adds a new size gradient
  12122. * @param gradient defines the gradient to use (between 0 and 1)
  12123. * @param factor defines the size factor to affect to the specified gradient
  12124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12125. * @returns the current particle system
  12126. */
  12127. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12128. /**
  12129. * Remove a specific size gradient
  12130. * @param gradient defines the gradient to remove
  12131. * @returns the current particle system
  12132. */
  12133. removeSizeGradient(gradient: number): IParticleSystem;
  12134. /**
  12135. * Adds a new color remap gradient
  12136. * @param gradient defines the gradient to use (between 0 and 1)
  12137. * @param min defines the color remap minimal range
  12138. * @param max defines the color remap maximal range
  12139. * @returns the current particle system
  12140. */
  12141. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12142. /**
  12143. * Remove a specific color remap gradient
  12144. * @param gradient defines the gradient to remove
  12145. * @returns the current particle system
  12146. */
  12147. removeColorRemapGradient(gradient: number): IParticleSystem;
  12148. /**
  12149. * Adds a new alpha remap gradient
  12150. * @param gradient defines the gradient to use (between 0 and 1)
  12151. * @param min defines the alpha remap minimal range
  12152. * @param max defines the alpha remap maximal range
  12153. * @returns the current particle system
  12154. */
  12155. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12156. /**
  12157. * Remove a specific alpha remap gradient
  12158. * @param gradient defines the gradient to remove
  12159. * @returns the current particle system
  12160. */
  12161. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12162. /**
  12163. * Adds a new angular speed gradient
  12164. * @param gradient defines the gradient to use (between 0 and 1)
  12165. * @param factor defines the angular speed to affect to the specified gradient
  12166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12167. * @returns the current particle system
  12168. */
  12169. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12170. /**
  12171. * Remove a specific angular speed gradient
  12172. * @param gradient defines the gradient to remove
  12173. * @returns the current particle system
  12174. */
  12175. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12176. /**
  12177. * Adds a new velocity gradient
  12178. * @param gradient defines the gradient to use (between 0 and 1)
  12179. * @param factor defines the velocity to affect to the specified gradient
  12180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12181. * @returns the current particle system
  12182. */
  12183. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12184. /**
  12185. * Remove a specific velocity gradient
  12186. * @param gradient defines the gradient to remove
  12187. * @returns the current particle system
  12188. */
  12189. removeVelocityGradient(gradient: number): IParticleSystem;
  12190. /**
  12191. * Adds a new limit velocity gradient
  12192. * @param gradient defines the gradient to use (between 0 and 1)
  12193. * @param factor defines the limit velocity value to affect to the specified gradient
  12194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12195. * @returns the current particle system
  12196. */
  12197. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12198. /**
  12199. * Remove a specific limit velocity gradient
  12200. * @param gradient defines the gradient to remove
  12201. * @returns the current particle system
  12202. */
  12203. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12204. /**
  12205. * Adds a new drag gradient
  12206. * @param gradient defines the gradient to use (between 0 and 1)
  12207. * @param factor defines the drag value to affect to the specified gradient
  12208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12209. * @returns the current particle system
  12210. */
  12211. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12212. /**
  12213. * Remove a specific drag gradient
  12214. * @param gradient defines the gradient to remove
  12215. * @returns the current particle system
  12216. */
  12217. removeDragGradient(gradient: number): IParticleSystem;
  12218. /**
  12219. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12220. * @param gradient defines the gradient to use (between 0 and 1)
  12221. * @param factor defines the emit rate value to affect to the specified gradient
  12222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12223. * @returns the current particle system
  12224. */
  12225. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12226. /**
  12227. * Remove a specific emit rate gradient
  12228. * @param gradient defines the gradient to remove
  12229. * @returns the current particle system
  12230. */
  12231. removeEmitRateGradient(gradient: number): IParticleSystem;
  12232. /**
  12233. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12234. * @param gradient defines the gradient to use (between 0 and 1)
  12235. * @param factor defines the start size value to affect to the specified gradient
  12236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12237. * @returns the current particle system
  12238. */
  12239. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12240. /**
  12241. * Remove a specific start size gradient
  12242. * @param gradient defines the gradient to remove
  12243. * @returns the current particle system
  12244. */
  12245. removeStartSizeGradient(gradient: number): IParticleSystem;
  12246. private _createRampGradientTexture;
  12247. /**
  12248. * Gets the current list of ramp gradients.
  12249. * You must use addRampGradient and removeRampGradient to udpate this list
  12250. * @returns the list of ramp gradients
  12251. */
  12252. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12253. /** Force the system to rebuild all gradients that need to be resync */
  12254. forceRefreshGradients(): void;
  12255. private _syncRampGradientTexture;
  12256. /**
  12257. * Adds a new ramp gradient used to remap particle colors
  12258. * @param gradient defines the gradient to use (between 0 and 1)
  12259. * @param color defines the color to affect to the specified gradient
  12260. * @returns the current particle system
  12261. */
  12262. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12263. /**
  12264. * Remove a specific ramp gradient
  12265. * @param gradient defines the gradient to remove
  12266. * @returns the current particle system
  12267. */
  12268. removeRampGradient(gradient: number): ParticleSystem;
  12269. /**
  12270. * Adds a new color gradient
  12271. * @param gradient defines the gradient to use (between 0 and 1)
  12272. * @param color1 defines the color to affect to the specified gradient
  12273. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12274. * @returns this particle system
  12275. */
  12276. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12277. /**
  12278. * Remove a specific color gradient
  12279. * @param gradient defines the gradient to remove
  12280. * @returns this particle system
  12281. */
  12282. removeColorGradient(gradient: number): IParticleSystem;
  12283. private _fetchR;
  12284. protected _reset(): void;
  12285. private _resetEffect;
  12286. private _createVertexBuffers;
  12287. private _createIndexBuffer;
  12288. /**
  12289. * Gets the maximum number of particles active at the same time.
  12290. * @returns The max number of active particles.
  12291. */
  12292. getCapacity(): number;
  12293. /**
  12294. * Gets whether there are still active particles in the system.
  12295. * @returns True if it is alive, otherwise false.
  12296. */
  12297. isAlive(): boolean;
  12298. /**
  12299. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12300. * @returns True if it has been started, otherwise false.
  12301. */
  12302. isStarted(): boolean;
  12303. private _prepareSubEmitterInternalArray;
  12304. /**
  12305. * Starts the particle system and begins to emit
  12306. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12307. */
  12308. start(delay?: number): void;
  12309. /**
  12310. * Stops the particle system.
  12311. * @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.
  12312. */
  12313. stop(stopSubEmitters?: boolean): void;
  12314. /**
  12315. * Remove all active particles
  12316. */
  12317. reset(): void;
  12318. /**
  12319. * @hidden (for internal use only)
  12320. */
  12321. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12322. /**
  12323. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12324. * Its lifetime will start back at 0.
  12325. */
  12326. recycleParticle: (particle: Particle) => void;
  12327. private _stopSubEmitters;
  12328. private _createParticle;
  12329. private _removeFromRoot;
  12330. private _emitFromParticle;
  12331. private _update;
  12332. /** @hidden */
  12333. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12334. /** @hidden */
  12335. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12336. /** @hidden */
  12337. private _getEffect;
  12338. /**
  12339. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12340. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12341. */
  12342. animate(preWarmOnly?: boolean): void;
  12343. private _appendParticleVertices;
  12344. /**
  12345. * Rebuilds the particle system.
  12346. */
  12347. rebuild(): void;
  12348. /**
  12349. * Is this system ready to be used/rendered
  12350. * @return true if the system is ready
  12351. */
  12352. isReady(): boolean;
  12353. private _render;
  12354. /**
  12355. * Renders the particle system in its current state.
  12356. * @returns the current number of particles
  12357. */
  12358. render(): number;
  12359. /**
  12360. * Disposes the particle system and free the associated resources
  12361. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12362. */
  12363. dispose(disposeTexture?: boolean): void;
  12364. /**
  12365. * Clones the particle system.
  12366. * @param name The name of the cloned object
  12367. * @param newEmitter The new emitter to use
  12368. * @returns the cloned particle system
  12369. */
  12370. clone(name: string, newEmitter: any): ParticleSystem;
  12371. /**
  12372. * Serializes the particle system to a JSON object
  12373. * @param serializeTexture defines if the texture must be serialized as well
  12374. * @returns the JSON object
  12375. */
  12376. serialize(serializeTexture?: boolean): any;
  12377. /** @hidden */
  12378. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12379. /** @hidden */
  12380. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12381. /**
  12382. * Parses a JSON object to create a particle system.
  12383. * @param parsedParticleSystem The JSON object to parse
  12384. * @param scene The scene to create the particle system in
  12385. * @param rootUrl The root url to use to load external dependencies like texture
  12386. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12387. * @returns the Parsed particle system
  12388. */
  12389. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12390. }
  12391. }
  12392. declare module "babylonjs/Particles/particle" {
  12393. import { Nullable } from "babylonjs/types";
  12394. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12395. import { Color4 } from "babylonjs/Maths/math.color";
  12396. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12397. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12398. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12399. /**
  12400. * A particle represents one of the element emitted by a particle system.
  12401. * This is mainly define by its coordinates, direction, velocity and age.
  12402. */
  12403. export class Particle {
  12404. /**
  12405. * The particle system the particle belongs to.
  12406. */
  12407. particleSystem: ParticleSystem;
  12408. private static _Count;
  12409. /**
  12410. * Unique ID of the particle
  12411. */
  12412. id: number;
  12413. /**
  12414. * The world position of the particle in the scene.
  12415. */
  12416. position: Vector3;
  12417. /**
  12418. * The world direction of the particle in the scene.
  12419. */
  12420. direction: Vector3;
  12421. /**
  12422. * The color of the particle.
  12423. */
  12424. color: Color4;
  12425. /**
  12426. * The color change of the particle per step.
  12427. */
  12428. colorStep: Color4;
  12429. /**
  12430. * Defines how long will the life of the particle be.
  12431. */
  12432. lifeTime: number;
  12433. /**
  12434. * The current age of the particle.
  12435. */
  12436. age: number;
  12437. /**
  12438. * The current size of the particle.
  12439. */
  12440. size: number;
  12441. /**
  12442. * The current scale of the particle.
  12443. */
  12444. scale: Vector2;
  12445. /**
  12446. * The current angle of the particle.
  12447. */
  12448. angle: number;
  12449. /**
  12450. * Defines how fast is the angle changing.
  12451. */
  12452. angularSpeed: number;
  12453. /**
  12454. * Defines the cell index used by the particle to be rendered from a sprite.
  12455. */
  12456. cellIndex: number;
  12457. /**
  12458. * The information required to support color remapping
  12459. */
  12460. remapData: Vector4;
  12461. /** @hidden */
  12462. _randomCellOffset?: number;
  12463. /** @hidden */
  12464. _initialDirection: Nullable<Vector3>;
  12465. /** @hidden */
  12466. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12467. /** @hidden */
  12468. _initialStartSpriteCellID: number;
  12469. /** @hidden */
  12470. _initialEndSpriteCellID: number;
  12471. /** @hidden */
  12472. _currentColorGradient: Nullable<ColorGradient>;
  12473. /** @hidden */
  12474. _currentColor1: Color4;
  12475. /** @hidden */
  12476. _currentColor2: Color4;
  12477. /** @hidden */
  12478. _currentSizeGradient: Nullable<FactorGradient>;
  12479. /** @hidden */
  12480. _currentSize1: number;
  12481. /** @hidden */
  12482. _currentSize2: number;
  12483. /** @hidden */
  12484. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12485. /** @hidden */
  12486. _currentAngularSpeed1: number;
  12487. /** @hidden */
  12488. _currentAngularSpeed2: number;
  12489. /** @hidden */
  12490. _currentVelocityGradient: Nullable<FactorGradient>;
  12491. /** @hidden */
  12492. _currentVelocity1: number;
  12493. /** @hidden */
  12494. _currentVelocity2: number;
  12495. /** @hidden */
  12496. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12497. /** @hidden */
  12498. _currentLimitVelocity1: number;
  12499. /** @hidden */
  12500. _currentLimitVelocity2: number;
  12501. /** @hidden */
  12502. _currentDragGradient: Nullable<FactorGradient>;
  12503. /** @hidden */
  12504. _currentDrag1: number;
  12505. /** @hidden */
  12506. _currentDrag2: number;
  12507. /** @hidden */
  12508. _randomNoiseCoordinates1: Vector3;
  12509. /** @hidden */
  12510. _randomNoiseCoordinates2: Vector3;
  12511. /** @hidden */
  12512. _localPosition?: Vector3;
  12513. /**
  12514. * Creates a new instance Particle
  12515. * @param particleSystem the particle system the particle belongs to
  12516. */
  12517. constructor(
  12518. /**
  12519. * The particle system the particle belongs to.
  12520. */
  12521. particleSystem: ParticleSystem);
  12522. private updateCellInfoFromSystem;
  12523. /**
  12524. * Defines how the sprite cell index is updated for the particle
  12525. */
  12526. updateCellIndex(): void;
  12527. /** @hidden */
  12528. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12529. /** @hidden */
  12530. _inheritParticleInfoToSubEmitters(): void;
  12531. /** @hidden */
  12532. _reset(): void;
  12533. /**
  12534. * Copy the properties of particle to another one.
  12535. * @param other the particle to copy the information to.
  12536. */
  12537. copyTo(other: Particle): void;
  12538. }
  12539. }
  12540. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12541. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12542. import { Effect } from "babylonjs/Materials/effect";
  12543. import { Particle } from "babylonjs/Particles/particle";
  12544. import { Scene } from "babylonjs/scene";
  12545. /**
  12546. * Particle emitter represents a volume emitting particles.
  12547. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12548. */
  12549. export interface IParticleEmitterType {
  12550. /**
  12551. * Called by the particle System when the direction is computed for the created particle.
  12552. * @param worldMatrix is the world matrix of the particle system
  12553. * @param directionToUpdate is the direction vector to update with the result
  12554. * @param particle is the particle we are computed the direction for
  12555. * @param isLocal defines if the direction should be set in local space
  12556. */
  12557. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12558. /**
  12559. * Called by the particle System when the position is computed for the created particle.
  12560. * @param worldMatrix is the world matrix of the particle system
  12561. * @param positionToUpdate is the position vector to update with the result
  12562. * @param particle is the particle we are computed the position for
  12563. * @param isLocal defines if the position should be set in local space
  12564. */
  12565. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12566. /**
  12567. * Clones the current emitter and returns a copy of it
  12568. * @returns the new emitter
  12569. */
  12570. clone(): IParticleEmitterType;
  12571. /**
  12572. * Called by the GPUParticleSystem to setup the update shader
  12573. * @param effect defines the update shader
  12574. */
  12575. applyToShader(effect: Effect): void;
  12576. /**
  12577. * Returns a string to use to update the GPU particles update shader
  12578. * @returns the effect defines string
  12579. */
  12580. getEffectDefines(): string;
  12581. /**
  12582. * Returns a string representing the class name
  12583. * @returns a string containing the class name
  12584. */
  12585. getClassName(): string;
  12586. /**
  12587. * Serializes the particle system to a JSON object.
  12588. * @returns the JSON object
  12589. */
  12590. serialize(): any;
  12591. /**
  12592. * Parse properties from a JSON object
  12593. * @param serializationObject defines the JSON object
  12594. * @param scene defines the hosting scene
  12595. */
  12596. parse(serializationObject: any, scene: Scene): void;
  12597. }
  12598. }
  12599. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12600. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12601. import { Effect } from "babylonjs/Materials/effect";
  12602. import { Particle } from "babylonjs/Particles/particle";
  12603. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12604. /**
  12605. * Particle emitter emitting particles from the inside of a box.
  12606. * It emits the particles randomly between 2 given directions.
  12607. */
  12608. export class BoxParticleEmitter implements IParticleEmitterType {
  12609. /**
  12610. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12611. */
  12612. direction1: Vector3;
  12613. /**
  12614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12615. */
  12616. direction2: Vector3;
  12617. /**
  12618. * 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.
  12619. */
  12620. minEmitBox: Vector3;
  12621. /**
  12622. * 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.
  12623. */
  12624. maxEmitBox: Vector3;
  12625. /**
  12626. * Creates a new instance BoxParticleEmitter
  12627. */
  12628. constructor();
  12629. /**
  12630. * Called by the particle System when the direction is computed for the created particle.
  12631. * @param worldMatrix is the world matrix of the particle system
  12632. * @param directionToUpdate is the direction vector to update with the result
  12633. * @param particle is the particle we are computed the direction for
  12634. * @param isLocal defines if the direction should be set in local space
  12635. */
  12636. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12637. /**
  12638. * Called by the particle System when the position is computed for the created particle.
  12639. * @param worldMatrix is the world matrix of the particle system
  12640. * @param positionToUpdate is the position vector to update with the result
  12641. * @param particle is the particle we are computed the position for
  12642. * @param isLocal defines if the position should be set in local space
  12643. */
  12644. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12645. /**
  12646. * Clones the current emitter and returns a copy of it
  12647. * @returns the new emitter
  12648. */
  12649. clone(): BoxParticleEmitter;
  12650. /**
  12651. * Called by the GPUParticleSystem to setup the update shader
  12652. * @param effect defines the update shader
  12653. */
  12654. applyToShader(effect: Effect): void;
  12655. /**
  12656. * Returns a string to use to update the GPU particles update shader
  12657. * @returns a string containng the defines string
  12658. */
  12659. getEffectDefines(): string;
  12660. /**
  12661. * Returns the string "BoxParticleEmitter"
  12662. * @returns a string containing the class name
  12663. */
  12664. getClassName(): string;
  12665. /**
  12666. * Serializes the particle system to a JSON object.
  12667. * @returns the JSON object
  12668. */
  12669. serialize(): any;
  12670. /**
  12671. * Parse properties from a JSON object
  12672. * @param serializationObject defines the JSON object
  12673. */
  12674. parse(serializationObject: any): void;
  12675. }
  12676. }
  12677. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12678. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12679. import { Effect } from "babylonjs/Materials/effect";
  12680. import { Particle } from "babylonjs/Particles/particle";
  12681. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12682. /**
  12683. * Particle emitter emitting particles from the inside of a cone.
  12684. * It emits the particles alongside the cone volume from the base to the particle.
  12685. * The emission direction might be randomized.
  12686. */
  12687. export class ConeParticleEmitter implements IParticleEmitterType {
  12688. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12689. directionRandomizer: number;
  12690. private _radius;
  12691. private _angle;
  12692. private _height;
  12693. /**
  12694. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12695. */
  12696. radiusRange: number;
  12697. /**
  12698. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12699. */
  12700. heightRange: number;
  12701. /**
  12702. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12703. */
  12704. emitFromSpawnPointOnly: boolean;
  12705. /**
  12706. * Gets or sets the radius of the emission cone
  12707. */
  12708. get radius(): number;
  12709. set radius(value: number);
  12710. /**
  12711. * Gets or sets the angle of the emission cone
  12712. */
  12713. get angle(): number;
  12714. set angle(value: number);
  12715. private _buildHeight;
  12716. /**
  12717. * Creates a new instance ConeParticleEmitter
  12718. * @param radius the radius of the emission cone (1 by default)
  12719. * @param angle the cone base angle (PI by default)
  12720. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12721. */
  12722. constructor(radius?: number, angle?: number,
  12723. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12724. directionRandomizer?: number);
  12725. /**
  12726. * Called by the particle System when the direction is computed for the created particle.
  12727. * @param worldMatrix is the world matrix of the particle system
  12728. * @param directionToUpdate is the direction vector to update with the result
  12729. * @param particle is the particle we are computed the direction for
  12730. * @param isLocal defines if the direction should be set in local space
  12731. */
  12732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12733. /**
  12734. * Called by the particle System when the position is computed for the created particle.
  12735. * @param worldMatrix is the world matrix of the particle system
  12736. * @param positionToUpdate is the position vector to update with the result
  12737. * @param particle is the particle we are computed the position for
  12738. * @param isLocal defines if the position should be set in local space
  12739. */
  12740. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12741. /**
  12742. * Clones the current emitter and returns a copy of it
  12743. * @returns the new emitter
  12744. */
  12745. clone(): ConeParticleEmitter;
  12746. /**
  12747. * Called by the GPUParticleSystem to setup the update shader
  12748. * @param effect defines the update shader
  12749. */
  12750. applyToShader(effect: Effect): void;
  12751. /**
  12752. * Returns a string to use to update the GPU particles update shader
  12753. * @returns a string containng the defines string
  12754. */
  12755. getEffectDefines(): string;
  12756. /**
  12757. * Returns the string "ConeParticleEmitter"
  12758. * @returns a string containing the class name
  12759. */
  12760. getClassName(): string;
  12761. /**
  12762. * Serializes the particle system to a JSON object.
  12763. * @returns the JSON object
  12764. */
  12765. serialize(): any;
  12766. /**
  12767. * Parse properties from a JSON object
  12768. * @param serializationObject defines the JSON object
  12769. */
  12770. parse(serializationObject: any): void;
  12771. }
  12772. }
  12773. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12774. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12775. import { Effect } from "babylonjs/Materials/effect";
  12776. import { Particle } from "babylonjs/Particles/particle";
  12777. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12778. /**
  12779. * Particle emitter emitting particles from the inside of a cylinder.
  12780. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12781. */
  12782. export class CylinderParticleEmitter implements IParticleEmitterType {
  12783. /**
  12784. * The radius of the emission cylinder.
  12785. */
  12786. radius: number;
  12787. /**
  12788. * The height of the emission cylinder.
  12789. */
  12790. height: number;
  12791. /**
  12792. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12793. */
  12794. radiusRange: number;
  12795. /**
  12796. * How much to randomize the particle direction [0-1].
  12797. */
  12798. directionRandomizer: number;
  12799. /**
  12800. * Creates a new instance CylinderParticleEmitter
  12801. * @param radius the radius of the emission cylinder (1 by default)
  12802. * @param height the height of the emission cylinder (1 by default)
  12803. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12804. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12805. */
  12806. constructor(
  12807. /**
  12808. * The radius of the emission cylinder.
  12809. */
  12810. radius?: number,
  12811. /**
  12812. * The height of the emission cylinder.
  12813. */
  12814. height?: number,
  12815. /**
  12816. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12817. */
  12818. radiusRange?: number,
  12819. /**
  12820. * How much to randomize the particle direction [0-1].
  12821. */
  12822. directionRandomizer?: number);
  12823. /**
  12824. * Called by the particle System when the direction is computed for the created particle.
  12825. * @param worldMatrix is the world matrix of the particle system
  12826. * @param directionToUpdate is the direction vector to update with the result
  12827. * @param particle is the particle we are computed the direction for
  12828. * @param isLocal defines if the direction should be set in local space
  12829. */
  12830. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12831. /**
  12832. * Called by the particle System when the position is computed for the created particle.
  12833. * @param worldMatrix is the world matrix of the particle system
  12834. * @param positionToUpdate is the position vector to update with the result
  12835. * @param particle is the particle we are computed the position for
  12836. * @param isLocal defines if the position should be set in local space
  12837. */
  12838. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12839. /**
  12840. * Clones the current emitter and returns a copy of it
  12841. * @returns the new emitter
  12842. */
  12843. clone(): CylinderParticleEmitter;
  12844. /**
  12845. * Called by the GPUParticleSystem to setup the update shader
  12846. * @param effect defines the update shader
  12847. */
  12848. applyToShader(effect: Effect): void;
  12849. /**
  12850. * Returns a string to use to update the GPU particles update shader
  12851. * @returns a string containng the defines string
  12852. */
  12853. getEffectDefines(): string;
  12854. /**
  12855. * Returns the string "CylinderParticleEmitter"
  12856. * @returns a string containing the class name
  12857. */
  12858. getClassName(): string;
  12859. /**
  12860. * Serializes the particle system to a JSON object.
  12861. * @returns the JSON object
  12862. */
  12863. serialize(): any;
  12864. /**
  12865. * Parse properties from a JSON object
  12866. * @param serializationObject defines the JSON object
  12867. */
  12868. parse(serializationObject: any): void;
  12869. }
  12870. /**
  12871. * Particle emitter emitting particles from the inside of a cylinder.
  12872. * It emits the particles randomly between two vectors.
  12873. */
  12874. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12875. /**
  12876. * The min limit of the emission direction.
  12877. */
  12878. direction1: Vector3;
  12879. /**
  12880. * The max limit of the emission direction.
  12881. */
  12882. direction2: Vector3;
  12883. /**
  12884. * Creates a new instance CylinderDirectedParticleEmitter
  12885. * @param radius the radius of the emission cylinder (1 by default)
  12886. * @param height the height of the emission cylinder (1 by default)
  12887. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12888. * @param direction1 the min limit of the emission direction (up vector by default)
  12889. * @param direction2 the max limit of the emission direction (up vector by default)
  12890. */
  12891. constructor(radius?: number, height?: number, radiusRange?: number,
  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. * Called by the particle System when the direction is computed for the created particle.
  12902. * @param worldMatrix is the world matrix of the particle system
  12903. * @param directionToUpdate is the direction vector to update with the result
  12904. * @param particle is the particle we are computed the direction for
  12905. */
  12906. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12907. /**
  12908. * Clones the current emitter and returns a copy of it
  12909. * @returns the new emitter
  12910. */
  12911. clone(): CylinderDirectedParticleEmitter;
  12912. /**
  12913. * Called by the GPUParticleSystem to setup the update shader
  12914. * @param effect defines the update shader
  12915. */
  12916. applyToShader(effect: Effect): void;
  12917. /**
  12918. * Returns a string to use to update the GPU particles update shader
  12919. * @returns a string containng the defines string
  12920. */
  12921. getEffectDefines(): string;
  12922. /**
  12923. * Returns the string "CylinderDirectedParticleEmitter"
  12924. * @returns a string containing the class name
  12925. */
  12926. getClassName(): string;
  12927. /**
  12928. * Serializes the particle system to a JSON object.
  12929. * @returns the JSON object
  12930. */
  12931. serialize(): any;
  12932. /**
  12933. * Parse properties from a JSON object
  12934. * @param serializationObject defines the JSON object
  12935. */
  12936. parse(serializationObject: any): void;
  12937. }
  12938. }
  12939. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12940. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12941. import { Effect } from "babylonjs/Materials/effect";
  12942. import { Particle } from "babylonjs/Particles/particle";
  12943. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12944. /**
  12945. * Particle emitter emitting particles from the inside of a hemisphere.
  12946. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12947. */
  12948. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12949. /**
  12950. * The radius of the emission hemisphere.
  12951. */
  12952. radius: number;
  12953. /**
  12954. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12955. */
  12956. radiusRange: number;
  12957. /**
  12958. * How much to randomize the particle direction [0-1].
  12959. */
  12960. directionRandomizer: number;
  12961. /**
  12962. * Creates a new instance HemisphericParticleEmitter
  12963. * @param radius the radius of the emission hemisphere (1 by default)
  12964. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12965. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12966. */
  12967. constructor(
  12968. /**
  12969. * The radius of the emission hemisphere.
  12970. */
  12971. radius?: number,
  12972. /**
  12973. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12974. */
  12975. radiusRange?: number,
  12976. /**
  12977. * How much to randomize the particle direction [0-1].
  12978. */
  12979. directionRandomizer?: number);
  12980. /**
  12981. * Called by the particle System when the direction is computed for the created particle.
  12982. * @param worldMatrix is the world matrix of the particle system
  12983. * @param directionToUpdate is the direction vector to update with the result
  12984. * @param particle is the particle we are computed the direction for
  12985. * @param isLocal defines if the direction should be set in local space
  12986. */
  12987. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12988. /**
  12989. * Called by the particle System when the position is computed for the created particle.
  12990. * @param worldMatrix is the world matrix of the particle system
  12991. * @param positionToUpdate is the position vector to update with the result
  12992. * @param particle is the particle we are computed the position for
  12993. * @param isLocal defines if the position should be set in local space
  12994. */
  12995. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12996. /**
  12997. * Clones the current emitter and returns a copy of it
  12998. * @returns the new emitter
  12999. */
  13000. clone(): HemisphericParticleEmitter;
  13001. /**
  13002. * Called by the GPUParticleSystem to setup the update shader
  13003. * @param effect defines the update shader
  13004. */
  13005. applyToShader(effect: Effect): void;
  13006. /**
  13007. * Returns a string to use to update the GPU particles update shader
  13008. * @returns a string containng the defines string
  13009. */
  13010. getEffectDefines(): string;
  13011. /**
  13012. * Returns the string "HemisphericParticleEmitter"
  13013. * @returns a string containing the class name
  13014. */
  13015. getClassName(): string;
  13016. /**
  13017. * Serializes the particle system to a JSON object.
  13018. * @returns the JSON object
  13019. */
  13020. serialize(): any;
  13021. /**
  13022. * Parse properties from a JSON object
  13023. * @param serializationObject defines the JSON object
  13024. */
  13025. parse(serializationObject: any): void;
  13026. }
  13027. }
  13028. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13029. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13030. import { Effect } from "babylonjs/Materials/effect";
  13031. import { Particle } from "babylonjs/Particles/particle";
  13032. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13033. /**
  13034. * Particle emitter emitting particles from a point.
  13035. * It emits the particles randomly between 2 given directions.
  13036. */
  13037. export class PointParticleEmitter implements IParticleEmitterType {
  13038. /**
  13039. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13040. */
  13041. direction1: Vector3;
  13042. /**
  13043. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13044. */
  13045. direction2: Vector3;
  13046. /**
  13047. * Creates a new instance PointParticleEmitter
  13048. */
  13049. constructor();
  13050. /**
  13051. * Called by the particle System when the direction is computed for the created particle.
  13052. * @param worldMatrix is the world matrix of the particle system
  13053. * @param directionToUpdate is the direction vector to update with the result
  13054. * @param particle is the particle we are computed the direction for
  13055. * @param isLocal defines if the direction should be set in local space
  13056. */
  13057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13058. /**
  13059. * Called by the particle System when the position is computed for the created particle.
  13060. * @param worldMatrix is the world matrix of the particle system
  13061. * @param positionToUpdate is the position vector to update with the result
  13062. * @param particle is the particle we are computed the position for
  13063. * @param isLocal defines if the position should be set in local space
  13064. */
  13065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13066. /**
  13067. * Clones the current emitter and returns a copy of it
  13068. * @returns the new emitter
  13069. */
  13070. clone(): PointParticleEmitter;
  13071. /**
  13072. * Called by the GPUParticleSystem to setup the update shader
  13073. * @param effect defines the update shader
  13074. */
  13075. applyToShader(effect: Effect): void;
  13076. /**
  13077. * Returns a string to use to update the GPU particles update shader
  13078. * @returns a string containng the defines string
  13079. */
  13080. getEffectDefines(): string;
  13081. /**
  13082. * Returns the string "PointParticleEmitter"
  13083. * @returns a string containing the class name
  13084. */
  13085. getClassName(): string;
  13086. /**
  13087. * Serializes the particle system to a JSON object.
  13088. * @returns the JSON object
  13089. */
  13090. serialize(): any;
  13091. /**
  13092. * Parse properties from a JSON object
  13093. * @param serializationObject defines the JSON object
  13094. */
  13095. parse(serializationObject: any): void;
  13096. }
  13097. }
  13098. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13099. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13100. import { Effect } from "babylonjs/Materials/effect";
  13101. import { Particle } from "babylonjs/Particles/particle";
  13102. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13103. /**
  13104. * Particle emitter emitting particles from the inside of a sphere.
  13105. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13106. */
  13107. export class SphereParticleEmitter implements IParticleEmitterType {
  13108. /**
  13109. * The radius of the emission sphere.
  13110. */
  13111. radius: number;
  13112. /**
  13113. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13114. */
  13115. radiusRange: number;
  13116. /**
  13117. * How much to randomize the particle direction [0-1].
  13118. */
  13119. directionRandomizer: number;
  13120. /**
  13121. * Creates a new instance SphereParticleEmitter
  13122. * @param radius the radius of the emission sphere (1 by default)
  13123. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13124. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13125. */
  13126. constructor(
  13127. /**
  13128. * The radius of the emission sphere.
  13129. */
  13130. radius?: number,
  13131. /**
  13132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13133. */
  13134. radiusRange?: number,
  13135. /**
  13136. * How much to randomize the particle direction [0-1].
  13137. */
  13138. directionRandomizer?: number);
  13139. /**
  13140. * Called by the particle System when the direction is computed for the created particle.
  13141. * @param worldMatrix is the world matrix of the particle system
  13142. * @param directionToUpdate is the direction vector to update with the result
  13143. * @param particle is the particle we are computed the direction for
  13144. * @param isLocal defines if the direction should be set in local space
  13145. */
  13146. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13147. /**
  13148. * Called by the particle System when the position is computed for the created particle.
  13149. * @param worldMatrix is the world matrix of the particle system
  13150. * @param positionToUpdate is the position vector to update with the result
  13151. * @param particle is the particle we are computed the position for
  13152. * @param isLocal defines if the position should be set in local space
  13153. */
  13154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13155. /**
  13156. * Clones the current emitter and returns a copy of it
  13157. * @returns the new emitter
  13158. */
  13159. clone(): SphereParticleEmitter;
  13160. /**
  13161. * Called by the GPUParticleSystem to setup the update shader
  13162. * @param effect defines the update shader
  13163. */
  13164. applyToShader(effect: Effect): void;
  13165. /**
  13166. * Returns a string to use to update the GPU particles update shader
  13167. * @returns a string containng the defines string
  13168. */
  13169. getEffectDefines(): string;
  13170. /**
  13171. * Returns the string "SphereParticleEmitter"
  13172. * @returns a string containing the class name
  13173. */
  13174. getClassName(): string;
  13175. /**
  13176. * Serializes the particle system to a JSON object.
  13177. * @returns the JSON object
  13178. */
  13179. serialize(): any;
  13180. /**
  13181. * Parse properties from a JSON object
  13182. * @param serializationObject defines the JSON object
  13183. */
  13184. parse(serializationObject: any): void;
  13185. }
  13186. /**
  13187. * Particle emitter emitting particles from the inside of a sphere.
  13188. * It emits the particles randomly between two vectors.
  13189. */
  13190. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13191. /**
  13192. * The min limit of the emission direction.
  13193. */
  13194. direction1: Vector3;
  13195. /**
  13196. * The max limit of the emission direction.
  13197. */
  13198. direction2: Vector3;
  13199. /**
  13200. * Creates a new instance SphereDirectedParticleEmitter
  13201. * @param radius the radius of the emission sphere (1 by default)
  13202. * @param direction1 the min limit of the emission direction (up vector by default)
  13203. * @param direction2 the max limit of the emission direction (up vector by default)
  13204. */
  13205. constructor(radius?: number,
  13206. /**
  13207. * The min limit of the emission direction.
  13208. */
  13209. direction1?: Vector3,
  13210. /**
  13211. * The max limit of the emission direction.
  13212. */
  13213. direction2?: Vector3);
  13214. /**
  13215. * Called by the particle System when the direction is computed for the created particle.
  13216. * @param worldMatrix is the world matrix of the particle system
  13217. * @param directionToUpdate is the direction vector to update with the result
  13218. * @param particle is the particle we are computed the direction for
  13219. */
  13220. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13221. /**
  13222. * Clones the current emitter and returns a copy of it
  13223. * @returns the new emitter
  13224. */
  13225. clone(): SphereDirectedParticleEmitter;
  13226. /**
  13227. * Called by the GPUParticleSystem to setup the update shader
  13228. * @param effect defines the update shader
  13229. */
  13230. applyToShader(effect: Effect): void;
  13231. /**
  13232. * Returns a string to use to update the GPU particles update shader
  13233. * @returns a string containng the defines string
  13234. */
  13235. getEffectDefines(): string;
  13236. /**
  13237. * Returns the string "SphereDirectedParticleEmitter"
  13238. * @returns a string containing the class name
  13239. */
  13240. getClassName(): string;
  13241. /**
  13242. * Serializes the particle system to a JSON object.
  13243. * @returns the JSON object
  13244. */
  13245. serialize(): any;
  13246. /**
  13247. * Parse properties from a JSON object
  13248. * @param serializationObject defines the JSON object
  13249. */
  13250. parse(serializationObject: any): void;
  13251. }
  13252. }
  13253. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13254. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13255. import { Effect } from "babylonjs/Materials/effect";
  13256. import { Particle } from "babylonjs/Particles/particle";
  13257. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13258. import { Nullable } from "babylonjs/types";
  13259. /**
  13260. * Particle emitter emitting particles from a custom list of positions.
  13261. */
  13262. export class CustomParticleEmitter implements IParticleEmitterType {
  13263. /**
  13264. * Gets or sets the position generator that will create the inital position of each particle.
  13265. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13266. */
  13267. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13268. /**
  13269. * Gets or sets the destination generator that will create the final destination of each particle.
  13270. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13271. */
  13272. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13273. /**
  13274. * Creates a new instance CustomParticleEmitter
  13275. */
  13276. constructor();
  13277. /**
  13278. * Called by the particle System when the direction is computed for the created particle.
  13279. * @param worldMatrix is the world matrix of the particle system
  13280. * @param directionToUpdate is the direction vector to update with the result
  13281. * @param particle is the particle we are computed the direction for
  13282. * @param isLocal defines if the direction should be set in local space
  13283. */
  13284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13285. /**
  13286. * Called by the particle System when the position is computed for the created particle.
  13287. * @param worldMatrix is the world matrix of the particle system
  13288. * @param positionToUpdate is the position vector to update with the result
  13289. * @param particle is the particle we are computed the position for
  13290. * @param isLocal defines if the position should be set in local space
  13291. */
  13292. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13293. /**
  13294. * Clones the current emitter and returns a copy of it
  13295. * @returns the new emitter
  13296. */
  13297. clone(): CustomParticleEmitter;
  13298. /**
  13299. * Called by the GPUParticleSystem to setup the update shader
  13300. * @param effect defines the update shader
  13301. */
  13302. applyToShader(effect: Effect): void;
  13303. /**
  13304. * Returns a string to use to update the GPU particles update shader
  13305. * @returns a string containng the defines string
  13306. */
  13307. getEffectDefines(): string;
  13308. /**
  13309. * Returns the string "PointParticleEmitter"
  13310. * @returns a string containing the class name
  13311. */
  13312. getClassName(): string;
  13313. /**
  13314. * Serializes the particle system to a JSON object.
  13315. * @returns the JSON object
  13316. */
  13317. serialize(): any;
  13318. /**
  13319. * Parse properties from a JSON object
  13320. * @param serializationObject defines the JSON object
  13321. */
  13322. parse(serializationObject: any): void;
  13323. }
  13324. }
  13325. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13326. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13327. import { Effect } from "babylonjs/Materials/effect";
  13328. import { Particle } from "babylonjs/Particles/particle";
  13329. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13330. import { Nullable } from "babylonjs/types";
  13331. import { Scene } from "babylonjs/scene";
  13332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13333. /**
  13334. * Particle emitter emitting particles from the inside of a box.
  13335. * It emits the particles randomly between 2 given directions.
  13336. */
  13337. export class MeshParticleEmitter implements IParticleEmitterType {
  13338. private _indices;
  13339. private _positions;
  13340. private _normals;
  13341. private _storedNormal;
  13342. private _mesh;
  13343. /**
  13344. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13345. */
  13346. direction1: Vector3;
  13347. /**
  13348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13349. */
  13350. direction2: Vector3;
  13351. /**
  13352. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13353. */
  13354. useMeshNormalsForDirection: boolean;
  13355. /** Defines the mesh to use as source */
  13356. get mesh(): Nullable<AbstractMesh>;
  13357. set mesh(value: Nullable<AbstractMesh>);
  13358. /**
  13359. * Creates a new instance MeshParticleEmitter
  13360. * @param mesh defines the mesh to use as source
  13361. */
  13362. constructor(mesh?: Nullable<AbstractMesh>);
  13363. /**
  13364. * Called by the particle System when the direction is computed for the created particle.
  13365. * @param worldMatrix is the world matrix of the particle system
  13366. * @param directionToUpdate is the direction vector to update with the result
  13367. * @param particle is the particle we are computed the direction for
  13368. * @param isLocal defines if the direction should be set in local space
  13369. */
  13370. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13371. /**
  13372. * Called by the particle System when the position is computed for the created particle.
  13373. * @param worldMatrix is the world matrix of the particle system
  13374. * @param positionToUpdate is the position vector to update with the result
  13375. * @param particle is the particle we are computed the position for
  13376. * @param isLocal defines if the position should be set in local space
  13377. */
  13378. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13379. /**
  13380. * Clones the current emitter and returns a copy of it
  13381. * @returns the new emitter
  13382. */
  13383. clone(): MeshParticleEmitter;
  13384. /**
  13385. * Called by the GPUParticleSystem to setup the update shader
  13386. * @param effect defines the update shader
  13387. */
  13388. applyToShader(effect: Effect): void;
  13389. /**
  13390. * Returns a string to use to update the GPU particles update shader
  13391. * @returns a string containng the defines string
  13392. */
  13393. getEffectDefines(): string;
  13394. /**
  13395. * Returns the string "BoxParticleEmitter"
  13396. * @returns a string containing the class name
  13397. */
  13398. getClassName(): string;
  13399. /**
  13400. * Serializes the particle system to a JSON object.
  13401. * @returns the JSON object
  13402. */
  13403. serialize(): any;
  13404. /**
  13405. * Parse properties from a JSON object
  13406. * @param serializationObject defines the JSON object
  13407. * @param scene defines the hosting scene
  13408. */
  13409. parse(serializationObject: any, scene: Scene): void;
  13410. }
  13411. }
  13412. declare module "babylonjs/Particles/EmitterTypes/index" {
  13413. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13414. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13415. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13416. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13417. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13418. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13419. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13420. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13421. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13422. }
  13423. declare module "babylonjs/Particles/IParticleSystem" {
  13424. import { Nullable } from "babylonjs/types";
  13425. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13426. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13429. import { Texture } from "babylonjs/Materials/Textures/texture";
  13430. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13431. import { Scene } from "babylonjs/scene";
  13432. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13433. import { Animation } from "babylonjs/Animations/animation";
  13434. /**
  13435. * Interface representing a particle system in Babylon.js.
  13436. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13437. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13438. */
  13439. export interface IParticleSystem {
  13440. /**
  13441. * List of animations used by the particle system.
  13442. */
  13443. animations: Animation[];
  13444. /**
  13445. * The id of the Particle system.
  13446. */
  13447. id: string;
  13448. /**
  13449. * The name of the Particle system.
  13450. */
  13451. name: string;
  13452. /**
  13453. * The emitter represents the Mesh or position we are attaching the particle system to.
  13454. */
  13455. emitter: Nullable<AbstractMesh | Vector3>;
  13456. /**
  13457. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13458. */
  13459. isBillboardBased: boolean;
  13460. /**
  13461. * The rendering group used by the Particle system to chose when to render.
  13462. */
  13463. renderingGroupId: number;
  13464. /**
  13465. * The layer mask we are rendering the particles through.
  13466. */
  13467. layerMask: number;
  13468. /**
  13469. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13470. */
  13471. updateSpeed: number;
  13472. /**
  13473. * The amount of time the particle system is running (depends of the overall update speed).
  13474. */
  13475. targetStopDuration: number;
  13476. /**
  13477. * The texture used to render each particle. (this can be a spritesheet)
  13478. */
  13479. particleTexture: Nullable<Texture>;
  13480. /**
  13481. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13482. */
  13483. blendMode: number;
  13484. /**
  13485. * Minimum life time of emitting particles.
  13486. */
  13487. minLifeTime: number;
  13488. /**
  13489. * Maximum life time of emitting particles.
  13490. */
  13491. maxLifeTime: number;
  13492. /**
  13493. * Minimum Size of emitting particles.
  13494. */
  13495. minSize: number;
  13496. /**
  13497. * Maximum Size of emitting particles.
  13498. */
  13499. maxSize: number;
  13500. /**
  13501. * Minimum scale of emitting particles on X axis.
  13502. */
  13503. minScaleX: number;
  13504. /**
  13505. * Maximum scale of emitting particles on X axis.
  13506. */
  13507. maxScaleX: number;
  13508. /**
  13509. * Minimum scale of emitting particles on Y axis.
  13510. */
  13511. minScaleY: number;
  13512. /**
  13513. * Maximum scale of emitting particles on Y axis.
  13514. */
  13515. maxScaleY: number;
  13516. /**
  13517. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13518. */
  13519. color1: Color4;
  13520. /**
  13521. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13522. */
  13523. color2: Color4;
  13524. /**
  13525. * Color the particle will have at the end of its lifetime.
  13526. */
  13527. colorDead: Color4;
  13528. /**
  13529. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13530. */
  13531. emitRate: number;
  13532. /**
  13533. * You can use gravity if you want to give an orientation to your particles.
  13534. */
  13535. gravity: Vector3;
  13536. /**
  13537. * Minimum power of emitting particles.
  13538. */
  13539. minEmitPower: number;
  13540. /**
  13541. * Maximum power of emitting particles.
  13542. */
  13543. maxEmitPower: number;
  13544. /**
  13545. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13546. */
  13547. minAngularSpeed: number;
  13548. /**
  13549. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13550. */
  13551. maxAngularSpeed: number;
  13552. /**
  13553. * Gets or sets the minimal initial rotation in radians.
  13554. */
  13555. minInitialRotation: number;
  13556. /**
  13557. * Gets or sets the maximal initial rotation in radians.
  13558. */
  13559. maxInitialRotation: number;
  13560. /**
  13561. * The particle emitter type defines the emitter used by the particle system.
  13562. * It can be for example box, sphere, or cone...
  13563. */
  13564. particleEmitterType: Nullable<IParticleEmitterType>;
  13565. /**
  13566. * Defines the delay in milliseconds before starting the system (0 by default)
  13567. */
  13568. startDelay: number;
  13569. /**
  13570. * 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
  13571. */
  13572. preWarmCycles: number;
  13573. /**
  13574. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13575. */
  13576. preWarmStepOffset: number;
  13577. /**
  13578. * 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)
  13579. */
  13580. spriteCellChangeSpeed: number;
  13581. /**
  13582. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13583. */
  13584. startSpriteCellID: number;
  13585. /**
  13586. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13587. */
  13588. endSpriteCellID: number;
  13589. /**
  13590. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13591. */
  13592. spriteCellWidth: number;
  13593. /**
  13594. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13595. */
  13596. spriteCellHeight: number;
  13597. /**
  13598. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13599. */
  13600. spriteRandomStartCell: boolean;
  13601. /**
  13602. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13603. */
  13604. isAnimationSheetEnabled: boolean;
  13605. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13606. translationPivot: Vector2;
  13607. /**
  13608. * Gets or sets a texture used to add random noise to particle positions
  13609. */
  13610. noiseTexture: Nullable<BaseTexture>;
  13611. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13612. noiseStrength: Vector3;
  13613. /**
  13614. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13615. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13616. */
  13617. billboardMode: number;
  13618. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13619. limitVelocityDamping: number;
  13620. /**
  13621. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13622. */
  13623. beginAnimationOnStart: boolean;
  13624. /**
  13625. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13626. */
  13627. beginAnimationFrom: number;
  13628. /**
  13629. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13630. */
  13631. beginAnimationTo: number;
  13632. /**
  13633. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13634. */
  13635. beginAnimationLoop: boolean;
  13636. /**
  13637. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13638. */
  13639. disposeOnStop: boolean;
  13640. /**
  13641. * Specifies if the particles are updated in emitter local space or world space
  13642. */
  13643. isLocal: boolean;
  13644. /** Snippet ID if the particle system was created from the snippet server */
  13645. snippetId: string;
  13646. /**
  13647. * Gets the maximum number of particles active at the same time.
  13648. * @returns The max number of active particles.
  13649. */
  13650. getCapacity(): number;
  13651. /**
  13652. * Gets the number of particles active at the same time.
  13653. * @returns The number of active particles.
  13654. */
  13655. getActiveCount(): number;
  13656. /**
  13657. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13658. * @returns True if it has been started, otherwise false.
  13659. */
  13660. isStarted(): boolean;
  13661. /**
  13662. * Animates the particle system for this frame.
  13663. */
  13664. animate(): void;
  13665. /**
  13666. * Renders the particle system in its current state.
  13667. * @returns the current number of particles
  13668. */
  13669. render(): number;
  13670. /**
  13671. * Dispose the particle system and frees its associated resources.
  13672. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13673. */
  13674. dispose(disposeTexture?: boolean): void;
  13675. /**
  13676. * Clones the particle system.
  13677. * @param name The name of the cloned object
  13678. * @param newEmitter The new emitter to use
  13679. * @returns the cloned particle system
  13680. */
  13681. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13682. /**
  13683. * Serializes the particle system to a JSON object
  13684. * @param serializeTexture defines if the texture must be serialized as well
  13685. * @returns the JSON object
  13686. */
  13687. serialize(serializeTexture: boolean): any;
  13688. /**
  13689. * Rebuild the particle system
  13690. */
  13691. rebuild(): void;
  13692. /** Force the system to rebuild all gradients that need to be resync */
  13693. forceRefreshGradients(): void;
  13694. /**
  13695. * Starts the particle system and begins to emit
  13696. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13697. */
  13698. start(delay?: number): void;
  13699. /**
  13700. * Stops the particle system.
  13701. */
  13702. stop(): void;
  13703. /**
  13704. * Remove all active particles
  13705. */
  13706. reset(): void;
  13707. /**
  13708. * Gets a boolean indicating that the system is stopping
  13709. * @returns true if the system is currently stopping
  13710. */
  13711. isStopping(): boolean;
  13712. /**
  13713. * Is this system ready to be used/rendered
  13714. * @return true if the system is ready
  13715. */
  13716. isReady(): boolean;
  13717. /**
  13718. * Returns the string "ParticleSystem"
  13719. * @returns a string containing the class name
  13720. */
  13721. getClassName(): string;
  13722. /**
  13723. * Adds a new color gradient
  13724. * @param gradient defines the gradient to use (between 0 and 1)
  13725. * @param color1 defines the color to affect to the specified gradient
  13726. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13727. * @returns the current particle system
  13728. */
  13729. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13730. /**
  13731. * Remove a specific color gradient
  13732. * @param gradient defines the gradient to remove
  13733. * @returns the current particle system
  13734. */
  13735. removeColorGradient(gradient: number): IParticleSystem;
  13736. /**
  13737. * Adds a new size gradient
  13738. * @param gradient defines the gradient to use (between 0 and 1)
  13739. * @param factor defines the size factor to affect to the specified gradient
  13740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13741. * @returns the current particle system
  13742. */
  13743. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13744. /**
  13745. * Remove a specific size gradient
  13746. * @param gradient defines the gradient to remove
  13747. * @returns the current particle system
  13748. */
  13749. removeSizeGradient(gradient: number): IParticleSystem;
  13750. /**
  13751. * Gets the current list of color gradients.
  13752. * You must use addColorGradient and removeColorGradient to udpate this list
  13753. * @returns the list of color gradients
  13754. */
  13755. getColorGradients(): Nullable<Array<ColorGradient>>;
  13756. /**
  13757. * Gets the current list of size gradients.
  13758. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13759. * @returns the list of size gradients
  13760. */
  13761. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13762. /**
  13763. * Gets the current list of angular speed gradients.
  13764. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13765. * @returns the list of angular speed gradients
  13766. */
  13767. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13768. /**
  13769. * Adds a new angular speed gradient
  13770. * @param gradient defines the gradient to use (between 0 and 1)
  13771. * @param factor defines the angular speed to affect to the specified gradient
  13772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13773. * @returns the current particle system
  13774. */
  13775. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13776. /**
  13777. * Remove a specific angular speed gradient
  13778. * @param gradient defines the gradient to remove
  13779. * @returns the current particle system
  13780. */
  13781. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13782. /**
  13783. * Gets the current list of velocity gradients.
  13784. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13785. * @returns the list of velocity gradients
  13786. */
  13787. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13788. /**
  13789. * Adds a new velocity gradient
  13790. * @param gradient defines the gradient to use (between 0 and 1)
  13791. * @param factor defines the velocity to affect to the specified gradient
  13792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13793. * @returns the current particle system
  13794. */
  13795. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13796. /**
  13797. * Remove a specific velocity gradient
  13798. * @param gradient defines the gradient to remove
  13799. * @returns the current particle system
  13800. */
  13801. removeVelocityGradient(gradient: number): IParticleSystem;
  13802. /**
  13803. * Gets the current list of limit velocity gradients.
  13804. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13805. * @returns the list of limit velocity gradients
  13806. */
  13807. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13808. /**
  13809. * Adds a new limit velocity gradient
  13810. * @param gradient defines the gradient to use (between 0 and 1)
  13811. * @param factor defines the limit velocity to affect to the specified gradient
  13812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13813. * @returns the current particle system
  13814. */
  13815. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13816. /**
  13817. * Remove a specific limit velocity gradient
  13818. * @param gradient defines the gradient to remove
  13819. * @returns the current particle system
  13820. */
  13821. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13822. /**
  13823. * Adds a new drag gradient
  13824. * @param gradient defines the gradient to use (between 0 and 1)
  13825. * @param factor defines the drag to affect to the specified gradient
  13826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13827. * @returns the current particle system
  13828. */
  13829. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13830. /**
  13831. * Remove a specific drag gradient
  13832. * @param gradient defines the gradient to remove
  13833. * @returns the current particle system
  13834. */
  13835. removeDragGradient(gradient: number): IParticleSystem;
  13836. /**
  13837. * Gets the current list of drag gradients.
  13838. * You must use addDragGradient and removeDragGradient to udpate this list
  13839. * @returns the list of drag gradients
  13840. */
  13841. getDragGradients(): Nullable<Array<FactorGradient>>;
  13842. /**
  13843. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13844. * @param gradient defines the gradient to use (between 0 and 1)
  13845. * @param factor defines the emit rate to affect to the specified gradient
  13846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13847. * @returns the current particle system
  13848. */
  13849. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13850. /**
  13851. * Remove a specific emit rate gradient
  13852. * @param gradient defines the gradient to remove
  13853. * @returns the current particle system
  13854. */
  13855. removeEmitRateGradient(gradient: number): IParticleSystem;
  13856. /**
  13857. * Gets the current list of emit rate gradients.
  13858. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13859. * @returns the list of emit rate gradients
  13860. */
  13861. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13862. /**
  13863. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13864. * @param gradient defines the gradient to use (between 0 and 1)
  13865. * @param factor defines the start size to affect to the specified gradient
  13866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13867. * @returns the current particle system
  13868. */
  13869. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13870. /**
  13871. * Remove a specific start size gradient
  13872. * @param gradient defines the gradient to remove
  13873. * @returns the current particle system
  13874. */
  13875. removeStartSizeGradient(gradient: number): IParticleSystem;
  13876. /**
  13877. * Gets the current list of start size gradients.
  13878. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13879. * @returns the list of start size gradients
  13880. */
  13881. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13882. /**
  13883. * Adds a new life time gradient
  13884. * @param gradient defines the gradient to use (between 0 and 1)
  13885. * @param factor defines the life time factor to affect to the specified gradient
  13886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13887. * @returns the current particle system
  13888. */
  13889. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13890. /**
  13891. * Remove a specific life time gradient
  13892. * @param gradient defines the gradient to remove
  13893. * @returns the current particle system
  13894. */
  13895. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13896. /**
  13897. * Gets the current list of life time gradients.
  13898. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13899. * @returns the list of life time gradients
  13900. */
  13901. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13902. /**
  13903. * Gets the current list of color gradients.
  13904. * You must use addColorGradient and removeColorGradient to udpate this list
  13905. * @returns the list of color gradients
  13906. */
  13907. getColorGradients(): Nullable<Array<ColorGradient>>;
  13908. /**
  13909. * Adds a new ramp gradient used to remap particle colors
  13910. * @param gradient defines the gradient to use (between 0 and 1)
  13911. * @param color defines the color to affect to the specified gradient
  13912. * @returns the current particle system
  13913. */
  13914. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13915. /**
  13916. * Gets the current list of ramp gradients.
  13917. * You must use addRampGradient and removeRampGradient to udpate this list
  13918. * @returns the list of ramp gradients
  13919. */
  13920. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13921. /** Gets or sets a boolean indicating that ramp gradients must be used
  13922. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13923. */
  13924. useRampGradients: boolean;
  13925. /**
  13926. * Adds a new color remap gradient
  13927. * @param gradient defines the gradient to use (between 0 and 1)
  13928. * @param min defines the color remap minimal range
  13929. * @param max defines the color remap maximal range
  13930. * @returns the current particle system
  13931. */
  13932. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13933. /**
  13934. * Gets the current list of color remap gradients.
  13935. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13936. * @returns the list of color remap gradients
  13937. */
  13938. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13939. /**
  13940. * Adds a new alpha remap gradient
  13941. * @param gradient defines the gradient to use (between 0 and 1)
  13942. * @param min defines the alpha remap minimal range
  13943. * @param max defines the alpha remap maximal range
  13944. * @returns the current particle system
  13945. */
  13946. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13947. /**
  13948. * Gets the current list of alpha remap gradients.
  13949. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13950. * @returns the list of alpha remap gradients
  13951. */
  13952. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13953. /**
  13954. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13957. * @returns the emitter
  13958. */
  13959. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13960. /**
  13961. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13962. * @param radius The radius of the hemisphere to emit from
  13963. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13964. * @returns the emitter
  13965. */
  13966. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13967. /**
  13968. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13969. * @param radius The radius of the sphere to emit from
  13970. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13971. * @returns the emitter
  13972. */
  13973. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13974. /**
  13975. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13976. * @param radius The radius of the sphere to emit from
  13977. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13978. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13979. * @returns the emitter
  13980. */
  13981. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13982. /**
  13983. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13984. * @param radius The radius of the emission cylinder
  13985. * @param height The height of the emission cylinder
  13986. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13987. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13988. * @returns the emitter
  13989. */
  13990. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13991. /**
  13992. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13993. * @param radius The radius of the cylinder to emit from
  13994. * @param height The height of the emission cylinder
  13995. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13996. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13997. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13998. * @returns the emitter
  13999. */
  14000. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14001. /**
  14002. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14003. * @param radius The radius of the cone to emit from
  14004. * @param angle The base angle of the cone
  14005. * @returns the emitter
  14006. */
  14007. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14008. /**
  14009. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14010. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14011. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14012. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14013. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14014. * @returns the emitter
  14015. */
  14016. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14017. /**
  14018. * Get hosting scene
  14019. * @returns the scene
  14020. */
  14021. getScene(): Scene;
  14022. }
  14023. }
  14024. declare module "babylonjs/Meshes/transformNode" {
  14025. import { DeepImmutable } from "babylonjs/types";
  14026. import { Observable } from "babylonjs/Misc/observable";
  14027. import { Nullable } from "babylonjs/types";
  14028. import { Camera } from "babylonjs/Cameras/camera";
  14029. import { Scene } from "babylonjs/scene";
  14030. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14031. import { Node } from "babylonjs/node";
  14032. import { Bone } from "babylonjs/Bones/bone";
  14033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14034. import { Space } from "babylonjs/Maths/math.axis";
  14035. /**
  14036. * 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.
  14037. * @see https://doc.babylonjs.com/how_to/transformnode
  14038. */
  14039. export class TransformNode extends Node {
  14040. /**
  14041. * Object will not rotate to face the camera
  14042. */
  14043. static BILLBOARDMODE_NONE: number;
  14044. /**
  14045. * Object will rotate to face the camera but only on the x axis
  14046. */
  14047. static BILLBOARDMODE_X: number;
  14048. /**
  14049. * Object will rotate to face the camera but only on the y axis
  14050. */
  14051. static BILLBOARDMODE_Y: number;
  14052. /**
  14053. * Object will rotate to face the camera but only on the z axis
  14054. */
  14055. static BILLBOARDMODE_Z: number;
  14056. /**
  14057. * Object will rotate to face the camera
  14058. */
  14059. static BILLBOARDMODE_ALL: number;
  14060. /**
  14061. * Object will rotate to face the camera's position instead of orientation
  14062. */
  14063. static BILLBOARDMODE_USE_POSITION: number;
  14064. private _forward;
  14065. private _forwardInverted;
  14066. private _up;
  14067. private _right;
  14068. private _rightInverted;
  14069. private _position;
  14070. private _rotation;
  14071. private _rotationQuaternion;
  14072. protected _scaling: Vector3;
  14073. protected _isDirty: boolean;
  14074. private _transformToBoneReferal;
  14075. private _isAbsoluteSynced;
  14076. private _billboardMode;
  14077. /**
  14078. * Gets or sets the billboard mode. Default is 0.
  14079. *
  14080. * | Value | Type | Description |
  14081. * | --- | --- | --- |
  14082. * | 0 | BILLBOARDMODE_NONE | |
  14083. * | 1 | BILLBOARDMODE_X | |
  14084. * | 2 | BILLBOARDMODE_Y | |
  14085. * | 4 | BILLBOARDMODE_Z | |
  14086. * | 7 | BILLBOARDMODE_ALL | |
  14087. *
  14088. */
  14089. get billboardMode(): number;
  14090. set billboardMode(value: number);
  14091. private _preserveParentRotationForBillboard;
  14092. /**
  14093. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14094. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14095. */
  14096. get preserveParentRotationForBillboard(): boolean;
  14097. set preserveParentRotationForBillboard(value: boolean);
  14098. /**
  14099. * 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
  14100. */
  14101. scalingDeterminant: number;
  14102. private _infiniteDistance;
  14103. /**
  14104. * Gets or sets the distance of the object to max, often used by skybox
  14105. */
  14106. get infiniteDistance(): boolean;
  14107. set infiniteDistance(value: boolean);
  14108. /**
  14109. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14110. * By default the system will update normals to compensate
  14111. */
  14112. ignoreNonUniformScaling: boolean;
  14113. /**
  14114. * 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
  14115. */
  14116. reIntegrateRotationIntoRotationQuaternion: boolean;
  14117. /** @hidden */
  14118. _poseMatrix: Nullable<Matrix>;
  14119. /** @hidden */
  14120. _localMatrix: Matrix;
  14121. private _usePivotMatrix;
  14122. private _absolutePosition;
  14123. private _absoluteScaling;
  14124. private _absoluteRotationQuaternion;
  14125. private _pivotMatrix;
  14126. private _pivotMatrixInverse;
  14127. protected _postMultiplyPivotMatrix: boolean;
  14128. protected _isWorldMatrixFrozen: boolean;
  14129. /** @hidden */
  14130. _indexInSceneTransformNodesArray: number;
  14131. /**
  14132. * An event triggered after the world matrix is updated
  14133. */
  14134. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14135. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14136. /**
  14137. * Gets a string identifying the name of the class
  14138. * @returns "TransformNode" string
  14139. */
  14140. getClassName(): string;
  14141. /**
  14142. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14143. */
  14144. get position(): Vector3;
  14145. set position(newPosition: Vector3);
  14146. /**
  14147. * 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)).
  14148. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14149. */
  14150. get rotation(): Vector3;
  14151. set rotation(newRotation: Vector3);
  14152. /**
  14153. * 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)).
  14154. */
  14155. get scaling(): Vector3;
  14156. set scaling(newScaling: Vector3);
  14157. /**
  14158. * 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).
  14159. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14160. */
  14161. get rotationQuaternion(): Nullable<Quaternion>;
  14162. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14163. /**
  14164. * The forward direction of that transform in world space.
  14165. */
  14166. get forward(): Vector3;
  14167. /**
  14168. * The up direction of that transform in world space.
  14169. */
  14170. get up(): Vector3;
  14171. /**
  14172. * The right direction of that transform in world space.
  14173. */
  14174. get right(): Vector3;
  14175. /**
  14176. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14177. * @param matrix the matrix to copy the pose from
  14178. * @returns this TransformNode.
  14179. */
  14180. updatePoseMatrix(matrix: Matrix): TransformNode;
  14181. /**
  14182. * Returns the mesh Pose matrix.
  14183. * @returns the pose matrix
  14184. */
  14185. getPoseMatrix(): Matrix;
  14186. /** @hidden */
  14187. _isSynchronized(): boolean;
  14188. /** @hidden */
  14189. _initCache(): void;
  14190. /**
  14191. * Flag the transform node as dirty (Forcing it to update everything)
  14192. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14193. * @returns this transform node
  14194. */
  14195. markAsDirty(property: string): TransformNode;
  14196. /**
  14197. * Returns the current mesh absolute position.
  14198. * Returns a Vector3.
  14199. */
  14200. get absolutePosition(): Vector3;
  14201. /**
  14202. * Returns the current mesh absolute scaling.
  14203. * Returns a Vector3.
  14204. */
  14205. get absoluteScaling(): Vector3;
  14206. /**
  14207. * Returns the current mesh absolute rotation.
  14208. * Returns a Quaternion.
  14209. */
  14210. get absoluteRotationQuaternion(): Quaternion;
  14211. /**
  14212. * Sets a new matrix to apply before all other transformation
  14213. * @param matrix defines the transform matrix
  14214. * @returns the current TransformNode
  14215. */
  14216. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14217. /**
  14218. * Sets a new pivot matrix to the current node
  14219. * @param matrix defines the new pivot matrix to use
  14220. * @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
  14221. * @returns the current TransformNode
  14222. */
  14223. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14224. /**
  14225. * Returns the mesh pivot matrix.
  14226. * Default : Identity.
  14227. * @returns the matrix
  14228. */
  14229. getPivotMatrix(): Matrix;
  14230. /**
  14231. * Instantiate (when possible) or clone that node with its hierarchy
  14232. * @param newParent defines the new parent to use for the instance (or clone)
  14233. * @param options defines options to configure how copy is done
  14234. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14235. * @returns an instance (or a clone) of the current node with its hiearchy
  14236. */
  14237. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14238. doNotInstantiate: boolean;
  14239. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14240. /**
  14241. * Prevents the World matrix to be computed any longer
  14242. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14243. * @returns the TransformNode.
  14244. */
  14245. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14246. /**
  14247. * Allows back the World matrix computation.
  14248. * @returns the TransformNode.
  14249. */
  14250. unfreezeWorldMatrix(): this;
  14251. /**
  14252. * True if the World matrix has been frozen.
  14253. */
  14254. get isWorldMatrixFrozen(): boolean;
  14255. /**
  14256. * Retuns the mesh absolute position in the World.
  14257. * @returns a Vector3.
  14258. */
  14259. getAbsolutePosition(): Vector3;
  14260. /**
  14261. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14262. * @param absolutePosition the absolute position to set
  14263. * @returns the TransformNode.
  14264. */
  14265. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14266. /**
  14267. * Sets the mesh position in its local space.
  14268. * @param vector3 the position to set in localspace
  14269. * @returns the TransformNode.
  14270. */
  14271. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14272. /**
  14273. * Returns the mesh position in the local space from the current World matrix values.
  14274. * @returns a new Vector3.
  14275. */
  14276. getPositionExpressedInLocalSpace(): Vector3;
  14277. /**
  14278. * Translates the mesh along the passed Vector3 in its local space.
  14279. * @param vector3 the distance to translate in localspace
  14280. * @returns the TransformNode.
  14281. */
  14282. locallyTranslate(vector3: Vector3): TransformNode;
  14283. private static _lookAtVectorCache;
  14284. /**
  14285. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14286. * @param targetPoint the position (must be in same space as current mesh) to look at
  14287. * @param yawCor optional yaw (y-axis) correction in radians
  14288. * @param pitchCor optional pitch (x-axis) correction in radians
  14289. * @param rollCor optional roll (z-axis) correction in radians
  14290. * @param space the choosen space of the target
  14291. * @returns the TransformNode.
  14292. */
  14293. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14294. /**
  14295. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14296. * This Vector3 is expressed in the World space.
  14297. * @param localAxis axis to rotate
  14298. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14299. */
  14300. getDirection(localAxis: Vector3): Vector3;
  14301. /**
  14302. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14303. * localAxis is expressed in the mesh local space.
  14304. * result is computed in the Wordl space from the mesh World matrix.
  14305. * @param localAxis axis to rotate
  14306. * @param result the resulting transformnode
  14307. * @returns this TransformNode.
  14308. */
  14309. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14310. /**
  14311. * Sets this transform node rotation to the given local axis.
  14312. * @param localAxis the axis in local space
  14313. * @param yawCor optional yaw (y-axis) correction in radians
  14314. * @param pitchCor optional pitch (x-axis) correction in radians
  14315. * @param rollCor optional roll (z-axis) correction in radians
  14316. * @returns this TransformNode
  14317. */
  14318. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14319. /**
  14320. * Sets a new pivot point to the current node
  14321. * @param point defines the new pivot point to use
  14322. * @param space defines if the point is in world or local space (local by default)
  14323. * @returns the current TransformNode
  14324. */
  14325. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14326. /**
  14327. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14328. * @returns the pivot point
  14329. */
  14330. getPivotPoint(): Vector3;
  14331. /**
  14332. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14333. * @param result the vector3 to store the result
  14334. * @returns this TransformNode.
  14335. */
  14336. getPivotPointToRef(result: Vector3): TransformNode;
  14337. /**
  14338. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14339. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14340. */
  14341. getAbsolutePivotPoint(): Vector3;
  14342. /**
  14343. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14344. * @param result vector3 to store the result
  14345. * @returns this TransformNode.
  14346. */
  14347. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14348. /**
  14349. * Defines the passed node as the parent of the current node.
  14350. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14351. * @see https://doc.babylonjs.com/how_to/parenting
  14352. * @param node the node ot set as the parent
  14353. * @returns this TransformNode.
  14354. */
  14355. setParent(node: Nullable<Node>): TransformNode;
  14356. private _nonUniformScaling;
  14357. /**
  14358. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14359. */
  14360. get nonUniformScaling(): boolean;
  14361. /** @hidden */
  14362. _updateNonUniformScalingState(value: boolean): boolean;
  14363. /**
  14364. * Attach the current TransformNode to another TransformNode associated with a bone
  14365. * @param bone Bone affecting the TransformNode
  14366. * @param affectedTransformNode TransformNode associated with the bone
  14367. * @returns this object
  14368. */
  14369. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14370. /**
  14371. * Detach the transform node if its associated with a bone
  14372. * @returns this object
  14373. */
  14374. detachFromBone(): TransformNode;
  14375. private static _rotationAxisCache;
  14376. /**
  14377. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14378. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14379. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14380. * The passed axis is also normalized.
  14381. * @param axis the axis to rotate around
  14382. * @param amount the amount to rotate in radians
  14383. * @param space Space to rotate in (Default: local)
  14384. * @returns the TransformNode.
  14385. */
  14386. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14387. /**
  14388. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14389. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14390. * The passed axis is also normalized. .
  14391. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14392. * @param point the point to rotate around
  14393. * @param axis the axis to rotate around
  14394. * @param amount the amount to rotate in radians
  14395. * @returns the TransformNode
  14396. */
  14397. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14398. /**
  14399. * Translates the mesh along the axis vector for the passed distance in the given space.
  14400. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14401. * @param axis the axis to translate in
  14402. * @param distance the distance to translate
  14403. * @param space Space to rotate in (Default: local)
  14404. * @returns the TransformNode.
  14405. */
  14406. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14407. /**
  14408. * Adds a rotation step to the mesh current rotation.
  14409. * x, y, z are Euler angles expressed in radians.
  14410. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14411. * This means this rotation is made in the mesh local space only.
  14412. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14413. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14414. * ```javascript
  14415. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14416. * ```
  14417. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14418. * 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.
  14419. * @param x Rotation to add
  14420. * @param y Rotation to add
  14421. * @param z Rotation to add
  14422. * @returns the TransformNode.
  14423. */
  14424. addRotation(x: number, y: number, z: number): TransformNode;
  14425. /**
  14426. * @hidden
  14427. */
  14428. protected _getEffectiveParent(): Nullable<Node>;
  14429. /**
  14430. * Computes the world matrix of the node
  14431. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14432. * @returns the world matrix
  14433. */
  14434. computeWorldMatrix(force?: boolean): Matrix;
  14435. /**
  14436. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14437. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14438. */
  14439. resetLocalMatrix(independentOfChildren?: boolean): void;
  14440. protected _afterComputeWorldMatrix(): void;
  14441. /**
  14442. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14443. * @param func callback function to add
  14444. *
  14445. * @returns the TransformNode.
  14446. */
  14447. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14448. /**
  14449. * Removes a registered callback function.
  14450. * @param func callback function to remove
  14451. * @returns the TransformNode.
  14452. */
  14453. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14454. /**
  14455. * Gets the position of the current mesh in camera space
  14456. * @param camera defines the camera to use
  14457. * @returns a position
  14458. */
  14459. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14460. /**
  14461. * Returns the distance from the mesh to the active camera
  14462. * @param camera defines the camera to use
  14463. * @returns the distance
  14464. */
  14465. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14466. /**
  14467. * Clone the current transform node
  14468. * @param name Name of the new clone
  14469. * @param newParent New parent for the clone
  14470. * @param doNotCloneChildren Do not clone children hierarchy
  14471. * @returns the new transform node
  14472. */
  14473. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14474. /**
  14475. * Serializes the objects information.
  14476. * @param currentSerializationObject defines the object to serialize in
  14477. * @returns the serialized object
  14478. */
  14479. serialize(currentSerializationObject?: any): any;
  14480. /**
  14481. * Returns a new TransformNode object parsed from the source provided.
  14482. * @param parsedTransformNode is the source.
  14483. * @param scene the scne the object belongs to
  14484. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14485. * @returns a new TransformNode object parsed from the source provided.
  14486. */
  14487. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14488. /**
  14489. * Get all child-transformNodes of this node
  14490. * @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
  14491. * @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
  14492. * @returns an array of TransformNode
  14493. */
  14494. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14495. /**
  14496. * Releases resources associated with this transform node.
  14497. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14498. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14499. */
  14500. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14501. /**
  14502. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14503. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14504. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14505. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14506. * @returns the current mesh
  14507. */
  14508. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14509. private _syncAbsoluteScalingAndRotation;
  14510. }
  14511. }
  14512. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14513. /**
  14514. * Class used to override all child animations of a given target
  14515. */
  14516. export class AnimationPropertiesOverride {
  14517. /**
  14518. * Gets or sets a value indicating if animation blending must be used
  14519. */
  14520. enableBlending: boolean;
  14521. /**
  14522. * Gets or sets the blending speed to use when enableBlending is true
  14523. */
  14524. blendingSpeed: number;
  14525. /**
  14526. * Gets or sets the default loop mode to use
  14527. */
  14528. loopMode: number;
  14529. }
  14530. }
  14531. declare module "babylonjs/Bones/bone" {
  14532. import { Skeleton } from "babylonjs/Bones/skeleton";
  14533. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14534. import { Nullable } from "babylonjs/types";
  14535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14536. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14537. import { Node } from "babylonjs/node";
  14538. import { Space } from "babylonjs/Maths/math.axis";
  14539. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14540. /**
  14541. * Class used to store bone information
  14542. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14543. */
  14544. export class Bone extends Node {
  14545. /**
  14546. * defines the bone name
  14547. */
  14548. name: string;
  14549. private static _tmpVecs;
  14550. private static _tmpQuat;
  14551. private static _tmpMats;
  14552. /**
  14553. * Gets the list of child bones
  14554. */
  14555. children: Bone[];
  14556. /** Gets the animations associated with this bone */
  14557. animations: import("babylonjs/Animations/animation").Animation[];
  14558. /**
  14559. * Gets or sets bone length
  14560. */
  14561. length: number;
  14562. /**
  14563. * @hidden Internal only
  14564. * Set this value to map this bone to a different index in the transform matrices
  14565. * Set this value to -1 to exclude the bone from the transform matrices
  14566. */
  14567. _index: Nullable<number>;
  14568. private _skeleton;
  14569. private _localMatrix;
  14570. private _restPose;
  14571. private _baseMatrix;
  14572. private _absoluteTransform;
  14573. private _invertedAbsoluteTransform;
  14574. private _parent;
  14575. private _scalingDeterminant;
  14576. private _worldTransform;
  14577. private _localScaling;
  14578. private _localRotation;
  14579. private _localPosition;
  14580. private _needToDecompose;
  14581. private _needToCompose;
  14582. /** @hidden */
  14583. _linkedTransformNode: Nullable<TransformNode>;
  14584. /** @hidden */
  14585. _waitingTransformNodeId: Nullable<string>;
  14586. /** @hidden */
  14587. get _matrix(): Matrix;
  14588. /** @hidden */
  14589. set _matrix(value: Matrix);
  14590. /**
  14591. * Create a new bone
  14592. * @param name defines the bone name
  14593. * @param skeleton defines the parent skeleton
  14594. * @param parentBone defines the parent (can be null if the bone is the root)
  14595. * @param localMatrix defines the local matrix
  14596. * @param restPose defines the rest pose matrix
  14597. * @param baseMatrix defines the base matrix
  14598. * @param index defines index of the bone in the hiearchy
  14599. */
  14600. constructor(
  14601. /**
  14602. * defines the bone name
  14603. */
  14604. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14605. /**
  14606. * Gets the current object class name.
  14607. * @return the class name
  14608. */
  14609. getClassName(): string;
  14610. /**
  14611. * Gets the parent skeleton
  14612. * @returns a skeleton
  14613. */
  14614. getSkeleton(): Skeleton;
  14615. /**
  14616. * Gets parent bone
  14617. * @returns a bone or null if the bone is the root of the bone hierarchy
  14618. */
  14619. getParent(): Nullable<Bone>;
  14620. /**
  14621. * Returns an array containing the root bones
  14622. * @returns an array containing the root bones
  14623. */
  14624. getChildren(): Array<Bone>;
  14625. /**
  14626. * Gets the node index in matrix array generated for rendering
  14627. * @returns the node index
  14628. */
  14629. getIndex(): number;
  14630. /**
  14631. * Sets the parent bone
  14632. * @param parent defines the parent (can be null if the bone is the root)
  14633. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14634. */
  14635. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14636. /**
  14637. * Gets the local matrix
  14638. * @returns a matrix
  14639. */
  14640. getLocalMatrix(): Matrix;
  14641. /**
  14642. * Gets the base matrix (initial matrix which remains unchanged)
  14643. * @returns a matrix
  14644. */
  14645. getBaseMatrix(): Matrix;
  14646. /**
  14647. * Gets the rest pose matrix
  14648. * @returns a matrix
  14649. */
  14650. getRestPose(): Matrix;
  14651. /**
  14652. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14653. */
  14654. getWorldMatrix(): Matrix;
  14655. /**
  14656. * Sets the local matrix to rest pose matrix
  14657. */
  14658. returnToRest(): void;
  14659. /**
  14660. * Gets the inverse of the absolute transform matrix.
  14661. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14662. * @returns a matrix
  14663. */
  14664. getInvertedAbsoluteTransform(): Matrix;
  14665. /**
  14666. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14667. * @returns a matrix
  14668. */
  14669. getAbsoluteTransform(): Matrix;
  14670. /**
  14671. * Links with the given transform node.
  14672. * The local matrix of this bone is copied from the transform node every frame.
  14673. * @param transformNode defines the transform node to link to
  14674. */
  14675. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14676. /**
  14677. * Gets the node used to drive the bone's transformation
  14678. * @returns a transform node or null
  14679. */
  14680. getTransformNode(): Nullable<TransformNode>;
  14681. /** Gets or sets current position (in local space) */
  14682. get position(): Vector3;
  14683. set position(newPosition: Vector3);
  14684. /** Gets or sets current rotation (in local space) */
  14685. get rotation(): Vector3;
  14686. set rotation(newRotation: Vector3);
  14687. /** Gets or sets current rotation quaternion (in local space) */
  14688. get rotationQuaternion(): Quaternion;
  14689. set rotationQuaternion(newRotation: Quaternion);
  14690. /** Gets or sets current scaling (in local space) */
  14691. get scaling(): Vector3;
  14692. set scaling(newScaling: Vector3);
  14693. /**
  14694. * Gets the animation properties override
  14695. */
  14696. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14697. private _decompose;
  14698. private _compose;
  14699. /**
  14700. * Update the base and local matrices
  14701. * @param matrix defines the new base or local matrix
  14702. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14703. * @param updateLocalMatrix defines if the local matrix should be updated
  14704. */
  14705. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14706. /** @hidden */
  14707. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14708. /**
  14709. * Flag the bone as dirty (Forcing it to update everything)
  14710. */
  14711. markAsDirty(): void;
  14712. /** @hidden */
  14713. _markAsDirtyAndCompose(): void;
  14714. private _markAsDirtyAndDecompose;
  14715. /**
  14716. * Translate the bone in local or world space
  14717. * @param vec The amount to translate the bone
  14718. * @param space The space that the translation is in
  14719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14720. */
  14721. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14722. /**
  14723. * Set the postion of the bone in local or world space
  14724. * @param position The position to set the bone
  14725. * @param space The space that the position is in
  14726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14727. */
  14728. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14729. /**
  14730. * Set the absolute position of the bone (world space)
  14731. * @param position The position to set the bone
  14732. * @param mesh The mesh that this bone is attached to
  14733. */
  14734. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14735. /**
  14736. * Scale the bone on the x, y and z axes (in local space)
  14737. * @param x The amount to scale the bone on the x axis
  14738. * @param y The amount to scale the bone on the y axis
  14739. * @param z The amount to scale the bone on the z axis
  14740. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14741. */
  14742. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14743. /**
  14744. * Set the bone scaling in local space
  14745. * @param scale defines the scaling vector
  14746. */
  14747. setScale(scale: Vector3): void;
  14748. /**
  14749. * Gets the current scaling in local space
  14750. * @returns the current scaling vector
  14751. */
  14752. getScale(): Vector3;
  14753. /**
  14754. * Gets the current scaling in local space and stores it in a target vector
  14755. * @param result defines the target vector
  14756. */
  14757. getScaleToRef(result: Vector3): void;
  14758. /**
  14759. * Set the yaw, pitch, and roll of the bone in local or world space
  14760. * @param yaw The rotation of the bone on the y axis
  14761. * @param pitch The rotation of the bone on the x axis
  14762. * @param roll The rotation of the bone on the z axis
  14763. * @param space The space that the axes of rotation are in
  14764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14765. */
  14766. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14767. /**
  14768. * Add a rotation to the bone on an axis in local or world space
  14769. * @param axis The axis to rotate the bone on
  14770. * @param amount The amount to rotate the bone
  14771. * @param space The space that the axis is in
  14772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14773. */
  14774. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14775. /**
  14776. * Set the rotation of the bone to a particular axis angle in local or world space
  14777. * @param axis The axis to rotate the bone on
  14778. * @param angle The angle that the bone should be rotated to
  14779. * @param space The space that the axis is in
  14780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14781. */
  14782. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14783. /**
  14784. * Set the euler rotation of the bone in local of world space
  14785. * @param rotation The euler rotation that the bone should be set to
  14786. * @param space The space that the rotation is in
  14787. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14788. */
  14789. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14790. /**
  14791. * Set the quaternion rotation of the bone in local of world space
  14792. * @param quat The quaternion rotation that the bone should be set to
  14793. * @param space The space that the rotation is in
  14794. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14795. */
  14796. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14797. /**
  14798. * Set the rotation matrix of the bone in local of world space
  14799. * @param rotMat The rotation matrix that the bone should be set to
  14800. * @param space The space that the rotation is in
  14801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14802. */
  14803. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14804. private _rotateWithMatrix;
  14805. private _getNegativeRotationToRef;
  14806. /**
  14807. * Get the position of the bone in local or world space
  14808. * @param space The space that the returned position is in
  14809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14810. * @returns The position of the bone
  14811. */
  14812. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14813. /**
  14814. * Copy the position of the bone to a vector3 in local or world space
  14815. * @param space The space that the returned position is in
  14816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14817. * @param result The vector3 to copy the position to
  14818. */
  14819. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14820. /**
  14821. * Get the absolute position of the bone (world space)
  14822. * @param mesh The mesh that this bone is attached to
  14823. * @returns The absolute position of the bone
  14824. */
  14825. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14826. /**
  14827. * Copy the absolute position of the bone (world space) to the result param
  14828. * @param mesh The mesh that this bone is attached to
  14829. * @param result The vector3 to copy the absolute position to
  14830. */
  14831. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14832. /**
  14833. * Compute the absolute transforms of this bone and its children
  14834. */
  14835. computeAbsoluteTransforms(): void;
  14836. /**
  14837. * Get the world direction from an axis that is in the local space of the bone
  14838. * @param localAxis The local direction that is used to compute the world direction
  14839. * @param mesh The mesh that this bone is attached to
  14840. * @returns The world direction
  14841. */
  14842. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14843. /**
  14844. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14845. * @param localAxis The local direction that is used to compute the world direction
  14846. * @param mesh The mesh that this bone is attached to
  14847. * @param result The vector3 that the world direction will be copied to
  14848. */
  14849. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14850. /**
  14851. * Get the euler rotation of the bone in local or world space
  14852. * @param space The space that the rotation should be in
  14853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14854. * @returns The euler rotation
  14855. */
  14856. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14857. /**
  14858. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14859. * @param space The space that the rotation should be in
  14860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14861. * @param result The vector3 that the rotation should be copied to
  14862. */
  14863. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14864. /**
  14865. * Get the quaternion rotation of the bone in either local or world space
  14866. * @param space The space that the rotation should be in
  14867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14868. * @returns The quaternion rotation
  14869. */
  14870. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14871. /**
  14872. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14873. * @param space The space that the rotation should be in
  14874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14875. * @param result The quaternion that the rotation should be copied to
  14876. */
  14877. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14878. /**
  14879. * Get the rotation matrix of the bone in local or world space
  14880. * @param space The space that the rotation should be in
  14881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14882. * @returns The rotation matrix
  14883. */
  14884. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14885. /**
  14886. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14887. * @param space The space that the rotation should be in
  14888. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14889. * @param result The quaternion that the rotation should be copied to
  14890. */
  14891. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14892. /**
  14893. * Get the world position of a point that is in the local space of the bone
  14894. * @param position The local position
  14895. * @param mesh The mesh that this bone is attached to
  14896. * @returns The world position
  14897. */
  14898. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14899. /**
  14900. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14901. * @param position The local position
  14902. * @param mesh The mesh that this bone is attached to
  14903. * @param result The vector3 that the world position should be copied to
  14904. */
  14905. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14906. /**
  14907. * Get the local position of a point that is in world space
  14908. * @param position The world position
  14909. * @param mesh The mesh that this bone is attached to
  14910. * @returns The local position
  14911. */
  14912. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14913. /**
  14914. * Get the local position of a point that is in world space and copy it to the result param
  14915. * @param position The world position
  14916. * @param mesh The mesh that this bone is attached to
  14917. * @param result The vector3 that the local position should be copied to
  14918. */
  14919. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14920. }
  14921. }
  14922. declare module "babylonjs/Animations/runtimeAnimation" {
  14923. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14924. import { Animatable } from "babylonjs/Animations/animatable";
  14925. import { Scene } from "babylonjs/scene";
  14926. /**
  14927. * Defines a runtime animation
  14928. */
  14929. export class RuntimeAnimation {
  14930. private _events;
  14931. /**
  14932. * The current frame of the runtime animation
  14933. */
  14934. private _currentFrame;
  14935. /**
  14936. * The animation used by the runtime animation
  14937. */
  14938. private _animation;
  14939. /**
  14940. * The target of the runtime animation
  14941. */
  14942. private _target;
  14943. /**
  14944. * The initiating animatable
  14945. */
  14946. private _host;
  14947. /**
  14948. * The original value of the runtime animation
  14949. */
  14950. private _originalValue;
  14951. /**
  14952. * The original blend value of the runtime animation
  14953. */
  14954. private _originalBlendValue;
  14955. /**
  14956. * The offsets cache of the runtime animation
  14957. */
  14958. private _offsetsCache;
  14959. /**
  14960. * The high limits cache of the runtime animation
  14961. */
  14962. private _highLimitsCache;
  14963. /**
  14964. * Specifies if the runtime animation has been stopped
  14965. */
  14966. private _stopped;
  14967. /**
  14968. * The blending factor of the runtime animation
  14969. */
  14970. private _blendingFactor;
  14971. /**
  14972. * The BabylonJS scene
  14973. */
  14974. private _scene;
  14975. /**
  14976. * The current value of the runtime animation
  14977. */
  14978. private _currentValue;
  14979. /** @hidden */
  14980. _animationState: _IAnimationState;
  14981. /**
  14982. * The active target of the runtime animation
  14983. */
  14984. private _activeTargets;
  14985. private _currentActiveTarget;
  14986. private _directTarget;
  14987. /**
  14988. * The target path of the runtime animation
  14989. */
  14990. private _targetPath;
  14991. /**
  14992. * The weight of the runtime animation
  14993. */
  14994. private _weight;
  14995. /**
  14996. * The ratio offset of the runtime animation
  14997. */
  14998. private _ratioOffset;
  14999. /**
  15000. * The previous delay of the runtime animation
  15001. */
  15002. private _previousDelay;
  15003. /**
  15004. * The previous ratio of the runtime animation
  15005. */
  15006. private _previousRatio;
  15007. private _enableBlending;
  15008. private _keys;
  15009. private _minFrame;
  15010. private _maxFrame;
  15011. private _minValue;
  15012. private _maxValue;
  15013. private _targetIsArray;
  15014. /**
  15015. * Gets the current frame of the runtime animation
  15016. */
  15017. get currentFrame(): number;
  15018. /**
  15019. * Gets the weight of the runtime animation
  15020. */
  15021. get weight(): number;
  15022. /**
  15023. * Gets the current value of the runtime animation
  15024. */
  15025. get currentValue(): any;
  15026. /**
  15027. * Gets the target path of the runtime animation
  15028. */
  15029. get targetPath(): string;
  15030. /**
  15031. * Gets the actual target of the runtime animation
  15032. */
  15033. get target(): any;
  15034. /**
  15035. * Gets the additive state of the runtime animation
  15036. */
  15037. get isAdditive(): boolean;
  15038. /** @hidden */
  15039. _onLoop: () => void;
  15040. /**
  15041. * Create a new RuntimeAnimation object
  15042. * @param target defines the target of the animation
  15043. * @param animation defines the source animation object
  15044. * @param scene defines the hosting scene
  15045. * @param host defines the initiating Animatable
  15046. */
  15047. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15048. private _preparePath;
  15049. /**
  15050. * Gets the animation from the runtime animation
  15051. */
  15052. get animation(): Animation;
  15053. /**
  15054. * Resets the runtime animation to the beginning
  15055. * @param restoreOriginal defines whether to restore the target property to the original value
  15056. */
  15057. reset(restoreOriginal?: boolean): void;
  15058. /**
  15059. * Specifies if the runtime animation is stopped
  15060. * @returns Boolean specifying if the runtime animation is stopped
  15061. */
  15062. isStopped(): boolean;
  15063. /**
  15064. * Disposes of the runtime animation
  15065. */
  15066. dispose(): void;
  15067. /**
  15068. * Apply the interpolated value to the target
  15069. * @param currentValue defines the value computed by the animation
  15070. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15071. */
  15072. setValue(currentValue: any, weight: number): void;
  15073. private _getOriginalValues;
  15074. private _setValue;
  15075. /**
  15076. * Gets the loop pmode of the runtime animation
  15077. * @returns Loop Mode
  15078. */
  15079. private _getCorrectLoopMode;
  15080. /**
  15081. * Move the current animation to a given frame
  15082. * @param frame defines the frame to move to
  15083. */
  15084. goToFrame(frame: number): void;
  15085. /**
  15086. * @hidden Internal use only
  15087. */
  15088. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15089. /**
  15090. * Execute the current animation
  15091. * @param delay defines the delay to add to the current frame
  15092. * @param from defines the lower bound of the animation range
  15093. * @param to defines the upper bound of the animation range
  15094. * @param loop defines if the current animation must loop
  15095. * @param speedRatio defines the current speed ratio
  15096. * @param weight defines the weight of the animation (default is -1 so no weight)
  15097. * @param onLoop optional callback called when animation loops
  15098. * @returns a boolean indicating if the animation is running
  15099. */
  15100. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15101. }
  15102. }
  15103. declare module "babylonjs/Animations/animatable" {
  15104. import { Animation } from "babylonjs/Animations/animation";
  15105. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15106. import { Nullable } from "babylonjs/types";
  15107. import { Observable } from "babylonjs/Misc/observable";
  15108. import { Scene } from "babylonjs/scene";
  15109. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15110. import { Node } from "babylonjs/node";
  15111. /**
  15112. * Class used to store an actual running animation
  15113. */
  15114. export class Animatable {
  15115. /** defines the target object */
  15116. target: any;
  15117. /** defines the starting frame number (default is 0) */
  15118. fromFrame: number;
  15119. /** defines the ending frame number (default is 100) */
  15120. toFrame: number;
  15121. /** defines if the animation must loop (default is false) */
  15122. loopAnimation: boolean;
  15123. /** defines a callback to call when animation ends if it is not looping */
  15124. onAnimationEnd?: (() => void) | null | undefined;
  15125. /** defines a callback to call when animation loops */
  15126. onAnimationLoop?: (() => void) | null | undefined;
  15127. /** defines whether the animation should be evaluated additively */
  15128. isAdditive: boolean;
  15129. private _localDelayOffset;
  15130. private _pausedDelay;
  15131. private _runtimeAnimations;
  15132. private _paused;
  15133. private _scene;
  15134. private _speedRatio;
  15135. private _weight;
  15136. private _syncRoot;
  15137. /**
  15138. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15139. * This will only apply for non looping animation (default is true)
  15140. */
  15141. disposeOnEnd: boolean;
  15142. /**
  15143. * Gets a boolean indicating if the animation has started
  15144. */
  15145. animationStarted: boolean;
  15146. /**
  15147. * Observer raised when the animation ends
  15148. */
  15149. onAnimationEndObservable: Observable<Animatable>;
  15150. /**
  15151. * Observer raised when the animation loops
  15152. */
  15153. onAnimationLoopObservable: Observable<Animatable>;
  15154. /**
  15155. * Gets the root Animatable used to synchronize and normalize animations
  15156. */
  15157. get syncRoot(): Nullable<Animatable>;
  15158. /**
  15159. * Gets the current frame of the first RuntimeAnimation
  15160. * Used to synchronize Animatables
  15161. */
  15162. get masterFrame(): number;
  15163. /**
  15164. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15165. */
  15166. get weight(): number;
  15167. set weight(value: number);
  15168. /**
  15169. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15170. */
  15171. get speedRatio(): number;
  15172. set speedRatio(value: number);
  15173. /**
  15174. * Creates a new Animatable
  15175. * @param scene defines the hosting scene
  15176. * @param target defines the target object
  15177. * @param fromFrame defines the starting frame number (default is 0)
  15178. * @param toFrame defines the ending frame number (default is 100)
  15179. * @param loopAnimation defines if the animation must loop (default is false)
  15180. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15181. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15182. * @param animations defines a group of animation to add to the new Animatable
  15183. * @param onAnimationLoop defines a callback to call when animation loops
  15184. * @param isAdditive defines whether the animation should be evaluated additively
  15185. */
  15186. constructor(scene: Scene,
  15187. /** defines the target object */
  15188. target: any,
  15189. /** defines the starting frame number (default is 0) */
  15190. fromFrame?: number,
  15191. /** defines the ending frame number (default is 100) */
  15192. toFrame?: number,
  15193. /** defines if the animation must loop (default is false) */
  15194. loopAnimation?: boolean, speedRatio?: number,
  15195. /** defines a callback to call when animation ends if it is not looping */
  15196. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15197. /** defines a callback to call when animation loops */
  15198. onAnimationLoop?: (() => void) | null | undefined,
  15199. /** defines whether the animation should be evaluated additively */
  15200. isAdditive?: boolean);
  15201. /**
  15202. * Synchronize and normalize current Animatable with a source Animatable
  15203. * This is useful when using animation weights and when animations are not of the same length
  15204. * @param root defines the root Animatable to synchronize with
  15205. * @returns the current Animatable
  15206. */
  15207. syncWith(root: Animatable): Animatable;
  15208. /**
  15209. * Gets the list of runtime animations
  15210. * @returns an array of RuntimeAnimation
  15211. */
  15212. getAnimations(): RuntimeAnimation[];
  15213. /**
  15214. * Adds more animations to the current animatable
  15215. * @param target defines the target of the animations
  15216. * @param animations defines the new animations to add
  15217. */
  15218. appendAnimations(target: any, animations: Animation[]): void;
  15219. /**
  15220. * Gets the source animation for a specific property
  15221. * @param property defines the propertyu to look for
  15222. * @returns null or the source animation for the given property
  15223. */
  15224. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15225. /**
  15226. * Gets the runtime animation for a specific property
  15227. * @param property defines the propertyu to look for
  15228. * @returns null or the runtime animation for the given property
  15229. */
  15230. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15231. /**
  15232. * Resets the animatable to its original state
  15233. */
  15234. reset(): void;
  15235. /**
  15236. * Allows the animatable to blend with current running animations
  15237. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15238. * @param blendingSpeed defines the blending speed to use
  15239. */
  15240. enableBlending(blendingSpeed: number): void;
  15241. /**
  15242. * Disable animation blending
  15243. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15244. */
  15245. disableBlending(): void;
  15246. /**
  15247. * Jump directly to a given frame
  15248. * @param frame defines the frame to jump to
  15249. */
  15250. goToFrame(frame: number): void;
  15251. /**
  15252. * Pause the animation
  15253. */
  15254. pause(): void;
  15255. /**
  15256. * Restart the animation
  15257. */
  15258. restart(): void;
  15259. private _raiseOnAnimationEnd;
  15260. /**
  15261. * Stop and delete the current animation
  15262. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15263. * @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)
  15264. */
  15265. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15266. /**
  15267. * Wait asynchronously for the animation to end
  15268. * @returns a promise which will be fullfilled when the animation ends
  15269. */
  15270. waitAsync(): Promise<Animatable>;
  15271. /** @hidden */
  15272. _animate(delay: number): boolean;
  15273. }
  15274. module "babylonjs/scene" {
  15275. interface Scene {
  15276. /** @hidden */
  15277. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15278. /** @hidden */
  15279. _processLateAnimationBindingsForMatrices(holder: {
  15280. totalWeight: number;
  15281. totalAdditiveWeight: number;
  15282. animations: RuntimeAnimation[];
  15283. additiveAnimations: RuntimeAnimation[];
  15284. originalValue: Matrix;
  15285. }): any;
  15286. /** @hidden */
  15287. _processLateAnimationBindingsForQuaternions(holder: {
  15288. totalWeight: number;
  15289. totalAdditiveWeight: number;
  15290. animations: RuntimeAnimation[];
  15291. additiveAnimations: RuntimeAnimation[];
  15292. originalValue: Quaternion;
  15293. }, refQuaternion: Quaternion): Quaternion;
  15294. /** @hidden */
  15295. _processLateAnimationBindings(): void;
  15296. /**
  15297. * Will start the animation sequence of a given target
  15298. * @param target defines the target
  15299. * @param from defines from which frame should animation start
  15300. * @param to defines until which frame should animation run.
  15301. * @param weight defines the weight to apply to the animation (1.0 by default)
  15302. * @param loop defines if the animation loops
  15303. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15304. * @param onAnimationEnd defines the function to be executed when the animation ends
  15305. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15306. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15307. * @param onAnimationLoop defines the callback to call when an animation loops
  15308. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15309. * @returns the animatable object created for this animation
  15310. */
  15311. 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;
  15312. /**
  15313. * Will start the animation sequence of a given target
  15314. * @param target defines the target
  15315. * @param from defines from which frame should animation start
  15316. * @param to defines until which frame should animation run.
  15317. * @param loop defines if the animation loops
  15318. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15319. * @param onAnimationEnd defines the function to be executed when the animation ends
  15320. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15321. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15322. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15323. * @param onAnimationLoop defines the callback to call when an animation loops
  15324. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15325. * @returns the animatable object created for this animation
  15326. */
  15327. 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;
  15328. /**
  15329. * Will start the animation sequence of a given target and its hierarchy
  15330. * @param target defines the target
  15331. * @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.
  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 animated 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 list of created animatables
  15343. */
  15344. 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[];
  15345. /**
  15346. * Begin a new animation on a given node
  15347. * @param target defines the target where the animation will take place
  15348. * @param animations defines the list of animations to start
  15349. * @param from defines the initial value
  15350. * @param to defines the final value
  15351. * @param loop defines if you want animation to loop (off by default)
  15352. * @param speedRatio defines the speed ratio to apply to all animations
  15353. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15354. * @param onAnimationLoop defines the callback to call when an animation loops
  15355. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15356. * @returns the list of created animatables
  15357. */
  15358. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15359. /**
  15360. * Begin a new animation on a given node and its hierarchy
  15361. * @param target defines the root node where the animation will take place
  15362. * @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.
  15363. * @param animations defines the list of animations to start
  15364. * @param from defines the initial value
  15365. * @param to defines the final value
  15366. * @param loop defines if you want animation to loop (off by default)
  15367. * @param speedRatio defines the speed ratio to apply to all animations
  15368. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15369. * @param onAnimationLoop defines the callback to call when an animation loops
  15370. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15371. * @returns the list of animatables created for all nodes
  15372. */
  15373. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15374. /**
  15375. * Gets the animatable associated with a specific target
  15376. * @param target defines the target of the animatable
  15377. * @returns the required animatable if found
  15378. */
  15379. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15380. /**
  15381. * Gets all animatables associated with a given target
  15382. * @param target defines the target to look animatables for
  15383. * @returns an array of Animatables
  15384. */
  15385. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15386. /**
  15387. * Stops and removes all animations that have been applied to the scene
  15388. */
  15389. stopAllAnimations(): void;
  15390. /**
  15391. * Gets the current delta time used by animation engine
  15392. */
  15393. deltaTime: number;
  15394. }
  15395. }
  15396. module "babylonjs/Bones/bone" {
  15397. interface Bone {
  15398. /**
  15399. * Copy an animation range from another bone
  15400. * @param source defines the source bone
  15401. * @param rangeName defines the range name to copy
  15402. * @param frameOffset defines the frame offset
  15403. * @param rescaleAsRequired defines if rescaling must be applied if required
  15404. * @param skelDimensionsRatio defines the scaling ratio
  15405. * @returns true if operation was successful
  15406. */
  15407. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15408. }
  15409. }
  15410. }
  15411. declare module "babylonjs/Bones/skeleton" {
  15412. import { Bone } from "babylonjs/Bones/bone";
  15413. import { Observable } from "babylonjs/Misc/observable";
  15414. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15415. import { Scene } from "babylonjs/scene";
  15416. import { Nullable } from "babylonjs/types";
  15417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15418. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15419. import { Animatable } from "babylonjs/Animations/animatable";
  15420. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15421. import { Animation } from "babylonjs/Animations/animation";
  15422. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15423. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15424. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15425. /**
  15426. * Class used to handle skinning animations
  15427. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15428. */
  15429. export class Skeleton implements IAnimatable {
  15430. /** defines the skeleton name */
  15431. name: string;
  15432. /** defines the skeleton Id */
  15433. id: string;
  15434. /**
  15435. * Defines the list of child bones
  15436. */
  15437. bones: Bone[];
  15438. /**
  15439. * Defines an estimate of the dimension of the skeleton at rest
  15440. */
  15441. dimensionsAtRest: Vector3;
  15442. /**
  15443. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15444. */
  15445. needInitialSkinMatrix: boolean;
  15446. /**
  15447. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15448. */
  15449. overrideMesh: Nullable<AbstractMesh>;
  15450. /**
  15451. * Gets the list of animations attached to this skeleton
  15452. */
  15453. animations: Array<Animation>;
  15454. private _scene;
  15455. private _isDirty;
  15456. private _transformMatrices;
  15457. private _transformMatrixTexture;
  15458. private _meshesWithPoseMatrix;
  15459. private _animatables;
  15460. private _identity;
  15461. private _synchronizedWithMesh;
  15462. private _ranges;
  15463. private _lastAbsoluteTransformsUpdateId;
  15464. private _canUseTextureForBones;
  15465. private _uniqueId;
  15466. /** @hidden */
  15467. _numBonesWithLinkedTransformNode: number;
  15468. /** @hidden */
  15469. _hasWaitingData: Nullable<boolean>;
  15470. /**
  15471. * Specifies if the skeleton should be serialized
  15472. */
  15473. doNotSerialize: boolean;
  15474. private _useTextureToStoreBoneMatrices;
  15475. /**
  15476. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15477. * Please note that this option is not available if the hardware does not support it
  15478. */
  15479. get useTextureToStoreBoneMatrices(): boolean;
  15480. set useTextureToStoreBoneMatrices(value: boolean);
  15481. private _animationPropertiesOverride;
  15482. /**
  15483. * Gets or sets the animation properties override
  15484. */
  15485. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15486. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15487. /**
  15488. * List of inspectable custom properties (used by the Inspector)
  15489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15490. */
  15491. inspectableCustomProperties: IInspectable[];
  15492. /**
  15493. * An observable triggered before computing the skeleton's matrices
  15494. */
  15495. onBeforeComputeObservable: Observable<Skeleton>;
  15496. /**
  15497. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15498. */
  15499. get isUsingTextureForMatrices(): boolean;
  15500. /**
  15501. * Gets the unique ID of this skeleton
  15502. */
  15503. get uniqueId(): number;
  15504. /**
  15505. * Creates a new skeleton
  15506. * @param name defines the skeleton name
  15507. * @param id defines the skeleton Id
  15508. * @param scene defines the hosting scene
  15509. */
  15510. constructor(
  15511. /** defines the skeleton name */
  15512. name: string,
  15513. /** defines the skeleton Id */
  15514. id: string, scene: Scene);
  15515. /**
  15516. * Gets the current object class name.
  15517. * @return the class name
  15518. */
  15519. getClassName(): string;
  15520. /**
  15521. * Returns an array containing the root bones
  15522. * @returns an array containing the root bones
  15523. */
  15524. getChildren(): Array<Bone>;
  15525. /**
  15526. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15527. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15528. * @returns a Float32Array containing matrices data
  15529. */
  15530. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15531. /**
  15532. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15533. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15534. * @returns a raw texture containing the data
  15535. */
  15536. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15537. /**
  15538. * Gets the current hosting scene
  15539. * @returns a scene object
  15540. */
  15541. getScene(): Scene;
  15542. /**
  15543. * Gets a string representing the current skeleton data
  15544. * @param fullDetails defines a boolean indicating if we want a verbose version
  15545. * @returns a string representing the current skeleton data
  15546. */
  15547. toString(fullDetails?: boolean): string;
  15548. /**
  15549. * Get bone's index searching by name
  15550. * @param name defines bone's name to search for
  15551. * @return the indice of the bone. Returns -1 if not found
  15552. */
  15553. getBoneIndexByName(name: string): number;
  15554. /**
  15555. * Creater a new animation range
  15556. * @param name defines the name of the range
  15557. * @param from defines the start key
  15558. * @param to defines the end key
  15559. */
  15560. createAnimationRange(name: string, from: number, to: number): void;
  15561. /**
  15562. * Delete a specific animation range
  15563. * @param name defines the name of the range
  15564. * @param deleteFrames defines if frames must be removed as well
  15565. */
  15566. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15567. /**
  15568. * Gets a specific animation range
  15569. * @param name defines the name of the range to look for
  15570. * @returns the requested animation range or null if not found
  15571. */
  15572. getAnimationRange(name: string): Nullable<AnimationRange>;
  15573. /**
  15574. * Gets the list of all animation ranges defined on this skeleton
  15575. * @returns an array
  15576. */
  15577. getAnimationRanges(): Nullable<AnimationRange>[];
  15578. /**
  15579. * Copy animation range from a source skeleton.
  15580. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15581. * @param source defines the source skeleton
  15582. * @param name defines the name of the range to copy
  15583. * @param rescaleAsRequired defines if rescaling must be applied if required
  15584. * @returns true if operation was successful
  15585. */
  15586. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15587. /**
  15588. * Forces the skeleton to go to rest pose
  15589. */
  15590. returnToRest(): void;
  15591. private _getHighestAnimationFrame;
  15592. /**
  15593. * Begin a specific animation range
  15594. * @param name defines the name of the range to start
  15595. * @param loop defines if looping must be turned on (false by default)
  15596. * @param speedRatio defines the speed ratio to apply (1 by default)
  15597. * @param onAnimationEnd defines a callback which will be called when animation will end
  15598. * @returns a new animatable
  15599. */
  15600. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15601. /**
  15602. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15603. * @param skeleton defines the Skeleton containing the animation range to convert
  15604. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15605. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15606. * @returns the original skeleton
  15607. */
  15608. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15609. /** @hidden */
  15610. _markAsDirty(): void;
  15611. /** @hidden */
  15612. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15613. /** @hidden */
  15614. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15615. private _computeTransformMatrices;
  15616. /**
  15617. * Build all resources required to render a skeleton
  15618. */
  15619. prepare(): void;
  15620. /**
  15621. * Gets the list of animatables currently running for this skeleton
  15622. * @returns an array of animatables
  15623. */
  15624. getAnimatables(): IAnimatable[];
  15625. /**
  15626. * Clone the current skeleton
  15627. * @param name defines the name of the new skeleton
  15628. * @param id defines the id of the new skeleton
  15629. * @returns the new skeleton
  15630. */
  15631. clone(name: string, id?: string): Skeleton;
  15632. /**
  15633. * Enable animation blending for this skeleton
  15634. * @param blendingSpeed defines the blending speed to apply
  15635. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15636. */
  15637. enableBlending(blendingSpeed?: number): void;
  15638. /**
  15639. * Releases all resources associated with the current skeleton
  15640. */
  15641. dispose(): void;
  15642. /**
  15643. * Serialize the skeleton in a JSON object
  15644. * @returns a JSON object
  15645. */
  15646. serialize(): any;
  15647. /**
  15648. * Creates a new skeleton from serialized data
  15649. * @param parsedSkeleton defines the serialized data
  15650. * @param scene defines the hosting scene
  15651. * @returns a new skeleton
  15652. */
  15653. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15654. /**
  15655. * Compute all node absolute transforms
  15656. * @param forceUpdate defines if computation must be done even if cache is up to date
  15657. */
  15658. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15659. /**
  15660. * Gets the root pose matrix
  15661. * @returns a matrix
  15662. */
  15663. getPoseMatrix(): Nullable<Matrix>;
  15664. /**
  15665. * Sorts bones per internal index
  15666. */
  15667. sortBones(): void;
  15668. private _sortBones;
  15669. }
  15670. }
  15671. declare module "babylonjs/Meshes/instancedMesh" {
  15672. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15673. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15674. import { Camera } from "babylonjs/Cameras/camera";
  15675. import { Node } from "babylonjs/node";
  15676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15677. import { Mesh } from "babylonjs/Meshes/mesh";
  15678. import { Material } from "babylonjs/Materials/material";
  15679. import { Skeleton } from "babylonjs/Bones/skeleton";
  15680. import { Light } from "babylonjs/Lights/light";
  15681. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15682. /**
  15683. * Creates an instance based on a source mesh.
  15684. */
  15685. export class InstancedMesh extends AbstractMesh {
  15686. private _sourceMesh;
  15687. private _currentLOD;
  15688. /** @hidden */
  15689. _indexInSourceMeshInstanceArray: number;
  15690. constructor(name: string, source: Mesh);
  15691. /**
  15692. * Returns the string "InstancedMesh".
  15693. */
  15694. getClassName(): string;
  15695. /** Gets the list of lights affecting that mesh */
  15696. get lightSources(): Light[];
  15697. _resyncLightSources(): void;
  15698. _resyncLightSource(light: Light): void;
  15699. _removeLightSource(light: Light, dispose: boolean): void;
  15700. /**
  15701. * If the source mesh receives shadows
  15702. */
  15703. get receiveShadows(): boolean;
  15704. /**
  15705. * The material of the source mesh
  15706. */
  15707. get material(): Nullable<Material>;
  15708. /**
  15709. * Visibility of the source mesh
  15710. */
  15711. get visibility(): number;
  15712. /**
  15713. * Skeleton of the source mesh
  15714. */
  15715. get skeleton(): Nullable<Skeleton>;
  15716. /**
  15717. * Rendering ground id of the source mesh
  15718. */
  15719. get renderingGroupId(): number;
  15720. set renderingGroupId(value: number);
  15721. /**
  15722. * Returns the total number of vertices (integer).
  15723. */
  15724. getTotalVertices(): number;
  15725. /**
  15726. * Returns a positive integer : the total number of indices in this mesh geometry.
  15727. * @returns the numner of indices or zero if the mesh has no geometry.
  15728. */
  15729. getTotalIndices(): number;
  15730. /**
  15731. * The source mesh of the instance
  15732. */
  15733. get sourceMesh(): Mesh;
  15734. /**
  15735. * Is this node ready to be used/rendered
  15736. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15737. * @return {boolean} is it ready
  15738. */
  15739. isReady(completeCheck?: boolean): boolean;
  15740. /**
  15741. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15742. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15743. * @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.
  15744. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15745. */
  15746. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15747. /**
  15748. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15749. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15750. * The `data` are either a numeric array either a Float32Array.
  15751. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15752. * 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).
  15753. * Note that a new underlying VertexBuffer object is created each call.
  15754. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15755. *
  15756. * Possible `kind` values :
  15757. * - VertexBuffer.PositionKind
  15758. * - VertexBuffer.UVKind
  15759. * - VertexBuffer.UV2Kind
  15760. * - VertexBuffer.UV3Kind
  15761. * - VertexBuffer.UV4Kind
  15762. * - VertexBuffer.UV5Kind
  15763. * - VertexBuffer.UV6Kind
  15764. * - VertexBuffer.ColorKind
  15765. * - VertexBuffer.MatricesIndicesKind
  15766. * - VertexBuffer.MatricesIndicesExtraKind
  15767. * - VertexBuffer.MatricesWeightsKind
  15768. * - VertexBuffer.MatricesWeightsExtraKind
  15769. *
  15770. * Returns the Mesh.
  15771. */
  15772. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15773. /**
  15774. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15775. * If the mesh has no geometry, it is simply returned as it is.
  15776. * The `data` are either a numeric array either a Float32Array.
  15777. * No new underlying VertexBuffer object is created.
  15778. * 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.
  15779. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15780. *
  15781. * Possible `kind` values :
  15782. * - VertexBuffer.PositionKind
  15783. * - VertexBuffer.UVKind
  15784. * - VertexBuffer.UV2Kind
  15785. * - VertexBuffer.UV3Kind
  15786. * - VertexBuffer.UV4Kind
  15787. * - VertexBuffer.UV5Kind
  15788. * - VertexBuffer.UV6Kind
  15789. * - VertexBuffer.ColorKind
  15790. * - VertexBuffer.MatricesIndicesKind
  15791. * - VertexBuffer.MatricesIndicesExtraKind
  15792. * - VertexBuffer.MatricesWeightsKind
  15793. * - VertexBuffer.MatricesWeightsExtraKind
  15794. *
  15795. * Returns the Mesh.
  15796. */
  15797. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15798. /**
  15799. * Sets the mesh indices.
  15800. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15801. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15802. * This method creates a new index buffer each call.
  15803. * Returns the Mesh.
  15804. */
  15805. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15806. /**
  15807. * Boolean : True if the mesh owns the requested kind of data.
  15808. */
  15809. isVerticesDataPresent(kind: string): boolean;
  15810. /**
  15811. * Returns an array of indices (IndicesArray).
  15812. */
  15813. getIndices(): Nullable<IndicesArray>;
  15814. get _positions(): Nullable<Vector3[]>;
  15815. /**
  15816. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15817. * This means the mesh underlying bounding box and sphere are recomputed.
  15818. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15819. * @returns the current mesh
  15820. */
  15821. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15822. /** @hidden */
  15823. _preActivate(): InstancedMesh;
  15824. /** @hidden */
  15825. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15826. /** @hidden */
  15827. _postActivate(): void;
  15828. getWorldMatrix(): Matrix;
  15829. get isAnInstance(): boolean;
  15830. /**
  15831. * Returns the current associated LOD AbstractMesh.
  15832. */
  15833. getLOD(camera: Camera): AbstractMesh;
  15834. /** @hidden */
  15835. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15836. /** @hidden */
  15837. _syncSubMeshes(): InstancedMesh;
  15838. /** @hidden */
  15839. _generatePointsArray(): boolean;
  15840. /**
  15841. * Creates a new InstancedMesh from the current mesh.
  15842. * - name (string) : the cloned mesh name
  15843. * - newParent (optional Node) : the optional Node to parent the clone to.
  15844. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15845. *
  15846. * Returns the clone.
  15847. */
  15848. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15849. /**
  15850. * Disposes the InstancedMesh.
  15851. * Returns nothing.
  15852. */
  15853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15854. }
  15855. module "babylonjs/Meshes/mesh" {
  15856. interface Mesh {
  15857. /**
  15858. * Register a custom buffer that will be instanced
  15859. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15860. * @param kind defines the buffer kind
  15861. * @param stride defines the stride in floats
  15862. */
  15863. registerInstancedBuffer(kind: string, stride: number): void;
  15864. /** @hidden */
  15865. _userInstancedBuffersStorage: {
  15866. data: {
  15867. [key: string]: Float32Array;
  15868. };
  15869. sizes: {
  15870. [key: string]: number;
  15871. };
  15872. vertexBuffers: {
  15873. [key: string]: Nullable<VertexBuffer>;
  15874. };
  15875. strides: {
  15876. [key: string]: number;
  15877. };
  15878. };
  15879. }
  15880. }
  15881. module "babylonjs/Meshes/abstractMesh" {
  15882. interface AbstractMesh {
  15883. /**
  15884. * Object used to store instanced buffers defined by user
  15885. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15886. */
  15887. instancedBuffers: {
  15888. [key: string]: any;
  15889. };
  15890. }
  15891. }
  15892. }
  15893. declare module "babylonjs/Materials/shaderMaterial" {
  15894. import { Nullable } from "babylonjs/types";
  15895. import { Scene } from "babylonjs/scene";
  15896. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15898. import { Mesh } from "babylonjs/Meshes/mesh";
  15899. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15901. import { Effect } from "babylonjs/Materials/effect";
  15902. import { Material } from "babylonjs/Materials/material";
  15903. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15904. /**
  15905. * Defines the options associated with the creation of a shader material.
  15906. */
  15907. export interface IShaderMaterialOptions {
  15908. /**
  15909. * Does the material work in alpha blend mode
  15910. */
  15911. needAlphaBlending: boolean;
  15912. /**
  15913. * Does the material work in alpha test mode
  15914. */
  15915. needAlphaTesting: boolean;
  15916. /**
  15917. * The list of attribute names used in the shader
  15918. */
  15919. attributes: string[];
  15920. /**
  15921. * The list of unifrom names used in the shader
  15922. */
  15923. uniforms: string[];
  15924. /**
  15925. * The list of UBO names used in the shader
  15926. */
  15927. uniformBuffers: string[];
  15928. /**
  15929. * The list of sampler names used in the shader
  15930. */
  15931. samplers: string[];
  15932. /**
  15933. * The list of defines used in the shader
  15934. */
  15935. defines: string[];
  15936. }
  15937. /**
  15938. * 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.
  15939. *
  15940. * This returned material effects how the mesh will look based on the code in the shaders.
  15941. *
  15942. * @see http://doc.babylonjs.com/how_to/shader_material
  15943. */
  15944. export class ShaderMaterial extends Material {
  15945. private _shaderPath;
  15946. private _options;
  15947. private _textures;
  15948. private _textureArrays;
  15949. private _floats;
  15950. private _ints;
  15951. private _floatsArrays;
  15952. private _colors3;
  15953. private _colors3Arrays;
  15954. private _colors4;
  15955. private _colors4Arrays;
  15956. private _vectors2;
  15957. private _vectors3;
  15958. private _vectors4;
  15959. private _matrices;
  15960. private _matrixArrays;
  15961. private _matrices3x3;
  15962. private _matrices2x2;
  15963. private _vectors2Arrays;
  15964. private _vectors3Arrays;
  15965. private _vectors4Arrays;
  15966. private _cachedWorldViewMatrix;
  15967. private _cachedWorldViewProjectionMatrix;
  15968. private _renderId;
  15969. private _multiview;
  15970. private _cachedDefines;
  15971. /**
  15972. * Instantiate a new shader material.
  15973. * 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.
  15974. * This returned material effects how the mesh will look based on the code in the shaders.
  15975. * @see http://doc.babylonjs.com/how_to/shader_material
  15976. * @param name Define the name of the material in the scene
  15977. * @param scene Define the scene the material belongs to
  15978. * @param shaderPath Defines the route to the shader code in one of three ways:
  15979. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15980. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15981. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15982. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15983. * @param options Define the options used to create the shader
  15984. */
  15985. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15986. /**
  15987. * Gets the shader path used to define the shader code
  15988. * It can be modified to trigger a new compilation
  15989. */
  15990. get shaderPath(): any;
  15991. /**
  15992. * Sets the shader path used to define the shader code
  15993. * It can be modified to trigger a new compilation
  15994. */
  15995. set shaderPath(shaderPath: any);
  15996. /**
  15997. * Gets the options used to compile the shader.
  15998. * They can be modified to trigger a new compilation
  15999. */
  16000. get options(): IShaderMaterialOptions;
  16001. /**
  16002. * Gets the current class name of the material e.g. "ShaderMaterial"
  16003. * Mainly use in serialization.
  16004. * @returns the class name
  16005. */
  16006. getClassName(): string;
  16007. /**
  16008. * Specifies if the material will require alpha blending
  16009. * @returns a boolean specifying if alpha blending is needed
  16010. */
  16011. needAlphaBlending(): boolean;
  16012. /**
  16013. * Specifies if this material should be rendered in alpha test mode
  16014. * @returns a boolean specifying if an alpha test is needed.
  16015. */
  16016. needAlphaTesting(): boolean;
  16017. private _checkUniform;
  16018. /**
  16019. * Set a texture in the shader.
  16020. * @param name Define the name of the uniform samplers as defined in the shader
  16021. * @param texture Define the texture to bind to this sampler
  16022. * @return the material itself allowing "fluent" like uniform updates
  16023. */
  16024. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16025. /**
  16026. * Set a texture array in the shader.
  16027. * @param name Define the name of the uniform sampler array as defined in the shader
  16028. * @param textures Define the list of textures to bind to this sampler
  16029. * @return the material itself allowing "fluent" like uniform updates
  16030. */
  16031. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16032. /**
  16033. * Set a float in the shader.
  16034. * @param name Define the name of the uniform as defined in the shader
  16035. * @param value Define the value to give to the uniform
  16036. * @return the material itself allowing "fluent" like uniform updates
  16037. */
  16038. setFloat(name: string, value: number): ShaderMaterial;
  16039. /**
  16040. * Set a int in the shader.
  16041. * @param name Define the name of the uniform as defined in the shader
  16042. * @param value Define the value to give to the uniform
  16043. * @return the material itself allowing "fluent" like uniform updates
  16044. */
  16045. setInt(name: string, value: number): ShaderMaterial;
  16046. /**
  16047. * Set an array of floats in the shader.
  16048. * @param name Define the name of the uniform as defined in the shader
  16049. * @param value Define the value to give to the uniform
  16050. * @return the material itself allowing "fluent" like uniform updates
  16051. */
  16052. setFloats(name: string, value: number[]): ShaderMaterial;
  16053. /**
  16054. * Set a vec3 in the shader from a Color3.
  16055. * @param name Define the name of the uniform as defined in the shader
  16056. * @param value Define the value to give to the uniform
  16057. * @return the material itself allowing "fluent" like uniform updates
  16058. */
  16059. setColor3(name: string, value: Color3): ShaderMaterial;
  16060. /**
  16061. * Set a vec3 array in the shader from a Color3 array.
  16062. * @param name Define the name of the uniform as defined in the shader
  16063. * @param value Define the value to give to the uniform
  16064. * @return the material itself allowing "fluent" like uniform updates
  16065. */
  16066. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16067. /**
  16068. * Set a vec4 in the shader from a Color4.
  16069. * @param name Define the name of the uniform as defined in the shader
  16070. * @param value Define the value to give to the uniform
  16071. * @return the material itself allowing "fluent" like uniform updates
  16072. */
  16073. setColor4(name: string, value: Color4): ShaderMaterial;
  16074. /**
  16075. * Set a vec4 array in the shader from a Color4 array.
  16076. * @param name Define the name of the uniform as defined in the shader
  16077. * @param value Define the value to give to the uniform
  16078. * @return the material itself allowing "fluent" like uniform updates
  16079. */
  16080. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16081. /**
  16082. * Set a vec2 in the shader from a Vector2.
  16083. * @param name Define the name of the uniform as defined in the shader
  16084. * @param value Define the value to give to the uniform
  16085. * @return the material itself allowing "fluent" like uniform updates
  16086. */
  16087. setVector2(name: string, value: Vector2): ShaderMaterial;
  16088. /**
  16089. * Set a vec3 in the shader from a Vector3.
  16090. * @param name Define the name of the uniform as defined in the shader
  16091. * @param value Define the value to give to the uniform
  16092. * @return the material itself allowing "fluent" like uniform updates
  16093. */
  16094. setVector3(name: string, value: Vector3): ShaderMaterial;
  16095. /**
  16096. * Set a vec4 in the shader from a Vector4.
  16097. * @param name Define the name of the uniform as defined in the shader
  16098. * @param value Define the value to give to the uniform
  16099. * @return the material itself allowing "fluent" like uniform updates
  16100. */
  16101. setVector4(name: string, value: Vector4): ShaderMaterial;
  16102. /**
  16103. * Set a mat4 in the shader from a Matrix.
  16104. * @param name Define the name of the uniform as defined in the shader
  16105. * @param value Define the value to give to the uniform
  16106. * @return the material itself allowing "fluent" like uniform updates
  16107. */
  16108. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16109. /**
  16110. * Set a float32Array in the shader from a matrix array.
  16111. * @param name Define the name of the uniform as defined in the shader
  16112. * @param value Define the value to give to the uniform
  16113. * @return the material itself allowing "fluent" like uniform updates
  16114. */
  16115. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16116. /**
  16117. * Set a mat3 in the shader from a Float32Array.
  16118. * @param name Define the name of the uniform as defined in the shader
  16119. * @param value Define the value to give to the uniform
  16120. * @return the material itself allowing "fluent" like uniform updates
  16121. */
  16122. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16123. /**
  16124. * Set a mat2 in the shader from a Float32Array.
  16125. * @param name Define the name of the uniform as defined in the shader
  16126. * @param value Define the value to give to the uniform
  16127. * @return the material itself allowing "fluent" like uniform updates
  16128. */
  16129. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16130. /**
  16131. * Set a vec2 array in the shader from a number array.
  16132. * @param name Define the name of the uniform as defined in the shader
  16133. * @param value Define the value to give to the uniform
  16134. * @return the material itself allowing "fluent" like uniform updates
  16135. */
  16136. setArray2(name: string, value: number[]): ShaderMaterial;
  16137. /**
  16138. * Set a vec3 array in the shader from a number array.
  16139. * @param name Define the name of the uniform as defined in the shader
  16140. * @param value Define the value to give to the uniform
  16141. * @return the material itself allowing "fluent" like uniform updates
  16142. */
  16143. setArray3(name: string, value: number[]): ShaderMaterial;
  16144. /**
  16145. * Set a vec4 array in the shader from a number array.
  16146. * @param name Define the name of the uniform as defined in the shader
  16147. * @param value Define the value to give to the uniform
  16148. * @return the material itself allowing "fluent" like uniform updates
  16149. */
  16150. setArray4(name: string, value: number[]): ShaderMaterial;
  16151. private _checkCache;
  16152. /**
  16153. * Specifies that the submesh is ready to be used
  16154. * @param mesh defines the mesh to check
  16155. * @param subMesh defines which submesh to check
  16156. * @param useInstances specifies that instances should be used
  16157. * @returns a boolean indicating that the submesh is ready or not
  16158. */
  16159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16160. /**
  16161. * Checks if the material is ready to render the requested mesh
  16162. * @param mesh Define the mesh to render
  16163. * @param useInstances Define whether or not the material is used with instances
  16164. * @returns true if ready, otherwise false
  16165. */
  16166. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16167. /**
  16168. * Binds the world matrix to the material
  16169. * @param world defines the world transformation matrix
  16170. * @param effectOverride - If provided, use this effect instead of internal effect
  16171. */
  16172. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16173. /**
  16174. * Binds the submesh to this material by preparing the effect and shader to draw
  16175. * @param world defines the world transformation matrix
  16176. * @param mesh defines the mesh containing the submesh
  16177. * @param subMesh defines the submesh to bind the material to
  16178. */
  16179. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16180. /**
  16181. * Binds the material to the mesh
  16182. * @param world defines the world transformation matrix
  16183. * @param mesh defines the mesh to bind the material to
  16184. * @param effectOverride - If provided, use this effect instead of internal effect
  16185. */
  16186. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16187. protected _afterBind(mesh?: Mesh): void;
  16188. /**
  16189. * Gets the active textures from the material
  16190. * @returns an array of textures
  16191. */
  16192. getActiveTextures(): BaseTexture[];
  16193. /**
  16194. * Specifies if the material uses a texture
  16195. * @param texture defines the texture to check against the material
  16196. * @returns a boolean specifying if the material uses the texture
  16197. */
  16198. hasTexture(texture: BaseTexture): boolean;
  16199. /**
  16200. * Makes a duplicate of the material, and gives it a new name
  16201. * @param name defines the new name for the duplicated material
  16202. * @returns the cloned material
  16203. */
  16204. clone(name: string): ShaderMaterial;
  16205. /**
  16206. * Disposes the material
  16207. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16208. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16209. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16210. */
  16211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16212. /**
  16213. * Serializes this material in a JSON representation
  16214. * @returns the serialized material object
  16215. */
  16216. serialize(): any;
  16217. /**
  16218. * Creates a shader material from parsed shader material data
  16219. * @param source defines the JSON represnetation of the material
  16220. * @param scene defines the hosting scene
  16221. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16222. * @returns a new material
  16223. */
  16224. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16225. }
  16226. }
  16227. declare module "babylonjs/Shaders/color.fragment" {
  16228. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16229. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16230. /** @hidden */
  16231. export var colorPixelShader: {
  16232. name: string;
  16233. shader: string;
  16234. };
  16235. }
  16236. declare module "babylonjs/Shaders/color.vertex" {
  16237. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16238. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16239. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16240. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16241. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16242. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16243. /** @hidden */
  16244. export var colorVertexShader: {
  16245. name: string;
  16246. shader: string;
  16247. };
  16248. }
  16249. declare module "babylonjs/Meshes/linesMesh" {
  16250. import { Nullable } from "babylonjs/types";
  16251. import { Scene } from "babylonjs/scene";
  16252. import { Color3 } from "babylonjs/Maths/math.color";
  16253. import { Node } from "babylonjs/node";
  16254. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16255. import { Mesh } from "babylonjs/Meshes/mesh";
  16256. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16257. import { Effect } from "babylonjs/Materials/effect";
  16258. import { Material } from "babylonjs/Materials/material";
  16259. import "babylonjs/Shaders/color.fragment";
  16260. import "babylonjs/Shaders/color.vertex";
  16261. /**
  16262. * Line mesh
  16263. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16264. */
  16265. export class LinesMesh extends Mesh {
  16266. /**
  16267. * If vertex color should be applied to the mesh
  16268. */
  16269. readonly useVertexColor?: boolean | undefined;
  16270. /**
  16271. * If vertex alpha should be applied to the mesh
  16272. */
  16273. readonly useVertexAlpha?: boolean | undefined;
  16274. /**
  16275. * Color of the line (Default: White)
  16276. */
  16277. color: Color3;
  16278. /**
  16279. * Alpha of the line (Default: 1)
  16280. */
  16281. alpha: number;
  16282. /**
  16283. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16284. * This margin is expressed in world space coordinates, so its value may vary.
  16285. * Default value is 0.1
  16286. */
  16287. intersectionThreshold: number;
  16288. private _colorShader;
  16289. private color4;
  16290. /**
  16291. * Creates a new LinesMesh
  16292. * @param name defines the name
  16293. * @param scene defines the hosting scene
  16294. * @param parent defines the parent mesh if any
  16295. * @param source defines the optional source LinesMesh used to clone data from
  16296. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16297. * When false, achieved by calling a clone(), also passing False.
  16298. * This will make creation of children, recursive.
  16299. * @param useVertexColor defines if this LinesMesh supports vertex color
  16300. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16301. */
  16302. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16303. /**
  16304. * If vertex color should be applied to the mesh
  16305. */
  16306. useVertexColor?: boolean | undefined,
  16307. /**
  16308. * If vertex alpha should be applied to the mesh
  16309. */
  16310. useVertexAlpha?: boolean | undefined);
  16311. private _addClipPlaneDefine;
  16312. private _removeClipPlaneDefine;
  16313. isReady(): boolean;
  16314. /**
  16315. * Returns the string "LineMesh"
  16316. */
  16317. getClassName(): string;
  16318. /**
  16319. * @hidden
  16320. */
  16321. get material(): Material;
  16322. /**
  16323. * @hidden
  16324. */
  16325. set material(value: Material);
  16326. /**
  16327. * @hidden
  16328. */
  16329. get checkCollisions(): boolean;
  16330. /** @hidden */
  16331. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16332. /** @hidden */
  16333. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16334. /**
  16335. * Disposes of the line mesh
  16336. * @param doNotRecurse If children should be disposed
  16337. */
  16338. dispose(doNotRecurse?: boolean): void;
  16339. /**
  16340. * Returns a new LineMesh object cloned from the current one.
  16341. */
  16342. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16343. /**
  16344. * Creates a new InstancedLinesMesh object from the mesh model.
  16345. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16346. * @param name defines the name of the new instance
  16347. * @returns a new InstancedLinesMesh
  16348. */
  16349. createInstance(name: string): InstancedLinesMesh;
  16350. }
  16351. /**
  16352. * Creates an instance based on a source LinesMesh
  16353. */
  16354. export class InstancedLinesMesh extends InstancedMesh {
  16355. /**
  16356. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16357. * This margin is expressed in world space coordinates, so its value may vary.
  16358. * Initilized with the intersectionThreshold value of the source LinesMesh
  16359. */
  16360. intersectionThreshold: number;
  16361. constructor(name: string, source: LinesMesh);
  16362. /**
  16363. * Returns the string "InstancedLinesMesh".
  16364. */
  16365. getClassName(): string;
  16366. }
  16367. }
  16368. declare module "babylonjs/Shaders/line.fragment" {
  16369. /** @hidden */
  16370. export var linePixelShader: {
  16371. name: string;
  16372. shader: string;
  16373. };
  16374. }
  16375. declare module "babylonjs/Shaders/line.vertex" {
  16376. /** @hidden */
  16377. export var lineVertexShader: {
  16378. name: string;
  16379. shader: string;
  16380. };
  16381. }
  16382. declare module "babylonjs/Rendering/edgesRenderer" {
  16383. import { Nullable } from "babylonjs/types";
  16384. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16386. import { Vector3 } from "babylonjs/Maths/math.vector";
  16387. import { IDisposable } from "babylonjs/scene";
  16388. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16389. import "babylonjs/Shaders/line.fragment";
  16390. import "babylonjs/Shaders/line.vertex";
  16391. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16392. module "babylonjs/Meshes/abstractMesh" {
  16393. interface AbstractMesh {
  16394. /**
  16395. * Gets the edgesRenderer associated with the mesh
  16396. */
  16397. edgesRenderer: Nullable<EdgesRenderer>;
  16398. }
  16399. }
  16400. module "babylonjs/Meshes/linesMesh" {
  16401. interface LinesMesh {
  16402. /**
  16403. * Enables the edge rendering mode on the mesh.
  16404. * This mode makes the mesh edges visible
  16405. * @param epsilon defines the maximal distance between two angles to detect a face
  16406. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16407. * @returns the currentAbstractMesh
  16408. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16409. */
  16410. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16411. }
  16412. }
  16413. module "babylonjs/Meshes/linesMesh" {
  16414. interface InstancedLinesMesh {
  16415. /**
  16416. * Enables the edge rendering mode on the mesh.
  16417. * This mode makes the mesh edges visible
  16418. * @param epsilon defines the maximal distance between two angles to detect a face
  16419. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16420. * @returns the current InstancedLinesMesh
  16421. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16422. */
  16423. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16424. }
  16425. }
  16426. /**
  16427. * Defines the minimum contract an Edges renderer should follow.
  16428. */
  16429. export interface IEdgesRenderer extends IDisposable {
  16430. /**
  16431. * Gets or sets a boolean indicating if the edgesRenderer is active
  16432. */
  16433. isEnabled: boolean;
  16434. /**
  16435. * Renders the edges of the attached mesh,
  16436. */
  16437. render(): void;
  16438. /**
  16439. * Checks wether or not the edges renderer is ready to render.
  16440. * @return true if ready, otherwise false.
  16441. */
  16442. isReady(): boolean;
  16443. }
  16444. /**
  16445. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16446. */
  16447. export class EdgesRenderer implements IEdgesRenderer {
  16448. /**
  16449. * Define the size of the edges with an orthographic camera
  16450. */
  16451. edgesWidthScalerForOrthographic: number;
  16452. /**
  16453. * Define the size of the edges with a perspective camera
  16454. */
  16455. edgesWidthScalerForPerspective: number;
  16456. protected _source: AbstractMesh;
  16457. protected _linesPositions: number[];
  16458. protected _linesNormals: number[];
  16459. protected _linesIndices: number[];
  16460. protected _epsilon: number;
  16461. protected _indicesCount: number;
  16462. protected _lineShader: ShaderMaterial;
  16463. protected _ib: DataBuffer;
  16464. protected _buffers: {
  16465. [key: string]: Nullable<VertexBuffer>;
  16466. };
  16467. protected _checkVerticesInsteadOfIndices: boolean;
  16468. private _meshRebuildObserver;
  16469. private _meshDisposeObserver;
  16470. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16471. isEnabled: boolean;
  16472. /**
  16473. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16474. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16475. * @param source Mesh used to create edges
  16476. * @param epsilon sum of angles in adjacency to check for edge
  16477. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16478. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16479. */
  16480. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16481. protected _prepareRessources(): void;
  16482. /** @hidden */
  16483. _rebuild(): void;
  16484. /**
  16485. * Releases the required resources for the edges renderer
  16486. */
  16487. dispose(): void;
  16488. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16489. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16490. /**
  16491. * Checks if the pair of p0 and p1 is en edge
  16492. * @param faceIndex
  16493. * @param edge
  16494. * @param faceNormals
  16495. * @param p0
  16496. * @param p1
  16497. * @private
  16498. */
  16499. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16500. /**
  16501. * push line into the position, normal and index buffer
  16502. * @protected
  16503. */
  16504. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16505. /**
  16506. * Generates lines edges from adjacencjes
  16507. * @private
  16508. */
  16509. _generateEdgesLines(): void;
  16510. /**
  16511. * Checks wether or not the edges renderer is ready to render.
  16512. * @return true if ready, otherwise false.
  16513. */
  16514. isReady(): boolean;
  16515. /**
  16516. * Renders the edges of the attached mesh,
  16517. */
  16518. render(): void;
  16519. }
  16520. /**
  16521. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16522. */
  16523. export class LineEdgesRenderer extends EdgesRenderer {
  16524. /**
  16525. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16526. * @param source LineMesh used to generate edges
  16527. * @param epsilon not important (specified angle for edge detection)
  16528. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16529. */
  16530. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16531. /**
  16532. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16533. */
  16534. _generateEdgesLines(): void;
  16535. }
  16536. }
  16537. declare module "babylonjs/Rendering/renderingGroup" {
  16538. import { SmartArray } from "babylonjs/Misc/smartArray";
  16539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16541. import { Nullable } from "babylonjs/types";
  16542. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16543. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16544. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16545. import { Material } from "babylonjs/Materials/material";
  16546. import { Scene } from "babylonjs/scene";
  16547. /**
  16548. * This represents the object necessary to create a rendering group.
  16549. * This is exclusively used and created by the rendering manager.
  16550. * To modify the behavior, you use the available helpers in your scene or meshes.
  16551. * @hidden
  16552. */
  16553. export class RenderingGroup {
  16554. index: number;
  16555. private static _zeroVector;
  16556. private _scene;
  16557. private _opaqueSubMeshes;
  16558. private _transparentSubMeshes;
  16559. private _alphaTestSubMeshes;
  16560. private _depthOnlySubMeshes;
  16561. private _particleSystems;
  16562. private _spriteManagers;
  16563. private _opaqueSortCompareFn;
  16564. private _alphaTestSortCompareFn;
  16565. private _transparentSortCompareFn;
  16566. private _renderOpaque;
  16567. private _renderAlphaTest;
  16568. private _renderTransparent;
  16569. /** @hidden */
  16570. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16571. onBeforeTransparentRendering: () => void;
  16572. /**
  16573. * Set the opaque sort comparison function.
  16574. * If null the sub meshes will be render in the order they were created
  16575. */
  16576. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16577. /**
  16578. * Set the alpha test sort comparison function.
  16579. * If null the sub meshes will be render in the order they were created
  16580. */
  16581. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16582. /**
  16583. * Set the transparent sort comparison function.
  16584. * If null the sub meshes will be render in the order they were created
  16585. */
  16586. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16587. /**
  16588. * Creates a new rendering group.
  16589. * @param index The rendering group index
  16590. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16591. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16592. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16593. */
  16594. 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>);
  16595. /**
  16596. * Render all the sub meshes contained in the group.
  16597. * @param customRenderFunction Used to override the default render behaviour of the group.
  16598. * @returns true if rendered some submeshes.
  16599. */
  16600. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16601. /**
  16602. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16603. * @param subMeshes The submeshes to render
  16604. */
  16605. private renderOpaqueSorted;
  16606. /**
  16607. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16608. * @param subMeshes The submeshes to render
  16609. */
  16610. private renderAlphaTestSorted;
  16611. /**
  16612. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16613. * @param subMeshes The submeshes to render
  16614. */
  16615. private renderTransparentSorted;
  16616. /**
  16617. * Renders the submeshes in a specified order.
  16618. * @param subMeshes The submeshes to sort before render
  16619. * @param sortCompareFn The comparison function use to sort
  16620. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16621. * @param transparent Specifies to activate blending if true
  16622. */
  16623. private static renderSorted;
  16624. /**
  16625. * Renders the submeshes in the order they were dispatched (no sort applied).
  16626. * @param subMeshes The submeshes to render
  16627. */
  16628. private static renderUnsorted;
  16629. /**
  16630. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16631. * are rendered back to front if in the same alpha index.
  16632. *
  16633. * @param a The first submesh
  16634. * @param b The second submesh
  16635. * @returns The result of the comparison
  16636. */
  16637. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16638. /**
  16639. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16640. * are rendered back to front.
  16641. *
  16642. * @param a The first submesh
  16643. * @param b The second submesh
  16644. * @returns The result of the comparison
  16645. */
  16646. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16647. /**
  16648. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16649. * are rendered front to back (prevent overdraw).
  16650. *
  16651. * @param a The first submesh
  16652. * @param b The second submesh
  16653. * @returns The result of the comparison
  16654. */
  16655. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16656. /**
  16657. * Resets the different lists of submeshes to prepare a new frame.
  16658. */
  16659. prepare(): void;
  16660. dispose(): void;
  16661. /**
  16662. * Inserts the submesh in its correct queue depending on its material.
  16663. * @param subMesh The submesh to dispatch
  16664. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16665. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16666. */
  16667. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16668. dispatchSprites(spriteManager: ISpriteManager): void;
  16669. dispatchParticles(particleSystem: IParticleSystem): void;
  16670. private _renderParticles;
  16671. private _renderSprites;
  16672. }
  16673. }
  16674. declare module "babylonjs/Rendering/renderingManager" {
  16675. import { Nullable } from "babylonjs/types";
  16676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16677. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16678. import { SmartArray } from "babylonjs/Misc/smartArray";
  16679. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16680. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16681. import { Material } from "babylonjs/Materials/material";
  16682. import { Scene } from "babylonjs/scene";
  16683. import { Camera } from "babylonjs/Cameras/camera";
  16684. /**
  16685. * Interface describing the different options available in the rendering manager
  16686. * regarding Auto Clear between groups.
  16687. */
  16688. export interface IRenderingManagerAutoClearSetup {
  16689. /**
  16690. * Defines whether or not autoclear is enable.
  16691. */
  16692. autoClear: boolean;
  16693. /**
  16694. * Defines whether or not to autoclear the depth buffer.
  16695. */
  16696. depth: boolean;
  16697. /**
  16698. * Defines whether or not to autoclear the stencil buffer.
  16699. */
  16700. stencil: boolean;
  16701. }
  16702. /**
  16703. * This class is used by the onRenderingGroupObservable
  16704. */
  16705. export class RenderingGroupInfo {
  16706. /**
  16707. * The Scene that being rendered
  16708. */
  16709. scene: Scene;
  16710. /**
  16711. * The camera currently used for the rendering pass
  16712. */
  16713. camera: Nullable<Camera>;
  16714. /**
  16715. * The ID of the renderingGroup being processed
  16716. */
  16717. renderingGroupId: number;
  16718. }
  16719. /**
  16720. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16721. * It is enable to manage the different groups as well as the different necessary sort functions.
  16722. * This should not be used directly aside of the few static configurations
  16723. */
  16724. export class RenderingManager {
  16725. /**
  16726. * The max id used for rendering groups (not included)
  16727. */
  16728. static MAX_RENDERINGGROUPS: number;
  16729. /**
  16730. * The min id used for rendering groups (included)
  16731. */
  16732. static MIN_RENDERINGGROUPS: number;
  16733. /**
  16734. * Used to globally prevent autoclearing scenes.
  16735. */
  16736. static AUTOCLEAR: boolean;
  16737. /**
  16738. * @hidden
  16739. */
  16740. _useSceneAutoClearSetup: boolean;
  16741. private _scene;
  16742. private _renderingGroups;
  16743. private _depthStencilBufferAlreadyCleaned;
  16744. private _autoClearDepthStencil;
  16745. private _customOpaqueSortCompareFn;
  16746. private _customAlphaTestSortCompareFn;
  16747. private _customTransparentSortCompareFn;
  16748. private _renderingGroupInfo;
  16749. /**
  16750. * Instantiates a new rendering group for a particular scene
  16751. * @param scene Defines the scene the groups belongs to
  16752. */
  16753. constructor(scene: Scene);
  16754. private _clearDepthStencilBuffer;
  16755. /**
  16756. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16757. * @hidden
  16758. */
  16759. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16760. /**
  16761. * Resets the different information of the group to prepare a new frame
  16762. * @hidden
  16763. */
  16764. reset(): void;
  16765. /**
  16766. * Dispose and release the group and its associated resources.
  16767. * @hidden
  16768. */
  16769. dispose(): void;
  16770. /**
  16771. * Clear the info related to rendering groups preventing retention points during dispose.
  16772. */
  16773. freeRenderingGroups(): void;
  16774. private _prepareRenderingGroup;
  16775. /**
  16776. * Add a sprite manager to the rendering manager in order to render it this frame.
  16777. * @param spriteManager Define the sprite manager to render
  16778. */
  16779. dispatchSprites(spriteManager: ISpriteManager): void;
  16780. /**
  16781. * Add a particle system to the rendering manager in order to render it this frame.
  16782. * @param particleSystem Define the particle system to render
  16783. */
  16784. dispatchParticles(particleSystem: IParticleSystem): void;
  16785. /**
  16786. * Add a submesh to the manager in order to render it this frame
  16787. * @param subMesh The submesh to dispatch
  16788. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16789. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16790. */
  16791. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16792. /**
  16793. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16794. * This allowed control for front to back rendering or reversly depending of the special needs.
  16795. *
  16796. * @param renderingGroupId The rendering group id corresponding to its index
  16797. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16798. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16799. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16800. */
  16801. 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;
  16802. /**
  16803. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16804. *
  16805. * @param renderingGroupId The rendering group id corresponding to its index
  16806. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16807. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16808. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16809. */
  16810. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16811. /**
  16812. * Gets the current auto clear configuration for one rendering group of the rendering
  16813. * manager.
  16814. * @param index the rendering group index to get the information for
  16815. * @returns The auto clear setup for the requested rendering group
  16816. */
  16817. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16818. }
  16819. }
  16820. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16821. import { SmartArray } from "babylonjs/Misc/smartArray";
  16822. import { Nullable } from "babylonjs/types";
  16823. import { Scene } from "babylonjs/scene";
  16824. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16825. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16827. import { Mesh } from "babylonjs/Meshes/mesh";
  16828. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16829. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16830. import { Effect } from "babylonjs/Materials/effect";
  16831. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16832. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16833. import "babylonjs/Shaders/shadowMap.fragment";
  16834. import "babylonjs/Shaders/shadowMap.vertex";
  16835. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16836. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  16837. import { Observable } from "babylonjs/Misc/observable";
  16838. /**
  16839. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16840. */
  16841. export interface ICustomShaderOptions {
  16842. /**
  16843. * Gets or sets the custom shader name to use
  16844. */
  16845. shaderName: string;
  16846. /**
  16847. * The list of attribute names used in the shader
  16848. */
  16849. attributes?: string[];
  16850. /**
  16851. * The list of unifrom names used in the shader
  16852. */
  16853. uniforms?: string[];
  16854. /**
  16855. * The list of sampler names used in the shader
  16856. */
  16857. samplers?: string[];
  16858. /**
  16859. * The list of defines used in the shader
  16860. */
  16861. defines?: string[];
  16862. }
  16863. /**
  16864. * Interface to implement to create a shadow generator compatible with BJS.
  16865. */
  16866. export interface IShadowGenerator {
  16867. /**
  16868. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16869. * @returns The render target texture if present otherwise, null
  16870. */
  16871. getShadowMap(): Nullable<RenderTargetTexture>;
  16872. /**
  16873. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16874. * @param subMesh The submesh we want to render in the shadow map
  16875. * @param useInstances Defines wether will draw in the map using instances
  16876. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16877. * @returns true if ready otherwise, false
  16878. */
  16879. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16880. /**
  16881. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16882. * @param defines Defines of the material we want to update
  16883. * @param lightIndex Index of the light in the enabled light list of the material
  16884. */
  16885. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16886. /**
  16887. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16888. * defined in the generator but impacting the effect).
  16889. * It implies the unifroms available on the materials are the standard BJS ones.
  16890. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16891. * @param effect The effect we are binfing the information for
  16892. */
  16893. bindShadowLight(lightIndex: string, effect: Effect): void;
  16894. /**
  16895. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16896. * (eq to shadow prjection matrix * light transform matrix)
  16897. * @returns The transform matrix used to create the shadow map
  16898. */
  16899. getTransformMatrix(): Matrix;
  16900. /**
  16901. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16902. * Cube and 2D textures for instance.
  16903. */
  16904. recreateShadowMap(): void;
  16905. /**
  16906. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16907. * @param onCompiled Callback triggered at the and of the effects compilation
  16908. * @param options Sets of optional options forcing the compilation with different modes
  16909. */
  16910. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16911. useInstances: boolean;
  16912. }>): void;
  16913. /**
  16914. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16915. * @param options Sets of optional options forcing the compilation with different modes
  16916. * @returns A promise that resolves when the compilation completes
  16917. */
  16918. forceCompilationAsync(options?: Partial<{
  16919. useInstances: boolean;
  16920. }>): Promise<void>;
  16921. /**
  16922. * Serializes the shadow generator setup to a json object.
  16923. * @returns The serialized JSON object
  16924. */
  16925. serialize(): any;
  16926. /**
  16927. * Disposes the Shadow map and related Textures and effects.
  16928. */
  16929. dispose(): void;
  16930. }
  16931. /**
  16932. * Default implementation IShadowGenerator.
  16933. * This is the main object responsible of generating shadows in the framework.
  16934. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16935. */
  16936. export class ShadowGenerator implements IShadowGenerator {
  16937. /**
  16938. * Name of the shadow generator class
  16939. */
  16940. static CLASSNAME: string;
  16941. /**
  16942. * Shadow generator mode None: no filtering applied.
  16943. */
  16944. static readonly FILTER_NONE: number;
  16945. /**
  16946. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16947. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16948. */
  16949. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16950. /**
  16951. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16952. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16953. */
  16954. static readonly FILTER_POISSONSAMPLING: number;
  16955. /**
  16956. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16957. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16958. */
  16959. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16960. /**
  16961. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16962. * edge artifacts on steep falloff.
  16963. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16964. */
  16965. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16966. /**
  16967. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16968. * edge artifacts on steep falloff.
  16969. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16970. */
  16971. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16972. /**
  16973. * Shadow generator mode PCF: Percentage Closer Filtering
  16974. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16975. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16976. */
  16977. static readonly FILTER_PCF: number;
  16978. /**
  16979. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16980. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16981. * Contact Hardening
  16982. */
  16983. static readonly FILTER_PCSS: number;
  16984. /**
  16985. * Reserved for PCF and PCSS
  16986. * Highest Quality.
  16987. *
  16988. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16989. *
  16990. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16991. */
  16992. static readonly QUALITY_HIGH: number;
  16993. /**
  16994. * Reserved for PCF and PCSS
  16995. * Good tradeoff for quality/perf cross devices
  16996. *
  16997. * Execute PCF on a 3*3 kernel.
  16998. *
  16999. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17000. */
  17001. static readonly QUALITY_MEDIUM: number;
  17002. /**
  17003. * Reserved for PCF and PCSS
  17004. * The lowest quality but the fastest.
  17005. *
  17006. * Execute PCF on a 1*1 kernel.
  17007. *
  17008. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17009. */
  17010. static readonly QUALITY_LOW: number;
  17011. /** Gets or sets the custom shader name to use */
  17012. customShaderOptions: ICustomShaderOptions;
  17013. /**
  17014. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17015. */
  17016. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17017. /**
  17018. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17019. */
  17020. onAfterShadowMapRenderObservable: Observable<Effect>;
  17021. /**
  17022. * Observable triggered before a mesh is rendered in the shadow map.
  17023. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17024. */
  17025. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17026. /**
  17027. * Observable triggered after a mesh is rendered in the shadow map.
  17028. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17029. */
  17030. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17031. protected _bias: number;
  17032. /**
  17033. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17034. */
  17035. get bias(): number;
  17036. /**
  17037. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17038. */
  17039. set bias(bias: number);
  17040. protected _normalBias: number;
  17041. /**
  17042. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17043. */
  17044. get normalBias(): number;
  17045. /**
  17046. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17047. */
  17048. set normalBias(normalBias: number);
  17049. protected _blurBoxOffset: number;
  17050. /**
  17051. * Gets the blur box offset: offset applied during the blur pass.
  17052. * Only useful if useKernelBlur = false
  17053. */
  17054. get blurBoxOffset(): number;
  17055. /**
  17056. * Sets the blur box offset: offset applied during the blur pass.
  17057. * Only useful if useKernelBlur = false
  17058. */
  17059. set blurBoxOffset(value: number);
  17060. protected _blurScale: number;
  17061. /**
  17062. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17063. * 2 means half of the size.
  17064. */
  17065. get blurScale(): number;
  17066. /**
  17067. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17068. * 2 means half of the size.
  17069. */
  17070. set blurScale(value: number);
  17071. protected _blurKernel: number;
  17072. /**
  17073. * Gets the blur kernel: kernel size of the blur pass.
  17074. * Only useful if useKernelBlur = true
  17075. */
  17076. get blurKernel(): number;
  17077. /**
  17078. * Sets the blur kernel: kernel size of the blur pass.
  17079. * Only useful if useKernelBlur = true
  17080. */
  17081. set blurKernel(value: number);
  17082. protected _useKernelBlur: boolean;
  17083. /**
  17084. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17085. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17086. */
  17087. get useKernelBlur(): boolean;
  17088. /**
  17089. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17090. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17091. */
  17092. set useKernelBlur(value: boolean);
  17093. protected _depthScale: number;
  17094. /**
  17095. * Gets the depth scale used in ESM mode.
  17096. */
  17097. get depthScale(): number;
  17098. /**
  17099. * Sets the depth scale used in ESM mode.
  17100. * This can override the scale stored on the light.
  17101. */
  17102. set depthScale(value: number);
  17103. protected _validateFilter(filter: number): number;
  17104. protected _filter: number;
  17105. /**
  17106. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17107. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17108. */
  17109. get filter(): number;
  17110. /**
  17111. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17112. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17113. */
  17114. set filter(value: number);
  17115. /**
  17116. * Gets if the current filter is set to Poisson Sampling.
  17117. */
  17118. get usePoissonSampling(): boolean;
  17119. /**
  17120. * Sets the current filter to Poisson Sampling.
  17121. */
  17122. set usePoissonSampling(value: boolean);
  17123. /**
  17124. * Gets if the current filter is set to ESM.
  17125. */
  17126. get useExponentialShadowMap(): boolean;
  17127. /**
  17128. * Sets the current filter is to ESM.
  17129. */
  17130. set useExponentialShadowMap(value: boolean);
  17131. /**
  17132. * Gets if the current filter is set to filtered ESM.
  17133. */
  17134. get useBlurExponentialShadowMap(): boolean;
  17135. /**
  17136. * Gets if the current filter is set to filtered ESM.
  17137. */
  17138. set useBlurExponentialShadowMap(value: boolean);
  17139. /**
  17140. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17141. * exponential to prevent steep falloff artifacts).
  17142. */
  17143. get useCloseExponentialShadowMap(): boolean;
  17144. /**
  17145. * Sets the current filter to "close ESM" (using the inverse of the
  17146. * exponential to prevent steep falloff artifacts).
  17147. */
  17148. set useCloseExponentialShadowMap(value: boolean);
  17149. /**
  17150. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17151. * exponential to prevent steep falloff artifacts).
  17152. */
  17153. get useBlurCloseExponentialShadowMap(): boolean;
  17154. /**
  17155. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17156. * exponential to prevent steep falloff artifacts).
  17157. */
  17158. set useBlurCloseExponentialShadowMap(value: boolean);
  17159. /**
  17160. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17161. */
  17162. get usePercentageCloserFiltering(): boolean;
  17163. /**
  17164. * Sets the current filter to "PCF" (percentage closer filtering).
  17165. */
  17166. set usePercentageCloserFiltering(value: boolean);
  17167. protected _filteringQuality: number;
  17168. /**
  17169. * Gets the PCF or PCSS Quality.
  17170. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17171. */
  17172. get filteringQuality(): number;
  17173. /**
  17174. * Sets the PCF or PCSS Quality.
  17175. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17176. */
  17177. set filteringQuality(filteringQuality: number);
  17178. /**
  17179. * Gets if the current filter is set to "PCSS" (contact hardening).
  17180. */
  17181. get useContactHardeningShadow(): boolean;
  17182. /**
  17183. * Sets the current filter to "PCSS" (contact hardening).
  17184. */
  17185. set useContactHardeningShadow(value: boolean);
  17186. protected _contactHardeningLightSizeUVRatio: number;
  17187. /**
  17188. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17189. * Using a ratio helps keeping shape stability independently of the map size.
  17190. *
  17191. * It does not account for the light projection as it was having too much
  17192. * instability during the light setup or during light position changes.
  17193. *
  17194. * Only valid if useContactHardeningShadow is true.
  17195. */
  17196. get contactHardeningLightSizeUVRatio(): number;
  17197. /**
  17198. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17199. * Using a ratio helps keeping shape stability independently of the map size.
  17200. *
  17201. * It does not account for the light projection as it was having too much
  17202. * instability during the light setup or during light position changes.
  17203. *
  17204. * Only valid if useContactHardeningShadow is true.
  17205. */
  17206. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17207. protected _darkness: number;
  17208. /** Gets or sets the actual darkness of a shadow */
  17209. get darkness(): number;
  17210. set darkness(value: number);
  17211. /**
  17212. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17213. * 0 means strongest and 1 would means no shadow.
  17214. * @returns the darkness.
  17215. */
  17216. getDarkness(): number;
  17217. /**
  17218. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17219. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17220. * @returns the shadow generator allowing fluent coding.
  17221. */
  17222. setDarkness(darkness: number): ShadowGenerator;
  17223. protected _transparencyShadow: boolean;
  17224. /** Gets or sets the ability to have transparent shadow */
  17225. get transparencyShadow(): boolean;
  17226. set transparencyShadow(value: boolean);
  17227. /**
  17228. * Sets the ability to have transparent shadow (boolean).
  17229. * @param transparent True if transparent else False
  17230. * @returns the shadow generator allowing fluent coding
  17231. */
  17232. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17233. /**
  17234. * Enables or disables shadows with varying strength based on the transparency
  17235. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17236. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17237. * mesh.visibility * alphaTexture.a
  17238. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17239. */
  17240. enableSoftTransparentShadow: boolean;
  17241. protected _shadowMap: Nullable<RenderTargetTexture>;
  17242. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17243. /**
  17244. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17245. * @returns The render target texture if present otherwise, null
  17246. */
  17247. getShadowMap(): Nullable<RenderTargetTexture>;
  17248. /**
  17249. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17250. * @returns The render target texture if the shadow map is present otherwise, null
  17251. */
  17252. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17253. /**
  17254. * Gets the class name of that object
  17255. * @returns "ShadowGenerator"
  17256. */
  17257. getClassName(): string;
  17258. /**
  17259. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17260. * @param mesh Mesh to add
  17261. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17262. * @returns the Shadow Generator itself
  17263. */
  17264. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17265. /**
  17266. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17267. * @param mesh Mesh to remove
  17268. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17269. * @returns the Shadow Generator itself
  17270. */
  17271. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17272. /**
  17273. * Controls the extent to which the shadows fade out at the edge of the frustum
  17274. */
  17275. frustumEdgeFalloff: number;
  17276. protected _light: IShadowLight;
  17277. /**
  17278. * Returns the associated light object.
  17279. * @returns the light generating the shadow
  17280. */
  17281. getLight(): IShadowLight;
  17282. /**
  17283. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17284. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17285. * It might on the other hand introduce peter panning.
  17286. */
  17287. forceBackFacesOnly: boolean;
  17288. protected _scene: Scene;
  17289. protected _lightDirection: Vector3;
  17290. protected _effect: Effect;
  17291. protected _viewMatrix: Matrix;
  17292. protected _projectionMatrix: Matrix;
  17293. protected _transformMatrix: Matrix;
  17294. protected _cachedPosition: Vector3;
  17295. protected _cachedDirection: Vector3;
  17296. protected _cachedDefines: string;
  17297. protected _currentRenderID: number;
  17298. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17299. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17300. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17301. protected _blurPostProcesses: PostProcess[];
  17302. protected _mapSize: number;
  17303. protected _currentFaceIndex: number;
  17304. protected _currentFaceIndexCache: number;
  17305. protected _textureType: number;
  17306. protected _defaultTextureMatrix: Matrix;
  17307. protected _storedUniqueId: Nullable<number>;
  17308. /** @hidden */
  17309. static _SceneComponentInitialization: (scene: Scene) => void;
  17310. /**
  17311. * Creates a ShadowGenerator object.
  17312. * A ShadowGenerator is the required tool to use the shadows.
  17313. * Each light casting shadows needs to use its own ShadowGenerator.
  17314. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17315. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17316. * @param light The light object generating the shadows.
  17317. * @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.
  17318. */
  17319. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17320. protected _initializeGenerator(): void;
  17321. protected _createTargetRenderTexture(): void;
  17322. protected _initializeShadowMap(): void;
  17323. protected _initializeBlurRTTAndPostProcesses(): void;
  17324. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17325. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17326. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17327. protected _applyFilterValues(): void;
  17328. /**
  17329. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17330. * @param onCompiled Callback triggered at the and of the effects compilation
  17331. * @param options Sets of optional options forcing the compilation with different modes
  17332. */
  17333. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17334. useInstances: boolean;
  17335. }>): void;
  17336. /**
  17337. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17338. * @param options Sets of optional options forcing the compilation with different modes
  17339. * @returns A promise that resolves when the compilation completes
  17340. */
  17341. forceCompilationAsync(options?: Partial<{
  17342. useInstances: boolean;
  17343. }>): Promise<void>;
  17344. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17345. private _prepareShadowDefines;
  17346. /**
  17347. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17348. * @param subMesh The submesh we want to render in the shadow map
  17349. * @param useInstances Defines wether will draw in the map using instances
  17350. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17351. * @returns true if ready otherwise, false
  17352. */
  17353. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17354. /**
  17355. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17356. * @param defines Defines of the material we want to update
  17357. * @param lightIndex Index of the light in the enabled light list of the material
  17358. */
  17359. prepareDefines(defines: any, lightIndex: number): void;
  17360. /**
  17361. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17362. * defined in the generator but impacting the effect).
  17363. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17364. * @param effect The effect we are binfing the information for
  17365. */
  17366. bindShadowLight(lightIndex: string, effect: Effect): void;
  17367. /**
  17368. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17369. * (eq to shadow prjection matrix * light transform matrix)
  17370. * @returns The transform matrix used to create the shadow map
  17371. */
  17372. getTransformMatrix(): Matrix;
  17373. /**
  17374. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17375. * Cube and 2D textures for instance.
  17376. */
  17377. recreateShadowMap(): void;
  17378. protected _disposeBlurPostProcesses(): void;
  17379. protected _disposeRTTandPostProcesses(): void;
  17380. /**
  17381. * Disposes the ShadowGenerator.
  17382. * Returns nothing.
  17383. */
  17384. dispose(): void;
  17385. /**
  17386. * Serializes the shadow generator setup to a json object.
  17387. * @returns The serialized JSON object
  17388. */
  17389. serialize(): any;
  17390. /**
  17391. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17392. * @param parsedShadowGenerator The JSON object to parse
  17393. * @param scene The scene to create the shadow map for
  17394. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17395. * @returns The parsed shadow generator
  17396. */
  17397. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17398. }
  17399. }
  17400. declare module "babylonjs/Lights/light" {
  17401. import { Nullable } from "babylonjs/types";
  17402. import { Scene } from "babylonjs/scene";
  17403. import { Vector3 } from "babylonjs/Maths/math.vector";
  17404. import { Color3 } from "babylonjs/Maths/math.color";
  17405. import { Node } from "babylonjs/node";
  17406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17407. import { Effect } from "babylonjs/Materials/effect";
  17408. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17409. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17410. /**
  17411. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17412. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17413. * 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.
  17414. */
  17415. export abstract class Light extends Node {
  17416. /**
  17417. * Falloff Default: light is falling off following the material specification:
  17418. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17419. */
  17420. static readonly FALLOFF_DEFAULT: number;
  17421. /**
  17422. * Falloff Physical: light is falling off following the inverse squared distance law.
  17423. */
  17424. static readonly FALLOFF_PHYSICAL: number;
  17425. /**
  17426. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17427. * to enhance interoperability with other engines.
  17428. */
  17429. static readonly FALLOFF_GLTF: number;
  17430. /**
  17431. * Falloff Standard: light is falling off like in the standard material
  17432. * to enhance interoperability with other materials.
  17433. */
  17434. static readonly FALLOFF_STANDARD: number;
  17435. /**
  17436. * If every light affecting the material is in this lightmapMode,
  17437. * material.lightmapTexture adds or multiplies
  17438. * (depends on material.useLightmapAsShadowmap)
  17439. * after every other light calculations.
  17440. */
  17441. static readonly LIGHTMAP_DEFAULT: number;
  17442. /**
  17443. * material.lightmapTexture as only diffuse lighting from this light
  17444. * adds only specular lighting from this light
  17445. * adds dynamic shadows
  17446. */
  17447. static readonly LIGHTMAP_SPECULAR: number;
  17448. /**
  17449. * material.lightmapTexture as only lighting
  17450. * no light calculation from this light
  17451. * only adds dynamic shadows from this light
  17452. */
  17453. static readonly LIGHTMAP_SHADOWSONLY: number;
  17454. /**
  17455. * Each light type uses the default quantity according to its type:
  17456. * point/spot lights use luminous intensity
  17457. * directional lights use illuminance
  17458. */
  17459. static readonly INTENSITYMODE_AUTOMATIC: number;
  17460. /**
  17461. * lumen (lm)
  17462. */
  17463. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17464. /**
  17465. * candela (lm/sr)
  17466. */
  17467. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17468. /**
  17469. * lux (lm/m^2)
  17470. */
  17471. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17472. /**
  17473. * nit (cd/m^2)
  17474. */
  17475. static readonly INTENSITYMODE_LUMINANCE: number;
  17476. /**
  17477. * Light type const id of the point light.
  17478. */
  17479. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17480. /**
  17481. * Light type const id of the directional light.
  17482. */
  17483. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17484. /**
  17485. * Light type const id of the spot light.
  17486. */
  17487. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17488. /**
  17489. * Light type const id of the hemispheric light.
  17490. */
  17491. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17492. /**
  17493. * Diffuse gives the basic color to an object.
  17494. */
  17495. diffuse: Color3;
  17496. /**
  17497. * Specular produces a highlight color on an object.
  17498. * Note: This is note affecting PBR materials.
  17499. */
  17500. specular: Color3;
  17501. /**
  17502. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17503. * falling off base on range or angle.
  17504. * This can be set to any values in Light.FALLOFF_x.
  17505. *
  17506. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17507. * other types of materials.
  17508. */
  17509. falloffType: number;
  17510. /**
  17511. * Strength of the light.
  17512. * Note: By default it is define in the framework own unit.
  17513. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17514. */
  17515. intensity: number;
  17516. private _range;
  17517. protected _inverseSquaredRange: number;
  17518. /**
  17519. * Defines how far from the source the light is impacting in scene units.
  17520. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17521. */
  17522. get range(): number;
  17523. /**
  17524. * Defines how far from the source the light is impacting in scene units.
  17525. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17526. */
  17527. set range(value: number);
  17528. /**
  17529. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17530. * of light.
  17531. */
  17532. private _photometricScale;
  17533. private _intensityMode;
  17534. /**
  17535. * Gets the photometric scale used to interpret the intensity.
  17536. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17537. */
  17538. get intensityMode(): number;
  17539. /**
  17540. * Sets the photometric scale used to interpret the intensity.
  17541. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17542. */
  17543. set intensityMode(value: number);
  17544. private _radius;
  17545. /**
  17546. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17547. */
  17548. get radius(): number;
  17549. /**
  17550. * sets the light radius used by PBR Materials to simulate soft area lights.
  17551. */
  17552. set radius(value: number);
  17553. private _renderPriority;
  17554. /**
  17555. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17556. * exceeding the number allowed of the materials.
  17557. */
  17558. renderPriority: number;
  17559. private _shadowEnabled;
  17560. /**
  17561. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17562. * the current shadow generator.
  17563. */
  17564. get shadowEnabled(): boolean;
  17565. /**
  17566. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17567. * the current shadow generator.
  17568. */
  17569. set shadowEnabled(value: boolean);
  17570. private _includedOnlyMeshes;
  17571. /**
  17572. * Gets the only meshes impacted by this light.
  17573. */
  17574. get includedOnlyMeshes(): AbstractMesh[];
  17575. /**
  17576. * Sets the only meshes impacted by this light.
  17577. */
  17578. set includedOnlyMeshes(value: AbstractMesh[]);
  17579. private _excludedMeshes;
  17580. /**
  17581. * Gets the meshes not impacted by this light.
  17582. */
  17583. get excludedMeshes(): AbstractMesh[];
  17584. /**
  17585. * Sets the meshes not impacted by this light.
  17586. */
  17587. set excludedMeshes(value: AbstractMesh[]);
  17588. private _excludeWithLayerMask;
  17589. /**
  17590. * Gets the layer id use to find what meshes are not impacted by the light.
  17591. * Inactive if 0
  17592. */
  17593. get excludeWithLayerMask(): number;
  17594. /**
  17595. * Sets the layer id use to find what meshes are not impacted by the light.
  17596. * Inactive if 0
  17597. */
  17598. set excludeWithLayerMask(value: number);
  17599. private _includeOnlyWithLayerMask;
  17600. /**
  17601. * Gets the layer id use to find what meshes are impacted by the light.
  17602. * Inactive if 0
  17603. */
  17604. get includeOnlyWithLayerMask(): number;
  17605. /**
  17606. * Sets the layer id use to find what meshes are impacted by the light.
  17607. * Inactive if 0
  17608. */
  17609. set includeOnlyWithLayerMask(value: number);
  17610. private _lightmapMode;
  17611. /**
  17612. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17613. */
  17614. get lightmapMode(): number;
  17615. /**
  17616. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17617. */
  17618. set lightmapMode(value: number);
  17619. /**
  17620. * Shadow generator associted to the light.
  17621. * @hidden Internal use only.
  17622. */
  17623. _shadowGenerator: Nullable<IShadowGenerator>;
  17624. /**
  17625. * @hidden Internal use only.
  17626. */
  17627. _excludedMeshesIds: string[];
  17628. /**
  17629. * @hidden Internal use only.
  17630. */
  17631. _includedOnlyMeshesIds: string[];
  17632. /**
  17633. * The current light unifom buffer.
  17634. * @hidden Internal use only.
  17635. */
  17636. _uniformBuffer: UniformBuffer;
  17637. /** @hidden */
  17638. _renderId: number;
  17639. /**
  17640. * Creates a Light object in the scene.
  17641. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17642. * @param name The firendly name of the light
  17643. * @param scene The scene the light belongs too
  17644. */
  17645. constructor(name: string, scene: Scene);
  17646. protected abstract _buildUniformLayout(): void;
  17647. /**
  17648. * Sets the passed Effect "effect" with the Light information.
  17649. * @param effect The effect to update
  17650. * @param lightIndex The index of the light in the effect to update
  17651. * @returns The light
  17652. */
  17653. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17654. /**
  17655. * Sets the passed Effect "effect" with the Light textures.
  17656. * @param effect The effect to update
  17657. * @param lightIndex The index of the light in the effect to update
  17658. * @returns The light
  17659. */
  17660. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17661. /**
  17662. * Binds the lights information from the scene to the effect for the given mesh.
  17663. * @param lightIndex Light index
  17664. * @param scene The scene where the light belongs to
  17665. * @param effect The effect we are binding the data to
  17666. * @param useSpecular Defines if specular is supported
  17667. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17668. */
  17669. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17670. /**
  17671. * Sets the passed Effect "effect" with the Light information.
  17672. * @param effect The effect to update
  17673. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17674. * @returns The light
  17675. */
  17676. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17677. /**
  17678. * Returns the string "Light".
  17679. * @returns the class name
  17680. */
  17681. getClassName(): string;
  17682. /** @hidden */
  17683. readonly _isLight: boolean;
  17684. /**
  17685. * Converts the light information to a readable string for debug purpose.
  17686. * @param fullDetails Supports for multiple levels of logging within scene loading
  17687. * @returns the human readable light info
  17688. */
  17689. toString(fullDetails?: boolean): string;
  17690. /** @hidden */
  17691. protected _syncParentEnabledState(): void;
  17692. /**
  17693. * Set the enabled state of this node.
  17694. * @param value - the new enabled state
  17695. */
  17696. setEnabled(value: boolean): void;
  17697. /**
  17698. * Returns the Light associated shadow generator if any.
  17699. * @return the associated shadow generator.
  17700. */
  17701. getShadowGenerator(): Nullable<IShadowGenerator>;
  17702. /**
  17703. * Returns a Vector3, the absolute light position in the World.
  17704. * @returns the world space position of the light
  17705. */
  17706. getAbsolutePosition(): Vector3;
  17707. /**
  17708. * Specifies if the light will affect the passed mesh.
  17709. * @param mesh The mesh to test against the light
  17710. * @return true the mesh is affected otherwise, false.
  17711. */
  17712. canAffectMesh(mesh: AbstractMesh): boolean;
  17713. /**
  17714. * Sort function to order lights for rendering.
  17715. * @param a First Light object to compare to second.
  17716. * @param b Second Light object to compare first.
  17717. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17718. */
  17719. static CompareLightsPriority(a: Light, b: Light): number;
  17720. /**
  17721. * Releases resources associated with this node.
  17722. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17723. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17724. */
  17725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17726. /**
  17727. * Returns the light type ID (integer).
  17728. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17729. */
  17730. getTypeID(): number;
  17731. /**
  17732. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17733. * @returns the scaled intensity in intensity mode unit
  17734. */
  17735. getScaledIntensity(): number;
  17736. /**
  17737. * Returns a new Light object, named "name", from the current one.
  17738. * @param name The name of the cloned light
  17739. * @param newParent The parent of this light, if it has one
  17740. * @returns the new created light
  17741. */
  17742. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  17743. /**
  17744. * Serializes the current light into a Serialization object.
  17745. * @returns the serialized object.
  17746. */
  17747. serialize(): any;
  17748. /**
  17749. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17750. * This new light is named "name" and added to the passed scene.
  17751. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17752. * @param name The friendly name of the light
  17753. * @param scene The scene the new light will belong to
  17754. * @returns the constructor function
  17755. */
  17756. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17757. /**
  17758. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17759. * @param parsedLight The JSON representation of the light
  17760. * @param scene The scene to create the parsed light in
  17761. * @returns the created light after parsing
  17762. */
  17763. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17764. private _hookArrayForExcluded;
  17765. private _hookArrayForIncludedOnly;
  17766. private _resyncMeshes;
  17767. /**
  17768. * Forces the meshes to update their light related information in their rendering used effects
  17769. * @hidden Internal Use Only
  17770. */
  17771. _markMeshesAsLightDirty(): void;
  17772. /**
  17773. * Recomputes the cached photometric scale if needed.
  17774. */
  17775. private _computePhotometricScale;
  17776. /**
  17777. * Returns the Photometric Scale according to the light type and intensity mode.
  17778. */
  17779. private _getPhotometricScale;
  17780. /**
  17781. * Reorder the light in the scene according to their defined priority.
  17782. * @hidden Internal Use Only
  17783. */
  17784. _reorderLightsInScene(): void;
  17785. /**
  17786. * Prepares the list of defines specific to the light type.
  17787. * @param defines the list of defines
  17788. * @param lightIndex defines the index of the light for the effect
  17789. */
  17790. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17791. }
  17792. }
  17793. declare module "babylonjs/Actions/action" {
  17794. import { Observable } from "babylonjs/Misc/observable";
  17795. import { Condition } from "babylonjs/Actions/condition";
  17796. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17797. import { ActionManager } from "babylonjs/Actions/actionManager";
  17798. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17799. /**
  17800. * Interface used to define Action
  17801. */
  17802. export interface IAction {
  17803. /**
  17804. * Trigger for the action
  17805. */
  17806. trigger: number;
  17807. /** Options of the trigger */
  17808. triggerOptions: any;
  17809. /**
  17810. * Gets the trigger parameters
  17811. * @returns the trigger parameters
  17812. */
  17813. getTriggerParameter(): any;
  17814. /**
  17815. * Internal only - executes current action event
  17816. * @hidden
  17817. */
  17818. _executeCurrent(evt?: ActionEvent): void;
  17819. /**
  17820. * Serialize placeholder for child classes
  17821. * @param parent of child
  17822. * @returns the serialized object
  17823. */
  17824. serialize(parent: any): any;
  17825. /**
  17826. * Internal only
  17827. * @hidden
  17828. */
  17829. _prepare(): void;
  17830. /**
  17831. * Internal only - manager for action
  17832. * @hidden
  17833. */
  17834. _actionManager: AbstractActionManager;
  17835. /**
  17836. * Adds action to chain of actions, may be a DoNothingAction
  17837. * @param action defines the next action to execute
  17838. * @returns The action passed in
  17839. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17840. */
  17841. then(action: IAction): IAction;
  17842. }
  17843. /**
  17844. * The action to be carried out following a trigger
  17845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17846. */
  17847. export class Action implements IAction {
  17848. /** the trigger, with or without parameters, for the action */
  17849. triggerOptions: any;
  17850. /**
  17851. * Trigger for the action
  17852. */
  17853. trigger: number;
  17854. /**
  17855. * Internal only - manager for action
  17856. * @hidden
  17857. */
  17858. _actionManager: ActionManager;
  17859. private _nextActiveAction;
  17860. private _child;
  17861. private _condition?;
  17862. private _triggerParameter;
  17863. /**
  17864. * An event triggered prior to action being executed.
  17865. */
  17866. onBeforeExecuteObservable: Observable<Action>;
  17867. /**
  17868. * Creates a new Action
  17869. * @param triggerOptions the trigger, with or without parameters, for the action
  17870. * @param condition an optional determinant of action
  17871. */
  17872. constructor(
  17873. /** the trigger, with or without parameters, for the action */
  17874. triggerOptions: any, condition?: Condition);
  17875. /**
  17876. * Internal only
  17877. * @hidden
  17878. */
  17879. _prepare(): void;
  17880. /**
  17881. * Gets the trigger parameters
  17882. * @returns the trigger parameters
  17883. */
  17884. getTriggerParameter(): any;
  17885. /**
  17886. * Internal only - executes current action event
  17887. * @hidden
  17888. */
  17889. _executeCurrent(evt?: ActionEvent): void;
  17890. /**
  17891. * Execute placeholder for child classes
  17892. * @param evt optional action event
  17893. */
  17894. execute(evt?: ActionEvent): void;
  17895. /**
  17896. * Skips to next active action
  17897. */
  17898. skipToNextActiveAction(): void;
  17899. /**
  17900. * Adds action to chain of actions, may be a DoNothingAction
  17901. * @param action defines the next action to execute
  17902. * @returns The action passed in
  17903. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17904. */
  17905. then(action: Action): Action;
  17906. /**
  17907. * Internal only
  17908. * @hidden
  17909. */
  17910. _getProperty(propertyPath: string): string;
  17911. /**
  17912. * Internal only
  17913. * @hidden
  17914. */
  17915. _getEffectiveTarget(target: any, propertyPath: string): any;
  17916. /**
  17917. * Serialize placeholder for child classes
  17918. * @param parent of child
  17919. * @returns the serialized object
  17920. */
  17921. serialize(parent: any): any;
  17922. /**
  17923. * Internal only called by serialize
  17924. * @hidden
  17925. */
  17926. protected _serialize(serializedAction: any, parent?: any): any;
  17927. /**
  17928. * Internal only
  17929. * @hidden
  17930. */
  17931. static _SerializeValueAsString: (value: any) => string;
  17932. /**
  17933. * Internal only
  17934. * @hidden
  17935. */
  17936. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17937. name: string;
  17938. targetType: string;
  17939. value: string;
  17940. };
  17941. }
  17942. }
  17943. declare module "babylonjs/Actions/condition" {
  17944. import { ActionManager } from "babylonjs/Actions/actionManager";
  17945. /**
  17946. * A Condition applied to an Action
  17947. */
  17948. export class Condition {
  17949. /**
  17950. * Internal only - manager for action
  17951. * @hidden
  17952. */
  17953. _actionManager: ActionManager;
  17954. /**
  17955. * Internal only
  17956. * @hidden
  17957. */
  17958. _evaluationId: number;
  17959. /**
  17960. * Internal only
  17961. * @hidden
  17962. */
  17963. _currentResult: boolean;
  17964. /**
  17965. * Creates a new Condition
  17966. * @param actionManager the manager of the action the condition is applied to
  17967. */
  17968. constructor(actionManager: ActionManager);
  17969. /**
  17970. * Check if the current condition is valid
  17971. * @returns a boolean
  17972. */
  17973. isValid(): boolean;
  17974. /**
  17975. * Internal only
  17976. * @hidden
  17977. */
  17978. _getProperty(propertyPath: string): string;
  17979. /**
  17980. * Internal only
  17981. * @hidden
  17982. */
  17983. _getEffectiveTarget(target: any, propertyPath: string): any;
  17984. /**
  17985. * Serialize placeholder for child classes
  17986. * @returns the serialized object
  17987. */
  17988. serialize(): any;
  17989. /**
  17990. * Internal only
  17991. * @hidden
  17992. */
  17993. protected _serialize(serializedCondition: any): any;
  17994. }
  17995. /**
  17996. * Defines specific conditional operators as extensions of Condition
  17997. */
  17998. export class ValueCondition extends Condition {
  17999. /** path to specify the property of the target the conditional operator uses */
  18000. propertyPath: string;
  18001. /** the value compared by the conditional operator against the current value of the property */
  18002. value: any;
  18003. /** the conditional operator, default ValueCondition.IsEqual */
  18004. operator: number;
  18005. /**
  18006. * Internal only
  18007. * @hidden
  18008. */
  18009. private static _IsEqual;
  18010. /**
  18011. * Internal only
  18012. * @hidden
  18013. */
  18014. private static _IsDifferent;
  18015. /**
  18016. * Internal only
  18017. * @hidden
  18018. */
  18019. private static _IsGreater;
  18020. /**
  18021. * Internal only
  18022. * @hidden
  18023. */
  18024. private static _IsLesser;
  18025. /**
  18026. * returns the number for IsEqual
  18027. */
  18028. static get IsEqual(): number;
  18029. /**
  18030. * Returns the number for IsDifferent
  18031. */
  18032. static get IsDifferent(): number;
  18033. /**
  18034. * Returns the number for IsGreater
  18035. */
  18036. static get IsGreater(): number;
  18037. /**
  18038. * Returns the number for IsLesser
  18039. */
  18040. static get IsLesser(): number;
  18041. /**
  18042. * Internal only The action manager for the condition
  18043. * @hidden
  18044. */
  18045. _actionManager: ActionManager;
  18046. /**
  18047. * Internal only
  18048. * @hidden
  18049. */
  18050. private _target;
  18051. /**
  18052. * Internal only
  18053. * @hidden
  18054. */
  18055. private _effectiveTarget;
  18056. /**
  18057. * Internal only
  18058. * @hidden
  18059. */
  18060. private _property;
  18061. /**
  18062. * Creates a new ValueCondition
  18063. * @param actionManager manager for the action the condition applies to
  18064. * @param target for the action
  18065. * @param propertyPath path to specify the property of the target the conditional operator uses
  18066. * @param value the value compared by the conditional operator against the current value of the property
  18067. * @param operator the conditional operator, default ValueCondition.IsEqual
  18068. */
  18069. constructor(actionManager: ActionManager, target: any,
  18070. /** path to specify the property of the target the conditional operator uses */
  18071. propertyPath: string,
  18072. /** the value compared by the conditional operator against the current value of the property */
  18073. value: any,
  18074. /** the conditional operator, default ValueCondition.IsEqual */
  18075. operator?: number);
  18076. /**
  18077. * Compares the given value with the property value for the specified conditional operator
  18078. * @returns the result of the comparison
  18079. */
  18080. isValid(): boolean;
  18081. /**
  18082. * Serialize the ValueCondition into a JSON compatible object
  18083. * @returns serialization object
  18084. */
  18085. serialize(): any;
  18086. /**
  18087. * Gets the name of the conditional operator for the ValueCondition
  18088. * @param operator the conditional operator
  18089. * @returns the name
  18090. */
  18091. static GetOperatorName(operator: number): string;
  18092. }
  18093. /**
  18094. * Defines a predicate condition as an extension of Condition
  18095. */
  18096. export class PredicateCondition extends Condition {
  18097. /** defines the predicate function used to validate the condition */
  18098. predicate: () => boolean;
  18099. /**
  18100. * Internal only - manager for action
  18101. * @hidden
  18102. */
  18103. _actionManager: ActionManager;
  18104. /**
  18105. * Creates a new PredicateCondition
  18106. * @param actionManager manager for the action the condition applies to
  18107. * @param predicate defines the predicate function used to validate the condition
  18108. */
  18109. constructor(actionManager: ActionManager,
  18110. /** defines the predicate function used to validate the condition */
  18111. predicate: () => boolean);
  18112. /**
  18113. * @returns the validity of the predicate condition
  18114. */
  18115. isValid(): boolean;
  18116. }
  18117. /**
  18118. * Defines a state condition as an extension of Condition
  18119. */
  18120. export class StateCondition extends Condition {
  18121. /** Value to compare with target state */
  18122. value: string;
  18123. /**
  18124. * Internal only - manager for action
  18125. * @hidden
  18126. */
  18127. _actionManager: ActionManager;
  18128. /**
  18129. * Internal only
  18130. * @hidden
  18131. */
  18132. private _target;
  18133. /**
  18134. * Creates a new StateCondition
  18135. * @param actionManager manager for the action the condition applies to
  18136. * @param target of the condition
  18137. * @param value to compare with target state
  18138. */
  18139. constructor(actionManager: ActionManager, target: any,
  18140. /** Value to compare with target state */
  18141. value: string);
  18142. /**
  18143. * Gets a boolean indicating if the current condition is met
  18144. * @returns the validity of the state
  18145. */
  18146. isValid(): boolean;
  18147. /**
  18148. * Serialize the StateCondition into a JSON compatible object
  18149. * @returns serialization object
  18150. */
  18151. serialize(): any;
  18152. }
  18153. }
  18154. declare module "babylonjs/Actions/directActions" {
  18155. import { Action } from "babylonjs/Actions/action";
  18156. import { Condition } from "babylonjs/Actions/condition";
  18157. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18158. /**
  18159. * This defines an action responsible to toggle a boolean once triggered.
  18160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18161. */
  18162. export class SwitchBooleanAction extends Action {
  18163. /**
  18164. * The path to the boolean property in the target object
  18165. */
  18166. propertyPath: string;
  18167. private _target;
  18168. private _effectiveTarget;
  18169. private _property;
  18170. /**
  18171. * Instantiate the action
  18172. * @param triggerOptions defines the trigger options
  18173. * @param target defines the object containing the boolean
  18174. * @param propertyPath defines the path to the boolean property in the target object
  18175. * @param condition defines the trigger related conditions
  18176. */
  18177. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18178. /** @hidden */
  18179. _prepare(): void;
  18180. /**
  18181. * Execute the action toggle the boolean value.
  18182. */
  18183. execute(): void;
  18184. /**
  18185. * Serializes the actions and its related information.
  18186. * @param parent defines the object to serialize in
  18187. * @returns the serialized object
  18188. */
  18189. serialize(parent: any): any;
  18190. }
  18191. /**
  18192. * This defines an action responsible to set a the state field of the target
  18193. * to a desired value once triggered.
  18194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18195. */
  18196. export class SetStateAction extends Action {
  18197. /**
  18198. * The value to store in the state field.
  18199. */
  18200. value: string;
  18201. private _target;
  18202. /**
  18203. * Instantiate the action
  18204. * @param triggerOptions defines the trigger options
  18205. * @param target defines the object containing the state property
  18206. * @param value defines the value to store in the state field
  18207. * @param condition defines the trigger related conditions
  18208. */
  18209. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18210. /**
  18211. * Execute the action and store the value on the target state property.
  18212. */
  18213. execute(): void;
  18214. /**
  18215. * Serializes the actions and its related information.
  18216. * @param parent defines the object to serialize in
  18217. * @returns the serialized object
  18218. */
  18219. serialize(parent: any): any;
  18220. }
  18221. /**
  18222. * This defines an action responsible to set a property of the target
  18223. * to a desired value once triggered.
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18225. */
  18226. export class SetValueAction extends Action {
  18227. /**
  18228. * The path of the property to set in the target.
  18229. */
  18230. propertyPath: string;
  18231. /**
  18232. * The value to set in the property
  18233. */
  18234. value: any;
  18235. private _target;
  18236. private _effectiveTarget;
  18237. private _property;
  18238. /**
  18239. * Instantiate the action
  18240. * @param triggerOptions defines the trigger options
  18241. * @param target defines the object containing the property
  18242. * @param propertyPath defines the path of the property to set in the target
  18243. * @param value defines the value to set in the property
  18244. * @param condition defines the trigger related conditions
  18245. */
  18246. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18247. /** @hidden */
  18248. _prepare(): void;
  18249. /**
  18250. * Execute the action and set the targetted property to the desired value.
  18251. */
  18252. execute(): void;
  18253. /**
  18254. * Serializes the actions and its related information.
  18255. * @param parent defines the object to serialize in
  18256. * @returns the serialized object
  18257. */
  18258. serialize(parent: any): any;
  18259. }
  18260. /**
  18261. * This defines an action responsible to increment the target value
  18262. * to a desired value once triggered.
  18263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18264. */
  18265. export class IncrementValueAction extends Action {
  18266. /**
  18267. * The path of the property to increment in the target.
  18268. */
  18269. propertyPath: string;
  18270. /**
  18271. * The value we should increment the property by.
  18272. */
  18273. value: any;
  18274. private _target;
  18275. private _effectiveTarget;
  18276. private _property;
  18277. /**
  18278. * Instantiate the action
  18279. * @param triggerOptions defines the trigger options
  18280. * @param target defines the object containing the property
  18281. * @param propertyPath defines the path of the property to increment in the target
  18282. * @param value defines the value value we should increment the property by
  18283. * @param condition defines the trigger related conditions
  18284. */
  18285. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18286. /** @hidden */
  18287. _prepare(): void;
  18288. /**
  18289. * Execute the action and increment the target of the value amount.
  18290. */
  18291. execute(): void;
  18292. /**
  18293. * Serializes the actions and its related information.
  18294. * @param parent defines the object to serialize in
  18295. * @returns the serialized object
  18296. */
  18297. serialize(parent: any): any;
  18298. }
  18299. /**
  18300. * This defines an action responsible to start an animation once triggered.
  18301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18302. */
  18303. export class PlayAnimationAction extends Action {
  18304. /**
  18305. * Where the animation should start (animation frame)
  18306. */
  18307. from: number;
  18308. /**
  18309. * Where the animation should stop (animation frame)
  18310. */
  18311. to: number;
  18312. /**
  18313. * Define if the animation should loop or stop after the first play.
  18314. */
  18315. loop?: boolean;
  18316. private _target;
  18317. /**
  18318. * Instantiate the action
  18319. * @param triggerOptions defines the trigger options
  18320. * @param target defines the target animation or animation name
  18321. * @param from defines from where the animation should start (animation frame)
  18322. * @param end defines where the animation should stop (animation frame)
  18323. * @param loop defines if the animation should loop or stop after the first play
  18324. * @param condition defines the trigger related conditions
  18325. */
  18326. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18327. /** @hidden */
  18328. _prepare(): void;
  18329. /**
  18330. * Execute the action and play the animation.
  18331. */
  18332. execute(): void;
  18333. /**
  18334. * Serializes the actions and its related information.
  18335. * @param parent defines the object to serialize in
  18336. * @returns the serialized object
  18337. */
  18338. serialize(parent: any): any;
  18339. }
  18340. /**
  18341. * This defines an action responsible to stop an animation once triggered.
  18342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18343. */
  18344. export class StopAnimationAction extends Action {
  18345. private _target;
  18346. /**
  18347. * Instantiate the action
  18348. * @param triggerOptions defines the trigger options
  18349. * @param target defines the target animation or animation name
  18350. * @param condition defines the trigger related conditions
  18351. */
  18352. constructor(triggerOptions: any, target: any, condition?: Condition);
  18353. /** @hidden */
  18354. _prepare(): void;
  18355. /**
  18356. * Execute the action and stop the animation.
  18357. */
  18358. execute(): void;
  18359. /**
  18360. * Serializes the actions and its related information.
  18361. * @param parent defines the object to serialize in
  18362. * @returns the serialized object
  18363. */
  18364. serialize(parent: any): any;
  18365. }
  18366. /**
  18367. * This defines an action responsible that does nothing once triggered.
  18368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18369. */
  18370. export class DoNothingAction extends Action {
  18371. /**
  18372. * Instantiate the action
  18373. * @param triggerOptions defines the trigger options
  18374. * @param condition defines the trigger related conditions
  18375. */
  18376. constructor(triggerOptions?: any, condition?: Condition);
  18377. /**
  18378. * Execute the action and do nothing.
  18379. */
  18380. execute(): void;
  18381. /**
  18382. * Serializes the actions and its related information.
  18383. * @param parent defines the object to serialize in
  18384. * @returns the serialized object
  18385. */
  18386. serialize(parent: any): any;
  18387. }
  18388. /**
  18389. * This defines an action responsible to trigger several actions once triggered.
  18390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18391. */
  18392. export class CombineAction extends Action {
  18393. /**
  18394. * The list of aggregated animations to run.
  18395. */
  18396. children: Action[];
  18397. /**
  18398. * Instantiate the action
  18399. * @param triggerOptions defines the trigger options
  18400. * @param children defines the list of aggregated animations to run
  18401. * @param condition defines the trigger related conditions
  18402. */
  18403. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18404. /** @hidden */
  18405. _prepare(): void;
  18406. /**
  18407. * Execute the action and executes all the aggregated actions.
  18408. */
  18409. execute(evt: ActionEvent): void;
  18410. /**
  18411. * Serializes the actions and its related information.
  18412. * @param parent defines the object to serialize in
  18413. * @returns the serialized object
  18414. */
  18415. serialize(parent: any): any;
  18416. }
  18417. /**
  18418. * This defines an action responsible to run code (external event) once triggered.
  18419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18420. */
  18421. export class ExecuteCodeAction extends Action {
  18422. /**
  18423. * The callback function to run.
  18424. */
  18425. func: (evt: ActionEvent) => void;
  18426. /**
  18427. * Instantiate the action
  18428. * @param triggerOptions defines the trigger options
  18429. * @param func defines the callback function to run
  18430. * @param condition defines the trigger related conditions
  18431. */
  18432. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18433. /**
  18434. * Execute the action and run the attached code.
  18435. */
  18436. execute(evt: ActionEvent): void;
  18437. }
  18438. /**
  18439. * This defines an action responsible to set the parent property of the target once triggered.
  18440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18441. */
  18442. export class SetParentAction extends Action {
  18443. private _parent;
  18444. private _target;
  18445. /**
  18446. * Instantiate the action
  18447. * @param triggerOptions defines the trigger options
  18448. * @param target defines the target containing the parent property
  18449. * @param parent defines from where the animation should start (animation frame)
  18450. * @param condition defines the trigger related conditions
  18451. */
  18452. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18453. /** @hidden */
  18454. _prepare(): void;
  18455. /**
  18456. * Execute the action and set the parent property.
  18457. */
  18458. execute(): void;
  18459. /**
  18460. * Serializes the actions and its related information.
  18461. * @param parent defines the object to serialize in
  18462. * @returns the serialized object
  18463. */
  18464. serialize(parent: any): any;
  18465. }
  18466. }
  18467. declare module "babylonjs/Actions/actionManager" {
  18468. import { Nullable } from "babylonjs/types";
  18469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18470. import { Scene } from "babylonjs/scene";
  18471. import { IAction } from "babylonjs/Actions/action";
  18472. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18473. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18474. /**
  18475. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18476. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18478. */
  18479. export class ActionManager extends AbstractActionManager {
  18480. /**
  18481. * Nothing
  18482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18483. */
  18484. static readonly NothingTrigger: number;
  18485. /**
  18486. * On pick
  18487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18488. */
  18489. static readonly OnPickTrigger: number;
  18490. /**
  18491. * On left pick
  18492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18493. */
  18494. static readonly OnLeftPickTrigger: number;
  18495. /**
  18496. * On right pick
  18497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18498. */
  18499. static readonly OnRightPickTrigger: number;
  18500. /**
  18501. * On center pick
  18502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18503. */
  18504. static readonly OnCenterPickTrigger: number;
  18505. /**
  18506. * On pick down
  18507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18508. */
  18509. static readonly OnPickDownTrigger: number;
  18510. /**
  18511. * On double pick
  18512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18513. */
  18514. static readonly OnDoublePickTrigger: number;
  18515. /**
  18516. * On pick up
  18517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18518. */
  18519. static readonly OnPickUpTrigger: number;
  18520. /**
  18521. * On pick out.
  18522. * This trigger will only be raised if you also declared a OnPickDown
  18523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18524. */
  18525. static readonly OnPickOutTrigger: number;
  18526. /**
  18527. * On long press
  18528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18529. */
  18530. static readonly OnLongPressTrigger: number;
  18531. /**
  18532. * On pointer over
  18533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18534. */
  18535. static readonly OnPointerOverTrigger: number;
  18536. /**
  18537. * On pointer out
  18538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18539. */
  18540. static readonly OnPointerOutTrigger: number;
  18541. /**
  18542. * On every frame
  18543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18544. */
  18545. static readonly OnEveryFrameTrigger: number;
  18546. /**
  18547. * On intersection enter
  18548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18549. */
  18550. static readonly OnIntersectionEnterTrigger: number;
  18551. /**
  18552. * On intersection exit
  18553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18554. */
  18555. static readonly OnIntersectionExitTrigger: number;
  18556. /**
  18557. * On key down
  18558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18559. */
  18560. static readonly OnKeyDownTrigger: number;
  18561. /**
  18562. * On key up
  18563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18564. */
  18565. static readonly OnKeyUpTrigger: number;
  18566. private _scene;
  18567. /**
  18568. * Creates a new action manager
  18569. * @param scene defines the hosting scene
  18570. */
  18571. constructor(scene: Scene);
  18572. /**
  18573. * Releases all associated resources
  18574. */
  18575. dispose(): void;
  18576. /**
  18577. * Gets hosting scene
  18578. * @returns the hosting scene
  18579. */
  18580. getScene(): Scene;
  18581. /**
  18582. * Does this action manager handles actions of any of the given triggers
  18583. * @param triggers defines the triggers to be tested
  18584. * @return a boolean indicating whether one (or more) of the triggers is handled
  18585. */
  18586. hasSpecificTriggers(triggers: number[]): boolean;
  18587. /**
  18588. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18589. * speed.
  18590. * @param triggerA defines the trigger to be tested
  18591. * @param triggerB defines the trigger to be tested
  18592. * @return a boolean indicating whether one (or more) of the triggers is handled
  18593. */
  18594. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18595. /**
  18596. * Does this action manager handles actions of a given trigger
  18597. * @param trigger defines the trigger to be tested
  18598. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18599. * @return whether the trigger is handled
  18600. */
  18601. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18602. /**
  18603. * Does this action manager has pointer triggers
  18604. */
  18605. get hasPointerTriggers(): boolean;
  18606. /**
  18607. * Does this action manager has pick triggers
  18608. */
  18609. get hasPickTriggers(): boolean;
  18610. /**
  18611. * Registers an action to this action manager
  18612. * @param action defines the action to be registered
  18613. * @return the action amended (prepared) after registration
  18614. */
  18615. registerAction(action: IAction): Nullable<IAction>;
  18616. /**
  18617. * Unregisters an action to this action manager
  18618. * @param action defines the action to be unregistered
  18619. * @return a boolean indicating whether the action has been unregistered
  18620. */
  18621. unregisterAction(action: IAction): Boolean;
  18622. /**
  18623. * Process a specific trigger
  18624. * @param trigger defines the trigger to process
  18625. * @param evt defines the event details to be processed
  18626. */
  18627. processTrigger(trigger: number, evt?: IActionEvent): void;
  18628. /** @hidden */
  18629. _getEffectiveTarget(target: any, propertyPath: string): any;
  18630. /** @hidden */
  18631. _getProperty(propertyPath: string): string;
  18632. /**
  18633. * Serialize this manager to a JSON object
  18634. * @param name defines the property name to store this manager
  18635. * @returns a JSON representation of this manager
  18636. */
  18637. serialize(name: string): any;
  18638. /**
  18639. * Creates a new ActionManager from a JSON data
  18640. * @param parsedActions defines the JSON data to read from
  18641. * @param object defines the hosting mesh
  18642. * @param scene defines the hosting scene
  18643. */
  18644. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18645. /**
  18646. * Get a trigger name by index
  18647. * @param trigger defines the trigger index
  18648. * @returns a trigger name
  18649. */
  18650. static GetTriggerName(trigger: number): string;
  18651. }
  18652. }
  18653. declare module "babylonjs/Sprites/sprite" {
  18654. import { Vector3 } from "babylonjs/Maths/math.vector";
  18655. import { Nullable } from "babylonjs/types";
  18656. import { ActionManager } from "babylonjs/Actions/actionManager";
  18657. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18658. import { Color4 } from "babylonjs/Maths/math.color";
  18659. import { Observable } from "babylonjs/Misc/observable";
  18660. /**
  18661. * Class used to represent a sprite
  18662. * @see http://doc.babylonjs.com/babylon101/sprites
  18663. */
  18664. export class Sprite {
  18665. /** defines the name */
  18666. name: string;
  18667. /** Gets or sets the current world position */
  18668. position: Vector3;
  18669. /** Gets or sets the main color */
  18670. color: Color4;
  18671. /** Gets or sets the width */
  18672. width: number;
  18673. /** Gets or sets the height */
  18674. height: number;
  18675. /** Gets or sets rotation angle */
  18676. angle: number;
  18677. /** Gets or sets the cell index in the sprite sheet */
  18678. cellIndex: number;
  18679. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18680. cellRef: string;
  18681. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18682. invertU: number;
  18683. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18684. invertV: number;
  18685. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18686. disposeWhenFinishedAnimating: boolean;
  18687. /** Gets the list of attached animations */
  18688. animations: Animation[];
  18689. /** Gets or sets a boolean indicating if the sprite can be picked */
  18690. isPickable: boolean;
  18691. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18692. useAlphaForPicking: boolean;
  18693. /** @hidden */
  18694. _xOffset: number;
  18695. /** @hidden */
  18696. _yOffset: number;
  18697. /** @hidden */
  18698. _xSize: number;
  18699. /** @hidden */
  18700. _ySize: number;
  18701. /**
  18702. * Gets or sets the associated action manager
  18703. */
  18704. actionManager: Nullable<ActionManager>;
  18705. /**
  18706. * An event triggered when the control has been disposed
  18707. */
  18708. onDisposeObservable: Observable<Sprite>;
  18709. private _animationStarted;
  18710. private _loopAnimation;
  18711. private _fromIndex;
  18712. private _toIndex;
  18713. private _delay;
  18714. private _direction;
  18715. private _manager;
  18716. private _time;
  18717. private _onAnimationEnd;
  18718. /**
  18719. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18720. */
  18721. isVisible: boolean;
  18722. /**
  18723. * Gets or sets the sprite size
  18724. */
  18725. get size(): number;
  18726. set size(value: number);
  18727. /**
  18728. * Gets or sets the unique id of the sprite
  18729. */
  18730. uniqueId: number;
  18731. /**
  18732. * Creates a new Sprite
  18733. * @param name defines the name
  18734. * @param manager defines the manager
  18735. */
  18736. constructor(
  18737. /** defines the name */
  18738. name: string, manager: ISpriteManager);
  18739. /**
  18740. * Returns the string "Sprite"
  18741. * @returns "Sprite"
  18742. */
  18743. getClassName(): string;
  18744. /**
  18745. * Starts an animation
  18746. * @param from defines the initial key
  18747. * @param to defines the end key
  18748. * @param loop defines if the animation must loop
  18749. * @param delay defines the start delay (in ms)
  18750. * @param onAnimationEnd defines a callback to call when animation ends
  18751. */
  18752. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18753. /** Stops current animation (if any) */
  18754. stopAnimation(): void;
  18755. /** @hidden */
  18756. _animate(deltaTime: number): void;
  18757. /** Release associated resources */
  18758. dispose(): void;
  18759. }
  18760. }
  18761. declare module "babylonjs/Collisions/pickingInfo" {
  18762. import { Nullable } from "babylonjs/types";
  18763. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18765. import { Sprite } from "babylonjs/Sprites/sprite";
  18766. import { Ray } from "babylonjs/Culling/ray";
  18767. /**
  18768. * Information about the result of picking within a scene
  18769. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18770. */
  18771. export class PickingInfo {
  18772. /** @hidden */
  18773. _pickingUnavailable: boolean;
  18774. /**
  18775. * If the pick collided with an object
  18776. */
  18777. hit: boolean;
  18778. /**
  18779. * Distance away where the pick collided
  18780. */
  18781. distance: number;
  18782. /**
  18783. * The location of pick collision
  18784. */
  18785. pickedPoint: Nullable<Vector3>;
  18786. /**
  18787. * The mesh corresponding the the pick collision
  18788. */
  18789. pickedMesh: Nullable<AbstractMesh>;
  18790. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18791. bu: number;
  18792. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18793. bv: number;
  18794. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18795. faceId: number;
  18796. /** Id of the the submesh that was picked */
  18797. subMeshId: number;
  18798. /** If a sprite was picked, this will be the sprite the pick collided with */
  18799. pickedSprite: Nullable<Sprite>;
  18800. /**
  18801. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18802. */
  18803. originMesh: Nullable<AbstractMesh>;
  18804. /**
  18805. * The ray that was used to perform the picking.
  18806. */
  18807. ray: Nullable<Ray>;
  18808. /**
  18809. * Gets the normal correspodning to the face the pick collided with
  18810. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18811. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18812. * @returns The normal correspodning to the face the pick collided with
  18813. */
  18814. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18815. /**
  18816. * Gets the texture coordinates of where the pick occured
  18817. * @returns the vector containing the coordnates of the texture
  18818. */
  18819. getTextureCoordinates(): Nullable<Vector2>;
  18820. }
  18821. }
  18822. declare module "babylonjs/Events/pointerEvents" {
  18823. import { Nullable } from "babylonjs/types";
  18824. import { Vector2 } from "babylonjs/Maths/math.vector";
  18825. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18826. import { Ray } from "babylonjs/Culling/ray";
  18827. /**
  18828. * Gather the list of pointer event types as constants.
  18829. */
  18830. export class PointerEventTypes {
  18831. /**
  18832. * 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.
  18833. */
  18834. static readonly POINTERDOWN: number;
  18835. /**
  18836. * The pointerup event is fired when a pointer is no longer active.
  18837. */
  18838. static readonly POINTERUP: number;
  18839. /**
  18840. * The pointermove event is fired when a pointer changes coordinates.
  18841. */
  18842. static readonly POINTERMOVE: number;
  18843. /**
  18844. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18845. */
  18846. static readonly POINTERWHEEL: number;
  18847. /**
  18848. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18849. */
  18850. static readonly POINTERPICK: number;
  18851. /**
  18852. * The pointertap event is fired when a the object has been touched and released without drag.
  18853. */
  18854. static readonly POINTERTAP: number;
  18855. /**
  18856. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18857. */
  18858. static readonly POINTERDOUBLETAP: number;
  18859. }
  18860. /**
  18861. * Base class of pointer info types.
  18862. */
  18863. export class PointerInfoBase {
  18864. /**
  18865. * Defines the type of event (PointerEventTypes)
  18866. */
  18867. type: number;
  18868. /**
  18869. * Defines the related dom event
  18870. */
  18871. event: PointerEvent | MouseWheelEvent;
  18872. /**
  18873. * Instantiates the base class of pointers info.
  18874. * @param type Defines the type of event (PointerEventTypes)
  18875. * @param event Defines the related dom event
  18876. */
  18877. constructor(
  18878. /**
  18879. * Defines the type of event (PointerEventTypes)
  18880. */
  18881. type: number,
  18882. /**
  18883. * Defines the related dom event
  18884. */
  18885. event: PointerEvent | MouseWheelEvent);
  18886. }
  18887. /**
  18888. * This class is used to store pointer related info for the onPrePointerObservable event.
  18889. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18890. */
  18891. export class PointerInfoPre extends PointerInfoBase {
  18892. /**
  18893. * Ray from a pointer if availible (eg. 6dof controller)
  18894. */
  18895. ray: Nullable<Ray>;
  18896. /**
  18897. * Defines the local position of the pointer on the canvas.
  18898. */
  18899. localPosition: Vector2;
  18900. /**
  18901. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18902. */
  18903. skipOnPointerObservable: boolean;
  18904. /**
  18905. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18906. * @param type Defines the type of event (PointerEventTypes)
  18907. * @param event Defines the related dom event
  18908. * @param localX Defines the local x coordinates of the pointer when the event occured
  18909. * @param localY Defines the local y coordinates of the pointer when the event occured
  18910. */
  18911. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18912. }
  18913. /**
  18914. * This type contains all the data related to a pointer event in Babylon.js.
  18915. * 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.
  18916. */
  18917. export class PointerInfo extends PointerInfoBase {
  18918. /**
  18919. * Defines the picking info associated to the info (if any)\
  18920. */
  18921. pickInfo: Nullable<PickingInfo>;
  18922. /**
  18923. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18924. * @param type Defines the type of event (PointerEventTypes)
  18925. * @param event Defines the related dom event
  18926. * @param pickInfo Defines the picking info associated to the info (if any)\
  18927. */
  18928. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18929. /**
  18930. * Defines the picking info associated to the info (if any)\
  18931. */
  18932. pickInfo: Nullable<PickingInfo>);
  18933. }
  18934. /**
  18935. * Data relating to a touch event on the screen.
  18936. */
  18937. export interface PointerTouch {
  18938. /**
  18939. * X coordinate of touch.
  18940. */
  18941. x: number;
  18942. /**
  18943. * Y coordinate of touch.
  18944. */
  18945. y: number;
  18946. /**
  18947. * Id of touch. Unique for each finger.
  18948. */
  18949. pointerId: number;
  18950. /**
  18951. * Event type passed from DOM.
  18952. */
  18953. type: any;
  18954. }
  18955. }
  18956. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18957. import { Observable } from "babylonjs/Misc/observable";
  18958. import { Nullable } from "babylonjs/types";
  18959. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18961. /**
  18962. * Manage the mouse inputs to control the movement of a free camera.
  18963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18964. */
  18965. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18966. /**
  18967. * Define if touch is enabled in the mouse input
  18968. */
  18969. touchEnabled: boolean;
  18970. /**
  18971. * Defines the camera the input is attached to.
  18972. */
  18973. camera: FreeCamera;
  18974. /**
  18975. * Defines the buttons associated with the input to handle camera move.
  18976. */
  18977. buttons: number[];
  18978. /**
  18979. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18980. */
  18981. angularSensibility: number;
  18982. private _pointerInput;
  18983. private _onMouseMove;
  18984. private _observer;
  18985. private previousPosition;
  18986. /**
  18987. * Observable for when a pointer move event occurs containing the move offset
  18988. */
  18989. onPointerMovedObservable: Observable<{
  18990. offsetX: number;
  18991. offsetY: number;
  18992. }>;
  18993. /**
  18994. * @hidden
  18995. * If the camera should be rotated automatically based on pointer movement
  18996. */
  18997. _allowCameraRotation: boolean;
  18998. /**
  18999. * Manage the mouse inputs to control the movement of a free camera.
  19000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19001. * @param touchEnabled Defines if touch is enabled or not
  19002. */
  19003. constructor(
  19004. /**
  19005. * Define if touch is enabled in the mouse input
  19006. */
  19007. touchEnabled?: boolean);
  19008. /**
  19009. * Attach the input controls to a specific dom element to get the input from.
  19010. * @param element Defines the element the controls should be listened from
  19011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19012. */
  19013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19014. /**
  19015. * Called on JS contextmenu event.
  19016. * Override this method to provide functionality.
  19017. */
  19018. protected onContextMenu(evt: PointerEvent): void;
  19019. /**
  19020. * Detach the current controls from the specified dom element.
  19021. * @param element Defines the element to stop listening the inputs from
  19022. */
  19023. detachControl(element: Nullable<HTMLElement>): void;
  19024. /**
  19025. * Gets the class name of the current intput.
  19026. * @returns the class name
  19027. */
  19028. getClassName(): string;
  19029. /**
  19030. * Get the friendly name associated with the input class.
  19031. * @returns the input friendly name
  19032. */
  19033. getSimpleName(): string;
  19034. }
  19035. }
  19036. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19037. import { Nullable } from "babylonjs/types";
  19038. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19039. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19040. /**
  19041. * Manage the touch inputs to control the movement of a free camera.
  19042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19043. */
  19044. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19045. /**
  19046. * Defines the camera the input is attached to.
  19047. */
  19048. camera: FreeCamera;
  19049. /**
  19050. * Defines the touch sensibility for rotation.
  19051. * The higher the faster.
  19052. */
  19053. touchAngularSensibility: number;
  19054. /**
  19055. * Defines the touch sensibility for move.
  19056. * The higher the faster.
  19057. */
  19058. touchMoveSensibility: number;
  19059. private _offsetX;
  19060. private _offsetY;
  19061. private _pointerPressed;
  19062. private _pointerInput;
  19063. private _observer;
  19064. private _onLostFocus;
  19065. /**
  19066. * Attach the input controls to a specific dom element to get the input from.
  19067. * @param element Defines the element the controls should be listened from
  19068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19069. */
  19070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19071. /**
  19072. * Detach the current controls from the specified dom element.
  19073. * @param element Defines the element to stop listening the inputs from
  19074. */
  19075. detachControl(element: Nullable<HTMLElement>): void;
  19076. /**
  19077. * Update the current camera state depending on the inputs that have been used this frame.
  19078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19079. */
  19080. checkInputs(): void;
  19081. /**
  19082. * Gets the class name of the current intput.
  19083. * @returns the class name
  19084. */
  19085. getClassName(): string;
  19086. /**
  19087. * Get the friendly name associated with the input class.
  19088. * @returns the input friendly name
  19089. */
  19090. getSimpleName(): string;
  19091. }
  19092. }
  19093. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19094. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19095. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19096. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19097. import { Nullable } from "babylonjs/types";
  19098. /**
  19099. * Default Inputs manager for the FreeCamera.
  19100. * It groups all the default supported inputs for ease of use.
  19101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19102. */
  19103. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19104. /**
  19105. * @hidden
  19106. */
  19107. _mouseInput: Nullable<FreeCameraMouseInput>;
  19108. /**
  19109. * Instantiates a new FreeCameraInputsManager.
  19110. * @param camera Defines the camera the inputs belong to
  19111. */
  19112. constructor(camera: FreeCamera);
  19113. /**
  19114. * Add keyboard input support to the input manager.
  19115. * @returns the current input manager
  19116. */
  19117. addKeyboard(): FreeCameraInputsManager;
  19118. /**
  19119. * Add mouse input support to the input manager.
  19120. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19121. * @returns the current input manager
  19122. */
  19123. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19124. /**
  19125. * Removes the mouse input support from the manager
  19126. * @returns the current input manager
  19127. */
  19128. removeMouse(): FreeCameraInputsManager;
  19129. /**
  19130. * Add touch input support to the input manager.
  19131. * @returns the current input manager
  19132. */
  19133. addTouch(): FreeCameraInputsManager;
  19134. /**
  19135. * Remove all attached input methods from a camera
  19136. */
  19137. clear(): void;
  19138. }
  19139. }
  19140. declare module "babylonjs/Cameras/freeCamera" {
  19141. import { Vector3 } from "babylonjs/Maths/math.vector";
  19142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19143. import { Scene } from "babylonjs/scene";
  19144. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19145. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19146. /**
  19147. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19148. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19149. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19150. */
  19151. export class FreeCamera extends TargetCamera {
  19152. /**
  19153. * Define the collision ellipsoid of the camera.
  19154. * This is helpful to simulate a camera body like the player body around the camera
  19155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19156. */
  19157. ellipsoid: Vector3;
  19158. /**
  19159. * Define an offset for the position of the ellipsoid around the camera.
  19160. * This can be helpful to determine the center of the body near the gravity center of the body
  19161. * instead of its head.
  19162. */
  19163. ellipsoidOffset: Vector3;
  19164. /**
  19165. * Enable or disable collisions of the camera with the rest of the scene objects.
  19166. */
  19167. checkCollisions: boolean;
  19168. /**
  19169. * Enable or disable gravity on the camera.
  19170. */
  19171. applyGravity: boolean;
  19172. /**
  19173. * Define the input manager associated to the camera.
  19174. */
  19175. inputs: FreeCameraInputsManager;
  19176. /**
  19177. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19178. * Higher values reduce sensitivity.
  19179. */
  19180. get angularSensibility(): number;
  19181. /**
  19182. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19183. * Higher values reduce sensitivity.
  19184. */
  19185. set angularSensibility(value: number);
  19186. /**
  19187. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19188. */
  19189. get keysUp(): number[];
  19190. set keysUp(value: number[]);
  19191. /**
  19192. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19193. */
  19194. get keysUpward(): number[];
  19195. set keysUpward(value: number[]);
  19196. /**
  19197. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19198. */
  19199. get keysDown(): number[];
  19200. set keysDown(value: number[]);
  19201. /**
  19202. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19203. */
  19204. get keysDownward(): number[];
  19205. set keysDownward(value: number[]);
  19206. /**
  19207. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19208. */
  19209. get keysLeft(): number[];
  19210. set keysLeft(value: number[]);
  19211. /**
  19212. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19213. */
  19214. get keysRight(): number[];
  19215. set keysRight(value: number[]);
  19216. /**
  19217. * Event raised when the camera collide with a mesh in the scene.
  19218. */
  19219. onCollide: (collidedMesh: AbstractMesh) => void;
  19220. private _collider;
  19221. private _needMoveForGravity;
  19222. private _oldPosition;
  19223. private _diffPosition;
  19224. private _newPosition;
  19225. /** @hidden */
  19226. _localDirection: Vector3;
  19227. /** @hidden */
  19228. _transformedDirection: Vector3;
  19229. /**
  19230. * Instantiates a Free Camera.
  19231. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19232. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19233. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19234. * @param name Define the name of the camera in the scene
  19235. * @param position Define the start position of the camera in the scene
  19236. * @param scene Define the scene the camera belongs to
  19237. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19238. */
  19239. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19240. /**
  19241. * Attached controls to the current camera.
  19242. * @param element Defines the element the controls should be listened from
  19243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19244. */
  19245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19246. /**
  19247. * Detach the current controls from the camera.
  19248. * The camera will stop reacting to inputs.
  19249. * @param element Defines the element to stop listening the inputs from
  19250. */
  19251. detachControl(element: HTMLElement): void;
  19252. private _collisionMask;
  19253. /**
  19254. * Define a collision mask to limit the list of object the camera can collide with
  19255. */
  19256. get collisionMask(): number;
  19257. set collisionMask(mask: number);
  19258. /** @hidden */
  19259. _collideWithWorld(displacement: Vector3): void;
  19260. private _onCollisionPositionChange;
  19261. /** @hidden */
  19262. _checkInputs(): void;
  19263. /** @hidden */
  19264. _decideIfNeedsToMove(): boolean;
  19265. /** @hidden */
  19266. _updatePosition(): void;
  19267. /**
  19268. * Destroy the camera and release the current resources hold by it.
  19269. */
  19270. dispose(): void;
  19271. /**
  19272. * Gets the current object class name.
  19273. * @return the class name
  19274. */
  19275. getClassName(): string;
  19276. }
  19277. }
  19278. declare module "babylonjs/Gamepads/gamepad" {
  19279. import { Observable } from "babylonjs/Misc/observable";
  19280. /**
  19281. * Represents a gamepad control stick position
  19282. */
  19283. export class StickValues {
  19284. /**
  19285. * The x component of the control stick
  19286. */
  19287. x: number;
  19288. /**
  19289. * The y component of the control stick
  19290. */
  19291. y: number;
  19292. /**
  19293. * Initializes the gamepad x and y control stick values
  19294. * @param x The x component of the gamepad control stick value
  19295. * @param y The y component of the gamepad control stick value
  19296. */
  19297. constructor(
  19298. /**
  19299. * The x component of the control stick
  19300. */
  19301. x: number,
  19302. /**
  19303. * The y component of the control stick
  19304. */
  19305. y: number);
  19306. }
  19307. /**
  19308. * An interface which manages callbacks for gamepad button changes
  19309. */
  19310. export interface GamepadButtonChanges {
  19311. /**
  19312. * Called when a gamepad has been changed
  19313. */
  19314. changed: boolean;
  19315. /**
  19316. * Called when a gamepad press event has been triggered
  19317. */
  19318. pressChanged: boolean;
  19319. /**
  19320. * Called when a touch event has been triggered
  19321. */
  19322. touchChanged: boolean;
  19323. /**
  19324. * Called when a value has changed
  19325. */
  19326. valueChanged: boolean;
  19327. }
  19328. /**
  19329. * Represents a gamepad
  19330. */
  19331. export class Gamepad {
  19332. /**
  19333. * The id of the gamepad
  19334. */
  19335. id: string;
  19336. /**
  19337. * The index of the gamepad
  19338. */
  19339. index: number;
  19340. /**
  19341. * The browser gamepad
  19342. */
  19343. browserGamepad: any;
  19344. /**
  19345. * Specifies what type of gamepad this represents
  19346. */
  19347. type: number;
  19348. private _leftStick;
  19349. private _rightStick;
  19350. /** @hidden */
  19351. _isConnected: boolean;
  19352. private _leftStickAxisX;
  19353. private _leftStickAxisY;
  19354. private _rightStickAxisX;
  19355. private _rightStickAxisY;
  19356. /**
  19357. * Triggered when the left control stick has been changed
  19358. */
  19359. private _onleftstickchanged;
  19360. /**
  19361. * Triggered when the right control stick has been changed
  19362. */
  19363. private _onrightstickchanged;
  19364. /**
  19365. * Represents a gamepad controller
  19366. */
  19367. static GAMEPAD: number;
  19368. /**
  19369. * Represents a generic controller
  19370. */
  19371. static GENERIC: number;
  19372. /**
  19373. * Represents an XBox controller
  19374. */
  19375. static XBOX: number;
  19376. /**
  19377. * Represents a pose-enabled controller
  19378. */
  19379. static POSE_ENABLED: number;
  19380. /**
  19381. * Represents an Dual Shock controller
  19382. */
  19383. static DUALSHOCK: number;
  19384. /**
  19385. * Specifies whether the left control stick should be Y-inverted
  19386. */
  19387. protected _invertLeftStickY: boolean;
  19388. /**
  19389. * Specifies if the gamepad has been connected
  19390. */
  19391. get isConnected(): boolean;
  19392. /**
  19393. * Initializes the gamepad
  19394. * @param id The id of the gamepad
  19395. * @param index The index of the gamepad
  19396. * @param browserGamepad The browser gamepad
  19397. * @param leftStickX The x component of the left joystick
  19398. * @param leftStickY The y component of the left joystick
  19399. * @param rightStickX The x component of the right joystick
  19400. * @param rightStickY The y component of the right joystick
  19401. */
  19402. constructor(
  19403. /**
  19404. * The id of the gamepad
  19405. */
  19406. id: string,
  19407. /**
  19408. * The index of the gamepad
  19409. */
  19410. index: number,
  19411. /**
  19412. * The browser gamepad
  19413. */
  19414. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19415. /**
  19416. * Callback triggered when the left joystick has changed
  19417. * @param callback
  19418. */
  19419. onleftstickchanged(callback: (values: StickValues) => void): void;
  19420. /**
  19421. * Callback triggered when the right joystick has changed
  19422. * @param callback
  19423. */
  19424. onrightstickchanged(callback: (values: StickValues) => void): void;
  19425. /**
  19426. * Gets the left joystick
  19427. */
  19428. get leftStick(): StickValues;
  19429. /**
  19430. * Sets the left joystick values
  19431. */
  19432. set leftStick(newValues: StickValues);
  19433. /**
  19434. * Gets the right joystick
  19435. */
  19436. get rightStick(): StickValues;
  19437. /**
  19438. * Sets the right joystick value
  19439. */
  19440. set rightStick(newValues: StickValues);
  19441. /**
  19442. * Updates the gamepad joystick positions
  19443. */
  19444. update(): void;
  19445. /**
  19446. * Disposes the gamepad
  19447. */
  19448. dispose(): void;
  19449. }
  19450. /**
  19451. * Represents a generic gamepad
  19452. */
  19453. export class GenericPad extends Gamepad {
  19454. private _buttons;
  19455. private _onbuttondown;
  19456. private _onbuttonup;
  19457. /**
  19458. * Observable triggered when a button has been pressed
  19459. */
  19460. onButtonDownObservable: Observable<number>;
  19461. /**
  19462. * Observable triggered when a button has been released
  19463. */
  19464. onButtonUpObservable: Observable<number>;
  19465. /**
  19466. * Callback triggered when a button has been pressed
  19467. * @param callback Called when a button has been pressed
  19468. */
  19469. onbuttondown(callback: (buttonPressed: number) => void): void;
  19470. /**
  19471. * Callback triggered when a button has been released
  19472. * @param callback Called when a button has been released
  19473. */
  19474. onbuttonup(callback: (buttonReleased: number) => void): void;
  19475. /**
  19476. * Initializes the generic gamepad
  19477. * @param id The id of the generic gamepad
  19478. * @param index The index of the generic gamepad
  19479. * @param browserGamepad The browser gamepad
  19480. */
  19481. constructor(id: string, index: number, browserGamepad: any);
  19482. private _setButtonValue;
  19483. /**
  19484. * Updates the generic gamepad
  19485. */
  19486. update(): void;
  19487. /**
  19488. * Disposes the generic gamepad
  19489. */
  19490. dispose(): void;
  19491. }
  19492. }
  19493. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19494. import { Observable } from "babylonjs/Misc/observable";
  19495. import { Nullable } from "babylonjs/types";
  19496. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19497. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19499. import { Ray } from "babylonjs/Culling/ray";
  19500. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19501. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19502. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19503. /**
  19504. * Defines the types of pose enabled controllers that are supported
  19505. */
  19506. export enum PoseEnabledControllerType {
  19507. /**
  19508. * HTC Vive
  19509. */
  19510. VIVE = 0,
  19511. /**
  19512. * Oculus Rift
  19513. */
  19514. OCULUS = 1,
  19515. /**
  19516. * Windows mixed reality
  19517. */
  19518. WINDOWS = 2,
  19519. /**
  19520. * Samsung gear VR
  19521. */
  19522. GEAR_VR = 3,
  19523. /**
  19524. * Google Daydream
  19525. */
  19526. DAYDREAM = 4,
  19527. /**
  19528. * Generic
  19529. */
  19530. GENERIC = 5
  19531. }
  19532. /**
  19533. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19534. */
  19535. export interface MutableGamepadButton {
  19536. /**
  19537. * Value of the button/trigger
  19538. */
  19539. value: number;
  19540. /**
  19541. * If the button/trigger is currently touched
  19542. */
  19543. touched: boolean;
  19544. /**
  19545. * If the button/trigger is currently pressed
  19546. */
  19547. pressed: boolean;
  19548. }
  19549. /**
  19550. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19551. * @hidden
  19552. */
  19553. export interface ExtendedGamepadButton extends GamepadButton {
  19554. /**
  19555. * If the button/trigger is currently pressed
  19556. */
  19557. readonly pressed: boolean;
  19558. /**
  19559. * If the button/trigger is currently touched
  19560. */
  19561. readonly touched: boolean;
  19562. /**
  19563. * Value of the button/trigger
  19564. */
  19565. readonly value: number;
  19566. }
  19567. /** @hidden */
  19568. export interface _GamePadFactory {
  19569. /**
  19570. * Returns whether or not the current gamepad can be created for this type of controller.
  19571. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19572. * @returns true if it can be created, otherwise false
  19573. */
  19574. canCreate(gamepadInfo: any): boolean;
  19575. /**
  19576. * Creates a new instance of the Gamepad.
  19577. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19578. * @returns the new gamepad instance
  19579. */
  19580. create(gamepadInfo: any): Gamepad;
  19581. }
  19582. /**
  19583. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19584. */
  19585. export class PoseEnabledControllerHelper {
  19586. /** @hidden */
  19587. static _ControllerFactories: _GamePadFactory[];
  19588. /** @hidden */
  19589. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19590. /**
  19591. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19592. * @param vrGamepad the gamepad to initialized
  19593. * @returns a vr controller of the type the gamepad identified as
  19594. */
  19595. static InitiateController(vrGamepad: any): Gamepad;
  19596. }
  19597. /**
  19598. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19599. */
  19600. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19601. /**
  19602. * If the controller is used in a webXR session
  19603. */
  19604. isXR: boolean;
  19605. private _deviceRoomPosition;
  19606. private _deviceRoomRotationQuaternion;
  19607. /**
  19608. * The device position in babylon space
  19609. */
  19610. devicePosition: Vector3;
  19611. /**
  19612. * The device rotation in babylon space
  19613. */
  19614. deviceRotationQuaternion: Quaternion;
  19615. /**
  19616. * The scale factor of the device in babylon space
  19617. */
  19618. deviceScaleFactor: number;
  19619. /**
  19620. * (Likely devicePosition should be used instead) The device position in its room space
  19621. */
  19622. position: Vector3;
  19623. /**
  19624. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19625. */
  19626. rotationQuaternion: Quaternion;
  19627. /**
  19628. * The type of controller (Eg. Windows mixed reality)
  19629. */
  19630. controllerType: PoseEnabledControllerType;
  19631. protected _calculatedPosition: Vector3;
  19632. private _calculatedRotation;
  19633. /**
  19634. * The raw pose from the device
  19635. */
  19636. rawPose: DevicePose;
  19637. private _trackPosition;
  19638. private _maxRotationDistFromHeadset;
  19639. private _draggedRoomRotation;
  19640. /**
  19641. * @hidden
  19642. */
  19643. _disableTrackPosition(fixedPosition: Vector3): void;
  19644. /**
  19645. * Internal, the mesh attached to the controller
  19646. * @hidden
  19647. */
  19648. _mesh: Nullable<AbstractMesh>;
  19649. private _poseControlledCamera;
  19650. private _leftHandSystemQuaternion;
  19651. /**
  19652. * Internal, matrix used to convert room space to babylon space
  19653. * @hidden
  19654. */
  19655. _deviceToWorld: Matrix;
  19656. /**
  19657. * Node to be used when casting a ray from the controller
  19658. * @hidden
  19659. */
  19660. _pointingPoseNode: Nullable<TransformNode>;
  19661. /**
  19662. * Name of the child mesh that can be used to cast a ray from the controller
  19663. */
  19664. static readonly POINTING_POSE: string;
  19665. /**
  19666. * Creates a new PoseEnabledController from a gamepad
  19667. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19668. */
  19669. constructor(browserGamepad: any);
  19670. private _workingMatrix;
  19671. /**
  19672. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19673. */
  19674. update(): void;
  19675. /**
  19676. * Updates only the pose device and mesh without doing any button event checking
  19677. */
  19678. protected _updatePoseAndMesh(): void;
  19679. /**
  19680. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19681. * @param poseData raw pose fromthe device
  19682. */
  19683. updateFromDevice(poseData: DevicePose): void;
  19684. /**
  19685. * @hidden
  19686. */
  19687. _meshAttachedObservable: Observable<AbstractMesh>;
  19688. /**
  19689. * Attaches a mesh to the controller
  19690. * @param mesh the mesh to be attached
  19691. */
  19692. attachToMesh(mesh: AbstractMesh): void;
  19693. /**
  19694. * Attaches the controllers mesh to a camera
  19695. * @param camera the camera the mesh should be attached to
  19696. */
  19697. attachToPoseControlledCamera(camera: TargetCamera): void;
  19698. /**
  19699. * Disposes of the controller
  19700. */
  19701. dispose(): void;
  19702. /**
  19703. * The mesh that is attached to the controller
  19704. */
  19705. get mesh(): Nullable<AbstractMesh>;
  19706. /**
  19707. * Gets the ray of the controller in the direction the controller is pointing
  19708. * @param length the length the resulting ray should be
  19709. * @returns a ray in the direction the controller is pointing
  19710. */
  19711. getForwardRay(length?: number): Ray;
  19712. }
  19713. }
  19714. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19715. import { Observable } from "babylonjs/Misc/observable";
  19716. import { Scene } from "babylonjs/scene";
  19717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19718. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19719. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19720. import { Nullable } from "babylonjs/types";
  19721. /**
  19722. * Defines the WebVRController object that represents controllers tracked in 3D space
  19723. */
  19724. export abstract class WebVRController extends PoseEnabledController {
  19725. /**
  19726. * Internal, the default controller model for the controller
  19727. */
  19728. protected _defaultModel: Nullable<AbstractMesh>;
  19729. /**
  19730. * Fired when the trigger state has changed
  19731. */
  19732. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19733. /**
  19734. * Fired when the main button state has changed
  19735. */
  19736. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19737. /**
  19738. * Fired when the secondary button state has changed
  19739. */
  19740. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19741. /**
  19742. * Fired when the pad state has changed
  19743. */
  19744. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19745. /**
  19746. * Fired when controllers stick values have changed
  19747. */
  19748. onPadValuesChangedObservable: Observable<StickValues>;
  19749. /**
  19750. * Array of button availible on the controller
  19751. */
  19752. protected _buttons: Array<MutableGamepadButton>;
  19753. private _onButtonStateChange;
  19754. /**
  19755. * Fired when a controller button's state has changed
  19756. * @param callback the callback containing the button that was modified
  19757. */
  19758. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19759. /**
  19760. * X and Y axis corresponding to the controllers joystick
  19761. */
  19762. pad: StickValues;
  19763. /**
  19764. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19765. */
  19766. hand: string;
  19767. /**
  19768. * The default controller model for the controller
  19769. */
  19770. get defaultModel(): Nullable<AbstractMesh>;
  19771. /**
  19772. * Creates a new WebVRController from a gamepad
  19773. * @param vrGamepad the gamepad that the WebVRController should be created from
  19774. */
  19775. constructor(vrGamepad: any);
  19776. /**
  19777. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19778. */
  19779. update(): void;
  19780. /**
  19781. * Function to be called when a button is modified
  19782. */
  19783. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19784. /**
  19785. * Loads a mesh and attaches it to the controller
  19786. * @param scene the scene the mesh should be added to
  19787. * @param meshLoaded callback for when the mesh has been loaded
  19788. */
  19789. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19790. private _setButtonValue;
  19791. private _changes;
  19792. private _checkChanges;
  19793. /**
  19794. * Disposes of th webVRCOntroller
  19795. */
  19796. dispose(): void;
  19797. }
  19798. }
  19799. declare module "babylonjs/Lights/hemisphericLight" {
  19800. import { Nullable } from "babylonjs/types";
  19801. import { Scene } from "babylonjs/scene";
  19802. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19803. import { Color3 } from "babylonjs/Maths/math.color";
  19804. import { Effect } from "babylonjs/Materials/effect";
  19805. import { Light } from "babylonjs/Lights/light";
  19806. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19807. /**
  19808. * The HemisphericLight simulates the ambient environment light,
  19809. * so the passed direction is the light reflection direction, not the incoming direction.
  19810. */
  19811. export class HemisphericLight extends Light {
  19812. /**
  19813. * The groundColor is the light in the opposite direction to the one specified during creation.
  19814. * 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.
  19815. */
  19816. groundColor: Color3;
  19817. /**
  19818. * The light reflection direction, not the incoming direction.
  19819. */
  19820. direction: Vector3;
  19821. /**
  19822. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19823. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19824. * The HemisphericLight can't cast shadows.
  19825. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19826. * @param name The friendly name of the light
  19827. * @param direction The direction of the light reflection
  19828. * @param scene The scene the light belongs to
  19829. */
  19830. constructor(name: string, direction: Vector3, scene: Scene);
  19831. protected _buildUniformLayout(): void;
  19832. /**
  19833. * Returns the string "HemisphericLight".
  19834. * @return The class name
  19835. */
  19836. getClassName(): string;
  19837. /**
  19838. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19839. * Returns the updated direction.
  19840. * @param target The target the direction should point to
  19841. * @return The computed direction
  19842. */
  19843. setDirectionToTarget(target: Vector3): Vector3;
  19844. /**
  19845. * Returns the shadow generator associated to the light.
  19846. * @returns Always null for hemispheric lights because it does not support shadows.
  19847. */
  19848. getShadowGenerator(): Nullable<IShadowGenerator>;
  19849. /**
  19850. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19851. * @param effect The effect to update
  19852. * @param lightIndex The index of the light in the effect to update
  19853. * @returns The hemispheric light
  19854. */
  19855. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19856. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19857. /**
  19858. * Computes the world matrix of the node
  19859. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19860. * @param useWasUpdatedFlag defines a reserved property
  19861. * @returns the world matrix
  19862. */
  19863. computeWorldMatrix(): Matrix;
  19864. /**
  19865. * Returns the integer 3.
  19866. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19867. */
  19868. getTypeID(): number;
  19869. /**
  19870. * Prepares the list of defines specific to the light type.
  19871. * @param defines the list of defines
  19872. * @param lightIndex defines the index of the light for the effect
  19873. */
  19874. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19875. }
  19876. }
  19877. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19878. /** @hidden */
  19879. export var vrMultiviewToSingleviewPixelShader: {
  19880. name: string;
  19881. shader: string;
  19882. };
  19883. }
  19884. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19886. import { Scene } from "babylonjs/scene";
  19887. /**
  19888. * Renders to multiple views with a single draw call
  19889. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19890. */
  19891. export class MultiviewRenderTarget extends RenderTargetTexture {
  19892. /**
  19893. * Creates a multiview render target
  19894. * @param scene scene used with the render target
  19895. * @param size the size of the render target (used for each view)
  19896. */
  19897. constructor(scene: Scene, size?: number | {
  19898. width: number;
  19899. height: number;
  19900. } | {
  19901. ratio: number;
  19902. });
  19903. /**
  19904. * @hidden
  19905. * @param faceIndex the face index, if its a cube texture
  19906. */
  19907. _bindFrameBuffer(faceIndex?: number): void;
  19908. /**
  19909. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19910. * @returns the view count
  19911. */
  19912. getViewCount(): number;
  19913. }
  19914. }
  19915. declare module "babylonjs/Maths/math.frustum" {
  19916. import { Matrix } from "babylonjs/Maths/math.vector";
  19917. import { DeepImmutable } from "babylonjs/types";
  19918. import { Plane } from "babylonjs/Maths/math.plane";
  19919. /**
  19920. * Represents a camera frustum
  19921. */
  19922. export class Frustum {
  19923. /**
  19924. * Gets the planes representing the frustum
  19925. * @param transform matrix to be applied to the returned planes
  19926. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19927. */
  19928. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19929. /**
  19930. * Gets the near frustum plane transformed by the transform matrix
  19931. * @param transform transformation matrix to be applied to the resulting frustum plane
  19932. * @param frustumPlane the resuling frustum plane
  19933. */
  19934. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19935. /**
  19936. * Gets the far frustum plane transformed by the transform matrix
  19937. * @param transform transformation matrix to be applied to the resulting frustum plane
  19938. * @param frustumPlane the resuling frustum plane
  19939. */
  19940. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19941. /**
  19942. * Gets the left frustum plane transformed by the transform matrix
  19943. * @param transform transformation matrix to be applied to the resulting frustum plane
  19944. * @param frustumPlane the resuling frustum plane
  19945. */
  19946. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19947. /**
  19948. * Gets the right frustum plane transformed by the transform matrix
  19949. * @param transform transformation matrix to be applied to the resulting frustum plane
  19950. * @param frustumPlane the resuling frustum plane
  19951. */
  19952. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19953. /**
  19954. * Gets the top frustum plane transformed by the transform matrix
  19955. * @param transform transformation matrix to be applied to the resulting frustum plane
  19956. * @param frustumPlane the resuling frustum plane
  19957. */
  19958. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19959. /**
  19960. * Gets the bottom frustum plane transformed by the transform matrix
  19961. * @param transform transformation matrix to be applied to the resulting frustum plane
  19962. * @param frustumPlane the resuling frustum plane
  19963. */
  19964. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19965. /**
  19966. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19967. * @param transform transformation matrix to be applied to the resulting frustum planes
  19968. * @param frustumPlanes the resuling frustum planes
  19969. */
  19970. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19971. }
  19972. }
  19973. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19974. import { Camera } from "babylonjs/Cameras/camera";
  19975. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19976. import { Nullable } from "babylonjs/types";
  19977. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19978. import { Matrix } from "babylonjs/Maths/math.vector";
  19979. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19980. module "babylonjs/Engines/engine" {
  19981. interface Engine {
  19982. /**
  19983. * Creates a new multiview render target
  19984. * @param width defines the width of the texture
  19985. * @param height defines the height of the texture
  19986. * @returns the created multiview texture
  19987. */
  19988. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19989. /**
  19990. * Binds a multiview framebuffer to be drawn to
  19991. * @param multiviewTexture texture to bind
  19992. */
  19993. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19994. }
  19995. }
  19996. module "babylonjs/Cameras/camera" {
  19997. interface Camera {
  19998. /**
  19999. * @hidden
  20000. * 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)
  20001. */
  20002. _useMultiviewToSingleView: boolean;
  20003. /**
  20004. * @hidden
  20005. * 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)
  20006. */
  20007. _multiviewTexture: Nullable<RenderTargetTexture>;
  20008. /**
  20009. * @hidden
  20010. * ensures the multiview texture of the camera exists and has the specified width/height
  20011. * @param width height to set on the multiview texture
  20012. * @param height width to set on the multiview texture
  20013. */
  20014. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20015. }
  20016. }
  20017. module "babylonjs/scene" {
  20018. interface Scene {
  20019. /** @hidden */
  20020. _transformMatrixR: Matrix;
  20021. /** @hidden */
  20022. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20023. /** @hidden */
  20024. _createMultiviewUbo(): void;
  20025. /** @hidden */
  20026. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20027. /** @hidden */
  20028. _renderMultiviewToSingleView(camera: Camera): void;
  20029. }
  20030. }
  20031. }
  20032. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20033. import { Camera } from "babylonjs/Cameras/camera";
  20034. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20035. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20036. import "babylonjs/Engines/Extensions/engine.multiview";
  20037. /**
  20038. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20039. * This will not be used for webXR as it supports displaying texture arrays directly
  20040. */
  20041. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20042. /**
  20043. * Initializes a VRMultiviewToSingleview
  20044. * @param name name of the post process
  20045. * @param camera camera to be applied to
  20046. * @param scaleFactor scaling factor to the size of the output texture
  20047. */
  20048. constructor(name: string, camera: Camera, scaleFactor: number);
  20049. }
  20050. }
  20051. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20052. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20053. import { Nullable } from "babylonjs/types";
  20054. import { Size } from "babylonjs/Maths/math.size";
  20055. import { Observable } from "babylonjs/Misc/observable";
  20056. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20057. /**
  20058. * Interface used to define additional presentation attributes
  20059. */
  20060. export interface IVRPresentationAttributes {
  20061. /**
  20062. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20063. */
  20064. highRefreshRate: boolean;
  20065. /**
  20066. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20067. */
  20068. foveationLevel: number;
  20069. }
  20070. module "babylonjs/Engines/engine" {
  20071. interface Engine {
  20072. /** @hidden */
  20073. _vrDisplay: any;
  20074. /** @hidden */
  20075. _vrSupported: boolean;
  20076. /** @hidden */
  20077. _oldSize: Size;
  20078. /** @hidden */
  20079. _oldHardwareScaleFactor: number;
  20080. /** @hidden */
  20081. _vrExclusivePointerMode: boolean;
  20082. /** @hidden */
  20083. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20084. /** @hidden */
  20085. _onVRDisplayPointerRestricted: () => void;
  20086. /** @hidden */
  20087. _onVRDisplayPointerUnrestricted: () => void;
  20088. /** @hidden */
  20089. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20090. /** @hidden */
  20091. _onVrDisplayDisconnect: Nullable<() => void>;
  20092. /** @hidden */
  20093. _onVrDisplayPresentChange: Nullable<() => void>;
  20094. /**
  20095. * Observable signaled when VR display mode changes
  20096. */
  20097. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20098. /**
  20099. * Observable signaled when VR request present is complete
  20100. */
  20101. onVRRequestPresentComplete: Observable<boolean>;
  20102. /**
  20103. * Observable signaled when VR request present starts
  20104. */
  20105. onVRRequestPresentStart: Observable<Engine>;
  20106. /**
  20107. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20108. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20109. */
  20110. isInVRExclusivePointerMode: boolean;
  20111. /**
  20112. * Gets a boolean indicating if a webVR device was detected
  20113. * @returns true if a webVR device was detected
  20114. */
  20115. isVRDevicePresent(): boolean;
  20116. /**
  20117. * Gets the current webVR device
  20118. * @returns the current webVR device (or null)
  20119. */
  20120. getVRDevice(): any;
  20121. /**
  20122. * Initializes a webVR display and starts listening to display change events
  20123. * The onVRDisplayChangedObservable will be notified upon these changes
  20124. * @returns A promise containing a VRDisplay and if vr is supported
  20125. */
  20126. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20127. /** @hidden */
  20128. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20129. /**
  20130. * Gets or sets the presentation attributes used to configure VR rendering
  20131. */
  20132. vrPresentationAttributes?: IVRPresentationAttributes;
  20133. /**
  20134. * Call this function to switch to webVR mode
  20135. * Will do nothing if webVR is not supported or if there is no webVR device
  20136. * @param options the webvr options provided to the camera. mainly used for multiview
  20137. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20138. */
  20139. enableVR(options: WebVROptions): void;
  20140. /** @hidden */
  20141. _onVRFullScreenTriggered(): void;
  20142. }
  20143. }
  20144. }
  20145. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20146. import { Nullable } from "babylonjs/types";
  20147. import { Observable } from "babylonjs/Misc/observable";
  20148. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20149. import { Scene } from "babylonjs/scene";
  20150. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20151. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20152. import { Node } from "babylonjs/node";
  20153. import { Ray } from "babylonjs/Culling/ray";
  20154. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20155. import "babylonjs/Engines/Extensions/engine.webVR";
  20156. /**
  20157. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20158. * IMPORTANT!! The data is right-hand data.
  20159. * @export
  20160. * @interface DevicePose
  20161. */
  20162. export interface DevicePose {
  20163. /**
  20164. * The position of the device, values in array are [x,y,z].
  20165. */
  20166. readonly position: Nullable<Float32Array>;
  20167. /**
  20168. * The linearVelocity of the device, values in array are [x,y,z].
  20169. */
  20170. readonly linearVelocity: Nullable<Float32Array>;
  20171. /**
  20172. * The linearAcceleration of the device, values in array are [x,y,z].
  20173. */
  20174. readonly linearAcceleration: Nullable<Float32Array>;
  20175. /**
  20176. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20177. */
  20178. readonly orientation: Nullable<Float32Array>;
  20179. /**
  20180. * The angularVelocity of the device, values in array are [x,y,z].
  20181. */
  20182. readonly angularVelocity: Nullable<Float32Array>;
  20183. /**
  20184. * The angularAcceleration of the device, values in array are [x,y,z].
  20185. */
  20186. readonly angularAcceleration: Nullable<Float32Array>;
  20187. }
  20188. /**
  20189. * Interface representing a pose controlled object in Babylon.
  20190. * A pose controlled object has both regular pose values as well as pose values
  20191. * from an external device such as a VR head mounted display
  20192. */
  20193. export interface PoseControlled {
  20194. /**
  20195. * The position of the object in babylon space.
  20196. */
  20197. position: Vector3;
  20198. /**
  20199. * The rotation quaternion of the object in babylon space.
  20200. */
  20201. rotationQuaternion: Quaternion;
  20202. /**
  20203. * The position of the device in babylon space.
  20204. */
  20205. devicePosition?: Vector3;
  20206. /**
  20207. * The rotation quaternion of the device in babylon space.
  20208. */
  20209. deviceRotationQuaternion: Quaternion;
  20210. /**
  20211. * The raw pose coming from the device.
  20212. */
  20213. rawPose: Nullable<DevicePose>;
  20214. /**
  20215. * The scale of the device to be used when translating from device space to babylon space.
  20216. */
  20217. deviceScaleFactor: number;
  20218. /**
  20219. * Updates the poseControlled values based on the input device pose.
  20220. * @param poseData the pose data to update the object with
  20221. */
  20222. updateFromDevice(poseData: DevicePose): void;
  20223. }
  20224. /**
  20225. * Set of options to customize the webVRCamera
  20226. */
  20227. export interface WebVROptions {
  20228. /**
  20229. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20230. */
  20231. trackPosition?: boolean;
  20232. /**
  20233. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20234. */
  20235. positionScale?: number;
  20236. /**
  20237. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20238. */
  20239. displayName?: string;
  20240. /**
  20241. * Should the native controller meshes be initialized. (default: true)
  20242. */
  20243. controllerMeshes?: boolean;
  20244. /**
  20245. * Creating a default HemiLight only on controllers. (default: true)
  20246. */
  20247. defaultLightingOnControllers?: boolean;
  20248. /**
  20249. * If you don't want to use the default VR button of the helper. (default: false)
  20250. */
  20251. useCustomVRButton?: boolean;
  20252. /**
  20253. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20254. */
  20255. customVRButton?: HTMLButtonElement;
  20256. /**
  20257. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20258. */
  20259. rayLength?: number;
  20260. /**
  20261. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20262. */
  20263. defaultHeight?: number;
  20264. /**
  20265. * If multiview should be used if availible (default: false)
  20266. */
  20267. useMultiview?: boolean;
  20268. }
  20269. /**
  20270. * This represents a WebVR camera.
  20271. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20272. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20273. */
  20274. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20275. private webVROptions;
  20276. /**
  20277. * @hidden
  20278. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20279. */
  20280. _vrDevice: any;
  20281. /**
  20282. * The rawPose of the vrDevice.
  20283. */
  20284. rawPose: Nullable<DevicePose>;
  20285. private _onVREnabled;
  20286. private _specsVersion;
  20287. private _attached;
  20288. private _frameData;
  20289. protected _descendants: Array<Node>;
  20290. private _deviceRoomPosition;
  20291. /** @hidden */
  20292. _deviceRoomRotationQuaternion: Quaternion;
  20293. private _standingMatrix;
  20294. /**
  20295. * Represents device position in babylon space.
  20296. */
  20297. devicePosition: Vector3;
  20298. /**
  20299. * Represents device rotation in babylon space.
  20300. */
  20301. deviceRotationQuaternion: Quaternion;
  20302. /**
  20303. * The scale of the device to be used when translating from device space to babylon space.
  20304. */
  20305. deviceScaleFactor: number;
  20306. private _deviceToWorld;
  20307. private _worldToDevice;
  20308. /**
  20309. * References to the webVR controllers for the vrDevice.
  20310. */
  20311. controllers: Array<WebVRController>;
  20312. /**
  20313. * Emits an event when a controller is attached.
  20314. */
  20315. onControllersAttachedObservable: Observable<WebVRController[]>;
  20316. /**
  20317. * Emits an event when a controller's mesh has been loaded;
  20318. */
  20319. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20320. /**
  20321. * Emits an event when the HMD's pose has been updated.
  20322. */
  20323. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20324. private _poseSet;
  20325. /**
  20326. * If the rig cameras be used as parent instead of this camera.
  20327. */
  20328. rigParenting: boolean;
  20329. private _lightOnControllers;
  20330. private _defaultHeight?;
  20331. /**
  20332. * Instantiates a WebVRFreeCamera.
  20333. * @param name The name of the WebVRFreeCamera
  20334. * @param position The starting anchor position for the camera
  20335. * @param scene The scene the camera belongs to
  20336. * @param webVROptions a set of customizable options for the webVRCamera
  20337. */
  20338. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20339. /**
  20340. * Gets the device distance from the ground in meters.
  20341. * @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.
  20342. */
  20343. deviceDistanceToRoomGround(): number;
  20344. /**
  20345. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20346. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20347. */
  20348. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20349. /**
  20350. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20351. * @returns A promise with a boolean set to if the standing matrix is supported.
  20352. */
  20353. useStandingMatrixAsync(): Promise<boolean>;
  20354. /**
  20355. * Disposes the camera
  20356. */
  20357. dispose(): void;
  20358. /**
  20359. * Gets a vrController by name.
  20360. * @param name The name of the controller to retreive
  20361. * @returns the controller matching the name specified or null if not found
  20362. */
  20363. getControllerByName(name: string): Nullable<WebVRController>;
  20364. private _leftController;
  20365. /**
  20366. * The controller corresponding to the users left hand.
  20367. */
  20368. get leftController(): Nullable<WebVRController>;
  20369. private _rightController;
  20370. /**
  20371. * The controller corresponding to the users right hand.
  20372. */
  20373. get rightController(): Nullable<WebVRController>;
  20374. /**
  20375. * Casts a ray forward from the vrCamera's gaze.
  20376. * @param length Length of the ray (default: 100)
  20377. * @returns the ray corresponding to the gaze
  20378. */
  20379. getForwardRay(length?: number): Ray;
  20380. /**
  20381. * @hidden
  20382. * Updates the camera based on device's frame data
  20383. */
  20384. _checkInputs(): void;
  20385. /**
  20386. * Updates the poseControlled values based on the input device pose.
  20387. * @param poseData Pose coming from the device
  20388. */
  20389. updateFromDevice(poseData: DevicePose): void;
  20390. private _htmlElementAttached;
  20391. private _detachIfAttached;
  20392. /**
  20393. * WebVR's attach control will start broadcasting frames to the device.
  20394. * Note that in certain browsers (chrome for example) this function must be called
  20395. * within a user-interaction callback. Example:
  20396. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20397. *
  20398. * @param element html element to attach the vrDevice to
  20399. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20400. */
  20401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20402. /**
  20403. * Detaches the camera from the html element and disables VR
  20404. *
  20405. * @param element html element to detach from
  20406. */
  20407. detachControl(element: HTMLElement): void;
  20408. /**
  20409. * @returns the name of this class
  20410. */
  20411. getClassName(): string;
  20412. /**
  20413. * Calls resetPose on the vrDisplay
  20414. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20415. */
  20416. resetToCurrentRotation(): void;
  20417. /**
  20418. * @hidden
  20419. * Updates the rig cameras (left and right eye)
  20420. */
  20421. _updateRigCameras(): void;
  20422. private _workingVector;
  20423. private _oneVector;
  20424. private _workingMatrix;
  20425. private updateCacheCalled;
  20426. private _correctPositionIfNotTrackPosition;
  20427. /**
  20428. * @hidden
  20429. * Updates the cached values of the camera
  20430. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20431. */
  20432. _updateCache(ignoreParentClass?: boolean): void;
  20433. /**
  20434. * @hidden
  20435. * Get current device position in babylon world
  20436. */
  20437. _computeDevicePosition(): void;
  20438. /**
  20439. * Updates the current device position and rotation in the babylon world
  20440. */
  20441. update(): void;
  20442. /**
  20443. * @hidden
  20444. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20445. * @returns an identity matrix
  20446. */
  20447. _getViewMatrix(): Matrix;
  20448. private _tmpMatrix;
  20449. /**
  20450. * This function is called by the two RIG cameras.
  20451. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20452. * @hidden
  20453. */
  20454. _getWebVRViewMatrix(): Matrix;
  20455. /** @hidden */
  20456. _getWebVRProjectionMatrix(): Matrix;
  20457. private _onGamepadConnectedObserver;
  20458. private _onGamepadDisconnectedObserver;
  20459. private _updateCacheWhenTrackingDisabledObserver;
  20460. /**
  20461. * Initializes the controllers and their meshes
  20462. */
  20463. initControllers(): void;
  20464. }
  20465. }
  20466. declare module "babylonjs/PostProcesses/postProcess" {
  20467. import { Nullable } from "babylonjs/types";
  20468. import { SmartArray } from "babylonjs/Misc/smartArray";
  20469. import { Observable } from "babylonjs/Misc/observable";
  20470. import { Vector2 } from "babylonjs/Maths/math.vector";
  20471. import { Camera } from "babylonjs/Cameras/camera";
  20472. import { Effect } from "babylonjs/Materials/effect";
  20473. import "babylonjs/Shaders/postprocess.vertex";
  20474. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20475. import { Engine } from "babylonjs/Engines/engine";
  20476. import { Color4 } from "babylonjs/Maths/math.color";
  20477. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20478. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20479. /**
  20480. * Size options for a post process
  20481. */
  20482. export type PostProcessOptions = {
  20483. width: number;
  20484. height: number;
  20485. };
  20486. /**
  20487. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20488. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20489. */
  20490. export class PostProcess {
  20491. /** Name of the PostProcess. */
  20492. name: string;
  20493. /**
  20494. * Gets or sets the unique id of the post process
  20495. */
  20496. uniqueId: number;
  20497. /**
  20498. * Width of the texture to apply the post process on
  20499. */
  20500. width: number;
  20501. /**
  20502. * Height of the texture to apply the post process on
  20503. */
  20504. height: number;
  20505. /**
  20506. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20507. * @hidden
  20508. */
  20509. _outputTexture: Nullable<InternalTexture>;
  20510. /**
  20511. * Sampling mode used by the shader
  20512. * See https://doc.babylonjs.com/classes/3.1/texture
  20513. */
  20514. renderTargetSamplingMode: number;
  20515. /**
  20516. * Clear color to use when screen clearing
  20517. */
  20518. clearColor: Color4;
  20519. /**
  20520. * If the buffer needs to be cleared before applying the post process. (default: true)
  20521. * Should be set to false if shader will overwrite all previous pixels.
  20522. */
  20523. autoClear: boolean;
  20524. /**
  20525. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20526. */
  20527. alphaMode: number;
  20528. /**
  20529. * Sets the setAlphaBlendConstants of the babylon engine
  20530. */
  20531. alphaConstants: Color4;
  20532. /**
  20533. * Animations to be used for the post processing
  20534. */
  20535. animations: import("babylonjs/Animations/animation").Animation[];
  20536. /**
  20537. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20538. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20539. */
  20540. enablePixelPerfectMode: boolean;
  20541. /**
  20542. * Force the postprocess to be applied without taking in account viewport
  20543. */
  20544. forceFullscreenViewport: boolean;
  20545. /**
  20546. * List of inspectable custom properties (used by the Inspector)
  20547. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20548. */
  20549. inspectableCustomProperties: IInspectable[];
  20550. /**
  20551. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20552. *
  20553. * | Value | Type | Description |
  20554. * | ----- | ----------------------------------- | ----------- |
  20555. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20556. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20557. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20558. *
  20559. */
  20560. scaleMode: number;
  20561. /**
  20562. * Force textures to be a power of two (default: false)
  20563. */
  20564. alwaysForcePOT: boolean;
  20565. private _samples;
  20566. /**
  20567. * Number of sample textures (default: 1)
  20568. */
  20569. get samples(): number;
  20570. set samples(n: number);
  20571. /**
  20572. * Modify the scale of the post process to be the same as the viewport (default: false)
  20573. */
  20574. adaptScaleToCurrentViewport: boolean;
  20575. private _camera;
  20576. private _scene;
  20577. private _engine;
  20578. private _options;
  20579. private _reusable;
  20580. private _textureType;
  20581. private _textureFormat;
  20582. /**
  20583. * Smart array of input and output textures for the post process.
  20584. * @hidden
  20585. */
  20586. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20587. /**
  20588. * The index in _textures that corresponds to the output texture.
  20589. * @hidden
  20590. */
  20591. _currentRenderTextureInd: number;
  20592. private _effect;
  20593. private _samplers;
  20594. private _fragmentUrl;
  20595. private _vertexUrl;
  20596. private _parameters;
  20597. private _scaleRatio;
  20598. protected _indexParameters: any;
  20599. private _shareOutputWithPostProcess;
  20600. private _texelSize;
  20601. private _forcedOutputTexture;
  20602. /**
  20603. * Returns the fragment url or shader name used in the post process.
  20604. * @returns the fragment url or name in the shader store.
  20605. */
  20606. getEffectName(): string;
  20607. /**
  20608. * An event triggered when the postprocess is activated.
  20609. */
  20610. onActivateObservable: Observable<Camera>;
  20611. private _onActivateObserver;
  20612. /**
  20613. * A function that is added to the onActivateObservable
  20614. */
  20615. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20616. /**
  20617. * An event triggered when the postprocess changes its size.
  20618. */
  20619. onSizeChangedObservable: Observable<PostProcess>;
  20620. private _onSizeChangedObserver;
  20621. /**
  20622. * A function that is added to the onSizeChangedObservable
  20623. */
  20624. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20625. /**
  20626. * An event triggered when the postprocess applies its effect.
  20627. */
  20628. onApplyObservable: Observable<Effect>;
  20629. private _onApplyObserver;
  20630. /**
  20631. * A function that is added to the onApplyObservable
  20632. */
  20633. set onApply(callback: (effect: Effect) => void);
  20634. /**
  20635. * An event triggered before rendering the postprocess
  20636. */
  20637. onBeforeRenderObservable: Observable<Effect>;
  20638. private _onBeforeRenderObserver;
  20639. /**
  20640. * A function that is added to the onBeforeRenderObservable
  20641. */
  20642. set onBeforeRender(callback: (effect: Effect) => void);
  20643. /**
  20644. * An event triggered after rendering the postprocess
  20645. */
  20646. onAfterRenderObservable: Observable<Effect>;
  20647. private _onAfterRenderObserver;
  20648. /**
  20649. * A function that is added to the onAfterRenderObservable
  20650. */
  20651. set onAfterRender(callback: (efect: Effect) => void);
  20652. /**
  20653. * 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
  20654. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20655. */
  20656. get inputTexture(): InternalTexture;
  20657. set inputTexture(value: InternalTexture);
  20658. /**
  20659. * Gets the camera which post process is applied to.
  20660. * @returns The camera the post process is applied to.
  20661. */
  20662. getCamera(): Camera;
  20663. /**
  20664. * Gets the texel size of the postprocess.
  20665. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20666. */
  20667. get texelSize(): Vector2;
  20668. /**
  20669. * Creates a new instance PostProcess
  20670. * @param name The name of the PostProcess.
  20671. * @param fragmentUrl The url of the fragment shader to be used.
  20672. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20673. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20674. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20675. * @param camera The camera to apply the render pass to.
  20676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20677. * @param engine The engine which the post process will be applied. (default: current engine)
  20678. * @param reusable If the post process can be reused on the same frame. (default: false)
  20679. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20680. * @param textureType Type of textures used when performing the post process. (default: 0)
  20681. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20682. * @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
  20683. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20684. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20685. */
  20686. constructor(
  20687. /** Name of the PostProcess. */
  20688. 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);
  20689. /**
  20690. * Gets a string idenfifying the name of the class
  20691. * @returns "PostProcess" string
  20692. */
  20693. getClassName(): string;
  20694. /**
  20695. * Gets the engine which this post process belongs to.
  20696. * @returns The engine the post process was enabled with.
  20697. */
  20698. getEngine(): Engine;
  20699. /**
  20700. * The effect that is created when initializing the post process.
  20701. * @returns The created effect corresponding the the postprocess.
  20702. */
  20703. getEffect(): Effect;
  20704. /**
  20705. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20706. * @param postProcess The post process to share the output with.
  20707. * @returns This post process.
  20708. */
  20709. shareOutputWith(postProcess: PostProcess): PostProcess;
  20710. /**
  20711. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20712. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20713. */
  20714. useOwnOutput(): void;
  20715. /**
  20716. * Updates the effect with the current post process compile time values and recompiles the shader.
  20717. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20718. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20719. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20720. * @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
  20721. * @param onCompiled Called when the shader has been compiled.
  20722. * @param onError Called if there is an error when compiling a shader.
  20723. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  20724. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  20725. */
  20726. 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;
  20727. /**
  20728. * The post process is reusable if it can be used multiple times within one frame.
  20729. * @returns If the post process is reusable
  20730. */
  20731. isReusable(): boolean;
  20732. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20733. markTextureDirty(): void;
  20734. /**
  20735. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20736. * 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.
  20737. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20738. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20739. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20740. * @returns The target texture that was bound to be written to.
  20741. */
  20742. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20743. /**
  20744. * If the post process is supported.
  20745. */
  20746. get isSupported(): boolean;
  20747. /**
  20748. * The aspect ratio of the output texture.
  20749. */
  20750. get aspectRatio(): number;
  20751. /**
  20752. * Get a value indicating if the post-process is ready to be used
  20753. * @returns true if the post-process is ready (shader is compiled)
  20754. */
  20755. isReady(): boolean;
  20756. /**
  20757. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20758. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20759. */
  20760. apply(): Nullable<Effect>;
  20761. private _disposeTextures;
  20762. /**
  20763. * Disposes the post process.
  20764. * @param camera The camera to dispose the post process on.
  20765. */
  20766. dispose(camera?: Camera): void;
  20767. }
  20768. }
  20769. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20770. /** @hidden */
  20771. export var kernelBlurVaryingDeclaration: {
  20772. name: string;
  20773. shader: string;
  20774. };
  20775. }
  20776. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20777. /** @hidden */
  20778. export var kernelBlurFragment: {
  20779. name: string;
  20780. shader: string;
  20781. };
  20782. }
  20783. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20784. /** @hidden */
  20785. export var kernelBlurFragment2: {
  20786. name: string;
  20787. shader: string;
  20788. };
  20789. }
  20790. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20791. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20792. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20793. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20794. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20795. /** @hidden */
  20796. export var kernelBlurPixelShader: {
  20797. name: string;
  20798. shader: string;
  20799. };
  20800. }
  20801. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20802. /** @hidden */
  20803. export var kernelBlurVertex: {
  20804. name: string;
  20805. shader: string;
  20806. };
  20807. }
  20808. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20809. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20810. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20811. /** @hidden */
  20812. export var kernelBlurVertexShader: {
  20813. name: string;
  20814. shader: string;
  20815. };
  20816. }
  20817. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20818. import { Vector2 } from "babylonjs/Maths/math.vector";
  20819. import { Nullable } from "babylonjs/types";
  20820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20821. import { Camera } from "babylonjs/Cameras/camera";
  20822. import { Effect } from "babylonjs/Materials/effect";
  20823. import { Engine } from "babylonjs/Engines/engine";
  20824. import "babylonjs/Shaders/kernelBlur.fragment";
  20825. import "babylonjs/Shaders/kernelBlur.vertex";
  20826. /**
  20827. * The Blur Post Process which blurs an image based on a kernel and direction.
  20828. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20829. */
  20830. export class BlurPostProcess extends PostProcess {
  20831. /** The direction in which to blur the image. */
  20832. direction: Vector2;
  20833. private blockCompilation;
  20834. protected _kernel: number;
  20835. protected _idealKernel: number;
  20836. protected _packedFloat: boolean;
  20837. private _staticDefines;
  20838. /**
  20839. * Sets the length in pixels of the blur sample region
  20840. */
  20841. set kernel(v: number);
  20842. /**
  20843. * Gets the length in pixels of the blur sample region
  20844. */
  20845. get kernel(): number;
  20846. /**
  20847. * Sets wether or not the blur needs to unpack/repack floats
  20848. */
  20849. set packedFloat(v: boolean);
  20850. /**
  20851. * Gets wether or not the blur is unpacking/repacking floats
  20852. */
  20853. get packedFloat(): boolean;
  20854. /**
  20855. * Creates a new instance BlurPostProcess
  20856. * @param name The name of the effect.
  20857. * @param direction The direction in which to blur the image.
  20858. * @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.
  20859. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20860. * @param camera The camera to apply the render pass to.
  20861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20862. * @param engine The engine which the post process will be applied. (default: current engine)
  20863. * @param reusable If the post process can be reused on the same frame. (default: false)
  20864. * @param textureType Type of textures used when performing the post process. (default: 0)
  20865. * @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)
  20866. */
  20867. constructor(name: string,
  20868. /** The direction in which to blur the image. */
  20869. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20870. /**
  20871. * Updates the effect with the current post process compile time values and recompiles the shader.
  20872. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20873. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20874. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20875. * @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
  20876. * @param onCompiled Called when the shader has been compiled.
  20877. * @param onError Called if there is an error when compiling a shader.
  20878. */
  20879. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20880. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20881. /**
  20882. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20883. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20884. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20885. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20886. * The gaps between physical kernels are compensated for in the weighting of the samples
  20887. * @param idealKernel Ideal blur kernel.
  20888. * @return Nearest best kernel.
  20889. */
  20890. protected _nearestBestKernel(idealKernel: number): number;
  20891. /**
  20892. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20893. * @param x The point on the Gaussian distribution to sample.
  20894. * @return the value of the Gaussian function at x.
  20895. */
  20896. protected _gaussianWeight(x: number): number;
  20897. /**
  20898. * Generates a string that can be used as a floating point number in GLSL.
  20899. * @param x Value to print.
  20900. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20901. * @return GLSL float string.
  20902. */
  20903. protected _glslFloat(x: number, decimalFigures?: number): string;
  20904. }
  20905. }
  20906. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20907. import { Scene } from "babylonjs/scene";
  20908. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20909. import { Plane } from "babylonjs/Maths/math.plane";
  20910. /**
  20911. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20912. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20913. * You can then easily use it as a reflectionTexture on a flat surface.
  20914. * In case the surface is not a plane, please consider relying on reflection probes.
  20915. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20916. */
  20917. export class MirrorTexture extends RenderTargetTexture {
  20918. private scene;
  20919. /**
  20920. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20921. * 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.
  20922. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20923. */
  20924. mirrorPlane: Plane;
  20925. /**
  20926. * Define the blur ratio used to blur the reflection if needed.
  20927. */
  20928. set blurRatio(value: number);
  20929. get blurRatio(): number;
  20930. /**
  20931. * Define the adaptive blur kernel used to blur the reflection if needed.
  20932. * This will autocompute the closest best match for the `blurKernel`
  20933. */
  20934. set adaptiveBlurKernel(value: number);
  20935. /**
  20936. * Define the blur kernel used to blur the reflection if needed.
  20937. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20938. */
  20939. set blurKernel(value: number);
  20940. /**
  20941. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20942. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20943. */
  20944. set blurKernelX(value: number);
  20945. get blurKernelX(): number;
  20946. /**
  20947. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20948. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20949. */
  20950. set blurKernelY(value: number);
  20951. get blurKernelY(): number;
  20952. private _autoComputeBlurKernel;
  20953. protected _onRatioRescale(): void;
  20954. private _updateGammaSpace;
  20955. private _imageProcessingConfigChangeObserver;
  20956. private _transformMatrix;
  20957. private _mirrorMatrix;
  20958. private _savedViewMatrix;
  20959. private _blurX;
  20960. private _blurY;
  20961. private _adaptiveBlurKernel;
  20962. private _blurKernelX;
  20963. private _blurKernelY;
  20964. private _blurRatio;
  20965. /**
  20966. * Instantiates a Mirror Texture.
  20967. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20968. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20969. * You can then easily use it as a reflectionTexture on a flat surface.
  20970. * In case the surface is not a plane, please consider relying on reflection probes.
  20971. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20972. * @param name
  20973. * @param size
  20974. * @param scene
  20975. * @param generateMipMaps
  20976. * @param type
  20977. * @param samplingMode
  20978. * @param generateDepthBuffer
  20979. */
  20980. constructor(name: string, size: number | {
  20981. width: number;
  20982. height: number;
  20983. } | {
  20984. ratio: number;
  20985. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20986. private _preparePostProcesses;
  20987. /**
  20988. * Clone the mirror texture.
  20989. * @returns the cloned texture
  20990. */
  20991. clone(): MirrorTexture;
  20992. /**
  20993. * Serialize the texture to a JSON representation you could use in Parse later on
  20994. * @returns the serialized JSON representation
  20995. */
  20996. serialize(): any;
  20997. /**
  20998. * Dispose the texture and release its associated resources.
  20999. */
  21000. dispose(): void;
  21001. }
  21002. }
  21003. declare module "babylonjs/Materials/Textures/texture" {
  21004. import { Observable } from "babylonjs/Misc/observable";
  21005. import { Nullable } from "babylonjs/types";
  21006. import { Matrix } from "babylonjs/Maths/math.vector";
  21007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21008. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21009. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  21010. import { Scene } from "babylonjs/scene";
  21011. /**
  21012. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21013. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21014. */
  21015. export class Texture extends BaseTexture {
  21016. /**
  21017. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  21018. */
  21019. static SerializeBuffers: boolean;
  21020. /** @hidden */
  21021. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  21022. /** @hidden */
  21023. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  21024. /** @hidden */
  21025. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  21026. /** nearest is mag = nearest and min = nearest and mip = linear */
  21027. static readonly NEAREST_SAMPLINGMODE: number;
  21028. /** nearest is mag = nearest and min = nearest and mip = linear */
  21029. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  21030. /** Bilinear is mag = linear and min = linear and mip = nearest */
  21031. static readonly BILINEAR_SAMPLINGMODE: number;
  21032. /** Bilinear is mag = linear and min = linear and mip = nearest */
  21033. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  21034. /** Trilinear is mag = linear and min = linear and mip = linear */
  21035. static readonly TRILINEAR_SAMPLINGMODE: number;
  21036. /** Trilinear is mag = linear and min = linear and mip = linear */
  21037. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  21038. /** mag = nearest and min = nearest and mip = nearest */
  21039. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  21040. /** mag = nearest and min = linear and mip = nearest */
  21041. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  21042. /** mag = nearest and min = linear and mip = linear */
  21043. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  21044. /** mag = nearest and min = linear and mip = none */
  21045. static readonly NEAREST_LINEAR: number;
  21046. /** mag = nearest and min = nearest and mip = none */
  21047. static readonly NEAREST_NEAREST: number;
  21048. /** mag = linear and min = nearest and mip = nearest */
  21049. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  21050. /** mag = linear and min = nearest and mip = linear */
  21051. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  21052. /** mag = linear and min = linear and mip = none */
  21053. static readonly LINEAR_LINEAR: number;
  21054. /** mag = linear and min = nearest and mip = none */
  21055. static readonly LINEAR_NEAREST: number;
  21056. /** Explicit coordinates mode */
  21057. static readonly EXPLICIT_MODE: number;
  21058. /** Spherical coordinates mode */
  21059. static readonly SPHERICAL_MODE: number;
  21060. /** Planar coordinates mode */
  21061. static readonly PLANAR_MODE: number;
  21062. /** Cubic coordinates mode */
  21063. static readonly CUBIC_MODE: number;
  21064. /** Projection coordinates mode */
  21065. static readonly PROJECTION_MODE: number;
  21066. /** Inverse Cubic coordinates mode */
  21067. static readonly SKYBOX_MODE: number;
  21068. /** Inverse Cubic coordinates mode */
  21069. static readonly INVCUBIC_MODE: number;
  21070. /** Equirectangular coordinates mode */
  21071. static readonly EQUIRECTANGULAR_MODE: number;
  21072. /** Equirectangular Fixed coordinates mode */
  21073. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  21074. /** Equirectangular Fixed Mirrored coordinates mode */
  21075. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  21076. /** Texture is not repeating outside of 0..1 UVs */
  21077. static readonly CLAMP_ADDRESSMODE: number;
  21078. /** Texture is repeating outside of 0..1 UVs */
  21079. static readonly WRAP_ADDRESSMODE: number;
  21080. /** Texture is repeating and mirrored */
  21081. static readonly MIRROR_ADDRESSMODE: number;
  21082. /**
  21083. * 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
  21084. */
  21085. static UseSerializedUrlIfAny: boolean;
  21086. /**
  21087. * Define the url of the texture.
  21088. */
  21089. url: Nullable<string>;
  21090. /**
  21091. * Define an offset on the texture to offset the u coordinates of the UVs
  21092. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21093. */
  21094. uOffset: number;
  21095. /**
  21096. * Define an offset on the texture to offset the v coordinates of the UVs
  21097. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21098. */
  21099. vOffset: number;
  21100. /**
  21101. * Define an offset on the texture to scale the u coordinates of the UVs
  21102. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21103. */
  21104. uScale: number;
  21105. /**
  21106. * Define an offset on the texture to scale the v coordinates of the UVs
  21107. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21108. */
  21109. vScale: number;
  21110. /**
  21111. * Define an offset on the texture to rotate around the u coordinates of the UVs
  21112. * @see http://doc.babylonjs.com/how_to/more_materials
  21113. */
  21114. uAng: number;
  21115. /**
  21116. * Define an offset on the texture to rotate around the v coordinates of the UVs
  21117. * @see http://doc.babylonjs.com/how_to/more_materials
  21118. */
  21119. vAng: number;
  21120. /**
  21121. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  21122. * @see http://doc.babylonjs.com/how_to/more_materials
  21123. */
  21124. wAng: number;
  21125. /**
  21126. * Defines the center of rotation (U)
  21127. */
  21128. uRotationCenter: number;
  21129. /**
  21130. * Defines the center of rotation (V)
  21131. */
  21132. vRotationCenter: number;
  21133. /**
  21134. * Defines the center of rotation (W)
  21135. */
  21136. wRotationCenter: number;
  21137. /**
  21138. * Are mip maps generated for this texture or not.
  21139. */
  21140. get noMipmap(): boolean;
  21141. /**
  21142. * List of inspectable custom properties (used by the Inspector)
  21143. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21144. */
  21145. inspectableCustomProperties: Nullable<IInspectable[]>;
  21146. private _noMipmap;
  21147. /** @hidden */
  21148. _invertY: boolean;
  21149. private _rowGenerationMatrix;
  21150. private _cachedTextureMatrix;
  21151. private _projectionModeMatrix;
  21152. private _t0;
  21153. private _t1;
  21154. private _t2;
  21155. private _cachedUOffset;
  21156. private _cachedVOffset;
  21157. private _cachedUScale;
  21158. private _cachedVScale;
  21159. private _cachedUAng;
  21160. private _cachedVAng;
  21161. private _cachedWAng;
  21162. private _cachedProjectionMatrixId;
  21163. private _cachedCoordinatesMode;
  21164. /** @hidden */
  21165. protected _initialSamplingMode: number;
  21166. /** @hidden */
  21167. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21168. private _deleteBuffer;
  21169. protected _format: Nullable<number>;
  21170. private _delayedOnLoad;
  21171. private _delayedOnError;
  21172. private _mimeType?;
  21173. /**
  21174. * Observable triggered once the texture has been loaded.
  21175. */
  21176. onLoadObservable: Observable<Texture>;
  21177. protected _isBlocking: boolean;
  21178. /**
  21179. * Is the texture preventing material to render while loading.
  21180. * If false, a default texture will be used instead of the loading one during the preparation step.
  21181. */
  21182. set isBlocking(value: boolean);
  21183. get isBlocking(): boolean;
  21184. /**
  21185. * Get the current sampling mode associated with the texture.
  21186. */
  21187. get samplingMode(): number;
  21188. /**
  21189. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21190. */
  21191. get invertY(): boolean;
  21192. /**
  21193. * Instantiates a new texture.
  21194. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21195. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21196. * @param url defines the url of the picture to load as a texture
  21197. * @param sceneOrEngine defines the scene or engine the texture will belong to
  21198. * @param noMipmap defines if the texture will require mip maps or not
  21199. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21200. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21201. * @param onLoad defines a callback triggered when the texture has been loaded
  21202. * @param onError defines a callback triggered when an error occurred during the loading session
  21203. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21204. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21205. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21206. * @param mimeType defines an optional mime type information
  21207. */
  21208. 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);
  21209. /**
  21210. * Update the url (and optional buffer) of this texture if url was null during construction.
  21211. * @param url the url of the texture
  21212. * @param buffer the buffer of the texture (defaults to null)
  21213. * @param onLoad callback called when the texture is loaded (defaults to null)
  21214. */
  21215. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21216. /**
  21217. * Finish the loading sequence of a texture flagged as delayed load.
  21218. * @hidden
  21219. */
  21220. delayLoad(): void;
  21221. private _prepareRowForTextureGeneration;
  21222. /**
  21223. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21224. * @returns the transform matrix of the texture.
  21225. */
  21226. getTextureMatrix(uBase?: number): Matrix;
  21227. /**
  21228. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21229. * @returns The reflection texture transform
  21230. */
  21231. getReflectionTextureMatrix(): Matrix;
  21232. /**
  21233. * Clones the texture.
  21234. * @returns the cloned texture
  21235. */
  21236. clone(): Texture;
  21237. /**
  21238. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21239. * @returns The JSON representation of the texture
  21240. */
  21241. serialize(): any;
  21242. /**
  21243. * Get the current class name of the texture useful for serialization or dynamic coding.
  21244. * @returns "Texture"
  21245. */
  21246. getClassName(): string;
  21247. /**
  21248. * Dispose the texture and release its associated resources.
  21249. */
  21250. dispose(): void;
  21251. /**
  21252. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21253. * @param parsedTexture Define the JSON representation of the texture
  21254. * @param scene Define the scene the parsed texture should be instantiated in
  21255. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21256. * @returns The parsed texture if successful
  21257. */
  21258. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21259. /**
  21260. * Creates a texture from its base 64 representation.
  21261. * @param data Define the base64 payload without the data: prefix
  21262. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21263. * @param scene Define the scene the texture should belong to
  21264. * @param noMipmap Forces the texture to not create mip map information if true
  21265. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21266. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21267. * @param onLoad define a callback triggered when the texture has been loaded
  21268. * @param onError define a callback triggered when an error occurred during the loading session
  21269. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21270. * @returns the created texture
  21271. */
  21272. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21273. /**
  21274. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21275. * @param data Define the base64 payload without the data: prefix
  21276. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21277. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21278. * @param scene Define the scene the texture should belong to
  21279. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21280. * @param noMipmap Forces the texture to not create mip map information if true
  21281. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21282. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21283. * @param onLoad define a callback triggered when the texture has been loaded
  21284. * @param onError define a callback triggered when an error occurred during the loading session
  21285. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21286. * @returns the created texture
  21287. */
  21288. 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;
  21289. }
  21290. }
  21291. declare module "babylonjs/PostProcesses/postProcessManager" {
  21292. import { Nullable } from "babylonjs/types";
  21293. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21294. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21295. import { Scene } from "babylonjs/scene";
  21296. /**
  21297. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21298. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21299. */
  21300. export class PostProcessManager {
  21301. private _scene;
  21302. private _indexBuffer;
  21303. private _vertexBuffers;
  21304. /**
  21305. * Creates a new instance PostProcess
  21306. * @param scene The scene that the post process is associated with.
  21307. */
  21308. constructor(scene: Scene);
  21309. private _prepareBuffers;
  21310. private _buildIndexBuffer;
  21311. /**
  21312. * Rebuilds the vertex buffers of the manager.
  21313. * @hidden
  21314. */
  21315. _rebuild(): void;
  21316. /**
  21317. * Prepares a frame to be run through a post process.
  21318. * @param sourceTexture The input texture to the post procesess. (default: null)
  21319. * @param postProcesses An array of post processes to be run. (default: null)
  21320. * @returns True if the post processes were able to be run.
  21321. * @hidden
  21322. */
  21323. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21324. /**
  21325. * Manually render a set of post processes to a texture.
  21326. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  21327. * @param postProcesses An array of post processes to be run.
  21328. * @param targetTexture The target texture to render to.
  21329. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21330. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21331. * @param lodLevel defines which lod of the texture to render to
  21332. */
  21333. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21334. /**
  21335. * Finalize the result of the output of the postprocesses.
  21336. * @param doNotPresent If true the result will not be displayed to the screen.
  21337. * @param targetTexture The target texture to render to.
  21338. * @param faceIndex The index of the face to bind the target texture to.
  21339. * @param postProcesses The array of post processes to render.
  21340. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21341. * @hidden
  21342. */
  21343. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21344. /**
  21345. * Disposes of the post process manager.
  21346. */
  21347. dispose(): void;
  21348. }
  21349. }
  21350. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21351. import { Observable } from "babylonjs/Misc/observable";
  21352. import { SmartArray } from "babylonjs/Misc/smartArray";
  21353. import { Nullable, Immutable } from "babylonjs/types";
  21354. import { Camera } from "babylonjs/Cameras/camera";
  21355. import { Scene } from "babylonjs/scene";
  21356. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21357. import { Color4 } from "babylonjs/Maths/math.color";
  21358. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21360. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21361. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21362. import { Texture } from "babylonjs/Materials/Textures/texture";
  21363. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21364. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21365. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21366. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21367. import { Engine } from "babylonjs/Engines/engine";
  21368. /**
  21369. * This Helps creating a texture that will be created from a camera in your scene.
  21370. * It is basically a dynamic texture that could be used to create special effects for instance.
  21371. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21372. */
  21373. export class RenderTargetTexture extends Texture {
  21374. isCube: boolean;
  21375. /**
  21376. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21377. */
  21378. static readonly REFRESHRATE_RENDER_ONCE: number;
  21379. /**
  21380. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21381. */
  21382. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21383. /**
  21384. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21385. * the central point of your effect and can save a lot of performances.
  21386. */
  21387. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21388. /**
  21389. * Use this predicate to dynamically define the list of mesh you want to render.
  21390. * If set, the renderList property will be overwritten.
  21391. */
  21392. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21393. private _renderList;
  21394. /**
  21395. * Use this list to define the list of mesh you want to render.
  21396. */
  21397. get renderList(): Nullable<Array<AbstractMesh>>;
  21398. set renderList(value: Nullable<Array<AbstractMesh>>);
  21399. /**
  21400. * Use this function to overload the renderList array at rendering time.
  21401. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21402. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21403. * the cube (if the RTT is a cube, else layerOrFace=0).
  21404. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21405. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21406. * hold dummy elements!
  21407. */
  21408. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21409. private _hookArray;
  21410. /**
  21411. * Define if particles should be rendered in your texture.
  21412. */
  21413. renderParticles: boolean;
  21414. /**
  21415. * Define if sprites should be rendered in your texture.
  21416. */
  21417. renderSprites: boolean;
  21418. /**
  21419. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21420. */
  21421. coordinatesMode: number;
  21422. /**
  21423. * Define the camera used to render the texture.
  21424. */
  21425. activeCamera: Nullable<Camera>;
  21426. /**
  21427. * Override the mesh isReady function with your own one.
  21428. */
  21429. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21430. /**
  21431. * Override the render function of the texture with your own one.
  21432. */
  21433. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21434. /**
  21435. * Define if camera post processes should be use while rendering the texture.
  21436. */
  21437. useCameraPostProcesses: boolean;
  21438. /**
  21439. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21440. */
  21441. ignoreCameraViewport: boolean;
  21442. private _postProcessManager;
  21443. private _postProcesses;
  21444. private _resizeObserver;
  21445. /**
  21446. * An event triggered when the texture is unbind.
  21447. */
  21448. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21449. /**
  21450. * An event triggered when the texture is unbind.
  21451. */
  21452. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21453. private _onAfterUnbindObserver;
  21454. /**
  21455. * Set a after unbind callback in the texture.
  21456. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21457. */
  21458. set onAfterUnbind(callback: () => void);
  21459. /**
  21460. * An event triggered before rendering the texture
  21461. */
  21462. onBeforeRenderObservable: Observable<number>;
  21463. private _onBeforeRenderObserver;
  21464. /**
  21465. * Set a before render callback in the texture.
  21466. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21467. */
  21468. set onBeforeRender(callback: (faceIndex: number) => void);
  21469. /**
  21470. * An event triggered after rendering the texture
  21471. */
  21472. onAfterRenderObservable: Observable<number>;
  21473. private _onAfterRenderObserver;
  21474. /**
  21475. * Set a after render callback in the texture.
  21476. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21477. */
  21478. set onAfterRender(callback: (faceIndex: number) => void);
  21479. /**
  21480. * An event triggered after the texture clear
  21481. */
  21482. onClearObservable: Observable<Engine>;
  21483. private _onClearObserver;
  21484. /**
  21485. * Set a clear callback in the texture.
  21486. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21487. */
  21488. set onClear(callback: (Engine: Engine) => void);
  21489. /**
  21490. * An event triggered when the texture is resized.
  21491. */
  21492. onResizeObservable: Observable<RenderTargetTexture>;
  21493. /**
  21494. * Define the clear color of the Render Target if it should be different from the scene.
  21495. */
  21496. clearColor: Color4;
  21497. protected _size: number | {
  21498. width: number;
  21499. height: number;
  21500. layers?: number;
  21501. };
  21502. protected _initialSizeParameter: number | {
  21503. width: number;
  21504. height: number;
  21505. } | {
  21506. ratio: number;
  21507. };
  21508. protected _sizeRatio: Nullable<number>;
  21509. /** @hidden */
  21510. _generateMipMaps: boolean;
  21511. protected _renderingManager: RenderingManager;
  21512. /** @hidden */
  21513. _waitingRenderList: string[];
  21514. protected _doNotChangeAspectRatio: boolean;
  21515. protected _currentRefreshId: number;
  21516. protected _refreshRate: number;
  21517. protected _textureMatrix: Matrix;
  21518. protected _samples: number;
  21519. protected _renderTargetOptions: RenderTargetCreationOptions;
  21520. /**
  21521. * Gets render target creation options that were used.
  21522. */
  21523. get renderTargetOptions(): RenderTargetCreationOptions;
  21524. protected _onRatioRescale(): void;
  21525. /**
  21526. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21527. * It must define where the camera used to render the texture is set
  21528. */
  21529. boundingBoxPosition: Vector3;
  21530. private _boundingBoxSize;
  21531. /**
  21532. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21533. * When defined, the cubemap will switch to local mode
  21534. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21535. * @example https://www.babylonjs-playground.com/#RNASML
  21536. */
  21537. set boundingBoxSize(value: Vector3);
  21538. get boundingBoxSize(): Vector3;
  21539. /**
  21540. * In case the RTT has been created with a depth texture, get the associated
  21541. * depth texture.
  21542. * Otherwise, return null.
  21543. */
  21544. get depthStencilTexture(): Nullable<InternalTexture>;
  21545. /**
  21546. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21547. * or used a shadow, depth texture...
  21548. * @param name The friendly name of the texture
  21549. * @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)
  21550. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21551. * @param generateMipMaps True if mip maps need to be generated after render.
  21552. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21553. * @param type The type of the buffer in the RTT (int, half float, float...)
  21554. * @param isCube True if a cube texture needs to be created
  21555. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21556. * @param generateDepthBuffer True to generate a depth buffer
  21557. * @param generateStencilBuffer True to generate a stencil buffer
  21558. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21559. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21560. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21561. */
  21562. constructor(name: string, size: number | {
  21563. width: number;
  21564. height: number;
  21565. layers?: number;
  21566. } | {
  21567. ratio: number;
  21568. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21569. /**
  21570. * Creates a depth stencil texture.
  21571. * This is only available in WebGL 2 or with the depth texture extension available.
  21572. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21573. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21574. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21575. */
  21576. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21577. private _processSizeParameter;
  21578. /**
  21579. * Define the number of samples to use in case of MSAA.
  21580. * It defaults to one meaning no MSAA has been enabled.
  21581. */
  21582. get samples(): number;
  21583. set samples(value: number);
  21584. /**
  21585. * Resets the refresh counter of the texture and start bak from scratch.
  21586. * Could be useful to regenerate the texture if it is setup to render only once.
  21587. */
  21588. resetRefreshCounter(): void;
  21589. /**
  21590. * Define the refresh rate of the texture or the rendering frequency.
  21591. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21592. */
  21593. get refreshRate(): number;
  21594. set refreshRate(value: number);
  21595. /**
  21596. * Adds a post process to the render target rendering passes.
  21597. * @param postProcess define the post process to add
  21598. */
  21599. addPostProcess(postProcess: PostProcess): void;
  21600. /**
  21601. * Clear all the post processes attached to the render target
  21602. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21603. */
  21604. clearPostProcesses(dispose?: boolean): void;
  21605. /**
  21606. * Remove one of the post process from the list of attached post processes to the texture
  21607. * @param postProcess define the post process to remove from the list
  21608. */
  21609. removePostProcess(postProcess: PostProcess): void;
  21610. /** @hidden */
  21611. _shouldRender(): boolean;
  21612. /**
  21613. * Gets the actual render size of the texture.
  21614. * @returns the width of the render size
  21615. */
  21616. getRenderSize(): number;
  21617. /**
  21618. * Gets the actual render width of the texture.
  21619. * @returns the width of the render size
  21620. */
  21621. getRenderWidth(): number;
  21622. /**
  21623. * Gets the actual render height of the texture.
  21624. * @returns the height of the render size
  21625. */
  21626. getRenderHeight(): number;
  21627. /**
  21628. * Gets the actual number of layers of the texture.
  21629. * @returns the number of layers
  21630. */
  21631. getRenderLayers(): number;
  21632. /**
  21633. * Get if the texture can be rescaled or not.
  21634. */
  21635. get canRescale(): boolean;
  21636. /**
  21637. * Resize the texture using a ratio.
  21638. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21639. */
  21640. scale(ratio: number): void;
  21641. /**
  21642. * Get the texture reflection matrix used to rotate/transform the reflection.
  21643. * @returns the reflection matrix
  21644. */
  21645. getReflectionTextureMatrix(): Matrix;
  21646. /**
  21647. * Resize the texture to a new desired size.
  21648. * Be carrefull as it will recreate all the data in the new texture.
  21649. * @param size Define the new size. It can be:
  21650. * - a number for squared texture,
  21651. * - an object containing { width: number, height: number }
  21652. * - or an object containing a ratio { ratio: number }
  21653. */
  21654. resize(size: number | {
  21655. width: number;
  21656. height: number;
  21657. } | {
  21658. ratio: number;
  21659. }): void;
  21660. private _defaultRenderListPrepared;
  21661. /**
  21662. * Renders all the objects from the render list into the texture.
  21663. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21664. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21665. */
  21666. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21667. private _bestReflectionRenderTargetDimension;
  21668. private _prepareRenderingManager;
  21669. /**
  21670. * @hidden
  21671. * @param faceIndex face index to bind to if this is a cubetexture
  21672. * @param layer defines the index of the texture to bind in the array
  21673. */
  21674. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21675. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21676. private renderToTarget;
  21677. /**
  21678. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21679. * This allowed control for front to back rendering or reversly depending of the special needs.
  21680. *
  21681. * @param renderingGroupId The rendering group id corresponding to its index
  21682. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21683. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21684. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21685. */
  21686. 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;
  21687. /**
  21688. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21689. *
  21690. * @param renderingGroupId The rendering group id corresponding to its index
  21691. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21692. */
  21693. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21694. /**
  21695. * Clones the texture.
  21696. * @returns the cloned texture
  21697. */
  21698. clone(): RenderTargetTexture;
  21699. /**
  21700. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21701. * @returns The JSON representation of the texture
  21702. */
  21703. serialize(): any;
  21704. /**
  21705. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21706. */
  21707. disposeFramebufferObjects(): void;
  21708. /**
  21709. * Dispose the texture and release its associated resources.
  21710. */
  21711. dispose(): void;
  21712. /** @hidden */
  21713. _rebuild(): void;
  21714. /**
  21715. * Clear the info related to rendering groups preventing retention point in material dispose.
  21716. */
  21717. freeRenderingGroups(): void;
  21718. /**
  21719. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21720. * @returns the view count
  21721. */
  21722. getViewCount(): number;
  21723. }
  21724. }
  21725. declare module "babylonjs/Misc/guid" {
  21726. /**
  21727. * Class used to manipulate GUIDs
  21728. */
  21729. export class GUID {
  21730. /**
  21731. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21732. * Be aware Math.random() could cause collisions, but:
  21733. * "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"
  21734. * @returns a pseudo random id
  21735. */
  21736. static RandomId(): string;
  21737. }
  21738. }
  21739. declare module "babylonjs/Materials/shadowDepthWrapper" {
  21740. import { Nullable } from "babylonjs/types";
  21741. import { Scene } from "babylonjs/scene";
  21742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21743. import { Material } from "babylonjs/Materials/material";
  21744. import { Effect } from "babylonjs/Materials/effect";
  21745. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  21746. /**
  21747. * Options to be used when creating a shadow depth material
  21748. */
  21749. export interface IIOptionShadowDepthMaterial {
  21750. /** Variables in the vertex shader code that need to have their names remapped.
  21751. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21752. * "var_name" should be either: worldPos or vNormalW
  21753. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21754. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21755. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21756. */
  21757. remappedVariables?: string[];
  21758. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21759. standalone?: boolean;
  21760. }
  21761. /**
  21762. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21763. */
  21764. export class ShadowDepthWrapper {
  21765. private _scene;
  21766. private _options?;
  21767. private _baseMaterial;
  21768. private _onEffectCreatedObserver;
  21769. private _subMeshToEffect;
  21770. private _subMeshToDepthEffect;
  21771. private _meshes;
  21772. /** @hidden */
  21773. _matriceNames: any;
  21774. /** Gets the standalone status of the wrapper */
  21775. get standalone(): boolean;
  21776. /** Gets the base material the wrapper is built upon */
  21777. get baseMaterial(): Material;
  21778. /**
  21779. * Instantiate a new shadow depth wrapper.
  21780. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21781. * generate the shadow depth map. For more information, please refer to the documentation:
  21782. * https://doc.babylonjs.com/babylon101/shadows
  21783. * @param baseMaterial Material to wrap
  21784. * @param scene Define the scene the material belongs to
  21785. * @param options Options used to create the wrapper
  21786. */
  21787. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21788. /**
  21789. * Gets the effect to use to generate the depth map
  21790. * @param subMesh subMesh to get the effect for
  21791. * @param shadowGenerator shadow generator to get the effect for
  21792. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21793. */
  21794. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21795. /**
  21796. * Specifies that the submesh is ready to be used for depth rendering
  21797. * @param subMesh submesh to check
  21798. * @param defines the list of defines to take into account when checking the effect
  21799. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21800. * @param useInstances specifies that instances should be used
  21801. * @returns a boolean indicating that the submesh is ready or not
  21802. */
  21803. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21804. /**
  21805. * Disposes the resources
  21806. */
  21807. dispose(): void;
  21808. private _makeEffect;
  21809. }
  21810. }
  21811. declare module "babylonjs/Materials/material" {
  21812. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21813. import { SmartArray } from "babylonjs/Misc/smartArray";
  21814. import { Observable } from "babylonjs/Misc/observable";
  21815. import { Nullable } from "babylonjs/types";
  21816. import { Scene } from "babylonjs/scene";
  21817. import { Matrix } from "babylonjs/Maths/math.vector";
  21818. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21820. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21821. import { Effect } from "babylonjs/Materials/effect";
  21822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21823. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21824. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21825. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21826. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  21827. import { Mesh } from "babylonjs/Meshes/mesh";
  21828. import { Animation } from "babylonjs/Animations/animation";
  21829. /**
  21830. * Options for compiling materials.
  21831. */
  21832. export interface IMaterialCompilationOptions {
  21833. /**
  21834. * Defines whether clip planes are enabled.
  21835. */
  21836. clipPlane: boolean;
  21837. /**
  21838. * Defines whether instances are enabled.
  21839. */
  21840. useInstances: boolean;
  21841. }
  21842. /**
  21843. * Base class for the main features of a material in Babylon.js
  21844. */
  21845. export class Material implements IAnimatable {
  21846. /**
  21847. * Returns the triangle fill mode
  21848. */
  21849. static readonly TriangleFillMode: number;
  21850. /**
  21851. * Returns the wireframe mode
  21852. */
  21853. static readonly WireFrameFillMode: number;
  21854. /**
  21855. * Returns the point fill mode
  21856. */
  21857. static readonly PointFillMode: number;
  21858. /**
  21859. * Returns the point list draw mode
  21860. */
  21861. static readonly PointListDrawMode: number;
  21862. /**
  21863. * Returns the line list draw mode
  21864. */
  21865. static readonly LineListDrawMode: number;
  21866. /**
  21867. * Returns the line loop draw mode
  21868. */
  21869. static readonly LineLoopDrawMode: number;
  21870. /**
  21871. * Returns the line strip draw mode
  21872. */
  21873. static readonly LineStripDrawMode: number;
  21874. /**
  21875. * Returns the triangle strip draw mode
  21876. */
  21877. static readonly TriangleStripDrawMode: number;
  21878. /**
  21879. * Returns the triangle fan draw mode
  21880. */
  21881. static readonly TriangleFanDrawMode: number;
  21882. /**
  21883. * Stores the clock-wise side orientation
  21884. */
  21885. static readonly ClockWiseSideOrientation: number;
  21886. /**
  21887. * Stores the counter clock-wise side orientation
  21888. */
  21889. static readonly CounterClockWiseSideOrientation: number;
  21890. /**
  21891. * The dirty texture flag value
  21892. */
  21893. static readonly TextureDirtyFlag: number;
  21894. /**
  21895. * The dirty light flag value
  21896. */
  21897. static readonly LightDirtyFlag: number;
  21898. /**
  21899. * The dirty fresnel flag value
  21900. */
  21901. static readonly FresnelDirtyFlag: number;
  21902. /**
  21903. * The dirty attribute flag value
  21904. */
  21905. static readonly AttributesDirtyFlag: number;
  21906. /**
  21907. * The dirty misc flag value
  21908. */
  21909. static readonly MiscDirtyFlag: number;
  21910. /**
  21911. * The all dirty flag value
  21912. */
  21913. static readonly AllDirtyFlag: number;
  21914. /**
  21915. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21916. */
  21917. static readonly MATERIAL_OPAQUE: number;
  21918. /**
  21919. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21920. */
  21921. static readonly MATERIAL_ALPHATEST: number;
  21922. /**
  21923. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21924. */
  21925. static readonly MATERIAL_ALPHABLEND: number;
  21926. /**
  21927. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21928. * They are also discarded below the alpha cutoff threshold to improve performances.
  21929. */
  21930. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21931. /**
  21932. * Custom callback helping to override the default shader used in the material.
  21933. */
  21934. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21935. /**
  21936. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21937. */
  21938. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21939. /**
  21940. * The ID of the material
  21941. */
  21942. id: string;
  21943. /**
  21944. * Gets or sets the unique id of the material
  21945. */
  21946. uniqueId: number;
  21947. /**
  21948. * The name of the material
  21949. */
  21950. name: string;
  21951. /**
  21952. * Gets or sets user defined metadata
  21953. */
  21954. metadata: any;
  21955. /**
  21956. * For internal use only. Please do not use.
  21957. */
  21958. reservedDataStore: any;
  21959. /**
  21960. * Specifies if the ready state should be checked on each call
  21961. */
  21962. checkReadyOnEveryCall: boolean;
  21963. /**
  21964. * Specifies if the ready state should be checked once
  21965. */
  21966. checkReadyOnlyOnce: boolean;
  21967. /**
  21968. * The state of the material
  21969. */
  21970. state: string;
  21971. /**
  21972. * The alpha value of the material
  21973. */
  21974. protected _alpha: number;
  21975. /**
  21976. * List of inspectable custom properties (used by the Inspector)
  21977. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21978. */
  21979. inspectableCustomProperties: IInspectable[];
  21980. /**
  21981. * Sets the alpha value of the material
  21982. */
  21983. set alpha(value: number);
  21984. /**
  21985. * Gets the alpha value of the material
  21986. */
  21987. get alpha(): number;
  21988. /**
  21989. * Specifies if back face culling is enabled
  21990. */
  21991. protected _backFaceCulling: boolean;
  21992. /**
  21993. * Sets the back-face culling state
  21994. */
  21995. set backFaceCulling(value: boolean);
  21996. /**
  21997. * Gets the back-face culling state
  21998. */
  21999. get backFaceCulling(): boolean;
  22000. /**
  22001. * Stores the value for side orientation
  22002. */
  22003. sideOrientation: number;
  22004. /**
  22005. * Callback triggered when the material is compiled
  22006. */
  22007. onCompiled: Nullable<(effect: Effect) => void>;
  22008. /**
  22009. * Callback triggered when an error occurs
  22010. */
  22011. onError: Nullable<(effect: Effect, errors: string) => void>;
  22012. /**
  22013. * Callback triggered to get the render target textures
  22014. */
  22015. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22016. /**
  22017. * Gets a boolean indicating that current material needs to register RTT
  22018. */
  22019. get hasRenderTargetTextures(): boolean;
  22020. /**
  22021. * Specifies if the material should be serialized
  22022. */
  22023. doNotSerialize: boolean;
  22024. /**
  22025. * @hidden
  22026. */
  22027. _storeEffectOnSubMeshes: boolean;
  22028. /**
  22029. * Stores the animations for the material
  22030. */
  22031. animations: Nullable<Array<Animation>>;
  22032. /**
  22033. * An event triggered when the material is disposed
  22034. */
  22035. onDisposeObservable: Observable<Material>;
  22036. /**
  22037. * An observer which watches for dispose events
  22038. */
  22039. private _onDisposeObserver;
  22040. private _onUnBindObservable;
  22041. /**
  22042. * Called during a dispose event
  22043. */
  22044. set onDispose(callback: () => void);
  22045. private _onBindObservable;
  22046. /**
  22047. * An event triggered when the material is bound
  22048. */
  22049. get onBindObservable(): Observable<AbstractMesh>;
  22050. /**
  22051. * An observer which watches for bind events
  22052. */
  22053. private _onBindObserver;
  22054. /**
  22055. * Called during a bind event
  22056. */
  22057. set onBind(callback: (Mesh: AbstractMesh) => void);
  22058. /**
  22059. * An event triggered when the material is unbound
  22060. */
  22061. get onUnBindObservable(): Observable<Material>;
  22062. protected _onEffectCreatedObservable: Nullable<Observable<{
  22063. effect: Effect;
  22064. subMesh: Nullable<SubMesh>;
  22065. }>>;
  22066. /**
  22067. * An event triggered when the effect is (re)created
  22068. */
  22069. get onEffectCreatedObservable(): Observable<{
  22070. effect: Effect;
  22071. subMesh: Nullable<SubMesh>;
  22072. }>;
  22073. /**
  22074. * Stores the value of the alpha mode
  22075. */
  22076. private _alphaMode;
  22077. /**
  22078. * Sets the value of the alpha mode.
  22079. *
  22080. * | Value | Type | Description |
  22081. * | --- | --- | --- |
  22082. * | 0 | ALPHA_DISABLE | |
  22083. * | 1 | ALPHA_ADD | |
  22084. * | 2 | ALPHA_COMBINE | |
  22085. * | 3 | ALPHA_SUBTRACT | |
  22086. * | 4 | ALPHA_MULTIPLY | |
  22087. * | 5 | ALPHA_MAXIMIZED | |
  22088. * | 6 | ALPHA_ONEONE | |
  22089. * | 7 | ALPHA_PREMULTIPLIED | |
  22090. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22091. * | 9 | ALPHA_INTERPOLATE | |
  22092. * | 10 | ALPHA_SCREENMODE | |
  22093. *
  22094. */
  22095. set alphaMode(value: number);
  22096. /**
  22097. * Gets the value of the alpha mode
  22098. */
  22099. get alphaMode(): number;
  22100. /**
  22101. * Stores the state of the need depth pre-pass value
  22102. */
  22103. private _needDepthPrePass;
  22104. /**
  22105. * Sets the need depth pre-pass value
  22106. */
  22107. set needDepthPrePass(value: boolean);
  22108. /**
  22109. * Gets the depth pre-pass value
  22110. */
  22111. get needDepthPrePass(): boolean;
  22112. /**
  22113. * Specifies if depth writing should be disabled
  22114. */
  22115. disableDepthWrite: boolean;
  22116. /**
  22117. * Specifies if color writing should be disabled
  22118. */
  22119. disableColorWrite: boolean;
  22120. /**
  22121. * Specifies if depth writing should be forced
  22122. */
  22123. forceDepthWrite: boolean;
  22124. /**
  22125. * Specifies the depth function that should be used. 0 means the default engine function
  22126. */
  22127. depthFunction: number;
  22128. /**
  22129. * Specifies if there should be a separate pass for culling
  22130. */
  22131. separateCullingPass: boolean;
  22132. /**
  22133. * Stores the state specifing if fog should be enabled
  22134. */
  22135. private _fogEnabled;
  22136. /**
  22137. * Sets the state for enabling fog
  22138. */
  22139. set fogEnabled(value: boolean);
  22140. /**
  22141. * Gets the value of the fog enabled state
  22142. */
  22143. get fogEnabled(): boolean;
  22144. /**
  22145. * Stores the size of points
  22146. */
  22147. pointSize: number;
  22148. /**
  22149. * Stores the z offset value
  22150. */
  22151. zOffset: number;
  22152. get wireframe(): boolean;
  22153. /**
  22154. * Sets the state of wireframe mode
  22155. */
  22156. set wireframe(value: boolean);
  22157. /**
  22158. * Gets the value specifying if point clouds are enabled
  22159. */
  22160. get pointsCloud(): boolean;
  22161. /**
  22162. * Sets the state of point cloud mode
  22163. */
  22164. set pointsCloud(value: boolean);
  22165. /**
  22166. * Gets the material fill mode
  22167. */
  22168. get fillMode(): number;
  22169. /**
  22170. * Sets the material fill mode
  22171. */
  22172. set fillMode(value: number);
  22173. /**
  22174. * @hidden
  22175. * Stores the effects for the material
  22176. */
  22177. _effect: Nullable<Effect>;
  22178. /**
  22179. * Specifies if uniform buffers should be used
  22180. */
  22181. private _useUBO;
  22182. /**
  22183. * Stores a reference to the scene
  22184. */
  22185. private _scene;
  22186. /**
  22187. * Stores the fill mode state
  22188. */
  22189. private _fillMode;
  22190. /**
  22191. * Specifies if the depth write state should be cached
  22192. */
  22193. private _cachedDepthWriteState;
  22194. /**
  22195. * Specifies if the color write state should be cached
  22196. */
  22197. private _cachedColorWriteState;
  22198. /**
  22199. * Specifies if the depth function state should be cached
  22200. */
  22201. private _cachedDepthFunctionState;
  22202. /**
  22203. * Stores the uniform buffer
  22204. */
  22205. protected _uniformBuffer: UniformBuffer;
  22206. /** @hidden */
  22207. _indexInSceneMaterialArray: number;
  22208. /** @hidden */
  22209. meshMap: Nullable<{
  22210. [id: string]: AbstractMesh | undefined;
  22211. }>;
  22212. /**
  22213. * Creates a material instance
  22214. * @param name defines the name of the material
  22215. * @param scene defines the scene to reference
  22216. * @param doNotAdd specifies if the material should be added to the scene
  22217. */
  22218. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22219. /**
  22220. * Returns a string representation of the current material
  22221. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22222. * @returns a string with material information
  22223. */
  22224. toString(fullDetails?: boolean): string;
  22225. /**
  22226. * Gets the class name of the material
  22227. * @returns a string with the class name of the material
  22228. */
  22229. getClassName(): string;
  22230. /**
  22231. * Specifies if updates for the material been locked
  22232. */
  22233. get isFrozen(): boolean;
  22234. /**
  22235. * Locks updates for the material
  22236. */
  22237. freeze(): void;
  22238. /**
  22239. * Unlocks updates for the material
  22240. */
  22241. unfreeze(): void;
  22242. /**
  22243. * Specifies if the material is ready to be used
  22244. * @param mesh defines the mesh to check
  22245. * @param useInstances specifies if instances should be used
  22246. * @returns a boolean indicating if the material is ready to be used
  22247. */
  22248. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22249. /**
  22250. * Specifies that the submesh is ready to be used
  22251. * @param mesh defines the mesh to check
  22252. * @param subMesh defines which submesh to check
  22253. * @param useInstances specifies that instances should be used
  22254. * @returns a boolean indicating that the submesh is ready or not
  22255. */
  22256. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22257. /**
  22258. * Returns the material effect
  22259. * @returns the effect associated with the material
  22260. */
  22261. getEffect(): Nullable<Effect>;
  22262. /**
  22263. * Returns the current scene
  22264. * @returns a Scene
  22265. */
  22266. getScene(): Scene;
  22267. /**
  22268. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22269. */
  22270. protected _forceAlphaTest: boolean;
  22271. /**
  22272. * The transparency mode of the material.
  22273. */
  22274. protected _transparencyMode: Nullable<number>;
  22275. /**
  22276. * Gets the current transparency mode.
  22277. */
  22278. get transparencyMode(): Nullable<number>;
  22279. /**
  22280. * Sets the transparency mode of the material.
  22281. *
  22282. * | Value | Type | Description |
  22283. * | ----- | ----------------------------------- | ----------- |
  22284. * | 0 | OPAQUE | |
  22285. * | 1 | ALPHATEST | |
  22286. * | 2 | ALPHABLEND | |
  22287. * | 3 | ALPHATESTANDBLEND | |
  22288. *
  22289. */
  22290. set transparencyMode(value: Nullable<number>);
  22291. /**
  22292. * Returns true if alpha blending should be disabled.
  22293. */
  22294. protected get _disableAlphaBlending(): boolean;
  22295. /**
  22296. * Specifies whether or not this material should be rendered in alpha blend mode.
  22297. * @returns a boolean specifying if alpha blending is needed
  22298. */
  22299. needAlphaBlending(): boolean;
  22300. /**
  22301. * Specifies if the mesh will require alpha blending
  22302. * @param mesh defines the mesh to check
  22303. * @returns a boolean specifying if alpha blending is needed for the mesh
  22304. */
  22305. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22306. /**
  22307. * Specifies whether or not this material should be rendered in alpha test mode.
  22308. * @returns a boolean specifying if an alpha test is needed.
  22309. */
  22310. needAlphaTesting(): boolean;
  22311. /**
  22312. * Specifies if material alpha testing should be turned on for the mesh
  22313. * @param mesh defines the mesh to check
  22314. */
  22315. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22316. /**
  22317. * Gets the texture used for the alpha test
  22318. * @returns the texture to use for alpha testing
  22319. */
  22320. getAlphaTestTexture(): Nullable<BaseTexture>;
  22321. /**
  22322. * Marks the material to indicate that it needs to be re-calculated
  22323. */
  22324. markDirty(): void;
  22325. /** @hidden */
  22326. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22327. /**
  22328. * Binds the material to the mesh
  22329. * @param world defines the world transformation matrix
  22330. * @param mesh defines the mesh to bind the material to
  22331. */
  22332. bind(world: Matrix, mesh?: Mesh): void;
  22333. /**
  22334. * Binds the submesh to the material
  22335. * @param world defines the world transformation matrix
  22336. * @param mesh defines the mesh containing the submesh
  22337. * @param subMesh defines the submesh to bind the material to
  22338. */
  22339. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22340. /**
  22341. * Binds the world matrix to the material
  22342. * @param world defines the world transformation matrix
  22343. */
  22344. bindOnlyWorldMatrix(world: Matrix): void;
  22345. /**
  22346. * Binds the scene's uniform buffer to the effect.
  22347. * @param effect defines the effect to bind to the scene uniform buffer
  22348. * @param sceneUbo defines the uniform buffer storing scene data
  22349. */
  22350. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22351. /**
  22352. * Binds the view matrix to the effect
  22353. * @param effect defines the effect to bind the view matrix to
  22354. */
  22355. bindView(effect: Effect): void;
  22356. /**
  22357. * Binds the view projection matrix to the effect
  22358. * @param effect defines the effect to bind the view projection matrix to
  22359. */
  22360. bindViewProjection(effect: Effect): void;
  22361. /**
  22362. * Processes to execute after binding the material to a mesh
  22363. * @param mesh defines the rendered mesh
  22364. */
  22365. protected _afterBind(mesh?: Mesh): void;
  22366. /**
  22367. * Unbinds the material from the mesh
  22368. */
  22369. unbind(): void;
  22370. /**
  22371. * Gets the active textures from the material
  22372. * @returns an array of textures
  22373. */
  22374. getActiveTextures(): BaseTexture[];
  22375. /**
  22376. * Specifies if the material uses a texture
  22377. * @param texture defines the texture to check against the material
  22378. * @returns a boolean specifying if the material uses the texture
  22379. */
  22380. hasTexture(texture: BaseTexture): boolean;
  22381. /**
  22382. * Makes a duplicate of the material, and gives it a new name
  22383. * @param name defines the new name for the duplicated material
  22384. * @returns the cloned material
  22385. */
  22386. clone(name: string): Nullable<Material>;
  22387. /**
  22388. * Gets the meshes bound to the material
  22389. * @returns an array of meshes bound to the material
  22390. */
  22391. getBindedMeshes(): AbstractMesh[];
  22392. /**
  22393. * Force shader compilation
  22394. * @param mesh defines the mesh associated with this material
  22395. * @param onCompiled defines a function to execute once the material is compiled
  22396. * @param options defines the options to configure the compilation
  22397. * @param onError defines a function to execute if the material fails compiling
  22398. */
  22399. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22400. /**
  22401. * Force shader compilation
  22402. * @param mesh defines the mesh that will use this material
  22403. * @param options defines additional options for compiling the shaders
  22404. * @returns a promise that resolves when the compilation completes
  22405. */
  22406. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22407. private static readonly _AllDirtyCallBack;
  22408. private static readonly _ImageProcessingDirtyCallBack;
  22409. private static readonly _TextureDirtyCallBack;
  22410. private static readonly _FresnelDirtyCallBack;
  22411. private static readonly _MiscDirtyCallBack;
  22412. private static readonly _LightsDirtyCallBack;
  22413. private static readonly _AttributeDirtyCallBack;
  22414. private static _FresnelAndMiscDirtyCallBack;
  22415. private static _TextureAndMiscDirtyCallBack;
  22416. private static readonly _DirtyCallbackArray;
  22417. private static readonly _RunDirtyCallBacks;
  22418. /**
  22419. * Marks a define in the material to indicate that it needs to be re-computed
  22420. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22421. */
  22422. markAsDirty(flag: number): void;
  22423. /**
  22424. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22425. * @param func defines a function which checks material defines against the submeshes
  22426. */
  22427. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22428. /**
  22429. * Indicates that we need to re-calculated for all submeshes
  22430. */
  22431. protected _markAllSubMeshesAsAllDirty(): void;
  22432. /**
  22433. * Indicates that image processing needs to be re-calculated for all submeshes
  22434. */
  22435. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22436. /**
  22437. * Indicates that textures need to be re-calculated for all submeshes
  22438. */
  22439. protected _markAllSubMeshesAsTexturesDirty(): void;
  22440. /**
  22441. * Indicates that fresnel needs to be re-calculated for all submeshes
  22442. */
  22443. protected _markAllSubMeshesAsFresnelDirty(): void;
  22444. /**
  22445. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22446. */
  22447. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22448. /**
  22449. * Indicates that lights need to be re-calculated for all submeshes
  22450. */
  22451. protected _markAllSubMeshesAsLightsDirty(): void;
  22452. /**
  22453. * Indicates that attributes need to be re-calculated for all submeshes
  22454. */
  22455. protected _markAllSubMeshesAsAttributesDirty(): void;
  22456. /**
  22457. * Indicates that misc needs to be re-calculated for all submeshes
  22458. */
  22459. protected _markAllSubMeshesAsMiscDirty(): void;
  22460. /**
  22461. * Indicates that textures and misc need to be re-calculated for all submeshes
  22462. */
  22463. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22464. /**
  22465. * Disposes the material
  22466. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22467. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22468. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22469. */
  22470. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22471. /** @hidden */
  22472. private releaseVertexArrayObject;
  22473. /**
  22474. * Serializes this material
  22475. * @returns the serialized material object
  22476. */
  22477. serialize(): any;
  22478. /**
  22479. * Creates a material from parsed material data
  22480. * @param parsedMaterial defines parsed material data
  22481. * @param scene defines the hosting scene
  22482. * @param rootUrl defines the root URL to use to load textures
  22483. * @returns a new material
  22484. */
  22485. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22486. }
  22487. }
  22488. declare module "babylonjs/Materials/multiMaterial" {
  22489. import { Nullable } from "babylonjs/types";
  22490. import { Scene } from "babylonjs/scene";
  22491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22492. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22493. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22494. import { Material } from "babylonjs/Materials/material";
  22495. /**
  22496. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22497. * separate meshes. This can be use to improve performances.
  22498. * @see http://doc.babylonjs.com/how_to/multi_materials
  22499. */
  22500. export class MultiMaterial extends Material {
  22501. private _subMaterials;
  22502. /**
  22503. * Gets or Sets the list of Materials used within the multi material.
  22504. * They need to be ordered according to the submeshes order in the associated mesh
  22505. */
  22506. get subMaterials(): Nullable<Material>[];
  22507. set subMaterials(value: Nullable<Material>[]);
  22508. /**
  22509. * Function used to align with Node.getChildren()
  22510. * @returns the list of Materials used within the multi material
  22511. */
  22512. getChildren(): Nullable<Material>[];
  22513. /**
  22514. * Instantiates a new Multi Material
  22515. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22516. * separate meshes. This can be use to improve performances.
  22517. * @see http://doc.babylonjs.com/how_to/multi_materials
  22518. * @param name Define the name in the scene
  22519. * @param scene Define the scene the material belongs to
  22520. */
  22521. constructor(name: string, scene: Scene);
  22522. private _hookArray;
  22523. /**
  22524. * Get one of the submaterial by its index in the submaterials array
  22525. * @param index The index to look the sub material at
  22526. * @returns The Material if the index has been defined
  22527. */
  22528. getSubMaterial(index: number): Nullable<Material>;
  22529. /**
  22530. * Get the list of active textures for the whole sub materials list.
  22531. * @returns All the textures that will be used during the rendering
  22532. */
  22533. getActiveTextures(): BaseTexture[];
  22534. /**
  22535. * Gets the current class name of the material e.g. "MultiMaterial"
  22536. * Mainly use in serialization.
  22537. * @returns the class name
  22538. */
  22539. getClassName(): string;
  22540. /**
  22541. * Checks if the material is ready to render the requested sub mesh
  22542. * @param mesh Define the mesh the submesh belongs to
  22543. * @param subMesh Define the sub mesh to look readyness for
  22544. * @param useInstances Define whether or not the material is used with instances
  22545. * @returns true if ready, otherwise false
  22546. */
  22547. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22548. /**
  22549. * Clones the current material and its related sub materials
  22550. * @param name Define the name of the newly cloned material
  22551. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22552. * @returns the cloned material
  22553. */
  22554. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22555. /**
  22556. * Serializes the materials into a JSON representation.
  22557. * @returns the JSON representation
  22558. */
  22559. serialize(): any;
  22560. /**
  22561. * Dispose the material and release its associated resources
  22562. * @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)
  22563. * @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)
  22564. * @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)
  22565. */
  22566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22567. /**
  22568. * Creates a MultiMaterial from parsed MultiMaterial data.
  22569. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22570. * @param scene defines the hosting scene
  22571. * @returns a new MultiMaterial
  22572. */
  22573. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22574. }
  22575. }
  22576. declare module "babylonjs/Meshes/subMesh" {
  22577. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22578. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22579. import { Engine } from "babylonjs/Engines/engine";
  22580. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22581. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22582. import { Effect } from "babylonjs/Materials/effect";
  22583. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22584. import { Plane } from "babylonjs/Maths/math.plane";
  22585. import { Collider } from "babylonjs/Collisions/collider";
  22586. import { Material } from "babylonjs/Materials/material";
  22587. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22589. import { Mesh } from "babylonjs/Meshes/mesh";
  22590. import { Ray } from "babylonjs/Culling/ray";
  22591. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22592. /**
  22593. * Base class for submeshes
  22594. */
  22595. export class BaseSubMesh {
  22596. /** @hidden */
  22597. _materialDefines: Nullable<MaterialDefines>;
  22598. /** @hidden */
  22599. _materialEffect: Nullable<Effect>;
  22600. /** @hidden */
  22601. _effectOverride: Nullable<Effect>;
  22602. /**
  22603. * Gets material defines used by the effect associated to the sub mesh
  22604. */
  22605. get materialDefines(): Nullable<MaterialDefines>;
  22606. /**
  22607. * Sets material defines used by the effect associated to the sub mesh
  22608. */
  22609. set materialDefines(defines: Nullable<MaterialDefines>);
  22610. /**
  22611. * Gets associated effect
  22612. */
  22613. get effect(): Nullable<Effect>;
  22614. /**
  22615. * Sets associated effect (effect used to render this submesh)
  22616. * @param effect defines the effect to associate with
  22617. * @param defines defines the set of defines used to compile this effect
  22618. */
  22619. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22620. }
  22621. /**
  22622. * Defines a subdivision inside a mesh
  22623. */
  22624. export class SubMesh extends BaseSubMesh implements ICullable {
  22625. /** the material index to use */
  22626. materialIndex: number;
  22627. /** vertex index start */
  22628. verticesStart: number;
  22629. /** vertices count */
  22630. verticesCount: number;
  22631. /** index start */
  22632. indexStart: number;
  22633. /** indices count */
  22634. indexCount: number;
  22635. /** @hidden */
  22636. _linesIndexCount: number;
  22637. private _mesh;
  22638. private _renderingMesh;
  22639. private _boundingInfo;
  22640. private _linesIndexBuffer;
  22641. /** @hidden */
  22642. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22643. /** @hidden */
  22644. _trianglePlanes: Plane[];
  22645. /** @hidden */
  22646. _lastColliderTransformMatrix: Nullable<Matrix>;
  22647. /** @hidden */
  22648. _renderId: number;
  22649. /** @hidden */
  22650. _alphaIndex: number;
  22651. /** @hidden */
  22652. _distanceToCamera: number;
  22653. /** @hidden */
  22654. _id: number;
  22655. private _currentMaterial;
  22656. /**
  22657. * Add a new submesh to a mesh
  22658. * @param materialIndex defines the material index to use
  22659. * @param verticesStart defines vertex index start
  22660. * @param verticesCount defines vertices count
  22661. * @param indexStart defines index start
  22662. * @param indexCount defines indices count
  22663. * @param mesh defines the parent mesh
  22664. * @param renderingMesh defines an optional rendering mesh
  22665. * @param createBoundingBox defines if bounding box should be created for this submesh
  22666. * @returns the new submesh
  22667. */
  22668. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22669. /**
  22670. * Creates a new submesh
  22671. * @param materialIndex defines the material index to use
  22672. * @param verticesStart defines vertex index start
  22673. * @param verticesCount defines vertices count
  22674. * @param indexStart defines index start
  22675. * @param indexCount defines indices count
  22676. * @param mesh defines the parent mesh
  22677. * @param renderingMesh defines an optional rendering mesh
  22678. * @param createBoundingBox defines if bounding box should be created for this submesh
  22679. */
  22680. constructor(
  22681. /** the material index to use */
  22682. materialIndex: number,
  22683. /** vertex index start */
  22684. verticesStart: number,
  22685. /** vertices count */
  22686. verticesCount: number,
  22687. /** index start */
  22688. indexStart: number,
  22689. /** indices count */
  22690. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22691. /**
  22692. * Returns true if this submesh covers the entire parent mesh
  22693. * @ignorenaming
  22694. */
  22695. get IsGlobal(): boolean;
  22696. /**
  22697. * Returns the submesh BoudingInfo object
  22698. * @returns current bounding info (or mesh's one if the submesh is global)
  22699. */
  22700. getBoundingInfo(): BoundingInfo;
  22701. /**
  22702. * Sets the submesh BoundingInfo
  22703. * @param boundingInfo defines the new bounding info to use
  22704. * @returns the SubMesh
  22705. */
  22706. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22707. /**
  22708. * Returns the mesh of the current submesh
  22709. * @return the parent mesh
  22710. */
  22711. getMesh(): AbstractMesh;
  22712. /**
  22713. * Returns the rendering mesh of the submesh
  22714. * @returns the rendering mesh (could be different from parent mesh)
  22715. */
  22716. getRenderingMesh(): Mesh;
  22717. /**
  22718. * Returns the submesh material
  22719. * @returns null or the current material
  22720. */
  22721. getMaterial(): Nullable<Material>;
  22722. /**
  22723. * Sets a new updated BoundingInfo object to the submesh
  22724. * @param data defines an optional position array to use to determine the bounding info
  22725. * @returns the SubMesh
  22726. */
  22727. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22728. /** @hidden */
  22729. _checkCollision(collider: Collider): boolean;
  22730. /**
  22731. * Updates the submesh BoundingInfo
  22732. * @param world defines the world matrix to use to update the bounding info
  22733. * @returns the submesh
  22734. */
  22735. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22736. /**
  22737. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22738. * @param frustumPlanes defines the frustum planes
  22739. * @returns true if the submesh is intersecting with the frustum
  22740. */
  22741. isInFrustum(frustumPlanes: Plane[]): boolean;
  22742. /**
  22743. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22744. * @param frustumPlanes defines the frustum planes
  22745. * @returns true if the submesh is inside the frustum
  22746. */
  22747. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22748. /**
  22749. * Renders the submesh
  22750. * @param enableAlphaMode defines if alpha needs to be used
  22751. * @returns the submesh
  22752. */
  22753. render(enableAlphaMode: boolean): SubMesh;
  22754. /**
  22755. * @hidden
  22756. */
  22757. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22758. /**
  22759. * Checks if the submesh intersects with a ray
  22760. * @param ray defines the ray to test
  22761. * @returns true is the passed ray intersects the submesh bounding box
  22762. */
  22763. canIntersects(ray: Ray): boolean;
  22764. /**
  22765. * Intersects current submesh with a ray
  22766. * @param ray defines the ray to test
  22767. * @param positions defines mesh's positions array
  22768. * @param indices defines mesh's indices array
  22769. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22770. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22771. * @returns intersection info or null if no intersection
  22772. */
  22773. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22774. /** @hidden */
  22775. private _intersectLines;
  22776. /** @hidden */
  22777. private _intersectUnIndexedLines;
  22778. /** @hidden */
  22779. private _intersectTriangles;
  22780. /** @hidden */
  22781. private _intersectUnIndexedTriangles;
  22782. /** @hidden */
  22783. _rebuild(): void;
  22784. /**
  22785. * Creates a new submesh from the passed mesh
  22786. * @param newMesh defines the new hosting mesh
  22787. * @param newRenderingMesh defines an optional rendering mesh
  22788. * @returns the new submesh
  22789. */
  22790. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22791. /**
  22792. * Release associated resources
  22793. */
  22794. dispose(): void;
  22795. /**
  22796. * Gets the class name
  22797. * @returns the string "SubMesh".
  22798. */
  22799. getClassName(): string;
  22800. /**
  22801. * Creates a new submesh from indices data
  22802. * @param materialIndex the index of the main mesh material
  22803. * @param startIndex the index where to start the copy in the mesh indices array
  22804. * @param indexCount the number of indices to copy then from the startIndex
  22805. * @param mesh the main mesh to create the submesh from
  22806. * @param renderingMesh the optional rendering mesh
  22807. * @returns a new submesh
  22808. */
  22809. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22810. }
  22811. }
  22812. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22813. /**
  22814. * Class used to represent data loading progression
  22815. */
  22816. export class SceneLoaderFlags {
  22817. private static _ForceFullSceneLoadingForIncremental;
  22818. private static _ShowLoadingScreen;
  22819. private static _CleanBoneMatrixWeights;
  22820. private static _loggingLevel;
  22821. /**
  22822. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22823. */
  22824. static get ForceFullSceneLoadingForIncremental(): boolean;
  22825. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22826. /**
  22827. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22828. */
  22829. static get ShowLoadingScreen(): boolean;
  22830. static set ShowLoadingScreen(value: boolean);
  22831. /**
  22832. * Defines the current logging level (while loading the scene)
  22833. * @ignorenaming
  22834. */
  22835. static get loggingLevel(): number;
  22836. static set loggingLevel(value: number);
  22837. /**
  22838. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22839. */
  22840. static get CleanBoneMatrixWeights(): boolean;
  22841. static set CleanBoneMatrixWeights(value: boolean);
  22842. }
  22843. }
  22844. declare module "babylonjs/Meshes/geometry" {
  22845. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22846. import { Scene } from "babylonjs/scene";
  22847. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22848. import { Engine } from "babylonjs/Engines/engine";
  22849. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22850. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22851. import { Effect } from "babylonjs/Materials/effect";
  22852. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22853. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22854. import { Mesh } from "babylonjs/Meshes/mesh";
  22855. /**
  22856. * Class used to store geometry data (vertex buffers + index buffer)
  22857. */
  22858. export class Geometry implements IGetSetVerticesData {
  22859. /**
  22860. * Gets or sets the ID of the geometry
  22861. */
  22862. id: string;
  22863. /**
  22864. * Gets or sets the unique ID of the geometry
  22865. */
  22866. uniqueId: number;
  22867. /**
  22868. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22869. */
  22870. delayLoadState: number;
  22871. /**
  22872. * Gets the file containing the data to load when running in delay load state
  22873. */
  22874. delayLoadingFile: Nullable<string>;
  22875. /**
  22876. * Callback called when the geometry is updated
  22877. */
  22878. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22879. private _scene;
  22880. private _engine;
  22881. private _meshes;
  22882. private _totalVertices;
  22883. /** @hidden */
  22884. _indices: IndicesArray;
  22885. /** @hidden */
  22886. _vertexBuffers: {
  22887. [key: string]: VertexBuffer;
  22888. };
  22889. private _isDisposed;
  22890. private _extend;
  22891. private _boundingBias;
  22892. /** @hidden */
  22893. _delayInfo: Array<string>;
  22894. private _indexBuffer;
  22895. private _indexBufferIsUpdatable;
  22896. /** @hidden */
  22897. _boundingInfo: Nullable<BoundingInfo>;
  22898. /** @hidden */
  22899. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22900. /** @hidden */
  22901. _softwareSkinningFrameId: number;
  22902. private _vertexArrayObjects;
  22903. private _updatable;
  22904. /** @hidden */
  22905. _positions: Nullable<Vector3[]>;
  22906. /**
  22907. * 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
  22908. */
  22909. get boundingBias(): Vector2;
  22910. /**
  22911. * 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
  22912. */
  22913. set boundingBias(value: Vector2);
  22914. /**
  22915. * Static function used to attach a new empty geometry to a mesh
  22916. * @param mesh defines the mesh to attach the geometry to
  22917. * @returns the new Geometry
  22918. */
  22919. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22920. /** Get the list of meshes using this geometry */
  22921. get meshes(): Mesh[];
  22922. /**
  22923. * Creates a new geometry
  22924. * @param id defines the unique ID
  22925. * @param scene defines the hosting scene
  22926. * @param vertexData defines the VertexData used to get geometry data
  22927. * @param updatable defines if geometry must be updatable (false by default)
  22928. * @param mesh defines the mesh that will be associated with the geometry
  22929. */
  22930. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22931. /**
  22932. * Gets the current extend of the geometry
  22933. */
  22934. get extend(): {
  22935. minimum: Vector3;
  22936. maximum: Vector3;
  22937. };
  22938. /**
  22939. * Gets the hosting scene
  22940. * @returns the hosting Scene
  22941. */
  22942. getScene(): Scene;
  22943. /**
  22944. * Gets the hosting engine
  22945. * @returns the hosting Engine
  22946. */
  22947. getEngine(): Engine;
  22948. /**
  22949. * Defines if the geometry is ready to use
  22950. * @returns true if the geometry is ready to be used
  22951. */
  22952. isReady(): boolean;
  22953. /**
  22954. * Gets a value indicating that the geometry should not be serialized
  22955. */
  22956. get doNotSerialize(): boolean;
  22957. /** @hidden */
  22958. _rebuild(): void;
  22959. /**
  22960. * Affects all geometry data in one call
  22961. * @param vertexData defines the geometry data
  22962. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22963. */
  22964. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22965. /**
  22966. * Set specific vertex data
  22967. * @param kind defines the data kind (Position, normal, etc...)
  22968. * @param data defines the vertex data to use
  22969. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22970. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22971. */
  22972. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22973. /**
  22974. * Removes a specific vertex data
  22975. * @param kind defines the data kind (Position, normal, etc...)
  22976. */
  22977. removeVerticesData(kind: string): void;
  22978. /**
  22979. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22980. * @param buffer defines the vertex buffer to use
  22981. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22982. */
  22983. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22984. /**
  22985. * Update a specific vertex buffer
  22986. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22987. * It will do nothing if the buffer is not updatable
  22988. * @param kind defines the data kind (Position, normal, etc...)
  22989. * @param data defines the data to use
  22990. * @param offset defines the offset in the target buffer where to store the data
  22991. * @param useBytes set to true if the offset is in bytes
  22992. */
  22993. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22994. /**
  22995. * Update a specific vertex buffer
  22996. * This function will create a new buffer if the current one is not updatable
  22997. * @param kind defines the data kind (Position, normal, etc...)
  22998. * @param data defines the data to use
  22999. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23000. */
  23001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23002. private _updateBoundingInfo;
  23003. /** @hidden */
  23004. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23005. /**
  23006. * Gets total number of vertices
  23007. * @returns the total number of vertices
  23008. */
  23009. getTotalVertices(): number;
  23010. /**
  23011. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23012. * @param kind defines the data kind (Position, normal, etc...)
  23013. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23014. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23015. * @returns a float array containing vertex data
  23016. */
  23017. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23018. /**
  23019. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23020. * @param kind defines the data kind (Position, normal, etc...)
  23021. * @returns true if the vertex buffer with the specified kind is updatable
  23022. */
  23023. isVertexBufferUpdatable(kind: string): boolean;
  23024. /**
  23025. * Gets a specific vertex buffer
  23026. * @param kind defines the data kind (Position, normal, etc...)
  23027. * @returns a VertexBuffer
  23028. */
  23029. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23030. /**
  23031. * Returns all vertex buffers
  23032. * @return an object holding all vertex buffers indexed by kind
  23033. */
  23034. getVertexBuffers(): Nullable<{
  23035. [key: string]: VertexBuffer;
  23036. }>;
  23037. /**
  23038. * Gets a boolean indicating if specific vertex buffer is present
  23039. * @param kind defines the data kind (Position, normal, etc...)
  23040. * @returns true if data is present
  23041. */
  23042. isVerticesDataPresent(kind: string): boolean;
  23043. /**
  23044. * Gets a list of all attached data kinds (Position, normal, etc...)
  23045. * @returns a list of string containing all kinds
  23046. */
  23047. getVerticesDataKinds(): string[];
  23048. /**
  23049. * Update index buffer
  23050. * @param indices defines the indices to store in the index buffer
  23051. * @param offset defines the offset in the target buffer where to store the data
  23052. * @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)
  23053. */
  23054. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23055. /**
  23056. * Creates a new index buffer
  23057. * @param indices defines the indices to store in the index buffer
  23058. * @param totalVertices defines the total number of vertices (could be null)
  23059. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23060. */
  23061. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23062. /**
  23063. * Return the total number of indices
  23064. * @returns the total number of indices
  23065. */
  23066. getTotalIndices(): number;
  23067. /**
  23068. * Gets the index buffer array
  23069. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23070. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23071. * @returns the index buffer array
  23072. */
  23073. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23074. /**
  23075. * Gets the index buffer
  23076. * @return the index buffer
  23077. */
  23078. getIndexBuffer(): Nullable<DataBuffer>;
  23079. /** @hidden */
  23080. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23081. /**
  23082. * Release the associated resources for a specific mesh
  23083. * @param mesh defines the source mesh
  23084. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23085. */
  23086. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23087. /**
  23088. * Apply current geometry to a given mesh
  23089. * @param mesh defines the mesh to apply geometry to
  23090. */
  23091. applyToMesh(mesh: Mesh): void;
  23092. private _updateExtend;
  23093. private _applyToMesh;
  23094. private notifyUpdate;
  23095. /**
  23096. * Load the geometry if it was flagged as delay loaded
  23097. * @param scene defines the hosting scene
  23098. * @param onLoaded defines a callback called when the geometry is loaded
  23099. */
  23100. load(scene: Scene, onLoaded?: () => void): void;
  23101. private _queueLoad;
  23102. /**
  23103. * Invert the geometry to move from a right handed system to a left handed one.
  23104. */
  23105. toLeftHanded(): void;
  23106. /** @hidden */
  23107. _resetPointsArrayCache(): void;
  23108. /** @hidden */
  23109. _generatePointsArray(): boolean;
  23110. /**
  23111. * Gets a value indicating if the geometry is disposed
  23112. * @returns true if the geometry was disposed
  23113. */
  23114. isDisposed(): boolean;
  23115. private _disposeVertexArrayObjects;
  23116. /**
  23117. * Free all associated resources
  23118. */
  23119. dispose(): void;
  23120. /**
  23121. * Clone the current geometry into a new geometry
  23122. * @param id defines the unique ID of the new geometry
  23123. * @returns a new geometry object
  23124. */
  23125. copy(id: string): Geometry;
  23126. /**
  23127. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23128. * @return a JSON representation of the current geometry data (without the vertices data)
  23129. */
  23130. serialize(): any;
  23131. private toNumberArray;
  23132. /**
  23133. * Serialize all vertices data into a JSON oject
  23134. * @returns a JSON representation of the current geometry data
  23135. */
  23136. serializeVerticeData(): any;
  23137. /**
  23138. * Extracts a clone of a mesh geometry
  23139. * @param mesh defines the source mesh
  23140. * @param id defines the unique ID of the new geometry object
  23141. * @returns the new geometry object
  23142. */
  23143. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23144. /**
  23145. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23146. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23147. * Be aware Math.random() could cause collisions, but:
  23148. * "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"
  23149. * @returns a string containing a new GUID
  23150. */
  23151. static RandomId(): string;
  23152. /** @hidden */
  23153. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23154. private static _CleanMatricesWeights;
  23155. /**
  23156. * Create a new geometry from persisted data (Using .babylon file format)
  23157. * @param parsedVertexData defines the persisted data
  23158. * @param scene defines the hosting scene
  23159. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23160. * @returns the new geometry object
  23161. */
  23162. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23163. }
  23164. }
  23165. declare module "babylonjs/Meshes/mesh.vertexData" {
  23166. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23167. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23168. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  23169. import { Geometry } from "babylonjs/Meshes/geometry";
  23170. import { Mesh } from "babylonjs/Meshes/mesh";
  23171. /**
  23172. * Define an interface for all classes that will get and set the data on vertices
  23173. */
  23174. export interface IGetSetVerticesData {
  23175. /**
  23176. * Gets a boolean indicating if specific vertex data is present
  23177. * @param kind defines the vertex data kind to use
  23178. * @returns true is data kind is present
  23179. */
  23180. isVerticesDataPresent(kind: string): boolean;
  23181. /**
  23182. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23183. * @param kind defines the data kind (Position, normal, etc...)
  23184. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23185. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23186. * @returns a float array containing vertex data
  23187. */
  23188. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23189. /**
  23190. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23191. * @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.
  23192. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23193. * @returns the indices array or an empty array if the mesh has no geometry
  23194. */
  23195. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23196. /**
  23197. * Set specific vertex data
  23198. * @param kind defines the data kind (Position, normal, etc...)
  23199. * @param data defines the vertex data to use
  23200. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23201. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23202. */
  23203. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23204. /**
  23205. * Update a specific associated vertex buffer
  23206. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23207. * - VertexBuffer.PositionKind
  23208. * - VertexBuffer.UVKind
  23209. * - VertexBuffer.UV2Kind
  23210. * - VertexBuffer.UV3Kind
  23211. * - VertexBuffer.UV4Kind
  23212. * - VertexBuffer.UV5Kind
  23213. * - VertexBuffer.UV6Kind
  23214. * - VertexBuffer.ColorKind
  23215. * - VertexBuffer.MatricesIndicesKind
  23216. * - VertexBuffer.MatricesIndicesExtraKind
  23217. * - VertexBuffer.MatricesWeightsKind
  23218. * - VertexBuffer.MatricesWeightsExtraKind
  23219. * @param data defines the data source
  23220. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23221. * @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)
  23222. */
  23223. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23224. /**
  23225. * Creates a new index buffer
  23226. * @param indices defines the indices to store in the index buffer
  23227. * @param totalVertices defines the total number of vertices (could be null)
  23228. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23229. */
  23230. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23231. }
  23232. /**
  23233. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23234. */
  23235. export class VertexData {
  23236. /**
  23237. * Mesh side orientation : usually the external or front surface
  23238. */
  23239. static readonly FRONTSIDE: number;
  23240. /**
  23241. * Mesh side orientation : usually the internal or back surface
  23242. */
  23243. static readonly BACKSIDE: number;
  23244. /**
  23245. * Mesh side orientation : both internal and external or front and back surfaces
  23246. */
  23247. static readonly DOUBLESIDE: number;
  23248. /**
  23249. * Mesh side orientation : by default, `FRONTSIDE`
  23250. */
  23251. static readonly DEFAULTSIDE: number;
  23252. /**
  23253. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23254. */
  23255. positions: Nullable<FloatArray>;
  23256. /**
  23257. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23258. */
  23259. normals: Nullable<FloatArray>;
  23260. /**
  23261. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23262. */
  23263. tangents: Nullable<FloatArray>;
  23264. /**
  23265. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23266. */
  23267. uvs: Nullable<FloatArray>;
  23268. /**
  23269. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23270. */
  23271. uvs2: Nullable<FloatArray>;
  23272. /**
  23273. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23274. */
  23275. uvs3: Nullable<FloatArray>;
  23276. /**
  23277. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23278. */
  23279. uvs4: Nullable<FloatArray>;
  23280. /**
  23281. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23282. */
  23283. uvs5: Nullable<FloatArray>;
  23284. /**
  23285. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23286. */
  23287. uvs6: Nullable<FloatArray>;
  23288. /**
  23289. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23290. */
  23291. colors: Nullable<FloatArray>;
  23292. /**
  23293. * 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).
  23294. */
  23295. matricesIndices: Nullable<FloatArray>;
  23296. /**
  23297. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23298. */
  23299. matricesWeights: Nullable<FloatArray>;
  23300. /**
  23301. * An array extending the number of possible indices
  23302. */
  23303. matricesIndicesExtra: Nullable<FloatArray>;
  23304. /**
  23305. * An array extending the number of possible weights when the number of indices is extended
  23306. */
  23307. matricesWeightsExtra: Nullable<FloatArray>;
  23308. /**
  23309. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23310. */
  23311. indices: Nullable<IndicesArray>;
  23312. /**
  23313. * Uses the passed data array to set the set the values for the specified kind of data
  23314. * @param data a linear array of floating numbers
  23315. * @param kind the type of data that is being set, eg positions, colors etc
  23316. */
  23317. set(data: FloatArray, kind: string): void;
  23318. /**
  23319. * Associates the vertexData to the passed Mesh.
  23320. * Sets it as updatable or not (default `false`)
  23321. * @param mesh the mesh the vertexData is applied to
  23322. * @param updatable when used and having the value true allows new data to update the vertexData
  23323. * @returns the VertexData
  23324. */
  23325. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23326. /**
  23327. * Associates the vertexData to the passed Geometry.
  23328. * Sets it as updatable or not (default `false`)
  23329. * @param geometry the geometry the vertexData is applied to
  23330. * @param updatable when used and having the value true allows new data to update the vertexData
  23331. * @returns VertexData
  23332. */
  23333. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23334. /**
  23335. * Updates the associated mesh
  23336. * @param mesh the mesh to be updated
  23337. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23338. * @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
  23339. * @returns VertexData
  23340. */
  23341. updateMesh(mesh: Mesh): VertexData;
  23342. /**
  23343. * Updates the associated geometry
  23344. * @param geometry the geometry to be updated
  23345. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23346. * @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
  23347. * @returns VertexData.
  23348. */
  23349. updateGeometry(geometry: Geometry): VertexData;
  23350. private _applyTo;
  23351. private _update;
  23352. /**
  23353. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23354. * @param matrix the transforming matrix
  23355. * @returns the VertexData
  23356. */
  23357. transform(matrix: Matrix): VertexData;
  23358. /**
  23359. * Merges the passed VertexData into the current one
  23360. * @param other the VertexData to be merged into the current one
  23361. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23362. * @returns the modified VertexData
  23363. */
  23364. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23365. private _mergeElement;
  23366. private _validate;
  23367. /**
  23368. * Serializes the VertexData
  23369. * @returns a serialized object
  23370. */
  23371. serialize(): any;
  23372. /**
  23373. * Extracts the vertexData from a mesh
  23374. * @param mesh the mesh from which to extract the VertexData
  23375. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23376. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23377. * @returns the object VertexData associated to the passed mesh
  23378. */
  23379. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23380. /**
  23381. * Extracts the vertexData from the geometry
  23382. * @param geometry the geometry from which to extract the VertexData
  23383. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23384. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23385. * @returns the object VertexData associated to the passed mesh
  23386. */
  23387. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23388. private static _ExtractFrom;
  23389. /**
  23390. * Creates the VertexData for a Ribbon
  23391. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23392. * * pathArray array of paths, each of which an array of successive Vector3
  23393. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23394. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23395. * * 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
  23396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23397. * * 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)
  23398. * * 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)
  23399. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23400. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23401. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23402. * @returns the VertexData of the ribbon
  23403. */
  23404. static CreateRibbon(options: {
  23405. pathArray: Vector3[][];
  23406. closeArray?: boolean;
  23407. closePath?: boolean;
  23408. offset?: number;
  23409. sideOrientation?: number;
  23410. frontUVs?: Vector4;
  23411. backUVs?: Vector4;
  23412. invertUV?: boolean;
  23413. uvs?: Vector2[];
  23414. colors?: Color4[];
  23415. }): VertexData;
  23416. /**
  23417. * Creates the VertexData for a box
  23418. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23419. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23420. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23421. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23422. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23423. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23424. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23425. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23426. * * 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)
  23427. * * 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)
  23428. * @returns the VertexData of the box
  23429. */
  23430. static CreateBox(options: {
  23431. size?: number;
  23432. width?: number;
  23433. height?: number;
  23434. depth?: number;
  23435. faceUV?: Vector4[];
  23436. faceColors?: Color4[];
  23437. sideOrientation?: number;
  23438. frontUVs?: Vector4;
  23439. backUVs?: Vector4;
  23440. }): VertexData;
  23441. /**
  23442. * Creates the VertexData for a tiled box
  23443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23444. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23445. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23446. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23447. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23448. * @returns the VertexData of the box
  23449. */
  23450. static CreateTiledBox(options: {
  23451. pattern?: number;
  23452. width?: number;
  23453. height?: number;
  23454. depth?: number;
  23455. tileSize?: number;
  23456. tileWidth?: number;
  23457. tileHeight?: number;
  23458. alignHorizontal?: number;
  23459. alignVertical?: number;
  23460. faceUV?: Vector4[];
  23461. faceColors?: Color4[];
  23462. sideOrientation?: number;
  23463. }): VertexData;
  23464. /**
  23465. * Creates the VertexData for a tiled plane
  23466. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23467. * * pattern a limited pattern arrangement depending on the number
  23468. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23469. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23470. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23472. * * 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)
  23473. * * 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)
  23474. * @returns the VertexData of the tiled plane
  23475. */
  23476. static CreateTiledPlane(options: {
  23477. pattern?: number;
  23478. tileSize?: number;
  23479. tileWidth?: number;
  23480. tileHeight?: number;
  23481. size?: number;
  23482. width?: number;
  23483. height?: number;
  23484. alignHorizontal?: number;
  23485. alignVertical?: number;
  23486. sideOrientation?: number;
  23487. frontUVs?: Vector4;
  23488. backUVs?: Vector4;
  23489. }): VertexData;
  23490. /**
  23491. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23492. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23493. * * segments sets the number of horizontal strips optional, default 32
  23494. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23495. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23496. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23497. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23498. * * 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
  23499. * * 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
  23500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23501. * * 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)
  23502. * * 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)
  23503. * @returns the VertexData of the ellipsoid
  23504. */
  23505. static CreateSphere(options: {
  23506. segments?: number;
  23507. diameter?: number;
  23508. diameterX?: number;
  23509. diameterY?: number;
  23510. diameterZ?: number;
  23511. arc?: number;
  23512. slice?: number;
  23513. sideOrientation?: number;
  23514. frontUVs?: Vector4;
  23515. backUVs?: Vector4;
  23516. }): VertexData;
  23517. /**
  23518. * Creates the VertexData for a cylinder, cone or prism
  23519. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23520. * * height sets the height (y direction) of the cylinder, optional, default 2
  23521. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23522. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23523. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23524. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23525. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23526. * * 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
  23527. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23528. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23529. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23530. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23531. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23532. * * 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)
  23533. * * 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)
  23534. * @returns the VertexData of the cylinder, cone or prism
  23535. */
  23536. static CreateCylinder(options: {
  23537. height?: number;
  23538. diameterTop?: number;
  23539. diameterBottom?: number;
  23540. diameter?: number;
  23541. tessellation?: number;
  23542. subdivisions?: number;
  23543. arc?: number;
  23544. faceColors?: Color4[];
  23545. faceUV?: Vector4[];
  23546. hasRings?: boolean;
  23547. enclose?: boolean;
  23548. sideOrientation?: number;
  23549. frontUVs?: Vector4;
  23550. backUVs?: Vector4;
  23551. }): VertexData;
  23552. /**
  23553. * Creates the VertexData for a torus
  23554. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23555. * * diameter the diameter of the torus, optional default 1
  23556. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23557. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23559. * * 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)
  23560. * * 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)
  23561. * @returns the VertexData of the torus
  23562. */
  23563. static CreateTorus(options: {
  23564. diameter?: number;
  23565. thickness?: number;
  23566. tessellation?: number;
  23567. sideOrientation?: number;
  23568. frontUVs?: Vector4;
  23569. backUVs?: Vector4;
  23570. }): VertexData;
  23571. /**
  23572. * Creates the VertexData of the LineSystem
  23573. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23574. * - lines an array of lines, each line being an array of successive Vector3
  23575. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23576. * @returns the VertexData of the LineSystem
  23577. */
  23578. static CreateLineSystem(options: {
  23579. lines: Vector3[][];
  23580. colors?: Nullable<Color4[][]>;
  23581. }): VertexData;
  23582. /**
  23583. * Create the VertexData for a DashedLines
  23584. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23585. * - points an array successive Vector3
  23586. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23587. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23588. * - dashNb the intended total number of dashes, optional, default 200
  23589. * @returns the VertexData for the DashedLines
  23590. */
  23591. static CreateDashedLines(options: {
  23592. points: Vector3[];
  23593. dashSize?: number;
  23594. gapSize?: number;
  23595. dashNb?: number;
  23596. }): VertexData;
  23597. /**
  23598. * Creates the VertexData for a Ground
  23599. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23600. * - width the width (x direction) of the ground, optional, default 1
  23601. * - height the height (z direction) of the ground, optional, default 1
  23602. * - subdivisions the number of subdivisions per side, optional, default 1
  23603. * @returns the VertexData of the Ground
  23604. */
  23605. static CreateGround(options: {
  23606. width?: number;
  23607. height?: number;
  23608. subdivisions?: number;
  23609. subdivisionsX?: number;
  23610. subdivisionsY?: number;
  23611. }): VertexData;
  23612. /**
  23613. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23614. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23615. * * xmin the ground minimum X coordinate, optional, default -1
  23616. * * zmin the ground minimum Z coordinate, optional, default -1
  23617. * * xmax the ground maximum X coordinate, optional, default 1
  23618. * * zmax the ground maximum Z coordinate, optional, default 1
  23619. * * 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}
  23620. * * 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}
  23621. * @returns the VertexData of the TiledGround
  23622. */
  23623. static CreateTiledGround(options: {
  23624. xmin: number;
  23625. zmin: number;
  23626. xmax: number;
  23627. zmax: number;
  23628. subdivisions?: {
  23629. w: number;
  23630. h: number;
  23631. };
  23632. precision?: {
  23633. w: number;
  23634. h: number;
  23635. };
  23636. }): VertexData;
  23637. /**
  23638. * Creates the VertexData of the Ground designed from a heightmap
  23639. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23640. * * width the width (x direction) of the ground
  23641. * * height the height (z direction) of the ground
  23642. * * subdivisions the number of subdivisions per side
  23643. * * minHeight the minimum altitude on the ground, optional, default 0
  23644. * * maxHeight the maximum altitude on the ground, optional default 1
  23645. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23646. * * buffer the array holding the image color data
  23647. * * bufferWidth the width of image
  23648. * * bufferHeight the height of image
  23649. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23650. * @returns the VertexData of the Ground designed from a heightmap
  23651. */
  23652. static CreateGroundFromHeightMap(options: {
  23653. width: number;
  23654. height: number;
  23655. subdivisions: number;
  23656. minHeight: number;
  23657. maxHeight: number;
  23658. colorFilter: Color3;
  23659. buffer: Uint8Array;
  23660. bufferWidth: number;
  23661. bufferHeight: number;
  23662. alphaFilter: number;
  23663. }): VertexData;
  23664. /**
  23665. * Creates the VertexData for a Plane
  23666. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23667. * * size sets the width and height of the plane to the value of size, optional default 1
  23668. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23669. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23670. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23671. * * 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)
  23672. * * 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)
  23673. * @returns the VertexData of the box
  23674. */
  23675. static CreatePlane(options: {
  23676. size?: number;
  23677. width?: number;
  23678. height?: number;
  23679. sideOrientation?: number;
  23680. frontUVs?: Vector4;
  23681. backUVs?: Vector4;
  23682. }): VertexData;
  23683. /**
  23684. * Creates the VertexData of the Disc or regular Polygon
  23685. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23686. * * radius the radius of the disc, optional default 0.5
  23687. * * tessellation the number of polygon sides, optional, default 64
  23688. * * 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
  23689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23690. * * 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)
  23691. * * 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)
  23692. * @returns the VertexData of the box
  23693. */
  23694. static CreateDisc(options: {
  23695. radius?: number;
  23696. tessellation?: number;
  23697. arc?: number;
  23698. sideOrientation?: number;
  23699. frontUVs?: Vector4;
  23700. backUVs?: Vector4;
  23701. }): VertexData;
  23702. /**
  23703. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23704. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23705. * @param polygon a mesh built from polygonTriangulation.build()
  23706. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23707. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23708. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23709. * @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)
  23710. * @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)
  23711. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  23712. * @returns the VertexData of the Polygon
  23713. */
  23714. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  23715. /**
  23716. * Creates the VertexData of the IcoSphere
  23717. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23718. * * radius the radius of the IcoSphere, optional default 1
  23719. * * radiusX allows stretching in the x direction, optional, default radius
  23720. * * radiusY allows stretching in the y direction, optional, default radius
  23721. * * radiusZ allows stretching in the z direction, optional, default radius
  23722. * * flat when true creates a flat shaded mesh, optional, default true
  23723. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 IcoSphere
  23728. */
  23729. static CreateIcoSphere(options: {
  23730. radius?: number;
  23731. radiusX?: number;
  23732. radiusY?: number;
  23733. radiusZ?: number;
  23734. flat?: boolean;
  23735. subdivisions?: number;
  23736. sideOrientation?: number;
  23737. frontUVs?: Vector4;
  23738. backUVs?: Vector4;
  23739. }): VertexData;
  23740. /**
  23741. * Creates the VertexData for a Polyhedron
  23742. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23743. * * type provided types are:
  23744. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23745. * * 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)
  23746. * * size the size of the IcoSphere, optional default 1
  23747. * * sizeX allows stretching in the x direction, optional, default size
  23748. * * sizeY allows stretching in the y direction, optional, default size
  23749. * * sizeZ allows stretching in the z direction, optional, default size
  23750. * * 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
  23751. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23752. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23753. * * flat when true creates a flat shaded mesh, optional, default true
  23754. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23755. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23756. * * 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)
  23757. * * 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)
  23758. * @returns the VertexData of the Polyhedron
  23759. */
  23760. static CreatePolyhedron(options: {
  23761. type?: number;
  23762. size?: number;
  23763. sizeX?: number;
  23764. sizeY?: number;
  23765. sizeZ?: number;
  23766. custom?: any;
  23767. faceUV?: Vector4[];
  23768. faceColors?: Color4[];
  23769. flat?: boolean;
  23770. sideOrientation?: number;
  23771. frontUVs?: Vector4;
  23772. backUVs?: Vector4;
  23773. }): VertexData;
  23774. /**
  23775. * Creates the VertexData for a TorusKnot
  23776. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23777. * * radius the radius of the torus knot, optional, default 2
  23778. * * tube the thickness of the tube, optional, default 0.5
  23779. * * radialSegments the number of sides on each tube segments, optional, default 32
  23780. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23781. * * p the number of windings around the z axis, optional, default 2
  23782. * * q the number of windings around the x axis, optional, default 3
  23783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23784. * * 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)
  23785. * * 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)
  23786. * @returns the VertexData of the Torus Knot
  23787. */
  23788. static CreateTorusKnot(options: {
  23789. radius?: number;
  23790. tube?: number;
  23791. radialSegments?: number;
  23792. tubularSegments?: number;
  23793. p?: number;
  23794. q?: number;
  23795. sideOrientation?: number;
  23796. frontUVs?: Vector4;
  23797. backUVs?: Vector4;
  23798. }): VertexData;
  23799. /**
  23800. * Compute normals for given positions and indices
  23801. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23802. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23803. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23804. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23805. * * facetNormals : optional array of facet normals (vector3)
  23806. * * facetPositions : optional array of facet positions (vector3)
  23807. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23808. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23809. * * bInfo : optional bounding info, required for facetPartitioning computation
  23810. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23811. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23812. * * useRightHandedSystem: optional boolean to for right handed system computation
  23813. * * depthSort : optional boolean to enable the facet depth sort computation
  23814. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23815. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23816. */
  23817. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23818. facetNormals?: any;
  23819. facetPositions?: any;
  23820. facetPartitioning?: any;
  23821. ratio?: number;
  23822. bInfo?: any;
  23823. bbSize?: Vector3;
  23824. subDiv?: any;
  23825. useRightHandedSystem?: boolean;
  23826. depthSort?: boolean;
  23827. distanceTo?: Vector3;
  23828. depthSortedFacets?: any;
  23829. }): void;
  23830. /** @hidden */
  23831. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23832. /**
  23833. * Applies VertexData created from the imported parameters to the geometry
  23834. * @param parsedVertexData the parsed data from an imported file
  23835. * @param geometry the geometry to apply the VertexData to
  23836. */
  23837. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23838. }
  23839. }
  23840. declare module "babylonjs/Morph/morphTarget" {
  23841. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23842. import { Observable } from "babylonjs/Misc/observable";
  23843. import { Nullable, FloatArray } from "babylonjs/types";
  23844. import { Scene } from "babylonjs/scene";
  23845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23846. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23847. /**
  23848. * Defines a target to use with MorphTargetManager
  23849. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23850. */
  23851. export class MorphTarget implements IAnimatable {
  23852. /** defines the name of the target */
  23853. name: string;
  23854. /**
  23855. * Gets or sets the list of animations
  23856. */
  23857. animations: import("babylonjs/Animations/animation").Animation[];
  23858. private _scene;
  23859. private _positions;
  23860. private _normals;
  23861. private _tangents;
  23862. private _uvs;
  23863. private _influence;
  23864. private _uniqueId;
  23865. /**
  23866. * Observable raised when the influence changes
  23867. */
  23868. onInfluenceChanged: Observable<boolean>;
  23869. /** @hidden */
  23870. _onDataLayoutChanged: Observable<void>;
  23871. /**
  23872. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23873. */
  23874. get influence(): number;
  23875. set influence(influence: number);
  23876. /**
  23877. * Gets or sets the id of the morph Target
  23878. */
  23879. id: string;
  23880. private _animationPropertiesOverride;
  23881. /**
  23882. * Gets or sets the animation properties override
  23883. */
  23884. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23885. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23886. /**
  23887. * Creates a new MorphTarget
  23888. * @param name defines the name of the target
  23889. * @param influence defines the influence to use
  23890. * @param scene defines the scene the morphtarget belongs to
  23891. */
  23892. constructor(
  23893. /** defines the name of the target */
  23894. name: string, influence?: number, scene?: Nullable<Scene>);
  23895. /**
  23896. * Gets the unique ID of this manager
  23897. */
  23898. get uniqueId(): number;
  23899. /**
  23900. * Gets a boolean defining if the target contains position data
  23901. */
  23902. get hasPositions(): boolean;
  23903. /**
  23904. * Gets a boolean defining if the target contains normal data
  23905. */
  23906. get hasNormals(): boolean;
  23907. /**
  23908. * Gets a boolean defining if the target contains tangent data
  23909. */
  23910. get hasTangents(): boolean;
  23911. /**
  23912. * Gets a boolean defining if the target contains texture coordinates data
  23913. */
  23914. get hasUVs(): boolean;
  23915. /**
  23916. * Affects position data to this target
  23917. * @param data defines the position data to use
  23918. */
  23919. setPositions(data: Nullable<FloatArray>): void;
  23920. /**
  23921. * Gets the position data stored in this target
  23922. * @returns a FloatArray containing the position data (or null if not present)
  23923. */
  23924. getPositions(): Nullable<FloatArray>;
  23925. /**
  23926. * Affects normal data to this target
  23927. * @param data defines the normal data to use
  23928. */
  23929. setNormals(data: Nullable<FloatArray>): void;
  23930. /**
  23931. * Gets the normal data stored in this target
  23932. * @returns a FloatArray containing the normal data (or null if not present)
  23933. */
  23934. getNormals(): Nullable<FloatArray>;
  23935. /**
  23936. * Affects tangent data to this target
  23937. * @param data defines the tangent data to use
  23938. */
  23939. setTangents(data: Nullable<FloatArray>): void;
  23940. /**
  23941. * Gets the tangent data stored in this target
  23942. * @returns a FloatArray containing the tangent data (or null if not present)
  23943. */
  23944. getTangents(): Nullable<FloatArray>;
  23945. /**
  23946. * Affects texture coordinates data to this target
  23947. * @param data defines the texture coordinates data to use
  23948. */
  23949. setUVs(data: Nullable<FloatArray>): void;
  23950. /**
  23951. * Gets the texture coordinates data stored in this target
  23952. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23953. */
  23954. getUVs(): Nullable<FloatArray>;
  23955. /**
  23956. * Clone the current target
  23957. * @returns a new MorphTarget
  23958. */
  23959. clone(): MorphTarget;
  23960. /**
  23961. * Serializes the current target into a Serialization object
  23962. * @returns the serialized object
  23963. */
  23964. serialize(): any;
  23965. /**
  23966. * Returns the string "MorphTarget"
  23967. * @returns "MorphTarget"
  23968. */
  23969. getClassName(): string;
  23970. /**
  23971. * Creates a new target from serialized data
  23972. * @param serializationObject defines the serialized data to use
  23973. * @returns a new MorphTarget
  23974. */
  23975. static Parse(serializationObject: any): MorphTarget;
  23976. /**
  23977. * Creates a MorphTarget from mesh data
  23978. * @param mesh defines the source mesh
  23979. * @param name defines the name to use for the new target
  23980. * @param influence defines the influence to attach to the target
  23981. * @returns a new MorphTarget
  23982. */
  23983. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23984. }
  23985. }
  23986. declare module "babylonjs/Morph/morphTargetManager" {
  23987. import { Nullable } from "babylonjs/types";
  23988. import { Scene } from "babylonjs/scene";
  23989. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23990. /**
  23991. * This class is used to deform meshes using morphing between different targets
  23992. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23993. */
  23994. export class MorphTargetManager {
  23995. private _targets;
  23996. private _targetInfluenceChangedObservers;
  23997. private _targetDataLayoutChangedObservers;
  23998. private _activeTargets;
  23999. private _scene;
  24000. private _influences;
  24001. private _supportsNormals;
  24002. private _supportsTangents;
  24003. private _supportsUVs;
  24004. private _vertexCount;
  24005. private _uniqueId;
  24006. private _tempInfluences;
  24007. /**
  24008. * Gets or sets a boolean indicating if normals must be morphed
  24009. */
  24010. enableNormalMorphing: boolean;
  24011. /**
  24012. * Gets or sets a boolean indicating if tangents must be morphed
  24013. */
  24014. enableTangentMorphing: boolean;
  24015. /**
  24016. * Gets or sets a boolean indicating if UV must be morphed
  24017. */
  24018. enableUVMorphing: boolean;
  24019. /**
  24020. * Creates a new MorphTargetManager
  24021. * @param scene defines the current scene
  24022. */
  24023. constructor(scene?: Nullable<Scene>);
  24024. /**
  24025. * Gets the unique ID of this manager
  24026. */
  24027. get uniqueId(): number;
  24028. /**
  24029. * Gets the number of vertices handled by this manager
  24030. */
  24031. get vertexCount(): number;
  24032. /**
  24033. * Gets a boolean indicating if this manager supports morphing of normals
  24034. */
  24035. get supportsNormals(): boolean;
  24036. /**
  24037. * Gets a boolean indicating if this manager supports morphing of tangents
  24038. */
  24039. get supportsTangents(): boolean;
  24040. /**
  24041. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  24042. */
  24043. get supportsUVs(): boolean;
  24044. /**
  24045. * Gets the number of targets stored in this manager
  24046. */
  24047. get numTargets(): number;
  24048. /**
  24049. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24050. */
  24051. get numInfluencers(): number;
  24052. /**
  24053. * Gets the list of influences (one per target)
  24054. */
  24055. get influences(): Float32Array;
  24056. /**
  24057. * Gets the active target at specified index. An active target is a target with an influence > 0
  24058. * @param index defines the index to check
  24059. * @returns the requested target
  24060. */
  24061. getActiveTarget(index: number): MorphTarget;
  24062. /**
  24063. * Gets the target at specified index
  24064. * @param index defines the index to check
  24065. * @returns the requested target
  24066. */
  24067. getTarget(index: number): MorphTarget;
  24068. /**
  24069. * Add a new target to this manager
  24070. * @param target defines the target to add
  24071. */
  24072. addTarget(target: MorphTarget): void;
  24073. /**
  24074. * Removes a target from the manager
  24075. * @param target defines the target to remove
  24076. */
  24077. removeTarget(target: MorphTarget): void;
  24078. /**
  24079. * Clone the current manager
  24080. * @returns a new MorphTargetManager
  24081. */
  24082. clone(): MorphTargetManager;
  24083. /**
  24084. * Serializes the current manager into a Serialization object
  24085. * @returns the serialized object
  24086. */
  24087. serialize(): any;
  24088. private _syncActiveTargets;
  24089. /**
  24090. * Syncrhonize the targets with all the meshes using this morph target manager
  24091. */
  24092. synchronize(): void;
  24093. /**
  24094. * Creates a new MorphTargetManager from serialized data
  24095. * @param serializationObject defines the serialized data
  24096. * @param scene defines the hosting scene
  24097. * @returns the new MorphTargetManager
  24098. */
  24099. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24100. }
  24101. }
  24102. declare module "babylonjs/Meshes/meshLODLevel" {
  24103. import { Mesh } from "babylonjs/Meshes/mesh";
  24104. import { Nullable } from "babylonjs/types";
  24105. /**
  24106. * Class used to represent a specific level of detail of a mesh
  24107. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24108. */
  24109. export class MeshLODLevel {
  24110. /** Defines the distance where this level should start being displayed */
  24111. distance: number;
  24112. /** Defines the mesh to use to render this level */
  24113. mesh: Nullable<Mesh>;
  24114. /**
  24115. * Creates a new LOD level
  24116. * @param distance defines the distance where this level should star being displayed
  24117. * @param mesh defines the mesh to use to render this level
  24118. */
  24119. constructor(
  24120. /** Defines the distance where this level should start being displayed */
  24121. distance: number,
  24122. /** Defines the mesh to use to render this level */
  24123. mesh: Nullable<Mesh>);
  24124. }
  24125. }
  24126. declare module "babylonjs/Meshes/groundMesh" {
  24127. import { Scene } from "babylonjs/scene";
  24128. import { Vector3 } from "babylonjs/Maths/math.vector";
  24129. import { Mesh } from "babylonjs/Meshes/mesh";
  24130. /**
  24131. * Mesh representing the gorund
  24132. */
  24133. export class GroundMesh extends Mesh {
  24134. /** If octree should be generated */
  24135. generateOctree: boolean;
  24136. private _heightQuads;
  24137. /** @hidden */
  24138. _subdivisionsX: number;
  24139. /** @hidden */
  24140. _subdivisionsY: number;
  24141. /** @hidden */
  24142. _width: number;
  24143. /** @hidden */
  24144. _height: number;
  24145. /** @hidden */
  24146. _minX: number;
  24147. /** @hidden */
  24148. _maxX: number;
  24149. /** @hidden */
  24150. _minZ: number;
  24151. /** @hidden */
  24152. _maxZ: number;
  24153. constructor(name: string, scene: Scene);
  24154. /**
  24155. * "GroundMesh"
  24156. * @returns "GroundMesh"
  24157. */
  24158. getClassName(): string;
  24159. /**
  24160. * The minimum of x and y subdivisions
  24161. */
  24162. get subdivisions(): number;
  24163. /**
  24164. * X subdivisions
  24165. */
  24166. get subdivisionsX(): number;
  24167. /**
  24168. * Y subdivisions
  24169. */
  24170. get subdivisionsY(): number;
  24171. /**
  24172. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  24173. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24174. * @param chunksCount the number of subdivisions for x and y
  24175. * @param octreeBlocksSize (Default: 32)
  24176. */
  24177. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  24178. /**
  24179. * Returns a height (y) value in the Worl system :
  24180. * the ground altitude at the coordinates (x, z) expressed in the World system.
  24181. * @param x x coordinate
  24182. * @param z z coordinate
  24183. * @returns the ground y position if (x, z) are outside the ground surface.
  24184. */
  24185. getHeightAtCoordinates(x: number, z: number): number;
  24186. /**
  24187. * Returns a normalized vector (Vector3) orthogonal to the ground
  24188. * at the ground coordinates (x, z) expressed in the World system.
  24189. * @param x x coordinate
  24190. * @param z z coordinate
  24191. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  24192. */
  24193. getNormalAtCoordinates(x: number, z: number): Vector3;
  24194. /**
  24195. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  24196. * at the ground coordinates (x, z) expressed in the World system.
  24197. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  24198. * @param x x coordinate
  24199. * @param z z coordinate
  24200. * @param ref vector to store the result
  24201. * @returns the GroundMesh.
  24202. */
  24203. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  24204. /**
  24205. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  24206. * if the ground has been updated.
  24207. * This can be used in the render loop.
  24208. * @returns the GroundMesh.
  24209. */
  24210. updateCoordinateHeights(): GroundMesh;
  24211. private _getFacetAt;
  24212. private _initHeightQuads;
  24213. private _computeHeightQuads;
  24214. /**
  24215. * Serializes this ground mesh
  24216. * @param serializationObject object to write serialization to
  24217. */
  24218. serialize(serializationObject: any): void;
  24219. /**
  24220. * Parses a serialized ground mesh
  24221. * @param parsedMesh the serialized mesh
  24222. * @param scene the scene to create the ground mesh in
  24223. * @returns the created ground mesh
  24224. */
  24225. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  24226. }
  24227. }
  24228. declare module "babylonjs/Physics/physicsJoint" {
  24229. import { Vector3 } from "babylonjs/Maths/math.vector";
  24230. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  24231. /**
  24232. * Interface for Physics-Joint data
  24233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24234. */
  24235. export interface PhysicsJointData {
  24236. /**
  24237. * The main pivot of the joint
  24238. */
  24239. mainPivot?: Vector3;
  24240. /**
  24241. * The connected pivot of the joint
  24242. */
  24243. connectedPivot?: Vector3;
  24244. /**
  24245. * The main axis of the joint
  24246. */
  24247. mainAxis?: Vector3;
  24248. /**
  24249. * The connected axis of the joint
  24250. */
  24251. connectedAxis?: Vector3;
  24252. /**
  24253. * The collision of the joint
  24254. */
  24255. collision?: boolean;
  24256. /**
  24257. * Native Oimo/Cannon/Energy data
  24258. */
  24259. nativeParams?: any;
  24260. }
  24261. /**
  24262. * This is a holder class for the physics joint created by the physics plugin
  24263. * It holds a set of functions to control the underlying joint
  24264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24265. */
  24266. export class PhysicsJoint {
  24267. /**
  24268. * The type of the physics joint
  24269. */
  24270. type: number;
  24271. /**
  24272. * The data for the physics joint
  24273. */
  24274. jointData: PhysicsJointData;
  24275. private _physicsJoint;
  24276. protected _physicsPlugin: IPhysicsEnginePlugin;
  24277. /**
  24278. * Initializes the physics joint
  24279. * @param type The type of the physics joint
  24280. * @param jointData The data for the physics joint
  24281. */
  24282. constructor(
  24283. /**
  24284. * The type of the physics joint
  24285. */
  24286. type: number,
  24287. /**
  24288. * The data for the physics joint
  24289. */
  24290. jointData: PhysicsJointData);
  24291. /**
  24292. * Gets the physics joint
  24293. */
  24294. get physicsJoint(): any;
  24295. /**
  24296. * Sets the physics joint
  24297. */
  24298. set physicsJoint(newJoint: any);
  24299. /**
  24300. * Sets the physics plugin
  24301. */
  24302. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24303. /**
  24304. * Execute a function that is physics-plugin specific.
  24305. * @param {Function} func the function that will be executed.
  24306. * It accepts two parameters: the physics world and the physics joint
  24307. */
  24308. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24309. /**
  24310. * Distance-Joint type
  24311. */
  24312. static DistanceJoint: number;
  24313. /**
  24314. * Hinge-Joint type
  24315. */
  24316. static HingeJoint: number;
  24317. /**
  24318. * Ball-and-Socket joint type
  24319. */
  24320. static BallAndSocketJoint: number;
  24321. /**
  24322. * Wheel-Joint type
  24323. */
  24324. static WheelJoint: number;
  24325. /**
  24326. * Slider-Joint type
  24327. */
  24328. static SliderJoint: number;
  24329. /**
  24330. * Prismatic-Joint type
  24331. */
  24332. static PrismaticJoint: number;
  24333. /**
  24334. * Universal-Joint type
  24335. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24336. */
  24337. static UniversalJoint: number;
  24338. /**
  24339. * Hinge-Joint 2 type
  24340. */
  24341. static Hinge2Joint: number;
  24342. /**
  24343. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24344. */
  24345. static PointToPointJoint: number;
  24346. /**
  24347. * Spring-Joint type
  24348. */
  24349. static SpringJoint: number;
  24350. /**
  24351. * Lock-Joint type
  24352. */
  24353. static LockJoint: number;
  24354. }
  24355. /**
  24356. * A class representing a physics distance joint
  24357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24358. */
  24359. export class DistanceJoint extends PhysicsJoint {
  24360. /**
  24361. *
  24362. * @param jointData The data for the Distance-Joint
  24363. */
  24364. constructor(jointData: DistanceJointData);
  24365. /**
  24366. * Update the predefined distance.
  24367. * @param maxDistance The maximum preferred distance
  24368. * @param minDistance The minimum preferred distance
  24369. */
  24370. updateDistance(maxDistance: number, minDistance?: number): void;
  24371. }
  24372. /**
  24373. * Represents a Motor-Enabled Joint
  24374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24375. */
  24376. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24377. /**
  24378. * Initializes the Motor-Enabled Joint
  24379. * @param type The type of the joint
  24380. * @param jointData The physica joint data for the joint
  24381. */
  24382. constructor(type: number, jointData: PhysicsJointData);
  24383. /**
  24384. * Set the motor values.
  24385. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24386. * @param force the force to apply
  24387. * @param maxForce max force for this motor.
  24388. */
  24389. setMotor(force?: number, maxForce?: number): void;
  24390. /**
  24391. * Set the motor's limits.
  24392. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24393. * @param upperLimit The upper limit of the motor
  24394. * @param lowerLimit The lower limit of the motor
  24395. */
  24396. setLimit(upperLimit: number, lowerLimit?: number): void;
  24397. }
  24398. /**
  24399. * This class represents a single physics Hinge-Joint
  24400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24401. */
  24402. export class HingeJoint extends MotorEnabledJoint {
  24403. /**
  24404. * Initializes the Hinge-Joint
  24405. * @param jointData The joint data for the Hinge-Joint
  24406. */
  24407. constructor(jointData: PhysicsJointData);
  24408. /**
  24409. * Set the motor values.
  24410. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24411. * @param {number} force the force to apply
  24412. * @param {number} maxForce max force for this motor.
  24413. */
  24414. setMotor(force?: number, maxForce?: number): void;
  24415. /**
  24416. * Set the motor's limits.
  24417. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24418. * @param upperLimit The upper limit of the motor
  24419. * @param lowerLimit The lower limit of the motor
  24420. */
  24421. setLimit(upperLimit: number, lowerLimit?: number): void;
  24422. }
  24423. /**
  24424. * This class represents a dual hinge physics joint (same as wheel joint)
  24425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24426. */
  24427. export class Hinge2Joint extends MotorEnabledJoint {
  24428. /**
  24429. * Initializes the Hinge2-Joint
  24430. * @param jointData The joint data for the Hinge2-Joint
  24431. */
  24432. constructor(jointData: PhysicsJointData);
  24433. /**
  24434. * Set the motor values.
  24435. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24436. * @param {number} targetSpeed the speed the motor is to reach
  24437. * @param {number} maxForce max force for this motor.
  24438. * @param {motorIndex} the motor's index, 0 or 1.
  24439. */
  24440. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24441. /**
  24442. * Set the motor limits.
  24443. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24444. * @param {number} upperLimit the upper limit
  24445. * @param {number} lowerLimit lower limit
  24446. * @param {motorIndex} the motor's index, 0 or 1.
  24447. */
  24448. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24449. }
  24450. /**
  24451. * Interface for a motor enabled joint
  24452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24453. */
  24454. export interface IMotorEnabledJoint {
  24455. /**
  24456. * Physics joint
  24457. */
  24458. physicsJoint: any;
  24459. /**
  24460. * Sets the motor of the motor-enabled joint
  24461. * @param force The force of the motor
  24462. * @param maxForce The maximum force of the motor
  24463. * @param motorIndex The index of the motor
  24464. */
  24465. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24466. /**
  24467. * Sets the limit of the motor
  24468. * @param upperLimit The upper limit of the motor
  24469. * @param lowerLimit The lower limit of the motor
  24470. * @param motorIndex The index of the motor
  24471. */
  24472. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24473. }
  24474. /**
  24475. * Joint data for a Distance-Joint
  24476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24477. */
  24478. export interface DistanceJointData extends PhysicsJointData {
  24479. /**
  24480. * Max distance the 2 joint objects can be apart
  24481. */
  24482. maxDistance: number;
  24483. }
  24484. /**
  24485. * Joint data from a spring joint
  24486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24487. */
  24488. export interface SpringJointData extends PhysicsJointData {
  24489. /**
  24490. * Length of the spring
  24491. */
  24492. length: number;
  24493. /**
  24494. * Stiffness of the spring
  24495. */
  24496. stiffness: number;
  24497. /**
  24498. * Damping of the spring
  24499. */
  24500. damping: number;
  24501. /** this callback will be called when applying the force to the impostors. */
  24502. forceApplicationCallback: () => void;
  24503. }
  24504. }
  24505. declare module "babylonjs/Physics/physicsRaycastResult" {
  24506. import { Vector3 } from "babylonjs/Maths/math.vector";
  24507. /**
  24508. * Holds the data for the raycast result
  24509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24510. */
  24511. export class PhysicsRaycastResult {
  24512. private _hasHit;
  24513. private _hitDistance;
  24514. private _hitNormalWorld;
  24515. private _hitPointWorld;
  24516. private _rayFromWorld;
  24517. private _rayToWorld;
  24518. /**
  24519. * Gets if there was a hit
  24520. */
  24521. get hasHit(): boolean;
  24522. /**
  24523. * Gets the distance from the hit
  24524. */
  24525. get hitDistance(): number;
  24526. /**
  24527. * Gets the hit normal/direction in the world
  24528. */
  24529. get hitNormalWorld(): Vector3;
  24530. /**
  24531. * Gets the hit point in the world
  24532. */
  24533. get hitPointWorld(): Vector3;
  24534. /**
  24535. * Gets the ray "start point" of the ray in the world
  24536. */
  24537. get rayFromWorld(): Vector3;
  24538. /**
  24539. * Gets the ray "end point" of the ray in the world
  24540. */
  24541. get rayToWorld(): Vector3;
  24542. /**
  24543. * Sets the hit data (normal & point in world space)
  24544. * @param hitNormalWorld defines the normal in world space
  24545. * @param hitPointWorld defines the point in world space
  24546. */
  24547. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24548. /**
  24549. * Sets the distance from the start point to the hit point
  24550. * @param distance
  24551. */
  24552. setHitDistance(distance: number): void;
  24553. /**
  24554. * Calculates the distance manually
  24555. */
  24556. calculateHitDistance(): void;
  24557. /**
  24558. * Resets all the values to default
  24559. * @param from The from point on world space
  24560. * @param to The to point on world space
  24561. */
  24562. reset(from?: Vector3, to?: Vector3): void;
  24563. }
  24564. /**
  24565. * Interface for the size containing width and height
  24566. */
  24567. interface IXYZ {
  24568. /**
  24569. * X
  24570. */
  24571. x: number;
  24572. /**
  24573. * Y
  24574. */
  24575. y: number;
  24576. /**
  24577. * Z
  24578. */
  24579. z: number;
  24580. }
  24581. }
  24582. declare module "babylonjs/Physics/IPhysicsEngine" {
  24583. import { Nullable } from "babylonjs/types";
  24584. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24586. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24587. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24588. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24589. /**
  24590. * Interface used to describe a physics joint
  24591. */
  24592. export interface PhysicsImpostorJoint {
  24593. /** Defines the main impostor to which the joint is linked */
  24594. mainImpostor: PhysicsImpostor;
  24595. /** Defines the impostor that is connected to the main impostor using this joint */
  24596. connectedImpostor: PhysicsImpostor;
  24597. /** Defines the joint itself */
  24598. joint: PhysicsJoint;
  24599. }
  24600. /** @hidden */
  24601. export interface IPhysicsEnginePlugin {
  24602. world: any;
  24603. name: string;
  24604. setGravity(gravity: Vector3): void;
  24605. setTimeStep(timeStep: number): void;
  24606. getTimeStep(): number;
  24607. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24608. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24609. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24610. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24611. removePhysicsBody(impostor: PhysicsImpostor): void;
  24612. generateJoint(joint: PhysicsImpostorJoint): void;
  24613. removeJoint(joint: PhysicsImpostorJoint): void;
  24614. isSupported(): boolean;
  24615. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24616. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24617. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24618. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24619. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24620. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24621. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24622. getBodyMass(impostor: PhysicsImpostor): number;
  24623. getBodyFriction(impostor: PhysicsImpostor): number;
  24624. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24625. getBodyRestitution(impostor: PhysicsImpostor): number;
  24626. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24627. getBodyPressure?(impostor: PhysicsImpostor): number;
  24628. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24629. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24630. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24631. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24632. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24633. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24634. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24635. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24636. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24637. sleepBody(impostor: PhysicsImpostor): void;
  24638. wakeUpBody(impostor: PhysicsImpostor): void;
  24639. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24641. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24642. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24643. getRadius(impostor: PhysicsImpostor): number;
  24644. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24645. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24646. dispose(): void;
  24647. }
  24648. /**
  24649. * Interface used to define a physics engine
  24650. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24651. */
  24652. export interface IPhysicsEngine {
  24653. /**
  24654. * Gets the gravity vector used by the simulation
  24655. */
  24656. gravity: Vector3;
  24657. /**
  24658. * Sets the gravity vector used by the simulation
  24659. * @param gravity defines the gravity vector to use
  24660. */
  24661. setGravity(gravity: Vector3): void;
  24662. /**
  24663. * Set the time step of the physics engine.
  24664. * Default is 1/60.
  24665. * To slow it down, enter 1/600 for example.
  24666. * To speed it up, 1/30
  24667. * @param newTimeStep the new timestep to apply to this world.
  24668. */
  24669. setTimeStep(newTimeStep: number): void;
  24670. /**
  24671. * Get the time step of the physics engine.
  24672. * @returns the current time step
  24673. */
  24674. getTimeStep(): number;
  24675. /**
  24676. * Set the sub time step of the physics engine.
  24677. * Default is 0 meaning there is no sub steps
  24678. * To increase physics resolution precision, set a small value (like 1 ms)
  24679. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24680. */
  24681. setSubTimeStep(subTimeStep: number): void;
  24682. /**
  24683. * Get the sub time step of the physics engine.
  24684. * @returns the current sub time step
  24685. */
  24686. getSubTimeStep(): number;
  24687. /**
  24688. * Release all resources
  24689. */
  24690. dispose(): void;
  24691. /**
  24692. * Gets the name of the current physics plugin
  24693. * @returns the name of the plugin
  24694. */
  24695. getPhysicsPluginName(): string;
  24696. /**
  24697. * Adding a new impostor for the impostor tracking.
  24698. * This will be done by the impostor itself.
  24699. * @param impostor the impostor to add
  24700. */
  24701. addImpostor(impostor: PhysicsImpostor): void;
  24702. /**
  24703. * Remove an impostor from the engine.
  24704. * This impostor and its mesh will not longer be updated by the physics engine.
  24705. * @param impostor the impostor to remove
  24706. */
  24707. removeImpostor(impostor: PhysicsImpostor): void;
  24708. /**
  24709. * Add a joint to the physics engine
  24710. * @param mainImpostor defines the main impostor to which the joint is added.
  24711. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24712. * @param joint defines the joint that will connect both impostors.
  24713. */
  24714. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24715. /**
  24716. * Removes a joint from the simulation
  24717. * @param mainImpostor defines the impostor used with the joint
  24718. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24719. * @param joint defines the joint to remove
  24720. */
  24721. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24722. /**
  24723. * Gets the current plugin used to run the simulation
  24724. * @returns current plugin
  24725. */
  24726. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24727. /**
  24728. * Gets the list of physic impostors
  24729. * @returns an array of PhysicsImpostor
  24730. */
  24731. getImpostors(): Array<PhysicsImpostor>;
  24732. /**
  24733. * Gets the impostor for a physics enabled object
  24734. * @param object defines the object impersonated by the impostor
  24735. * @returns the PhysicsImpostor or null if not found
  24736. */
  24737. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24738. /**
  24739. * Gets the impostor for a physics body object
  24740. * @param body defines physics body used by the impostor
  24741. * @returns the PhysicsImpostor or null if not found
  24742. */
  24743. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24744. /**
  24745. * Does a raycast in the physics world
  24746. * @param from when should the ray start?
  24747. * @param to when should the ray end?
  24748. * @returns PhysicsRaycastResult
  24749. */
  24750. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24751. /**
  24752. * Called by the scene. No need to call it.
  24753. * @param delta defines the timespam between frames
  24754. */
  24755. _step(delta: number): void;
  24756. }
  24757. }
  24758. declare module "babylonjs/Physics/physicsImpostor" {
  24759. import { Nullable, IndicesArray } from "babylonjs/types";
  24760. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24763. import { Scene } from "babylonjs/scene";
  24764. import { Bone } from "babylonjs/Bones/bone";
  24765. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24766. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24767. import { Space } from "babylonjs/Maths/math.axis";
  24768. /**
  24769. * The interface for the physics imposter parameters
  24770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24771. */
  24772. export interface PhysicsImpostorParameters {
  24773. /**
  24774. * The mass of the physics imposter
  24775. */
  24776. mass: number;
  24777. /**
  24778. * The friction of the physics imposter
  24779. */
  24780. friction?: number;
  24781. /**
  24782. * The coefficient of restitution of the physics imposter
  24783. */
  24784. restitution?: number;
  24785. /**
  24786. * The native options of the physics imposter
  24787. */
  24788. nativeOptions?: any;
  24789. /**
  24790. * Specifies if the parent should be ignored
  24791. */
  24792. ignoreParent?: boolean;
  24793. /**
  24794. * Specifies if bi-directional transformations should be disabled
  24795. */
  24796. disableBidirectionalTransformation?: boolean;
  24797. /**
  24798. * The pressure inside the physics imposter, soft object only
  24799. */
  24800. pressure?: number;
  24801. /**
  24802. * The stiffness the physics imposter, soft object only
  24803. */
  24804. stiffness?: number;
  24805. /**
  24806. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24807. */
  24808. velocityIterations?: number;
  24809. /**
  24810. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24811. */
  24812. positionIterations?: number;
  24813. /**
  24814. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24815. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24816. * Add to fix multiple points
  24817. */
  24818. fixedPoints?: number;
  24819. /**
  24820. * The collision margin around a soft object
  24821. */
  24822. margin?: number;
  24823. /**
  24824. * The collision margin around a soft object
  24825. */
  24826. damping?: number;
  24827. /**
  24828. * The path for a rope based on an extrusion
  24829. */
  24830. path?: any;
  24831. /**
  24832. * The shape of an extrusion used for a rope based on an extrusion
  24833. */
  24834. shape?: any;
  24835. }
  24836. /**
  24837. * Interface for a physics-enabled object
  24838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24839. */
  24840. export interface IPhysicsEnabledObject {
  24841. /**
  24842. * The position of the physics-enabled object
  24843. */
  24844. position: Vector3;
  24845. /**
  24846. * The rotation of the physics-enabled object
  24847. */
  24848. rotationQuaternion: Nullable<Quaternion>;
  24849. /**
  24850. * The scale of the physics-enabled object
  24851. */
  24852. scaling: Vector3;
  24853. /**
  24854. * The rotation of the physics-enabled object
  24855. */
  24856. rotation?: Vector3;
  24857. /**
  24858. * The parent of the physics-enabled object
  24859. */
  24860. parent?: any;
  24861. /**
  24862. * The bounding info of the physics-enabled object
  24863. * @returns The bounding info of the physics-enabled object
  24864. */
  24865. getBoundingInfo(): BoundingInfo;
  24866. /**
  24867. * Computes the world matrix
  24868. * @param force Specifies if the world matrix should be computed by force
  24869. * @returns A world matrix
  24870. */
  24871. computeWorldMatrix(force: boolean): Matrix;
  24872. /**
  24873. * Gets the world matrix
  24874. * @returns A world matrix
  24875. */
  24876. getWorldMatrix?(): Matrix;
  24877. /**
  24878. * Gets the child meshes
  24879. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24880. * @returns An array of abstract meshes
  24881. */
  24882. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24883. /**
  24884. * Gets the vertex data
  24885. * @param kind The type of vertex data
  24886. * @returns A nullable array of numbers, or a float32 array
  24887. */
  24888. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24889. /**
  24890. * Gets the indices from the mesh
  24891. * @returns A nullable array of index arrays
  24892. */
  24893. getIndices?(): Nullable<IndicesArray>;
  24894. /**
  24895. * Gets the scene from the mesh
  24896. * @returns the indices array or null
  24897. */
  24898. getScene?(): Scene;
  24899. /**
  24900. * Gets the absolute position from the mesh
  24901. * @returns the absolute position
  24902. */
  24903. getAbsolutePosition(): Vector3;
  24904. /**
  24905. * Gets the absolute pivot point from the mesh
  24906. * @returns the absolute pivot point
  24907. */
  24908. getAbsolutePivotPoint(): Vector3;
  24909. /**
  24910. * Rotates the mesh
  24911. * @param axis The axis of rotation
  24912. * @param amount The amount of rotation
  24913. * @param space The space of the rotation
  24914. * @returns The rotation transform node
  24915. */
  24916. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24917. /**
  24918. * Translates the mesh
  24919. * @param axis The axis of translation
  24920. * @param distance The distance of translation
  24921. * @param space The space of the translation
  24922. * @returns The transform node
  24923. */
  24924. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24925. /**
  24926. * Sets the absolute position of the mesh
  24927. * @param absolutePosition The absolute position of the mesh
  24928. * @returns The transform node
  24929. */
  24930. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24931. /**
  24932. * Gets the class name of the mesh
  24933. * @returns The class name
  24934. */
  24935. getClassName(): string;
  24936. }
  24937. /**
  24938. * Represents a physics imposter
  24939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24940. */
  24941. export class PhysicsImpostor {
  24942. /**
  24943. * The physics-enabled object used as the physics imposter
  24944. */
  24945. object: IPhysicsEnabledObject;
  24946. /**
  24947. * The type of the physics imposter
  24948. */
  24949. type: number;
  24950. private _options;
  24951. private _scene?;
  24952. /**
  24953. * The default object size of the imposter
  24954. */
  24955. static DEFAULT_OBJECT_SIZE: Vector3;
  24956. /**
  24957. * The identity quaternion of the imposter
  24958. */
  24959. static IDENTITY_QUATERNION: Quaternion;
  24960. /** @hidden */
  24961. _pluginData: any;
  24962. private _physicsEngine;
  24963. private _physicsBody;
  24964. private _bodyUpdateRequired;
  24965. private _onBeforePhysicsStepCallbacks;
  24966. private _onAfterPhysicsStepCallbacks;
  24967. /** @hidden */
  24968. _onPhysicsCollideCallbacks: Array<{
  24969. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24970. otherImpostors: Array<PhysicsImpostor>;
  24971. }>;
  24972. private _deltaPosition;
  24973. private _deltaRotation;
  24974. private _deltaRotationConjugated;
  24975. /** @hidden */
  24976. _isFromLine: boolean;
  24977. private _parent;
  24978. private _isDisposed;
  24979. private static _tmpVecs;
  24980. private static _tmpQuat;
  24981. /**
  24982. * Specifies if the physics imposter is disposed
  24983. */
  24984. get isDisposed(): boolean;
  24985. /**
  24986. * Gets the mass of the physics imposter
  24987. */
  24988. get mass(): number;
  24989. set mass(value: number);
  24990. /**
  24991. * Gets the coefficient of friction
  24992. */
  24993. get friction(): number;
  24994. /**
  24995. * Sets the coefficient of friction
  24996. */
  24997. set friction(value: number);
  24998. /**
  24999. * Gets the coefficient of restitution
  25000. */
  25001. get restitution(): number;
  25002. /**
  25003. * Sets the coefficient of restitution
  25004. */
  25005. set restitution(value: number);
  25006. /**
  25007. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  25008. */
  25009. get pressure(): number;
  25010. /**
  25011. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  25012. */
  25013. set pressure(value: number);
  25014. /**
  25015. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  25016. */
  25017. get stiffness(): number;
  25018. /**
  25019. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  25020. */
  25021. set stiffness(value: number);
  25022. /**
  25023. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  25024. */
  25025. get velocityIterations(): number;
  25026. /**
  25027. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  25028. */
  25029. set velocityIterations(value: number);
  25030. /**
  25031. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  25032. */
  25033. get positionIterations(): number;
  25034. /**
  25035. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  25036. */
  25037. set positionIterations(value: number);
  25038. /**
  25039. * The unique id of the physics imposter
  25040. * set by the physics engine when adding this impostor to the array
  25041. */
  25042. uniqueId: number;
  25043. /**
  25044. * @hidden
  25045. */
  25046. soft: boolean;
  25047. /**
  25048. * @hidden
  25049. */
  25050. segments: number;
  25051. private _joints;
  25052. /**
  25053. * Initializes the physics imposter
  25054. * @param object The physics-enabled object used as the physics imposter
  25055. * @param type The type of the physics imposter
  25056. * @param _options The options for the physics imposter
  25057. * @param _scene The Babylon scene
  25058. */
  25059. constructor(
  25060. /**
  25061. * The physics-enabled object used as the physics imposter
  25062. */
  25063. object: IPhysicsEnabledObject,
  25064. /**
  25065. * The type of the physics imposter
  25066. */
  25067. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25068. /**
  25069. * This function will completly initialize this impostor.
  25070. * It will create a new body - but only if this mesh has no parent.
  25071. * If it has, this impostor will not be used other than to define the impostor
  25072. * of the child mesh.
  25073. * @hidden
  25074. */
  25075. _init(): void;
  25076. private _getPhysicsParent;
  25077. /**
  25078. * Should a new body be generated.
  25079. * @returns boolean specifying if body initialization is required
  25080. */
  25081. isBodyInitRequired(): boolean;
  25082. /**
  25083. * Sets the updated scaling
  25084. * @param updated Specifies if the scaling is updated
  25085. */
  25086. setScalingUpdated(): void;
  25087. /**
  25088. * Force a regeneration of this or the parent's impostor's body.
  25089. * Use under cautious - This will remove all joints already implemented.
  25090. */
  25091. forceUpdate(): void;
  25092. /**
  25093. * Gets the body that holds this impostor. Either its own, or its parent.
  25094. */
  25095. get physicsBody(): any;
  25096. /**
  25097. * Get the parent of the physics imposter
  25098. * @returns Physics imposter or null
  25099. */
  25100. get parent(): Nullable<PhysicsImpostor>;
  25101. /**
  25102. * Sets the parent of the physics imposter
  25103. */
  25104. set parent(value: Nullable<PhysicsImpostor>);
  25105. /**
  25106. * Set the physics body. Used mainly by the physics engine/plugin
  25107. */
  25108. set physicsBody(physicsBody: any);
  25109. /**
  25110. * Resets the update flags
  25111. */
  25112. resetUpdateFlags(): void;
  25113. /**
  25114. * Gets the object extend size
  25115. * @returns the object extend size
  25116. */
  25117. getObjectExtendSize(): Vector3;
  25118. /**
  25119. * Gets the object center
  25120. * @returns The object center
  25121. */
  25122. getObjectCenter(): Vector3;
  25123. /**
  25124. * Get a specific parameter from the options parameters
  25125. * @param paramName The object parameter name
  25126. * @returns The object parameter
  25127. */
  25128. getParam(paramName: string): any;
  25129. /**
  25130. * Sets a specific parameter in the options given to the physics plugin
  25131. * @param paramName The parameter name
  25132. * @param value The value of the parameter
  25133. */
  25134. setParam(paramName: string, value: number): void;
  25135. /**
  25136. * Specifically change the body's mass option. Won't recreate the physics body object
  25137. * @param mass The mass of the physics imposter
  25138. */
  25139. setMass(mass: number): void;
  25140. /**
  25141. * Gets the linear velocity
  25142. * @returns linear velocity or null
  25143. */
  25144. getLinearVelocity(): Nullable<Vector3>;
  25145. /**
  25146. * Sets the linear velocity
  25147. * @param velocity linear velocity or null
  25148. */
  25149. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25150. /**
  25151. * Gets the angular velocity
  25152. * @returns angular velocity or null
  25153. */
  25154. getAngularVelocity(): Nullable<Vector3>;
  25155. /**
  25156. * Sets the angular velocity
  25157. * @param velocity The velocity or null
  25158. */
  25159. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25160. /**
  25161. * Execute a function with the physics plugin native code
  25162. * Provide a function the will have two variables - the world object and the physics body object
  25163. * @param func The function to execute with the physics plugin native code
  25164. */
  25165. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25166. /**
  25167. * Register a function that will be executed before the physics world is stepping forward
  25168. * @param func The function to execute before the physics world is stepped forward
  25169. */
  25170. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25171. /**
  25172. * Unregister a function that will be executed before the physics world is stepping forward
  25173. * @param func The function to execute before the physics world is stepped forward
  25174. */
  25175. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25176. /**
  25177. * Register a function that will be executed after the physics step
  25178. * @param func The function to execute after physics step
  25179. */
  25180. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25181. /**
  25182. * Unregisters a function that will be executed after the physics step
  25183. * @param func The function to execute after physics step
  25184. */
  25185. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25186. /**
  25187. * register a function that will be executed when this impostor collides against a different body
  25188. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  25189. * @param func Callback that is executed on collision
  25190. */
  25191. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25192. /**
  25193. * Unregisters the physics imposter on contact
  25194. * @param collideAgainst The physics object to collide against
  25195. * @param func Callback to execute on collision
  25196. */
  25197. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25198. private _tmpQuat;
  25199. private _tmpQuat2;
  25200. /**
  25201. * Get the parent rotation
  25202. * @returns The parent rotation
  25203. */
  25204. getParentsRotation(): Quaternion;
  25205. /**
  25206. * this function is executed by the physics engine.
  25207. */
  25208. beforeStep: () => void;
  25209. /**
  25210. * this function is executed by the physics engine
  25211. */
  25212. afterStep: () => void;
  25213. /**
  25214. * Legacy collision detection event support
  25215. */
  25216. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25217. /**
  25218. * event and body object due to cannon's event-based architecture.
  25219. */
  25220. onCollide: (e: {
  25221. body: any;
  25222. }) => void;
  25223. /**
  25224. * Apply a force
  25225. * @param force The force to apply
  25226. * @param contactPoint The contact point for the force
  25227. * @returns The physics imposter
  25228. */
  25229. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25230. /**
  25231. * Apply an impulse
  25232. * @param force The impulse force
  25233. * @param contactPoint The contact point for the impulse force
  25234. * @returns The physics imposter
  25235. */
  25236. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25237. /**
  25238. * A help function to create a joint
  25239. * @param otherImpostor A physics imposter used to create a joint
  25240. * @param jointType The type of joint
  25241. * @param jointData The data for the joint
  25242. * @returns The physics imposter
  25243. */
  25244. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25245. /**
  25246. * Add a joint to this impostor with a different impostor
  25247. * @param otherImpostor A physics imposter used to add a joint
  25248. * @param joint The joint to add
  25249. * @returns The physics imposter
  25250. */
  25251. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25252. /**
  25253. * Add an anchor to a cloth impostor
  25254. * @param otherImpostor rigid impostor to anchor to
  25255. * @param width ratio across width from 0 to 1
  25256. * @param height ratio up height from 0 to 1
  25257. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  25258. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  25259. * @returns impostor the soft imposter
  25260. */
  25261. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25262. /**
  25263. * Add a hook to a rope impostor
  25264. * @param otherImpostor rigid impostor to anchor to
  25265. * @param length ratio across rope from 0 to 1
  25266. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25267. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25268. * @returns impostor the rope imposter
  25269. */
  25270. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25271. /**
  25272. * Will keep this body still, in a sleep mode.
  25273. * @returns the physics imposter
  25274. */
  25275. sleep(): PhysicsImpostor;
  25276. /**
  25277. * Wake the body up.
  25278. * @returns The physics imposter
  25279. */
  25280. wakeUp(): PhysicsImpostor;
  25281. /**
  25282. * Clones the physics imposter
  25283. * @param newObject The physics imposter clones to this physics-enabled object
  25284. * @returns A nullable physics imposter
  25285. */
  25286. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25287. /**
  25288. * Disposes the physics imposter
  25289. */
  25290. dispose(): void;
  25291. /**
  25292. * Sets the delta position
  25293. * @param position The delta position amount
  25294. */
  25295. setDeltaPosition(position: Vector3): void;
  25296. /**
  25297. * Sets the delta rotation
  25298. * @param rotation The delta rotation amount
  25299. */
  25300. setDeltaRotation(rotation: Quaternion): void;
  25301. /**
  25302. * Gets the box size of the physics imposter and stores the result in the input parameter
  25303. * @param result Stores the box size
  25304. * @returns The physics imposter
  25305. */
  25306. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25307. /**
  25308. * Gets the radius of the physics imposter
  25309. * @returns Radius of the physics imposter
  25310. */
  25311. getRadius(): number;
  25312. /**
  25313. * Sync a bone with this impostor
  25314. * @param bone The bone to sync to the impostor.
  25315. * @param boneMesh The mesh that the bone is influencing.
  25316. * @param jointPivot The pivot of the joint / bone in local space.
  25317. * @param distToJoint Optional distance from the impostor to the joint.
  25318. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25319. */
  25320. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25321. /**
  25322. * Sync impostor to a bone
  25323. * @param bone The bone that the impostor will be synced to.
  25324. * @param boneMesh The mesh that the bone is influencing.
  25325. * @param jointPivot The pivot of the joint / bone in local space.
  25326. * @param distToJoint Optional distance from the impostor to the joint.
  25327. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25328. * @param boneAxis Optional vector3 axis the bone is aligned with
  25329. */
  25330. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25331. /**
  25332. * No-Imposter type
  25333. */
  25334. static NoImpostor: number;
  25335. /**
  25336. * Sphere-Imposter type
  25337. */
  25338. static SphereImpostor: number;
  25339. /**
  25340. * Box-Imposter type
  25341. */
  25342. static BoxImpostor: number;
  25343. /**
  25344. * Plane-Imposter type
  25345. */
  25346. static PlaneImpostor: number;
  25347. /**
  25348. * Mesh-imposter type
  25349. */
  25350. static MeshImpostor: number;
  25351. /**
  25352. * Capsule-Impostor type (Ammo.js plugin only)
  25353. */
  25354. static CapsuleImpostor: number;
  25355. /**
  25356. * Cylinder-Imposter type
  25357. */
  25358. static CylinderImpostor: number;
  25359. /**
  25360. * Particle-Imposter type
  25361. */
  25362. static ParticleImpostor: number;
  25363. /**
  25364. * Heightmap-Imposter type
  25365. */
  25366. static HeightmapImpostor: number;
  25367. /**
  25368. * ConvexHull-Impostor type (Ammo.js plugin only)
  25369. */
  25370. static ConvexHullImpostor: number;
  25371. /**
  25372. * Custom-Imposter type (Ammo.js plugin only)
  25373. */
  25374. static CustomImpostor: number;
  25375. /**
  25376. * Rope-Imposter type
  25377. */
  25378. static RopeImpostor: number;
  25379. /**
  25380. * Cloth-Imposter type
  25381. */
  25382. static ClothImpostor: number;
  25383. /**
  25384. * Softbody-Imposter type
  25385. */
  25386. static SoftbodyImpostor: number;
  25387. }
  25388. }
  25389. declare module "babylonjs/Meshes/mesh" {
  25390. import { Observable } from "babylonjs/Misc/observable";
  25391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25392. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25393. import { Camera } from "babylonjs/Cameras/camera";
  25394. import { Scene } from "babylonjs/scene";
  25395. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25396. import { Color4 } from "babylonjs/Maths/math.color";
  25397. import { Engine } from "babylonjs/Engines/engine";
  25398. import { Node } from "babylonjs/node";
  25399. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25400. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25401. import { Buffer } from "babylonjs/Meshes/buffer";
  25402. import { Geometry } from "babylonjs/Meshes/geometry";
  25403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25405. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25406. import { Effect } from "babylonjs/Materials/effect";
  25407. import { Material } from "babylonjs/Materials/material";
  25408. import { Skeleton } from "babylonjs/Bones/skeleton";
  25409. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25410. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25411. import { Path3D } from "babylonjs/Maths/math.path";
  25412. import { Plane } from "babylonjs/Maths/math.plane";
  25413. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25414. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25415. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25416. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25417. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25418. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25419. /**
  25420. * @hidden
  25421. **/
  25422. export class _CreationDataStorage {
  25423. closePath?: boolean;
  25424. closeArray?: boolean;
  25425. idx: number[];
  25426. dashSize: number;
  25427. gapSize: number;
  25428. path3D: Path3D;
  25429. pathArray: Vector3[][];
  25430. arc: number;
  25431. radius: number;
  25432. cap: number;
  25433. tessellation: number;
  25434. }
  25435. /**
  25436. * @hidden
  25437. **/
  25438. class _InstanceDataStorage {
  25439. visibleInstances: any;
  25440. batchCache: _InstancesBatch;
  25441. instancesBufferSize: number;
  25442. instancesBuffer: Nullable<Buffer>;
  25443. instancesData: Float32Array;
  25444. overridenInstanceCount: number;
  25445. isFrozen: boolean;
  25446. previousBatch: Nullable<_InstancesBatch>;
  25447. hardwareInstancedRendering: boolean;
  25448. sideOrientation: number;
  25449. manualUpdate: boolean;
  25450. }
  25451. /**
  25452. * @hidden
  25453. **/
  25454. export class _InstancesBatch {
  25455. mustReturn: boolean;
  25456. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25457. renderSelf: boolean[];
  25458. hardwareInstancedRendering: boolean[];
  25459. }
  25460. /**
  25461. * Class used to represent renderable models
  25462. */
  25463. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25464. /**
  25465. * Mesh side orientation : usually the external or front surface
  25466. */
  25467. static readonly FRONTSIDE: number;
  25468. /**
  25469. * Mesh side orientation : usually the internal or back surface
  25470. */
  25471. static readonly BACKSIDE: number;
  25472. /**
  25473. * Mesh side orientation : both internal and external or front and back surfaces
  25474. */
  25475. static readonly DOUBLESIDE: number;
  25476. /**
  25477. * Mesh side orientation : by default, `FRONTSIDE`
  25478. */
  25479. static readonly DEFAULTSIDE: number;
  25480. /**
  25481. * Mesh cap setting : no cap
  25482. */
  25483. static readonly NO_CAP: number;
  25484. /**
  25485. * Mesh cap setting : one cap at the beginning of the mesh
  25486. */
  25487. static readonly CAP_START: number;
  25488. /**
  25489. * Mesh cap setting : one cap at the end of the mesh
  25490. */
  25491. static readonly CAP_END: number;
  25492. /**
  25493. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25494. */
  25495. static readonly CAP_ALL: number;
  25496. /**
  25497. * Mesh pattern setting : no flip or rotate
  25498. */
  25499. static readonly NO_FLIP: number;
  25500. /**
  25501. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25502. */
  25503. static readonly FLIP_TILE: number;
  25504. /**
  25505. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25506. */
  25507. static readonly ROTATE_TILE: number;
  25508. /**
  25509. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25510. */
  25511. static readonly FLIP_ROW: number;
  25512. /**
  25513. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25514. */
  25515. static readonly ROTATE_ROW: number;
  25516. /**
  25517. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25518. */
  25519. static readonly FLIP_N_ROTATE_TILE: number;
  25520. /**
  25521. * Mesh pattern setting : rotate pattern and rotate
  25522. */
  25523. static readonly FLIP_N_ROTATE_ROW: number;
  25524. /**
  25525. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25526. */
  25527. static readonly CENTER: number;
  25528. /**
  25529. * Mesh tile positioning : part tiles on left
  25530. */
  25531. static readonly LEFT: number;
  25532. /**
  25533. * Mesh tile positioning : part tiles on right
  25534. */
  25535. static readonly RIGHT: number;
  25536. /**
  25537. * Mesh tile positioning : part tiles on top
  25538. */
  25539. static readonly TOP: number;
  25540. /**
  25541. * Mesh tile positioning : part tiles on bottom
  25542. */
  25543. static readonly BOTTOM: number;
  25544. /**
  25545. * Gets the default side orientation.
  25546. * @param orientation the orientation to value to attempt to get
  25547. * @returns the default orientation
  25548. * @hidden
  25549. */
  25550. static _GetDefaultSideOrientation(orientation?: number): number;
  25551. private _internalMeshDataInfo;
  25552. /**
  25553. * An event triggered before rendering the mesh
  25554. */
  25555. get onBeforeRenderObservable(): Observable<Mesh>;
  25556. /**
  25557. * An event triggered before binding the mesh
  25558. */
  25559. get onBeforeBindObservable(): Observable<Mesh>;
  25560. /**
  25561. * An event triggered after rendering the mesh
  25562. */
  25563. get onAfterRenderObservable(): Observable<Mesh>;
  25564. /**
  25565. * An event triggered before drawing the mesh
  25566. */
  25567. get onBeforeDrawObservable(): Observable<Mesh>;
  25568. private _onBeforeDrawObserver;
  25569. /**
  25570. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25571. */
  25572. set onBeforeDraw(callback: () => void);
  25573. get hasInstances(): boolean;
  25574. /**
  25575. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25576. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25577. */
  25578. delayLoadState: number;
  25579. /**
  25580. * Gets the list of instances created from this mesh
  25581. * it is not supposed to be modified manually.
  25582. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25583. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25584. */
  25585. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25586. /**
  25587. * Gets the file containing delay loading data for this mesh
  25588. */
  25589. delayLoadingFile: string;
  25590. /** @hidden */
  25591. _binaryInfo: any;
  25592. /**
  25593. * User defined function used to change how LOD level selection is done
  25594. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25595. */
  25596. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25597. /**
  25598. * Gets or sets the morph target manager
  25599. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25600. */
  25601. get morphTargetManager(): Nullable<MorphTargetManager>;
  25602. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25603. /** @hidden */
  25604. _creationDataStorage: Nullable<_CreationDataStorage>;
  25605. /** @hidden */
  25606. _geometry: Nullable<Geometry>;
  25607. /** @hidden */
  25608. _delayInfo: Array<string>;
  25609. /** @hidden */
  25610. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25611. /** @hidden */
  25612. _instanceDataStorage: _InstanceDataStorage;
  25613. private _effectiveMaterial;
  25614. /** @hidden */
  25615. _shouldGenerateFlatShading: boolean;
  25616. /** @hidden */
  25617. _originalBuilderSideOrientation: number;
  25618. /**
  25619. * Use this property to change the original side orientation defined at construction time
  25620. */
  25621. overrideMaterialSideOrientation: Nullable<number>;
  25622. /**
  25623. * Gets the source mesh (the one used to clone this one from)
  25624. */
  25625. get source(): Nullable<Mesh>;
  25626. /**
  25627. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25628. */
  25629. get isUnIndexed(): boolean;
  25630. set isUnIndexed(value: boolean);
  25631. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25632. get worldMatrixInstancedBuffer(): Float32Array;
  25633. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25634. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25635. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25636. /**
  25637. * @constructor
  25638. * @param name The value used by scene.getMeshByName() to do a lookup.
  25639. * @param scene The scene to add this mesh to.
  25640. * @param parent The parent of this mesh, if it has one
  25641. * @param source An optional Mesh from which geometry is shared, cloned.
  25642. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25643. * When false, achieved by calling a clone(), also passing False.
  25644. * This will make creation of children, recursive.
  25645. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25646. */
  25647. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25648. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25649. doNotInstantiate: boolean;
  25650. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25651. /**
  25652. * Gets the class name
  25653. * @returns the string "Mesh".
  25654. */
  25655. getClassName(): string;
  25656. /** @hidden */
  25657. get _isMesh(): boolean;
  25658. /**
  25659. * Returns a description of this mesh
  25660. * @param fullDetails define if full details about this mesh must be used
  25661. * @returns a descriptive string representing this mesh
  25662. */
  25663. toString(fullDetails?: boolean): string;
  25664. /** @hidden */
  25665. _unBindEffect(): void;
  25666. /**
  25667. * Gets a boolean indicating if this mesh has LOD
  25668. */
  25669. get hasLODLevels(): boolean;
  25670. /**
  25671. * Gets the list of MeshLODLevel associated with the current mesh
  25672. * @returns an array of MeshLODLevel
  25673. */
  25674. getLODLevels(): MeshLODLevel[];
  25675. private _sortLODLevels;
  25676. /**
  25677. * Add a mesh as LOD level triggered at the given distance.
  25678. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25679. * @param distance The distance from the center of the object to show this level
  25680. * @param mesh The mesh to be added as LOD level (can be null)
  25681. * @return This mesh (for chaining)
  25682. */
  25683. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25684. /**
  25685. * Returns the LOD level mesh at the passed distance or null if not found.
  25686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25687. * @param distance The distance from the center of the object to show this level
  25688. * @returns a Mesh or `null`
  25689. */
  25690. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25691. /**
  25692. * Remove a mesh from the LOD array
  25693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25694. * @param mesh defines the mesh to be removed
  25695. * @return This mesh (for chaining)
  25696. */
  25697. removeLODLevel(mesh: Mesh): Mesh;
  25698. /**
  25699. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25700. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25701. * @param camera defines the camera to use to compute distance
  25702. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25703. * @return This mesh (for chaining)
  25704. */
  25705. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25706. /**
  25707. * Gets the mesh internal Geometry object
  25708. */
  25709. get geometry(): Nullable<Geometry>;
  25710. /**
  25711. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25712. * @returns the total number of vertices
  25713. */
  25714. getTotalVertices(): number;
  25715. /**
  25716. * Returns the content of an associated vertex buffer
  25717. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25718. * - VertexBuffer.PositionKind
  25719. * - VertexBuffer.UVKind
  25720. * - VertexBuffer.UV2Kind
  25721. * - VertexBuffer.UV3Kind
  25722. * - VertexBuffer.UV4Kind
  25723. * - VertexBuffer.UV5Kind
  25724. * - VertexBuffer.UV6Kind
  25725. * - VertexBuffer.ColorKind
  25726. * - VertexBuffer.MatricesIndicesKind
  25727. * - VertexBuffer.MatricesIndicesExtraKind
  25728. * - VertexBuffer.MatricesWeightsKind
  25729. * - VertexBuffer.MatricesWeightsExtraKind
  25730. * @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
  25731. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25732. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25733. */
  25734. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25735. /**
  25736. * Returns the mesh VertexBuffer object from the requested `kind`
  25737. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25738. * - VertexBuffer.PositionKind
  25739. * - VertexBuffer.NormalKind
  25740. * - VertexBuffer.UVKind
  25741. * - VertexBuffer.UV2Kind
  25742. * - VertexBuffer.UV3Kind
  25743. * - VertexBuffer.UV4Kind
  25744. * - VertexBuffer.UV5Kind
  25745. * - VertexBuffer.UV6Kind
  25746. * - VertexBuffer.ColorKind
  25747. * - VertexBuffer.MatricesIndicesKind
  25748. * - VertexBuffer.MatricesIndicesExtraKind
  25749. * - VertexBuffer.MatricesWeightsKind
  25750. * - VertexBuffer.MatricesWeightsExtraKind
  25751. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25752. */
  25753. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25754. /**
  25755. * Tests if a specific vertex buffer is associated with this mesh
  25756. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25757. * - VertexBuffer.PositionKind
  25758. * - VertexBuffer.NormalKind
  25759. * - VertexBuffer.UVKind
  25760. * - VertexBuffer.UV2Kind
  25761. * - VertexBuffer.UV3Kind
  25762. * - VertexBuffer.UV4Kind
  25763. * - VertexBuffer.UV5Kind
  25764. * - VertexBuffer.UV6Kind
  25765. * - VertexBuffer.ColorKind
  25766. * - VertexBuffer.MatricesIndicesKind
  25767. * - VertexBuffer.MatricesIndicesExtraKind
  25768. * - VertexBuffer.MatricesWeightsKind
  25769. * - VertexBuffer.MatricesWeightsExtraKind
  25770. * @returns a boolean
  25771. */
  25772. isVerticesDataPresent(kind: string): boolean;
  25773. /**
  25774. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25775. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25776. * - VertexBuffer.PositionKind
  25777. * - VertexBuffer.UVKind
  25778. * - VertexBuffer.UV2Kind
  25779. * - VertexBuffer.UV3Kind
  25780. * - VertexBuffer.UV4Kind
  25781. * - VertexBuffer.UV5Kind
  25782. * - VertexBuffer.UV6Kind
  25783. * - VertexBuffer.ColorKind
  25784. * - VertexBuffer.MatricesIndicesKind
  25785. * - VertexBuffer.MatricesIndicesExtraKind
  25786. * - VertexBuffer.MatricesWeightsKind
  25787. * - VertexBuffer.MatricesWeightsExtraKind
  25788. * @returns a boolean
  25789. */
  25790. isVertexBufferUpdatable(kind: string): boolean;
  25791. /**
  25792. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25793. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25794. * - VertexBuffer.PositionKind
  25795. * - VertexBuffer.NormalKind
  25796. * - VertexBuffer.UVKind
  25797. * - VertexBuffer.UV2Kind
  25798. * - VertexBuffer.UV3Kind
  25799. * - VertexBuffer.UV4Kind
  25800. * - VertexBuffer.UV5Kind
  25801. * - VertexBuffer.UV6Kind
  25802. * - VertexBuffer.ColorKind
  25803. * - VertexBuffer.MatricesIndicesKind
  25804. * - VertexBuffer.MatricesIndicesExtraKind
  25805. * - VertexBuffer.MatricesWeightsKind
  25806. * - VertexBuffer.MatricesWeightsExtraKind
  25807. * @returns an array of strings
  25808. */
  25809. getVerticesDataKinds(): string[];
  25810. /**
  25811. * Returns a positive integer : the total number of indices in this mesh geometry.
  25812. * @returns the numner of indices or zero if the mesh has no geometry.
  25813. */
  25814. getTotalIndices(): number;
  25815. /**
  25816. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25817. * @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.
  25818. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25819. * @returns the indices array or an empty array if the mesh has no geometry
  25820. */
  25821. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25822. get isBlocked(): boolean;
  25823. /**
  25824. * Determine if the current mesh is ready to be rendered
  25825. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25826. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25827. * @returns true if all associated assets are ready (material, textures, shaders)
  25828. */
  25829. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25830. /**
  25831. * 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.
  25832. */
  25833. get areNormalsFrozen(): boolean;
  25834. /**
  25835. * 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.
  25836. * @returns the current mesh
  25837. */
  25838. freezeNormals(): Mesh;
  25839. /**
  25840. * 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
  25841. * @returns the current mesh
  25842. */
  25843. unfreezeNormals(): Mesh;
  25844. /**
  25845. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25846. */
  25847. set overridenInstanceCount(count: number);
  25848. /** @hidden */
  25849. _preActivate(): Mesh;
  25850. /** @hidden */
  25851. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25852. /** @hidden */
  25853. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25854. /**
  25855. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25856. * This means the mesh underlying bounding box and sphere are recomputed.
  25857. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25858. * @returns the current mesh
  25859. */
  25860. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25861. /** @hidden */
  25862. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25863. /**
  25864. * This function will subdivide the mesh into multiple submeshes
  25865. * @param count defines the expected number of submeshes
  25866. */
  25867. subdivide(count: number): void;
  25868. /**
  25869. * Copy a FloatArray into a specific associated vertex buffer
  25870. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25871. * - VertexBuffer.PositionKind
  25872. * - VertexBuffer.UVKind
  25873. * - VertexBuffer.UV2Kind
  25874. * - VertexBuffer.UV3Kind
  25875. * - VertexBuffer.UV4Kind
  25876. * - VertexBuffer.UV5Kind
  25877. * - VertexBuffer.UV6Kind
  25878. * - VertexBuffer.ColorKind
  25879. * - VertexBuffer.MatricesIndicesKind
  25880. * - VertexBuffer.MatricesIndicesExtraKind
  25881. * - VertexBuffer.MatricesWeightsKind
  25882. * - VertexBuffer.MatricesWeightsExtraKind
  25883. * @param data defines the data source
  25884. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25885. * @param stride defines the data stride size (can be null)
  25886. * @returns the current mesh
  25887. */
  25888. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25889. /**
  25890. * Delete a vertex buffer associated with this mesh
  25891. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25892. * - VertexBuffer.PositionKind
  25893. * - VertexBuffer.UVKind
  25894. * - VertexBuffer.UV2Kind
  25895. * - VertexBuffer.UV3Kind
  25896. * - VertexBuffer.UV4Kind
  25897. * - VertexBuffer.UV5Kind
  25898. * - VertexBuffer.UV6Kind
  25899. * - VertexBuffer.ColorKind
  25900. * - VertexBuffer.MatricesIndicesKind
  25901. * - VertexBuffer.MatricesIndicesExtraKind
  25902. * - VertexBuffer.MatricesWeightsKind
  25903. * - VertexBuffer.MatricesWeightsExtraKind
  25904. */
  25905. removeVerticesData(kind: string): void;
  25906. /**
  25907. * Flags an associated vertex buffer as updatable
  25908. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25909. * - VertexBuffer.PositionKind
  25910. * - VertexBuffer.UVKind
  25911. * - VertexBuffer.UV2Kind
  25912. * - VertexBuffer.UV3Kind
  25913. * - VertexBuffer.UV4Kind
  25914. * - VertexBuffer.UV5Kind
  25915. * - VertexBuffer.UV6Kind
  25916. * - VertexBuffer.ColorKind
  25917. * - VertexBuffer.MatricesIndicesKind
  25918. * - VertexBuffer.MatricesIndicesExtraKind
  25919. * - VertexBuffer.MatricesWeightsKind
  25920. * - VertexBuffer.MatricesWeightsExtraKind
  25921. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25922. */
  25923. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25924. /**
  25925. * Sets the mesh global Vertex Buffer
  25926. * @param buffer defines the buffer to use
  25927. * @returns the current mesh
  25928. */
  25929. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25930. /**
  25931. * Update a specific associated vertex buffer
  25932. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25933. * - VertexBuffer.PositionKind
  25934. * - VertexBuffer.UVKind
  25935. * - VertexBuffer.UV2Kind
  25936. * - VertexBuffer.UV3Kind
  25937. * - VertexBuffer.UV4Kind
  25938. * - VertexBuffer.UV5Kind
  25939. * - VertexBuffer.UV6Kind
  25940. * - VertexBuffer.ColorKind
  25941. * - VertexBuffer.MatricesIndicesKind
  25942. * - VertexBuffer.MatricesIndicesExtraKind
  25943. * - VertexBuffer.MatricesWeightsKind
  25944. * - VertexBuffer.MatricesWeightsExtraKind
  25945. * @param data defines the data source
  25946. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25947. * @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)
  25948. * @returns the current mesh
  25949. */
  25950. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25951. /**
  25952. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25953. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25954. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25955. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25956. * @returns the current mesh
  25957. */
  25958. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25959. /**
  25960. * Creates a un-shared specific occurence of the geometry for the mesh.
  25961. * @returns the current mesh
  25962. */
  25963. makeGeometryUnique(): Mesh;
  25964. /**
  25965. * Set the index buffer of this mesh
  25966. * @param indices defines the source data
  25967. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25968. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25969. * @returns the current mesh
  25970. */
  25971. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25972. /**
  25973. * Update the current index buffer
  25974. * @param indices defines the source data
  25975. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25976. * @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)
  25977. * @returns the current mesh
  25978. */
  25979. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25980. /**
  25981. * Invert the geometry to move from a right handed system to a left handed one.
  25982. * @returns the current mesh
  25983. */
  25984. toLeftHanded(): Mesh;
  25985. /** @hidden */
  25986. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25987. /** @hidden */
  25988. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25989. /**
  25990. * Registers for this mesh a javascript function called just before the rendering process
  25991. * @param func defines the function to call before rendering this mesh
  25992. * @returns the current mesh
  25993. */
  25994. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25995. /**
  25996. * Disposes a previously registered javascript function called before the rendering
  25997. * @param func defines the function to remove
  25998. * @returns the current mesh
  25999. */
  26000. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26001. /**
  26002. * Registers for this mesh a javascript function called just after the rendering is complete
  26003. * @param func defines the function to call after rendering this mesh
  26004. * @returns the current mesh
  26005. */
  26006. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26007. /**
  26008. * Disposes a previously registered javascript function called after the rendering.
  26009. * @param func defines the function to remove
  26010. * @returns the current mesh
  26011. */
  26012. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26013. /** @hidden */
  26014. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  26015. /** @hidden */
  26016. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26017. /** @hidden */
  26018. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  26019. /** @hidden */
  26020. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26021. /** @hidden */
  26022. _rebuild(): void;
  26023. /** @hidden */
  26024. _freeze(): void;
  26025. /** @hidden */
  26026. _unFreeze(): void;
  26027. /**
  26028. * 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
  26029. * @param subMesh defines the subMesh to render
  26030. * @param enableAlphaMode defines if alpha mode can be changed
  26031. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  26032. * @returns the current mesh
  26033. */
  26034. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  26035. private _onBeforeDraw;
  26036. /**
  26037. * Renormalize the mesh and patch it up if there are no weights
  26038. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26039. * However in the case of zero weights then we set just a single influence to 1.
  26040. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26041. */
  26042. cleanMatrixWeights(): void;
  26043. private normalizeSkinFourWeights;
  26044. private normalizeSkinWeightsAndExtra;
  26045. /**
  26046. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26047. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26048. * the user know there was an issue with importing the mesh
  26049. * @returns a validation object with skinned, valid and report string
  26050. */
  26051. validateSkinning(): {
  26052. skinned: boolean;
  26053. valid: boolean;
  26054. report: string;
  26055. };
  26056. /** @hidden */
  26057. _checkDelayState(): Mesh;
  26058. private _queueLoad;
  26059. /**
  26060. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26061. * A mesh is in the frustum if its bounding box intersects the frustum
  26062. * @param frustumPlanes defines the frustum to test
  26063. * @returns true if the mesh is in the frustum planes
  26064. */
  26065. isInFrustum(frustumPlanes: Plane[]): boolean;
  26066. /**
  26067. * Sets the mesh material by the material or multiMaterial `id` property
  26068. * @param id is a string identifying the material or the multiMaterial
  26069. * @returns the current mesh
  26070. */
  26071. setMaterialByID(id: string): Mesh;
  26072. /**
  26073. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26074. * @returns an array of IAnimatable
  26075. */
  26076. getAnimatables(): IAnimatable[];
  26077. /**
  26078. * Modifies the mesh geometry according to the passed transformation matrix.
  26079. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26080. * The mesh normals are modified using the same transformation.
  26081. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26082. * @param transform defines the transform matrix to use
  26083. * @see http://doc.babylonjs.com/resources/baking_transformations
  26084. * @returns the current mesh
  26085. */
  26086. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26087. /**
  26088. * Modifies the mesh geometry according to its own current World Matrix.
  26089. * The mesh World Matrix is then reset.
  26090. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26091. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26092. * @see http://doc.babylonjs.com/resources/baking_transformations
  26093. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  26094. * @returns the current mesh
  26095. */
  26096. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  26097. /** @hidden */
  26098. get _positions(): Nullable<Vector3[]>;
  26099. /** @hidden */
  26100. _resetPointsArrayCache(): Mesh;
  26101. /** @hidden */
  26102. _generatePointsArray(): boolean;
  26103. /**
  26104. * Returns a new Mesh object generated from the current mesh properties.
  26105. * This method must not get confused with createInstance()
  26106. * @param name is a string, the name given to the new mesh
  26107. * @param newParent can be any Node object (default `null`)
  26108. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26109. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26110. * @returns a new mesh
  26111. */
  26112. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26113. /**
  26114. * Releases resources associated with this mesh.
  26115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26117. */
  26118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26119. /** @hidden */
  26120. _disposeInstanceSpecificData(): void;
  26121. /**
  26122. * Modifies the mesh geometry according to a displacement map.
  26123. * 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.
  26124. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26125. * @param url is a string, the URL from the image file is to be downloaded.
  26126. * @param minHeight is the lower limit of the displacement.
  26127. * @param maxHeight is the upper limit of the displacement.
  26128. * @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.
  26129. * @param uvOffset is an optional vector2 used to offset UV.
  26130. * @param uvScale is an optional vector2 used to scale UV.
  26131. * @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.
  26132. * @returns the Mesh.
  26133. */
  26134. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26135. /**
  26136. * Modifies the mesh geometry according to a displacementMap buffer.
  26137. * 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.
  26138. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26139. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26140. * @param heightMapWidth is the width of the buffer image.
  26141. * @param heightMapHeight is the height of the buffer image.
  26142. * @param minHeight is the lower limit of the displacement.
  26143. * @param maxHeight is the upper limit of the displacement.
  26144. * @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.
  26145. * @param uvOffset is an optional vector2 used to offset UV.
  26146. * @param uvScale is an optional vector2 used to scale UV.
  26147. * @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.
  26148. * @returns the Mesh.
  26149. */
  26150. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26151. /**
  26152. * Modify the mesh to get a flat shading rendering.
  26153. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26154. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26155. * @returns current mesh
  26156. */
  26157. convertToFlatShadedMesh(): Mesh;
  26158. /**
  26159. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26160. * In other words, more vertices, no more indices and a single bigger VBO.
  26161. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26162. * @returns current mesh
  26163. */
  26164. convertToUnIndexedMesh(): Mesh;
  26165. /**
  26166. * Inverses facet orientations.
  26167. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26168. * @param flipNormals will also inverts the normals
  26169. * @returns current mesh
  26170. */
  26171. flipFaces(flipNormals?: boolean): Mesh;
  26172. /**
  26173. * Increase the number of facets and hence vertices in a mesh
  26174. * Vertex normals are interpolated from existing vertex normals
  26175. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26176. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  26177. */
  26178. increaseVertices(numberPerEdge: number): void;
  26179. /**
  26180. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  26181. * This will undo any application of covertToFlatShadedMesh
  26182. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26183. */
  26184. forceSharedVertices(): void;
  26185. /** @hidden */
  26186. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  26187. /** @hidden */
  26188. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  26189. /**
  26190. * Creates a new InstancedMesh object from the mesh model.
  26191. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26192. * @param name defines the name of the new instance
  26193. * @returns a new InstancedMesh
  26194. */
  26195. createInstance(name: string): InstancedMesh;
  26196. /**
  26197. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26198. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26199. * @returns the current mesh
  26200. */
  26201. synchronizeInstances(): Mesh;
  26202. /**
  26203. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26204. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26205. * This should be used together with the simplification to avoid disappearing triangles.
  26206. * @param successCallback an optional success callback to be called after the optimization finished.
  26207. * @returns the current mesh
  26208. */
  26209. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26210. /**
  26211. * Serialize current mesh
  26212. * @param serializationObject defines the object which will receive the serialization data
  26213. */
  26214. serialize(serializationObject: any): void;
  26215. /** @hidden */
  26216. _syncGeometryWithMorphTargetManager(): void;
  26217. /** @hidden */
  26218. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  26219. /**
  26220. * Returns a new Mesh object parsed from the source provided.
  26221. * @param parsedMesh is the source
  26222. * @param scene defines the hosting scene
  26223. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26224. * @returns a new Mesh
  26225. */
  26226. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26227. /**
  26228. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26229. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26230. * @param name defines the name of the mesh to create
  26231. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26232. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26233. * @param closePath creates a seam between the first and the last points of each path of the path array
  26234. * @param offset is taken in account only if the `pathArray` is containing a single path
  26235. * @param scene defines the hosting scene
  26236. * @param updatable defines if the mesh must be flagged as updatable
  26237. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26238. * @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)
  26239. * @returns a new Mesh
  26240. */
  26241. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26242. /**
  26243. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26244. * @param name defines the name of the mesh to create
  26245. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26246. * @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
  26247. * @param scene defines the hosting scene
  26248. * @param updatable defines if the mesh must be flagged as updatable
  26249. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26250. * @returns a new Mesh
  26251. */
  26252. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26253. /**
  26254. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26255. * @param name defines the name of the mesh to create
  26256. * @param size sets the size (float) of each box side (default 1)
  26257. * @param scene defines the hosting scene
  26258. * @param updatable defines if the mesh must be flagged as updatable
  26259. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26260. * @returns a new Mesh
  26261. */
  26262. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26263. /**
  26264. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26265. * @param name defines the name of the mesh to create
  26266. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26267. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26268. * @param scene defines the hosting scene
  26269. * @param updatable defines if the mesh must be flagged as updatable
  26270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26271. * @returns a new Mesh
  26272. */
  26273. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26274. /**
  26275. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26276. * @param name defines the name of the mesh to create
  26277. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26278. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26279. * @param scene defines the hosting scene
  26280. * @returns a new Mesh
  26281. */
  26282. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26283. /**
  26284. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26285. * @param name defines the name of the mesh to create
  26286. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26287. * @param diameterTop set the top cap diameter (floats, default 1)
  26288. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26289. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26290. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26291. * @param scene defines the hosting scene
  26292. * @param updatable defines if the mesh must be flagged as updatable
  26293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26294. * @returns a new Mesh
  26295. */
  26296. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26297. /**
  26298. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26299. * @param name defines the name of the mesh to create
  26300. * @param diameter sets the diameter size (float) of the torus (default 1)
  26301. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26302. * @param tessellation sets the number of torus sides (postive integer, default 16)
  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 CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26309. /**
  26310. * Creates a torus knot 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 radius sets the global radius size (float) of the torus knot (default 2)
  26313. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26314. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26315. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26316. * @param p the number of windings on X axis (positive integers, default 2)
  26317. * @param q the number of windings on Y axis (positive integers, default 3)
  26318. * @param scene defines the hosting scene
  26319. * @param updatable defines if the mesh must be flagged as updatable
  26320. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26321. * @returns a new Mesh
  26322. */
  26323. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26324. /**
  26325. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26326. * @param name defines the name of the mesh to create
  26327. * @param points is an array successive Vector3
  26328. * @param scene defines the hosting scene
  26329. * @param updatable defines if the mesh must be flagged as updatable
  26330. * @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).
  26331. * @returns a new Mesh
  26332. */
  26333. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26334. /**
  26335. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26336. * @param name defines the name of the mesh to create
  26337. * @param points is an array successive Vector3
  26338. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26339. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26340. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26341. * @param scene defines the hosting scene
  26342. * @param updatable defines if the mesh must be flagged as updatable
  26343. * @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)
  26344. * @returns a new Mesh
  26345. */
  26346. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26347. /**
  26348. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26349. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26350. * 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.
  26351. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26352. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26353. * Remember you can only change the shape positions, not their number when updating a polygon.
  26354. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26355. * @param name defines the name of the mesh to create
  26356. * @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
  26357. * @param scene defines the hosting scene
  26358. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26359. * @param updatable defines if the mesh must be flagged as updatable
  26360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26361. * @param earcutInjection can be used to inject your own earcut reference
  26362. * @returns a new Mesh
  26363. */
  26364. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26365. /**
  26366. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26367. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26368. * @param name defines the name of the mesh to create
  26369. * @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
  26370. * @param depth defines the height of extrusion
  26371. * @param scene defines the hosting scene
  26372. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26373. * @param updatable defines if the mesh must be flagged as updatable
  26374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26375. * @param earcutInjection can be used to inject your own earcut reference
  26376. * @returns a new Mesh
  26377. */
  26378. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26379. /**
  26380. * Creates an extruded shape mesh.
  26381. * 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
  26382. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26383. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26384. * @param name defines the name of the mesh to create
  26385. * @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
  26386. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26387. * @param scale is the value to scale the shape
  26388. * @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
  26389. * @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
  26390. * @param scene defines the hosting scene
  26391. * @param updatable defines if the mesh must be flagged as updatable
  26392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26393. * @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)
  26394. * @returns a new Mesh
  26395. */
  26396. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26397. /**
  26398. * Creates an custom extruded shape mesh.
  26399. * The custom extrusion is a parametric shape.
  26400. * It has no predefined shape. Its final shape will depend on the input parameters.
  26401. * Please consider using the same method from the MeshBuilder class instead
  26402. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26403. * @param name defines the name of the mesh to create
  26404. * @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
  26405. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26406. * @param scaleFunction is a custom Javascript function called on each path point
  26407. * @param rotationFunction is a custom Javascript function called on each path point
  26408. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26409. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26410. * @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
  26411. * @param scene defines the hosting scene
  26412. * @param updatable defines if the mesh must be flagged as updatable
  26413. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26414. * @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)
  26415. * @returns a new Mesh
  26416. */
  26417. 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;
  26418. /**
  26419. * Creates lathe mesh.
  26420. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26421. * Please consider using the same method from the MeshBuilder class instead
  26422. * @param name defines the name of the mesh to create
  26423. * @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
  26424. * @param radius is the radius value of the lathe
  26425. * @param tessellation is the side number of the lathe.
  26426. * @param scene defines the hosting scene
  26427. * @param updatable defines if the mesh must be flagged as updatable
  26428. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26429. * @returns a new Mesh
  26430. */
  26431. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26432. /**
  26433. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26434. * @param name defines the name of the mesh to create
  26435. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26436. * @param scene defines the hosting scene
  26437. * @param updatable defines if the mesh must be flagged as updatable
  26438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26439. * @returns a new Mesh
  26440. */
  26441. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26442. /**
  26443. * Creates a ground mesh.
  26444. * Please consider using the same method from the MeshBuilder class instead
  26445. * @param name defines the name of the mesh to create
  26446. * @param width set the width of the ground
  26447. * @param height set the height of the ground
  26448. * @param subdivisions sets the number of subdivisions per side
  26449. * @param scene defines the hosting scene
  26450. * @param updatable defines if the mesh must be flagged as updatable
  26451. * @returns a new Mesh
  26452. */
  26453. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26454. /**
  26455. * Creates a tiled ground mesh.
  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 xmin set the ground minimum X coordinate
  26459. * @param zmin set the ground minimum Y coordinate
  26460. * @param xmax set the ground maximum X coordinate
  26461. * @param zmax set the ground maximum Z coordinate
  26462. * @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
  26463. * @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
  26464. * @param scene defines the hosting scene
  26465. * @param updatable defines if the mesh must be flagged as updatable
  26466. * @returns a new Mesh
  26467. */
  26468. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26469. w: number;
  26470. h: number;
  26471. }, precision: {
  26472. w: number;
  26473. h: number;
  26474. }, scene: Scene, updatable?: boolean): Mesh;
  26475. /**
  26476. * Creates a ground mesh from a height map.
  26477. * Please consider using the same method from the MeshBuilder class instead
  26478. * @see http://doc.babylonjs.com/babylon101/height_map
  26479. * @param name defines the name of the mesh to create
  26480. * @param url sets the URL of the height map image resource
  26481. * @param width set the ground width size
  26482. * @param height set the ground height size
  26483. * @param subdivisions sets the number of subdivision per side
  26484. * @param minHeight is the minimum altitude on the ground
  26485. * @param maxHeight is the maximum altitude on the ground
  26486. * @param scene defines the hosting scene
  26487. * @param updatable defines if the mesh must be flagged as updatable
  26488. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26489. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26490. * @returns a new Mesh
  26491. */
  26492. 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;
  26493. /**
  26494. * Creates a tube mesh.
  26495. * The tube is a parametric shape.
  26496. * It has no predefined shape. Its final shape will depend on the input parameters.
  26497. * Please consider using the same method from the MeshBuilder class instead
  26498. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26499. * @param name defines the name of the mesh to create
  26500. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26501. * @param radius sets the tube radius size
  26502. * @param tessellation is the number of sides on the tubular surface
  26503. * @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
  26504. * @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
  26505. * @param scene defines the hosting scene
  26506. * @param updatable defines if the mesh must be flagged as updatable
  26507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26508. * @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)
  26509. * @returns a new Mesh
  26510. */
  26511. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26512. (i: number, distance: number): number;
  26513. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26514. /**
  26515. * Creates a polyhedron mesh.
  26516. * Please consider using the same method from the MeshBuilder class instead.
  26517. * * 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
  26518. * * The parameter `size` (positive float, default 1) sets the polygon size
  26519. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26520. * * 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`
  26521. * * 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
  26522. * * 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)`)
  26523. * * 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
  26524. * * 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
  26525. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26526. * * 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
  26527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26528. * @param name defines the name of the mesh to create
  26529. * @param options defines the options used to create the mesh
  26530. * @param scene defines the hosting scene
  26531. * @returns a new Mesh
  26532. */
  26533. static CreatePolyhedron(name: string, options: {
  26534. type?: number;
  26535. size?: number;
  26536. sizeX?: number;
  26537. sizeY?: number;
  26538. sizeZ?: number;
  26539. custom?: any;
  26540. faceUV?: Vector4[];
  26541. faceColors?: Color4[];
  26542. updatable?: boolean;
  26543. sideOrientation?: number;
  26544. }, scene: Scene): Mesh;
  26545. /**
  26546. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26547. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26548. * * 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`)
  26549. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26550. * * 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
  26551. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26552. * * 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
  26553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26554. * @param name defines the name of the mesh
  26555. * @param options defines the options used to create the mesh
  26556. * @param scene defines the hosting scene
  26557. * @returns a new Mesh
  26558. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26559. */
  26560. static CreateIcoSphere(name: string, options: {
  26561. radius?: number;
  26562. flat?: boolean;
  26563. subdivisions?: number;
  26564. sideOrientation?: number;
  26565. updatable?: boolean;
  26566. }, scene: Scene): Mesh;
  26567. /**
  26568. * Creates a decal mesh.
  26569. * Please consider using the same method from the MeshBuilder class instead.
  26570. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26571. * @param name defines the name of the mesh
  26572. * @param sourceMesh defines the mesh receiving the decal
  26573. * @param position sets the position of the decal in world coordinates
  26574. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26575. * @param size sets the decal scaling
  26576. * @param angle sets the angle to rotate the decal
  26577. * @returns a new Mesh
  26578. */
  26579. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26580. /**
  26581. * Prepare internal position array for software CPU skinning
  26582. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26583. */
  26584. setPositionsForCPUSkinning(): Float32Array;
  26585. /**
  26586. * Prepare internal normal array for software CPU skinning
  26587. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26588. */
  26589. setNormalsForCPUSkinning(): Float32Array;
  26590. /**
  26591. * Updates the vertex buffer by applying transformation from the bones
  26592. * @param skeleton defines the skeleton to apply to current mesh
  26593. * @returns the current mesh
  26594. */
  26595. applySkeleton(skeleton: Skeleton): Mesh;
  26596. /**
  26597. * 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
  26598. * @param meshes defines the list of meshes to scan
  26599. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26600. */
  26601. static MinMax(meshes: AbstractMesh[]): {
  26602. min: Vector3;
  26603. max: Vector3;
  26604. };
  26605. /**
  26606. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26607. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26608. * @returns a vector3
  26609. */
  26610. static Center(meshesOrMinMaxVector: {
  26611. min: Vector3;
  26612. max: Vector3;
  26613. } | AbstractMesh[]): Vector3;
  26614. /**
  26615. * Merge the array of meshes into a single mesh for performance reasons.
  26616. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26617. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26618. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26619. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26620. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26621. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26622. * @returns a new mesh
  26623. */
  26624. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26625. /** @hidden */
  26626. addInstance(instance: InstancedMesh): void;
  26627. /** @hidden */
  26628. removeInstance(instance: InstancedMesh): void;
  26629. }
  26630. }
  26631. declare module "babylonjs/Cameras/camera" {
  26632. import { SmartArray } from "babylonjs/Misc/smartArray";
  26633. import { Observable } from "babylonjs/Misc/observable";
  26634. import { Nullable } from "babylonjs/types";
  26635. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26636. import { Scene } from "babylonjs/scene";
  26637. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26638. import { Node } from "babylonjs/node";
  26639. import { Mesh } from "babylonjs/Meshes/mesh";
  26640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26641. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26642. import { Viewport } from "babylonjs/Maths/math.viewport";
  26643. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26644. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26645. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26646. import { Ray } from "babylonjs/Culling/ray";
  26647. /**
  26648. * This is the base class of all the camera used in the application.
  26649. * @see http://doc.babylonjs.com/features/cameras
  26650. */
  26651. export class Camera extends Node {
  26652. /** @hidden */
  26653. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26654. /**
  26655. * This is the default projection mode used by the cameras.
  26656. * It helps recreating a feeling of perspective and better appreciate depth.
  26657. * This is the best way to simulate real life cameras.
  26658. */
  26659. static readonly PERSPECTIVE_CAMERA: number;
  26660. /**
  26661. * This helps creating camera with an orthographic mode.
  26662. * 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.
  26663. */
  26664. static readonly ORTHOGRAPHIC_CAMERA: number;
  26665. /**
  26666. * This is the default FOV mode for perspective cameras.
  26667. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26668. */
  26669. static readonly FOVMODE_VERTICAL_FIXED: number;
  26670. /**
  26671. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26672. */
  26673. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26674. /**
  26675. * This specifies ther is no need for a camera rig.
  26676. * Basically only one eye is rendered corresponding to the camera.
  26677. */
  26678. static readonly RIG_MODE_NONE: number;
  26679. /**
  26680. * Simulates a camera Rig with one blue eye and one red eye.
  26681. * This can be use with 3d blue and red glasses.
  26682. */
  26683. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26684. /**
  26685. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26686. */
  26687. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26688. /**
  26689. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26690. */
  26691. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26692. /**
  26693. * Defines that both eyes of the camera will be rendered over under each other.
  26694. */
  26695. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26696. /**
  26697. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26698. */
  26699. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26700. /**
  26701. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26702. */
  26703. static readonly RIG_MODE_VR: number;
  26704. /**
  26705. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26706. */
  26707. static readonly RIG_MODE_WEBVR: number;
  26708. /**
  26709. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26710. */
  26711. static readonly RIG_MODE_CUSTOM: number;
  26712. /**
  26713. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26714. */
  26715. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26716. /**
  26717. * Define the input manager associated with the camera.
  26718. */
  26719. inputs: CameraInputsManager<Camera>;
  26720. /** @hidden */
  26721. _position: Vector3;
  26722. /**
  26723. * Define the current local position of the camera in the scene
  26724. */
  26725. get position(): Vector3;
  26726. set position(newPosition: Vector3);
  26727. /**
  26728. * The vector the camera should consider as up.
  26729. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26730. */
  26731. upVector: Vector3;
  26732. /**
  26733. * Define the current limit on the left side for an orthographic camera
  26734. * In scene unit
  26735. */
  26736. orthoLeft: Nullable<number>;
  26737. /**
  26738. * Define the current limit on the right side for an orthographic camera
  26739. * In scene unit
  26740. */
  26741. orthoRight: Nullable<number>;
  26742. /**
  26743. * Define the current limit on the bottom side for an orthographic camera
  26744. * In scene unit
  26745. */
  26746. orthoBottom: Nullable<number>;
  26747. /**
  26748. * Define the current limit on the top side for an orthographic camera
  26749. * In scene unit
  26750. */
  26751. orthoTop: Nullable<number>;
  26752. /**
  26753. * Field Of View is set in Radians. (default is 0.8)
  26754. */
  26755. fov: number;
  26756. /**
  26757. * Define the minimum distance the camera can see from.
  26758. * This is important to note that the depth buffer are not infinite and the closer it starts
  26759. * the more your scene might encounter depth fighting issue.
  26760. */
  26761. minZ: number;
  26762. /**
  26763. * Define the maximum distance the camera can see to.
  26764. * This is important to note that the depth buffer are not infinite and the further it end
  26765. * the more your scene might encounter depth fighting issue.
  26766. */
  26767. maxZ: number;
  26768. /**
  26769. * Define the default inertia of the camera.
  26770. * This helps giving a smooth feeling to the camera movement.
  26771. */
  26772. inertia: number;
  26773. /**
  26774. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26775. */
  26776. mode: number;
  26777. /**
  26778. * Define whether the camera is intermediate.
  26779. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26780. */
  26781. isIntermediate: boolean;
  26782. /**
  26783. * Define the viewport of the camera.
  26784. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26785. */
  26786. viewport: Viewport;
  26787. /**
  26788. * Restricts the camera to viewing objects with the same layerMask.
  26789. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26790. */
  26791. layerMask: number;
  26792. /**
  26793. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26794. */
  26795. fovMode: number;
  26796. /**
  26797. * Rig mode of the camera.
  26798. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26799. * This is normally controlled byt the camera themselves as internal use.
  26800. */
  26801. cameraRigMode: number;
  26802. /**
  26803. * Defines the distance between both "eyes" in case of a RIG
  26804. */
  26805. interaxialDistance: number;
  26806. /**
  26807. * Defines if stereoscopic rendering is done side by side or over under.
  26808. */
  26809. isStereoscopicSideBySide: boolean;
  26810. /**
  26811. * 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
  26812. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26813. * else in the scene. (Eg. security camera)
  26814. *
  26815. * 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)
  26816. */
  26817. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26818. /**
  26819. * When set, the camera will render to this render target instead of the default canvas
  26820. *
  26821. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26822. */
  26823. outputRenderTarget: Nullable<RenderTargetTexture>;
  26824. /**
  26825. * Observable triggered when the camera view matrix has changed.
  26826. */
  26827. onViewMatrixChangedObservable: Observable<Camera>;
  26828. /**
  26829. * Observable triggered when the camera Projection matrix has changed.
  26830. */
  26831. onProjectionMatrixChangedObservable: Observable<Camera>;
  26832. /**
  26833. * Observable triggered when the inputs have been processed.
  26834. */
  26835. onAfterCheckInputsObservable: Observable<Camera>;
  26836. /**
  26837. * Observable triggered when reset has been called and applied to the camera.
  26838. */
  26839. onRestoreStateObservable: Observable<Camera>;
  26840. /**
  26841. * Is this camera a part of a rig system?
  26842. */
  26843. isRigCamera: boolean;
  26844. /**
  26845. * If isRigCamera set to true this will be set with the parent camera.
  26846. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26847. */
  26848. rigParent?: Camera;
  26849. /** @hidden */
  26850. _cameraRigParams: any;
  26851. /** @hidden */
  26852. _rigCameras: Camera[];
  26853. /** @hidden */
  26854. _rigPostProcess: Nullable<PostProcess>;
  26855. protected _webvrViewMatrix: Matrix;
  26856. /** @hidden */
  26857. _skipRendering: boolean;
  26858. /** @hidden */
  26859. _projectionMatrix: Matrix;
  26860. /** @hidden */
  26861. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26862. /** @hidden */
  26863. _activeMeshes: SmartArray<AbstractMesh>;
  26864. protected _globalPosition: Vector3;
  26865. /** @hidden */
  26866. _computedViewMatrix: Matrix;
  26867. private _doNotComputeProjectionMatrix;
  26868. private _transformMatrix;
  26869. private _frustumPlanes;
  26870. private _refreshFrustumPlanes;
  26871. private _storedFov;
  26872. private _stateStored;
  26873. /**
  26874. * Instantiates a new camera object.
  26875. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26876. * @see http://doc.babylonjs.com/features/cameras
  26877. * @param name Defines the name of the camera in the scene
  26878. * @param position Defines the position of the camera
  26879. * @param scene Defines the scene the camera belongs too
  26880. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26881. */
  26882. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26883. /**
  26884. * Store current camera state (fov, position, etc..)
  26885. * @returns the camera
  26886. */
  26887. storeState(): Camera;
  26888. /**
  26889. * Restores the camera state values if it has been stored. You must call storeState() first
  26890. */
  26891. protected _restoreStateValues(): boolean;
  26892. /**
  26893. * Restored camera state. You must call storeState() first.
  26894. * @returns true if restored and false otherwise
  26895. */
  26896. restoreState(): boolean;
  26897. /**
  26898. * Gets the class name of the camera.
  26899. * @returns the class name
  26900. */
  26901. getClassName(): string;
  26902. /** @hidden */
  26903. readonly _isCamera: boolean;
  26904. /**
  26905. * Gets a string representation of the camera useful for debug purpose.
  26906. * @param fullDetails Defines that a more verboe level of logging is required
  26907. * @returns the string representation
  26908. */
  26909. toString(fullDetails?: boolean): string;
  26910. /**
  26911. * Gets the current world space position of the camera.
  26912. */
  26913. get globalPosition(): Vector3;
  26914. /**
  26915. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26916. * @returns the active meshe list
  26917. */
  26918. getActiveMeshes(): SmartArray<AbstractMesh>;
  26919. /**
  26920. * Check whether a mesh is part of the current active mesh list of the camera
  26921. * @param mesh Defines the mesh to check
  26922. * @returns true if active, false otherwise
  26923. */
  26924. isActiveMesh(mesh: Mesh): boolean;
  26925. /**
  26926. * Is this camera ready to be used/rendered
  26927. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26928. * @return true if the camera is ready
  26929. */
  26930. isReady(completeCheck?: boolean): boolean;
  26931. /** @hidden */
  26932. _initCache(): void;
  26933. /** @hidden */
  26934. _updateCache(ignoreParentClass?: boolean): void;
  26935. /** @hidden */
  26936. _isSynchronized(): boolean;
  26937. /** @hidden */
  26938. _isSynchronizedViewMatrix(): boolean;
  26939. /** @hidden */
  26940. _isSynchronizedProjectionMatrix(): boolean;
  26941. /**
  26942. * Attach the input controls to a specific dom element to get the input from.
  26943. * @param element Defines the element the controls should be listened from
  26944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26945. */
  26946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26947. /**
  26948. * Detach the current controls from the specified dom element.
  26949. * @param element Defines the element to stop listening the inputs from
  26950. */
  26951. detachControl(element: HTMLElement): void;
  26952. /**
  26953. * Update the camera state according to the different inputs gathered during the frame.
  26954. */
  26955. update(): void;
  26956. /** @hidden */
  26957. _checkInputs(): void;
  26958. /** @hidden */
  26959. get rigCameras(): Camera[];
  26960. /**
  26961. * Gets the post process used by the rig cameras
  26962. */
  26963. get rigPostProcess(): Nullable<PostProcess>;
  26964. /**
  26965. * Internal, gets the first post proces.
  26966. * @returns the first post process to be run on this camera.
  26967. */
  26968. _getFirstPostProcess(): Nullable<PostProcess>;
  26969. private _cascadePostProcessesToRigCams;
  26970. /**
  26971. * Attach a post process to the camera.
  26972. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26973. * @param postProcess The post process to attach to the camera
  26974. * @param insertAt The position of the post process in case several of them are in use in the scene
  26975. * @returns the position the post process has been inserted at
  26976. */
  26977. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26978. /**
  26979. * Detach a post process to the camera.
  26980. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26981. * @param postProcess The post process to detach from the camera
  26982. */
  26983. detachPostProcess(postProcess: PostProcess): void;
  26984. /**
  26985. * Gets the current world matrix of the camera
  26986. */
  26987. getWorldMatrix(): Matrix;
  26988. /** @hidden */
  26989. _getViewMatrix(): Matrix;
  26990. /**
  26991. * Gets the current view matrix of the camera.
  26992. * @param force forces the camera to recompute the matrix without looking at the cached state
  26993. * @returns the view matrix
  26994. */
  26995. getViewMatrix(force?: boolean): Matrix;
  26996. /**
  26997. * Freeze the projection matrix.
  26998. * It will prevent the cache check of the camera projection compute and can speed up perf
  26999. * if no parameter of the camera are meant to change
  27000. * @param projection Defines manually a projection if necessary
  27001. */
  27002. freezeProjectionMatrix(projection?: Matrix): void;
  27003. /**
  27004. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  27005. */
  27006. unfreezeProjectionMatrix(): void;
  27007. /**
  27008. * Gets the current projection matrix of the camera.
  27009. * @param force forces the camera to recompute the matrix without looking at the cached state
  27010. * @returns the projection matrix
  27011. */
  27012. getProjectionMatrix(force?: boolean): Matrix;
  27013. /**
  27014. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  27015. * @returns a Matrix
  27016. */
  27017. getTransformationMatrix(): Matrix;
  27018. private _updateFrustumPlanes;
  27019. /**
  27020. * Checks if a cullable object (mesh...) is in the camera frustum
  27021. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  27022. * @param target The object to check
  27023. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  27024. * @returns true if the object is in frustum otherwise false
  27025. */
  27026. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  27027. /**
  27028. * Checks if a cullable object (mesh...) is in the camera frustum
  27029. * Unlike isInFrustum this cheks the full bounding box
  27030. * @param target The object to check
  27031. * @returns true if the object is in frustum otherwise false
  27032. */
  27033. isCompletelyInFrustum(target: ICullable): boolean;
  27034. /**
  27035. * Gets a ray in the forward direction from the camera.
  27036. * @param length Defines the length of the ray to create
  27037. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  27038. * @param origin Defines the start point of the ray which defaults to the camera position
  27039. * @returns the forward ray
  27040. */
  27041. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  27042. /**
  27043. * Releases resources associated with this node.
  27044. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27045. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27046. */
  27047. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27048. /** @hidden */
  27049. _isLeftCamera: boolean;
  27050. /**
  27051. * Gets the left camera of a rig setup in case of Rigged Camera
  27052. */
  27053. get isLeftCamera(): boolean;
  27054. /** @hidden */
  27055. _isRightCamera: boolean;
  27056. /**
  27057. * Gets the right camera of a rig setup in case of Rigged Camera
  27058. */
  27059. get isRightCamera(): boolean;
  27060. /**
  27061. * Gets the left camera of a rig setup in case of Rigged Camera
  27062. */
  27063. get leftCamera(): Nullable<FreeCamera>;
  27064. /**
  27065. * Gets the right camera of a rig setup in case of Rigged Camera
  27066. */
  27067. get rightCamera(): Nullable<FreeCamera>;
  27068. /**
  27069. * Gets the left camera target of a rig setup in case of Rigged Camera
  27070. * @returns the target position
  27071. */
  27072. getLeftTarget(): Nullable<Vector3>;
  27073. /**
  27074. * Gets the right camera target of a rig setup in case of Rigged Camera
  27075. * @returns the target position
  27076. */
  27077. getRightTarget(): Nullable<Vector3>;
  27078. /**
  27079. * @hidden
  27080. */
  27081. setCameraRigMode(mode: number, rigParams: any): void;
  27082. /** @hidden */
  27083. static _setStereoscopicRigMode(camera: Camera): void;
  27084. /** @hidden */
  27085. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  27086. /** @hidden */
  27087. static _setVRRigMode(camera: Camera, rigParams: any): void;
  27088. /** @hidden */
  27089. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  27090. /** @hidden */
  27091. _getVRProjectionMatrix(): Matrix;
  27092. protected _updateCameraRotationMatrix(): void;
  27093. protected _updateWebVRCameraRotationMatrix(): void;
  27094. /**
  27095. * This function MUST be overwritten by the different WebVR cameras available.
  27096. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27097. * @hidden
  27098. */
  27099. _getWebVRProjectionMatrix(): Matrix;
  27100. /**
  27101. * This function MUST be overwritten by the different WebVR cameras available.
  27102. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27103. * @hidden
  27104. */
  27105. _getWebVRViewMatrix(): Matrix;
  27106. /** @hidden */
  27107. setCameraRigParameter(name: string, value: any): void;
  27108. /**
  27109. * needs to be overridden by children so sub has required properties to be copied
  27110. * @hidden
  27111. */
  27112. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  27113. /**
  27114. * May need to be overridden by children
  27115. * @hidden
  27116. */
  27117. _updateRigCameras(): void;
  27118. /** @hidden */
  27119. _setupInputs(): void;
  27120. /**
  27121. * Serialiaze the camera setup to a json represention
  27122. * @returns the JSON representation
  27123. */
  27124. serialize(): any;
  27125. /**
  27126. * Clones the current camera.
  27127. * @param name The cloned camera name
  27128. * @returns the cloned camera
  27129. */
  27130. clone(name: string): Camera;
  27131. /**
  27132. * Gets the direction of the camera relative to a given local axis.
  27133. * @param localAxis Defines the reference axis to provide a relative direction.
  27134. * @return the direction
  27135. */
  27136. getDirection(localAxis: Vector3): Vector3;
  27137. /**
  27138. * Returns the current camera absolute rotation
  27139. */
  27140. get absoluteRotation(): Quaternion;
  27141. /**
  27142. * Gets the direction of the camera relative to a given local axis into a passed vector.
  27143. * @param localAxis Defines the reference axis to provide a relative direction.
  27144. * @param result Defines the vector to store the result in
  27145. */
  27146. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  27147. /**
  27148. * Gets a camera constructor for a given camera type
  27149. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  27150. * @param name The name of the camera the result will be able to instantiate
  27151. * @param scene The scene the result will construct the camera in
  27152. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  27153. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  27154. * @returns a factory method to construc the camera
  27155. */
  27156. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  27157. /**
  27158. * Compute the world matrix of the camera.
  27159. * @returns the camera world matrix
  27160. */
  27161. computeWorldMatrix(): Matrix;
  27162. /**
  27163. * Parse a JSON and creates the camera from the parsed information
  27164. * @param parsedCamera The JSON to parse
  27165. * @param scene The scene to instantiate the camera in
  27166. * @returns the newly constructed camera
  27167. */
  27168. static Parse(parsedCamera: any, scene: Scene): Camera;
  27169. }
  27170. }
  27171. declare module "babylonjs/Meshes/Builders/discBuilder" {
  27172. import { Nullable } from "babylonjs/types";
  27173. import { Scene } from "babylonjs/scene";
  27174. import { Vector4 } from "babylonjs/Maths/math.vector";
  27175. import { Mesh } from "babylonjs/Meshes/mesh";
  27176. /**
  27177. * Class containing static functions to help procedurally build meshes
  27178. */
  27179. export class DiscBuilder {
  27180. /**
  27181. * Creates a plane polygonal mesh. By default, this is a disc
  27182. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27183. * * 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
  27184. * * 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
  27185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27186. * * 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
  27187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27188. * @param name defines the name of the mesh
  27189. * @param options defines the options used to create the mesh
  27190. * @param scene defines the hosting scene
  27191. * @returns the plane polygonal mesh
  27192. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27193. */
  27194. static CreateDisc(name: string, options: {
  27195. radius?: number;
  27196. tessellation?: number;
  27197. arc?: number;
  27198. updatable?: boolean;
  27199. sideOrientation?: number;
  27200. frontUVs?: Vector4;
  27201. backUVs?: Vector4;
  27202. }, scene?: Nullable<Scene>): Mesh;
  27203. }
  27204. }
  27205. declare module "babylonjs/Materials/fresnelParameters" {
  27206. import { DeepImmutable } from "babylonjs/types";
  27207. import { Color3 } from "babylonjs/Maths/math.color";
  27208. /**
  27209. * Options to be used when creating a FresnelParameters.
  27210. */
  27211. export type IFresnelParametersCreationOptions = {
  27212. /**
  27213. * Define the color used on edges (grazing angle)
  27214. */
  27215. leftColor?: Color3;
  27216. /**
  27217. * Define the color used on center
  27218. */
  27219. rightColor?: Color3;
  27220. /**
  27221. * Define bias applied to computed fresnel term
  27222. */
  27223. bias?: number;
  27224. /**
  27225. * Defined the power exponent applied to fresnel term
  27226. */
  27227. power?: number;
  27228. /**
  27229. * Define if the fresnel effect is enable or not.
  27230. */
  27231. isEnabled?: boolean;
  27232. };
  27233. /**
  27234. * Serialized format for FresnelParameters.
  27235. */
  27236. export type IFresnelParametersSerialized = {
  27237. /**
  27238. * Define the color used on edges (grazing angle) [as an array]
  27239. */
  27240. leftColor: number[];
  27241. /**
  27242. * Define the color used on center [as an array]
  27243. */
  27244. rightColor: number[];
  27245. /**
  27246. * Define bias applied to computed fresnel term
  27247. */
  27248. bias: number;
  27249. /**
  27250. * Defined the power exponent applied to fresnel term
  27251. */
  27252. power?: number;
  27253. /**
  27254. * Define if the fresnel effect is enable or not.
  27255. */
  27256. isEnabled: boolean;
  27257. };
  27258. /**
  27259. * This represents all the required information to add a fresnel effect on a material:
  27260. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27261. */
  27262. export class FresnelParameters {
  27263. private _isEnabled;
  27264. /**
  27265. * Define if the fresnel effect is enable or not.
  27266. */
  27267. get isEnabled(): boolean;
  27268. set isEnabled(value: boolean);
  27269. /**
  27270. * Define the color used on edges (grazing angle)
  27271. */
  27272. leftColor: Color3;
  27273. /**
  27274. * Define the color used on center
  27275. */
  27276. rightColor: Color3;
  27277. /**
  27278. * Define bias applied to computed fresnel term
  27279. */
  27280. bias: number;
  27281. /**
  27282. * Defined the power exponent applied to fresnel term
  27283. */
  27284. power: number;
  27285. /**
  27286. * Creates a new FresnelParameters object.
  27287. *
  27288. * @param options provide your own settings to optionally to override defaults
  27289. */
  27290. constructor(options?: IFresnelParametersCreationOptions);
  27291. /**
  27292. * Clones the current fresnel and its valuues
  27293. * @returns a clone fresnel configuration
  27294. */
  27295. clone(): FresnelParameters;
  27296. /**
  27297. * Determines equality between FresnelParameters objects
  27298. * @param otherFresnelParameters defines the second operand
  27299. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27300. */
  27301. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27302. /**
  27303. * Serializes the current fresnel parameters to a JSON representation.
  27304. * @return the JSON serialization
  27305. */
  27306. serialize(): IFresnelParametersSerialized;
  27307. /**
  27308. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27309. * @param parsedFresnelParameters Define the JSON representation
  27310. * @returns the parsed parameters
  27311. */
  27312. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27313. }
  27314. }
  27315. declare module "babylonjs/Materials/pushMaterial" {
  27316. import { Nullable } from "babylonjs/types";
  27317. import { Scene } from "babylonjs/scene";
  27318. import { Matrix } from "babylonjs/Maths/math.vector";
  27319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27320. import { Mesh } from "babylonjs/Meshes/mesh";
  27321. import { Material } from "babylonjs/Materials/material";
  27322. import { Effect } from "babylonjs/Materials/effect";
  27323. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27324. /**
  27325. * Base class of materials working in push mode in babylon JS
  27326. * @hidden
  27327. */
  27328. export class PushMaterial extends Material {
  27329. protected _activeEffect: Effect;
  27330. protected _normalMatrix: Matrix;
  27331. /**
  27332. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27333. * This means that the material can keep using a previous shader while a new one is being compiled.
  27334. * This is mostly used when shader parallel compilation is supported (true by default)
  27335. */
  27336. allowShaderHotSwapping: boolean;
  27337. constructor(name: string, scene: Scene);
  27338. getEffect(): Effect;
  27339. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27340. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27341. /**
  27342. * Binds the given world matrix to the active effect
  27343. *
  27344. * @param world the matrix to bind
  27345. */
  27346. bindOnlyWorldMatrix(world: Matrix): void;
  27347. /**
  27348. * Binds the given normal matrix to the active effect
  27349. *
  27350. * @param normalMatrix the matrix to bind
  27351. */
  27352. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27353. bind(world: Matrix, mesh?: Mesh): void;
  27354. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27355. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27356. }
  27357. }
  27358. declare module "babylonjs/Materials/materialFlags" {
  27359. /**
  27360. * This groups all the flags used to control the materials channel.
  27361. */
  27362. export class MaterialFlags {
  27363. private static _DiffuseTextureEnabled;
  27364. /**
  27365. * Are diffuse textures enabled in the application.
  27366. */
  27367. static get DiffuseTextureEnabled(): boolean;
  27368. static set DiffuseTextureEnabled(value: boolean);
  27369. private static _AmbientTextureEnabled;
  27370. /**
  27371. * Are ambient textures enabled in the application.
  27372. */
  27373. static get AmbientTextureEnabled(): boolean;
  27374. static set AmbientTextureEnabled(value: boolean);
  27375. private static _OpacityTextureEnabled;
  27376. /**
  27377. * Are opacity textures enabled in the application.
  27378. */
  27379. static get OpacityTextureEnabled(): boolean;
  27380. static set OpacityTextureEnabled(value: boolean);
  27381. private static _ReflectionTextureEnabled;
  27382. /**
  27383. * Are reflection textures enabled in the application.
  27384. */
  27385. static get ReflectionTextureEnabled(): boolean;
  27386. static set ReflectionTextureEnabled(value: boolean);
  27387. private static _EmissiveTextureEnabled;
  27388. /**
  27389. * Are emissive textures enabled in the application.
  27390. */
  27391. static get EmissiveTextureEnabled(): boolean;
  27392. static set EmissiveTextureEnabled(value: boolean);
  27393. private static _SpecularTextureEnabled;
  27394. /**
  27395. * Are specular textures enabled in the application.
  27396. */
  27397. static get SpecularTextureEnabled(): boolean;
  27398. static set SpecularTextureEnabled(value: boolean);
  27399. private static _BumpTextureEnabled;
  27400. /**
  27401. * Are bump textures enabled in the application.
  27402. */
  27403. static get BumpTextureEnabled(): boolean;
  27404. static set BumpTextureEnabled(value: boolean);
  27405. private static _LightmapTextureEnabled;
  27406. /**
  27407. * Are lightmap textures enabled in the application.
  27408. */
  27409. static get LightmapTextureEnabled(): boolean;
  27410. static set LightmapTextureEnabled(value: boolean);
  27411. private static _RefractionTextureEnabled;
  27412. /**
  27413. * Are refraction textures enabled in the application.
  27414. */
  27415. static get RefractionTextureEnabled(): boolean;
  27416. static set RefractionTextureEnabled(value: boolean);
  27417. private static _ColorGradingTextureEnabled;
  27418. /**
  27419. * Are color grading textures enabled in the application.
  27420. */
  27421. static get ColorGradingTextureEnabled(): boolean;
  27422. static set ColorGradingTextureEnabled(value: boolean);
  27423. private static _FresnelEnabled;
  27424. /**
  27425. * Are fresnels enabled in the application.
  27426. */
  27427. static get FresnelEnabled(): boolean;
  27428. static set FresnelEnabled(value: boolean);
  27429. private static _ClearCoatTextureEnabled;
  27430. /**
  27431. * Are clear coat textures enabled in the application.
  27432. */
  27433. static get ClearCoatTextureEnabled(): boolean;
  27434. static set ClearCoatTextureEnabled(value: boolean);
  27435. private static _ClearCoatBumpTextureEnabled;
  27436. /**
  27437. * Are clear coat bump textures enabled in the application.
  27438. */
  27439. static get ClearCoatBumpTextureEnabled(): boolean;
  27440. static set ClearCoatBumpTextureEnabled(value: boolean);
  27441. private static _ClearCoatTintTextureEnabled;
  27442. /**
  27443. * Are clear coat tint textures enabled in the application.
  27444. */
  27445. static get ClearCoatTintTextureEnabled(): boolean;
  27446. static set ClearCoatTintTextureEnabled(value: boolean);
  27447. private static _SheenTextureEnabled;
  27448. /**
  27449. * Are sheen textures enabled in the application.
  27450. */
  27451. static get SheenTextureEnabled(): boolean;
  27452. static set SheenTextureEnabled(value: boolean);
  27453. private static _AnisotropicTextureEnabled;
  27454. /**
  27455. * Are anisotropic textures enabled in the application.
  27456. */
  27457. static get AnisotropicTextureEnabled(): boolean;
  27458. static set AnisotropicTextureEnabled(value: boolean);
  27459. private static _ThicknessTextureEnabled;
  27460. /**
  27461. * Are thickness textures enabled in the application.
  27462. */
  27463. static get ThicknessTextureEnabled(): boolean;
  27464. static set ThicknessTextureEnabled(value: boolean);
  27465. }
  27466. }
  27467. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27468. /** @hidden */
  27469. export var defaultFragmentDeclaration: {
  27470. name: string;
  27471. shader: string;
  27472. };
  27473. }
  27474. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27475. /** @hidden */
  27476. export var defaultUboDeclaration: {
  27477. name: string;
  27478. shader: string;
  27479. };
  27480. }
  27481. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27482. /** @hidden */
  27483. export var lightFragmentDeclaration: {
  27484. name: string;
  27485. shader: string;
  27486. };
  27487. }
  27488. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27489. /** @hidden */
  27490. export var lightUboDeclaration: {
  27491. name: string;
  27492. shader: string;
  27493. };
  27494. }
  27495. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27496. /** @hidden */
  27497. export var lightsFragmentFunctions: {
  27498. name: string;
  27499. shader: string;
  27500. };
  27501. }
  27502. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27503. /** @hidden */
  27504. export var shadowsFragmentFunctions: {
  27505. name: string;
  27506. shader: string;
  27507. };
  27508. }
  27509. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27510. /** @hidden */
  27511. export var fresnelFunction: {
  27512. name: string;
  27513. shader: string;
  27514. };
  27515. }
  27516. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27517. /** @hidden */
  27518. export var reflectionFunction: {
  27519. name: string;
  27520. shader: string;
  27521. };
  27522. }
  27523. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  27524. /** @hidden */
  27525. export var bumpFragmentMainFunctions: {
  27526. name: string;
  27527. shader: string;
  27528. };
  27529. }
  27530. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27531. /** @hidden */
  27532. export var bumpFragmentFunctions: {
  27533. name: string;
  27534. shader: string;
  27535. };
  27536. }
  27537. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27538. /** @hidden */
  27539. export var logDepthDeclaration: {
  27540. name: string;
  27541. shader: string;
  27542. };
  27543. }
  27544. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27545. /** @hidden */
  27546. export var bumpFragment: {
  27547. name: string;
  27548. shader: string;
  27549. };
  27550. }
  27551. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27552. /** @hidden */
  27553. export var depthPrePass: {
  27554. name: string;
  27555. shader: string;
  27556. };
  27557. }
  27558. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27559. /** @hidden */
  27560. export var lightFragment: {
  27561. name: string;
  27562. shader: string;
  27563. };
  27564. }
  27565. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27566. /** @hidden */
  27567. export var logDepthFragment: {
  27568. name: string;
  27569. shader: string;
  27570. };
  27571. }
  27572. declare module "babylonjs/Shaders/default.fragment" {
  27573. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27574. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27575. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27576. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27577. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27578. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27579. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27580. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27581. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27582. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27583. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27584. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27585. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27586. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27587. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27588. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27589. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27590. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27591. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27592. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27593. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27594. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27595. /** @hidden */
  27596. export var defaultPixelShader: {
  27597. name: string;
  27598. shader: string;
  27599. };
  27600. }
  27601. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27602. /** @hidden */
  27603. export var defaultVertexDeclaration: {
  27604. name: string;
  27605. shader: string;
  27606. };
  27607. }
  27608. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27609. /** @hidden */
  27610. export var bumpVertexDeclaration: {
  27611. name: string;
  27612. shader: string;
  27613. };
  27614. }
  27615. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27616. /** @hidden */
  27617. export var bumpVertex: {
  27618. name: string;
  27619. shader: string;
  27620. };
  27621. }
  27622. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27623. /** @hidden */
  27624. export var fogVertex: {
  27625. name: string;
  27626. shader: string;
  27627. };
  27628. }
  27629. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27630. /** @hidden */
  27631. export var shadowsVertex: {
  27632. name: string;
  27633. shader: string;
  27634. };
  27635. }
  27636. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27637. /** @hidden */
  27638. export var pointCloudVertex: {
  27639. name: string;
  27640. shader: string;
  27641. };
  27642. }
  27643. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27644. /** @hidden */
  27645. export var logDepthVertex: {
  27646. name: string;
  27647. shader: string;
  27648. };
  27649. }
  27650. declare module "babylonjs/Shaders/default.vertex" {
  27651. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27652. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27653. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27654. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27655. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27656. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27657. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27658. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27659. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27660. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27661. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27662. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27663. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27664. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27665. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27666. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27667. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27668. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27669. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27670. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27671. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27672. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27673. /** @hidden */
  27674. export var defaultVertexShader: {
  27675. name: string;
  27676. shader: string;
  27677. };
  27678. }
  27679. declare module "babylonjs/Materials/standardMaterial" {
  27680. import { SmartArray } from "babylonjs/Misc/smartArray";
  27681. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27682. import { Nullable } from "babylonjs/types";
  27683. import { Scene } from "babylonjs/scene";
  27684. import { Matrix } from "babylonjs/Maths/math.vector";
  27685. import { Color3 } from "babylonjs/Maths/math.color";
  27686. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27688. import { Mesh } from "babylonjs/Meshes/mesh";
  27689. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27690. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27691. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27692. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27693. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27695. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27696. import "babylonjs/Shaders/default.fragment";
  27697. import "babylonjs/Shaders/default.vertex";
  27698. /** @hidden */
  27699. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27700. MAINUV1: boolean;
  27701. MAINUV2: boolean;
  27702. DIFFUSE: boolean;
  27703. DIFFUSEDIRECTUV: number;
  27704. AMBIENT: boolean;
  27705. AMBIENTDIRECTUV: number;
  27706. OPACITY: boolean;
  27707. OPACITYDIRECTUV: number;
  27708. OPACITYRGB: boolean;
  27709. REFLECTION: boolean;
  27710. EMISSIVE: boolean;
  27711. EMISSIVEDIRECTUV: number;
  27712. SPECULAR: boolean;
  27713. SPECULARDIRECTUV: number;
  27714. BUMP: boolean;
  27715. BUMPDIRECTUV: number;
  27716. PARALLAX: boolean;
  27717. PARALLAXOCCLUSION: boolean;
  27718. SPECULAROVERALPHA: boolean;
  27719. CLIPPLANE: boolean;
  27720. CLIPPLANE2: boolean;
  27721. CLIPPLANE3: boolean;
  27722. CLIPPLANE4: boolean;
  27723. CLIPPLANE5: boolean;
  27724. CLIPPLANE6: boolean;
  27725. ALPHATEST: boolean;
  27726. DEPTHPREPASS: boolean;
  27727. ALPHAFROMDIFFUSE: boolean;
  27728. POINTSIZE: boolean;
  27729. FOG: boolean;
  27730. SPECULARTERM: boolean;
  27731. DIFFUSEFRESNEL: boolean;
  27732. OPACITYFRESNEL: boolean;
  27733. REFLECTIONFRESNEL: boolean;
  27734. REFRACTIONFRESNEL: boolean;
  27735. EMISSIVEFRESNEL: boolean;
  27736. FRESNEL: boolean;
  27737. NORMAL: boolean;
  27738. UV1: boolean;
  27739. UV2: boolean;
  27740. VERTEXCOLOR: boolean;
  27741. VERTEXALPHA: boolean;
  27742. NUM_BONE_INFLUENCERS: number;
  27743. BonesPerMesh: number;
  27744. BONETEXTURE: boolean;
  27745. INSTANCES: boolean;
  27746. GLOSSINESS: boolean;
  27747. ROUGHNESS: boolean;
  27748. EMISSIVEASILLUMINATION: boolean;
  27749. LINKEMISSIVEWITHDIFFUSE: boolean;
  27750. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27751. LIGHTMAP: boolean;
  27752. LIGHTMAPDIRECTUV: number;
  27753. OBJECTSPACE_NORMALMAP: boolean;
  27754. USELIGHTMAPASSHADOWMAP: boolean;
  27755. REFLECTIONMAP_3D: boolean;
  27756. REFLECTIONMAP_SPHERICAL: boolean;
  27757. REFLECTIONMAP_PLANAR: boolean;
  27758. REFLECTIONMAP_CUBIC: boolean;
  27759. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27760. REFLECTIONMAP_PROJECTION: boolean;
  27761. REFLECTIONMAP_SKYBOX: boolean;
  27762. REFLECTIONMAP_EXPLICIT: boolean;
  27763. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27764. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27765. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27766. INVERTCUBICMAP: boolean;
  27767. LOGARITHMICDEPTH: boolean;
  27768. REFRACTION: boolean;
  27769. REFRACTIONMAP_3D: boolean;
  27770. REFLECTIONOVERALPHA: boolean;
  27771. TWOSIDEDLIGHTING: boolean;
  27772. SHADOWFLOAT: boolean;
  27773. MORPHTARGETS: boolean;
  27774. MORPHTARGETS_NORMAL: boolean;
  27775. MORPHTARGETS_TANGENT: boolean;
  27776. MORPHTARGETS_UV: boolean;
  27777. NUM_MORPH_INFLUENCERS: number;
  27778. NONUNIFORMSCALING: boolean;
  27779. PREMULTIPLYALPHA: boolean;
  27780. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27781. ALPHABLEND: boolean;
  27782. IMAGEPROCESSING: boolean;
  27783. VIGNETTE: boolean;
  27784. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27785. VIGNETTEBLENDMODEOPAQUE: boolean;
  27786. TONEMAPPING: boolean;
  27787. TONEMAPPING_ACES: boolean;
  27788. CONTRAST: boolean;
  27789. COLORCURVES: boolean;
  27790. COLORGRADING: boolean;
  27791. COLORGRADING3D: boolean;
  27792. SAMPLER3DGREENDEPTH: boolean;
  27793. SAMPLER3DBGRMAP: boolean;
  27794. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27795. MULTIVIEW: boolean;
  27796. /**
  27797. * If the reflection texture on this material is in linear color space
  27798. * @hidden
  27799. */
  27800. IS_REFLECTION_LINEAR: boolean;
  27801. /**
  27802. * If the refraction texture on this material is in linear color space
  27803. * @hidden
  27804. */
  27805. IS_REFRACTION_LINEAR: boolean;
  27806. EXPOSURE: boolean;
  27807. constructor();
  27808. setReflectionMode(modeToEnable: string): void;
  27809. }
  27810. /**
  27811. * This is the default material used in Babylon. It is the best trade off between quality
  27812. * and performances.
  27813. * @see http://doc.babylonjs.com/babylon101/materials
  27814. */
  27815. export class StandardMaterial extends PushMaterial {
  27816. private _diffuseTexture;
  27817. /**
  27818. * The basic texture of the material as viewed under a light.
  27819. */
  27820. diffuseTexture: Nullable<BaseTexture>;
  27821. private _ambientTexture;
  27822. /**
  27823. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27824. */
  27825. ambientTexture: Nullable<BaseTexture>;
  27826. private _opacityTexture;
  27827. /**
  27828. * Define the transparency of the material from a texture.
  27829. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27830. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27831. */
  27832. opacityTexture: Nullable<BaseTexture>;
  27833. private _reflectionTexture;
  27834. /**
  27835. * Define the texture used to display the reflection.
  27836. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27837. */
  27838. reflectionTexture: Nullable<BaseTexture>;
  27839. private _emissiveTexture;
  27840. /**
  27841. * Define texture of the material as if self lit.
  27842. * This will be mixed in the final result even in the absence of light.
  27843. */
  27844. emissiveTexture: Nullable<BaseTexture>;
  27845. private _specularTexture;
  27846. /**
  27847. * Define how the color and intensity of the highlight given by the light in the material.
  27848. */
  27849. specularTexture: Nullable<BaseTexture>;
  27850. private _bumpTexture;
  27851. /**
  27852. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27853. * 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.
  27854. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27855. */
  27856. bumpTexture: Nullable<BaseTexture>;
  27857. private _lightmapTexture;
  27858. /**
  27859. * Complex lighting can be computationally expensive to compute at runtime.
  27860. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27861. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27862. */
  27863. lightmapTexture: Nullable<BaseTexture>;
  27864. private _refractionTexture;
  27865. /**
  27866. * Define the texture used to display the refraction.
  27867. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27868. */
  27869. refractionTexture: Nullable<BaseTexture>;
  27870. /**
  27871. * The color of the material lit by the environmental background lighting.
  27872. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27873. */
  27874. ambientColor: Color3;
  27875. /**
  27876. * The basic color of the material as viewed under a light.
  27877. */
  27878. diffuseColor: Color3;
  27879. /**
  27880. * Define how the color and intensity of the highlight given by the light in the material.
  27881. */
  27882. specularColor: Color3;
  27883. /**
  27884. * Define the color of the material as if self lit.
  27885. * This will be mixed in the final result even in the absence of light.
  27886. */
  27887. emissiveColor: Color3;
  27888. /**
  27889. * Defines how sharp are the highlights in the material.
  27890. * The bigger the value the sharper giving a more glossy feeling to the result.
  27891. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27892. */
  27893. specularPower: number;
  27894. private _useAlphaFromDiffuseTexture;
  27895. /**
  27896. * Does the transparency come from the diffuse texture alpha channel.
  27897. */
  27898. useAlphaFromDiffuseTexture: boolean;
  27899. private _useEmissiveAsIllumination;
  27900. /**
  27901. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27902. */
  27903. useEmissiveAsIllumination: boolean;
  27904. private _linkEmissiveWithDiffuse;
  27905. /**
  27906. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27907. * the emissive level when the final color is close to one.
  27908. */
  27909. linkEmissiveWithDiffuse: boolean;
  27910. private _useSpecularOverAlpha;
  27911. /**
  27912. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27913. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27914. */
  27915. useSpecularOverAlpha: boolean;
  27916. private _useReflectionOverAlpha;
  27917. /**
  27918. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27919. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27920. */
  27921. useReflectionOverAlpha: boolean;
  27922. private _disableLighting;
  27923. /**
  27924. * Does lights from the scene impacts this material.
  27925. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27926. */
  27927. disableLighting: boolean;
  27928. private _useObjectSpaceNormalMap;
  27929. /**
  27930. * Allows using an object space normal map (instead of tangent space).
  27931. */
  27932. useObjectSpaceNormalMap: boolean;
  27933. private _useParallax;
  27934. /**
  27935. * Is parallax enabled or not.
  27936. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27937. */
  27938. useParallax: boolean;
  27939. private _useParallaxOcclusion;
  27940. /**
  27941. * Is parallax occlusion enabled or not.
  27942. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27943. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27944. */
  27945. useParallaxOcclusion: boolean;
  27946. /**
  27947. * 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.
  27948. */
  27949. parallaxScaleBias: number;
  27950. private _roughness;
  27951. /**
  27952. * Helps to define how blurry the reflections should appears in the material.
  27953. */
  27954. roughness: number;
  27955. /**
  27956. * In case of refraction, define the value of the index of refraction.
  27957. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27958. */
  27959. indexOfRefraction: number;
  27960. /**
  27961. * Invert the refraction texture alongside the y axis.
  27962. * It can be useful with procedural textures or probe for instance.
  27963. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27964. */
  27965. invertRefractionY: boolean;
  27966. /**
  27967. * Defines the alpha limits in alpha test mode.
  27968. */
  27969. alphaCutOff: number;
  27970. private _useLightmapAsShadowmap;
  27971. /**
  27972. * In case of light mapping, define whether the map contains light or shadow informations.
  27973. */
  27974. useLightmapAsShadowmap: boolean;
  27975. private _diffuseFresnelParameters;
  27976. /**
  27977. * Define the diffuse fresnel parameters of the material.
  27978. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27979. */
  27980. diffuseFresnelParameters: FresnelParameters;
  27981. private _opacityFresnelParameters;
  27982. /**
  27983. * Define the opacity fresnel parameters of the material.
  27984. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27985. */
  27986. opacityFresnelParameters: FresnelParameters;
  27987. private _reflectionFresnelParameters;
  27988. /**
  27989. * Define the reflection fresnel parameters of the material.
  27990. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27991. */
  27992. reflectionFresnelParameters: FresnelParameters;
  27993. private _refractionFresnelParameters;
  27994. /**
  27995. * Define the refraction fresnel parameters of the material.
  27996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27997. */
  27998. refractionFresnelParameters: FresnelParameters;
  27999. private _emissiveFresnelParameters;
  28000. /**
  28001. * Define the emissive fresnel parameters of the material.
  28002. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28003. */
  28004. emissiveFresnelParameters: FresnelParameters;
  28005. private _useReflectionFresnelFromSpecular;
  28006. /**
  28007. * If true automatically deducts the fresnels values from the material specularity.
  28008. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28009. */
  28010. useReflectionFresnelFromSpecular: boolean;
  28011. private _useGlossinessFromSpecularMapAlpha;
  28012. /**
  28013. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  28014. */
  28015. useGlossinessFromSpecularMapAlpha: boolean;
  28016. private _maxSimultaneousLights;
  28017. /**
  28018. * Defines the maximum number of lights that can be used in the material
  28019. */
  28020. maxSimultaneousLights: number;
  28021. private _invertNormalMapX;
  28022. /**
  28023. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28024. */
  28025. invertNormalMapX: boolean;
  28026. private _invertNormalMapY;
  28027. /**
  28028. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28029. */
  28030. invertNormalMapY: boolean;
  28031. private _twoSidedLighting;
  28032. /**
  28033. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28034. */
  28035. twoSidedLighting: boolean;
  28036. /**
  28037. * Default configuration related to image processing available in the standard Material.
  28038. */
  28039. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28040. /**
  28041. * Gets the image processing configuration used either in this material.
  28042. */
  28043. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28044. /**
  28045. * Sets the Default image processing configuration used either in the this material.
  28046. *
  28047. * If sets to null, the scene one is in use.
  28048. */
  28049. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28050. /**
  28051. * Keep track of the image processing observer to allow dispose and replace.
  28052. */
  28053. private _imageProcessingObserver;
  28054. /**
  28055. * Attaches a new image processing configuration to the Standard Material.
  28056. * @param configuration
  28057. */
  28058. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  28059. /**
  28060. * Gets wether the color curves effect is enabled.
  28061. */
  28062. get cameraColorCurvesEnabled(): boolean;
  28063. /**
  28064. * Sets wether the color curves effect is enabled.
  28065. */
  28066. set cameraColorCurvesEnabled(value: boolean);
  28067. /**
  28068. * Gets wether the color grading effect is enabled.
  28069. */
  28070. get cameraColorGradingEnabled(): boolean;
  28071. /**
  28072. * Gets wether the color grading effect is enabled.
  28073. */
  28074. set cameraColorGradingEnabled(value: boolean);
  28075. /**
  28076. * Gets wether tonemapping is enabled or not.
  28077. */
  28078. get cameraToneMappingEnabled(): boolean;
  28079. /**
  28080. * Sets wether tonemapping is enabled or not
  28081. */
  28082. set cameraToneMappingEnabled(value: boolean);
  28083. /**
  28084. * The camera exposure used on this material.
  28085. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28086. * This corresponds to a photographic exposure.
  28087. */
  28088. get cameraExposure(): number;
  28089. /**
  28090. * The camera exposure used on this material.
  28091. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28092. * This corresponds to a photographic exposure.
  28093. */
  28094. set cameraExposure(value: number);
  28095. /**
  28096. * Gets The camera contrast used on this material.
  28097. */
  28098. get cameraContrast(): number;
  28099. /**
  28100. * Sets The camera contrast used on this material.
  28101. */
  28102. set cameraContrast(value: number);
  28103. /**
  28104. * Gets the Color Grading 2D Lookup Texture.
  28105. */
  28106. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28107. /**
  28108. * Sets the Color Grading 2D Lookup Texture.
  28109. */
  28110. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28111. /**
  28112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28114. * 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;
  28115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28116. */
  28117. get cameraColorCurves(): Nullable<ColorCurves>;
  28118. /**
  28119. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28120. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28121. * 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;
  28122. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28123. */
  28124. set cameraColorCurves(value: Nullable<ColorCurves>);
  28125. protected _renderTargets: SmartArray<RenderTargetTexture>;
  28126. protected _worldViewProjectionMatrix: Matrix;
  28127. protected _globalAmbientColor: Color3;
  28128. protected _useLogarithmicDepth: boolean;
  28129. protected _rebuildInParallel: boolean;
  28130. /**
  28131. * Instantiates a new standard material.
  28132. * This is the default material used in Babylon. It is the best trade off between quality
  28133. * and performances.
  28134. * @see http://doc.babylonjs.com/babylon101/materials
  28135. * @param name Define the name of the material in the scene
  28136. * @param scene Define the scene the material belong to
  28137. */
  28138. constructor(name: string, scene: Scene);
  28139. /**
  28140. * Gets a boolean indicating that current material needs to register RTT
  28141. */
  28142. get hasRenderTargetTextures(): boolean;
  28143. /**
  28144. * Gets the current class name of the material e.g. "StandardMaterial"
  28145. * Mainly use in serialization.
  28146. * @returns the class name
  28147. */
  28148. getClassName(): string;
  28149. /**
  28150. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  28151. * You can try switching to logarithmic depth.
  28152. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  28153. */
  28154. get useLogarithmicDepth(): boolean;
  28155. set useLogarithmicDepth(value: boolean);
  28156. /**
  28157. * Specifies if the material will require alpha blending
  28158. * @returns a boolean specifying if alpha blending is needed
  28159. */
  28160. needAlphaBlending(): boolean;
  28161. /**
  28162. * Specifies if this material should be rendered in alpha test mode
  28163. * @returns a boolean specifying if an alpha test is needed.
  28164. */
  28165. needAlphaTesting(): boolean;
  28166. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  28167. /**
  28168. * Get the texture used for alpha test purpose.
  28169. * @returns the diffuse texture in case of the standard material.
  28170. */
  28171. getAlphaTestTexture(): Nullable<BaseTexture>;
  28172. /**
  28173. * Get if the submesh is ready to be used and all its information available.
  28174. * Child classes can use it to update shaders
  28175. * @param mesh defines the mesh to check
  28176. * @param subMesh defines which submesh to check
  28177. * @param useInstances specifies that instances should be used
  28178. * @returns a boolean indicating that the submesh is ready or not
  28179. */
  28180. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28181. /**
  28182. * Builds the material UBO layouts.
  28183. * Used internally during the effect preparation.
  28184. */
  28185. buildUniformLayout(): void;
  28186. /**
  28187. * Unbinds the material from the mesh
  28188. */
  28189. unbind(): void;
  28190. /**
  28191. * Binds the submesh to this material by preparing the effect and shader to draw
  28192. * @param world defines the world transformation matrix
  28193. * @param mesh defines the mesh containing the submesh
  28194. * @param subMesh defines the submesh to bind the material to
  28195. */
  28196. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28197. /**
  28198. * Get the list of animatables in the material.
  28199. * @returns the list of animatables object used in the material
  28200. */
  28201. getAnimatables(): IAnimatable[];
  28202. /**
  28203. * Gets the active textures from the material
  28204. * @returns an array of textures
  28205. */
  28206. getActiveTextures(): BaseTexture[];
  28207. /**
  28208. * Specifies if the material uses a texture
  28209. * @param texture defines the texture to check against the material
  28210. * @returns a boolean specifying if the material uses the texture
  28211. */
  28212. hasTexture(texture: BaseTexture): boolean;
  28213. /**
  28214. * Disposes the material
  28215. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28216. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28217. */
  28218. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28219. /**
  28220. * Makes a duplicate of the material, and gives it a new name
  28221. * @param name defines the new name for the duplicated material
  28222. * @returns the cloned material
  28223. */
  28224. clone(name: string): StandardMaterial;
  28225. /**
  28226. * Serializes this material in a JSON representation
  28227. * @returns the serialized material object
  28228. */
  28229. serialize(): any;
  28230. /**
  28231. * Creates a standard material from parsed material data
  28232. * @param source defines the JSON representation of the material
  28233. * @param scene defines the hosting scene
  28234. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28235. * @returns a new standard material
  28236. */
  28237. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  28238. /**
  28239. * Are diffuse textures enabled in the application.
  28240. */
  28241. static get DiffuseTextureEnabled(): boolean;
  28242. static set DiffuseTextureEnabled(value: boolean);
  28243. /**
  28244. * Are ambient textures enabled in the application.
  28245. */
  28246. static get AmbientTextureEnabled(): boolean;
  28247. static set AmbientTextureEnabled(value: boolean);
  28248. /**
  28249. * Are opacity textures enabled in the application.
  28250. */
  28251. static get OpacityTextureEnabled(): boolean;
  28252. static set OpacityTextureEnabled(value: boolean);
  28253. /**
  28254. * Are reflection textures enabled in the application.
  28255. */
  28256. static get ReflectionTextureEnabled(): boolean;
  28257. static set ReflectionTextureEnabled(value: boolean);
  28258. /**
  28259. * Are emissive textures enabled in the application.
  28260. */
  28261. static get EmissiveTextureEnabled(): boolean;
  28262. static set EmissiveTextureEnabled(value: boolean);
  28263. /**
  28264. * Are specular textures enabled in the application.
  28265. */
  28266. static get SpecularTextureEnabled(): boolean;
  28267. static set SpecularTextureEnabled(value: boolean);
  28268. /**
  28269. * Are bump textures enabled in the application.
  28270. */
  28271. static get BumpTextureEnabled(): boolean;
  28272. static set BumpTextureEnabled(value: boolean);
  28273. /**
  28274. * Are lightmap textures enabled in the application.
  28275. */
  28276. static get LightmapTextureEnabled(): boolean;
  28277. static set LightmapTextureEnabled(value: boolean);
  28278. /**
  28279. * Are refraction textures enabled in the application.
  28280. */
  28281. static get RefractionTextureEnabled(): boolean;
  28282. static set RefractionTextureEnabled(value: boolean);
  28283. /**
  28284. * Are color grading textures enabled in the application.
  28285. */
  28286. static get ColorGradingTextureEnabled(): boolean;
  28287. static set ColorGradingTextureEnabled(value: boolean);
  28288. /**
  28289. * Are fresnels enabled in the application.
  28290. */
  28291. static get FresnelEnabled(): boolean;
  28292. static set FresnelEnabled(value: boolean);
  28293. }
  28294. }
  28295. declare module "babylonjs/Particles/solidParticleSystem" {
  28296. import { Nullable } from "babylonjs/types";
  28297. import { Mesh } from "babylonjs/Meshes/mesh";
  28298. import { Scene, IDisposable } from "babylonjs/scene";
  28299. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  28300. import { Material } from "babylonjs/Materials/material";
  28301. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28302. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28303. /**
  28304. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28305. *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.
  28306. * The SPS is also a particle system. It provides some methods to manage the particles.
  28307. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28308. *
  28309. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28310. */
  28311. export class SolidParticleSystem implements IDisposable {
  28312. /**
  28313. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28314. * Example : var p = SPS.particles[i];
  28315. */
  28316. particles: SolidParticle[];
  28317. /**
  28318. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28319. */
  28320. nbParticles: number;
  28321. /**
  28322. * If the particles must ever face the camera (default false). Useful for planar particles.
  28323. */
  28324. billboard: boolean;
  28325. /**
  28326. * Recompute normals when adding a shape
  28327. */
  28328. recomputeNormals: boolean;
  28329. /**
  28330. * This a counter ofr your own usage. It's not set by any SPS functions.
  28331. */
  28332. counter: number;
  28333. /**
  28334. * The SPS name. This name is also given to the underlying mesh.
  28335. */
  28336. name: string;
  28337. /**
  28338. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28339. */
  28340. mesh: Mesh;
  28341. /**
  28342. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28343. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28344. */
  28345. vars: any;
  28346. /**
  28347. * This array is populated when the SPS is set as 'pickable'.
  28348. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28349. * Each element of this array is an object `{idx: int, faceId: int}`.
  28350. * `idx` is the picked particle index in the `SPS.particles` array
  28351. * `faceId` is the picked face index counted within this particle.
  28352. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28353. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28354. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28355. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28356. */
  28357. pickedParticles: {
  28358. idx: number;
  28359. faceId: number;
  28360. }[];
  28361. /**
  28362. * This array is populated when the SPS is set as 'pickable'
  28363. * Each key of this array is a submesh index.
  28364. * Each element of this array is a second array defined like this :
  28365. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28366. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28367. * `idx` is the picked particle index in the `SPS.particles` array
  28368. * `faceId` is the picked face index counted within this particle.
  28369. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28370. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28371. */
  28372. pickedBySubMesh: {
  28373. idx: number;
  28374. faceId: number;
  28375. }[][];
  28376. /**
  28377. * This array is populated when `enableDepthSort` is set to true.
  28378. * Each element of this array is an instance of the class DepthSortedParticle.
  28379. */
  28380. depthSortedParticles: DepthSortedParticle[];
  28381. /**
  28382. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28383. * @hidden
  28384. */
  28385. _bSphereOnly: boolean;
  28386. /**
  28387. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28388. * @hidden
  28389. */
  28390. _bSphereRadiusFactor: number;
  28391. private _scene;
  28392. private _positions;
  28393. private _indices;
  28394. private _normals;
  28395. private _colors;
  28396. private _uvs;
  28397. private _indices32;
  28398. private _positions32;
  28399. private _normals32;
  28400. private _fixedNormal32;
  28401. private _colors32;
  28402. private _uvs32;
  28403. private _index;
  28404. private _updatable;
  28405. private _pickable;
  28406. private _isVisibilityBoxLocked;
  28407. private _alwaysVisible;
  28408. private _depthSort;
  28409. private _expandable;
  28410. private _shapeCounter;
  28411. private _copy;
  28412. private _color;
  28413. private _computeParticleColor;
  28414. private _computeParticleTexture;
  28415. private _computeParticleRotation;
  28416. private _computeParticleVertex;
  28417. private _computeBoundingBox;
  28418. private _depthSortParticles;
  28419. private _camera;
  28420. private _mustUnrotateFixedNormals;
  28421. private _particlesIntersect;
  28422. private _needs32Bits;
  28423. private _isNotBuilt;
  28424. private _lastParticleId;
  28425. private _idxOfId;
  28426. private _multimaterialEnabled;
  28427. private _useModelMaterial;
  28428. private _indicesByMaterial;
  28429. private _materialIndexes;
  28430. private _depthSortFunction;
  28431. private _materialSortFunction;
  28432. private _materials;
  28433. private _multimaterial;
  28434. private _materialIndexesById;
  28435. private _defaultMaterial;
  28436. private _autoUpdateSubMeshes;
  28437. private _tmpVertex;
  28438. /**
  28439. * Creates a SPS (Solid Particle System) object.
  28440. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28441. * @param scene (Scene) is the scene in which the SPS is added.
  28442. * @param options defines the options of the sps e.g.
  28443. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28444. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28445. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28446. * * 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.
  28447. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28448. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28449. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28450. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28451. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28452. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28453. */
  28454. constructor(name: string, scene: Scene, options?: {
  28455. updatable?: boolean;
  28456. isPickable?: boolean;
  28457. enableDepthSort?: boolean;
  28458. particleIntersection?: boolean;
  28459. boundingSphereOnly?: boolean;
  28460. bSphereRadiusFactor?: number;
  28461. expandable?: boolean;
  28462. useModelMaterial?: boolean;
  28463. enableMultiMaterial?: boolean;
  28464. });
  28465. /**
  28466. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28467. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28468. * @returns the created mesh
  28469. */
  28470. buildMesh(): Mesh;
  28471. /**
  28472. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28473. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28474. * Thus the particles generated from `digest()` have their property `position` set yet.
  28475. * @param mesh ( Mesh ) is the mesh to be digested
  28476. * @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
  28477. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28478. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28479. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28480. * @returns the current SPS
  28481. */
  28482. digest(mesh: Mesh, options?: {
  28483. facetNb?: number;
  28484. number?: number;
  28485. delta?: number;
  28486. storage?: [];
  28487. }): SolidParticleSystem;
  28488. /**
  28489. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28490. * @hidden
  28491. */
  28492. private _unrotateFixedNormals;
  28493. /**
  28494. * Resets the temporary working copy particle
  28495. * @hidden
  28496. */
  28497. private _resetCopy;
  28498. /**
  28499. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28500. * @param p the current index in the positions array to be updated
  28501. * @param ind the current index in the indices array
  28502. * @param shape a Vector3 array, the shape geometry
  28503. * @param positions the positions array to be updated
  28504. * @param meshInd the shape indices array
  28505. * @param indices the indices array to be updated
  28506. * @param meshUV the shape uv array
  28507. * @param uvs the uv array to be updated
  28508. * @param meshCol the shape color array
  28509. * @param colors the color array to be updated
  28510. * @param meshNor the shape normals array
  28511. * @param normals the normals array to be updated
  28512. * @param idx the particle index
  28513. * @param idxInShape the particle index in its shape
  28514. * @param options the addShape() method passed options
  28515. * @model the particle model
  28516. * @hidden
  28517. */
  28518. private _meshBuilder;
  28519. /**
  28520. * Returns a shape Vector3 array from positions float array
  28521. * @param positions float array
  28522. * @returns a vector3 array
  28523. * @hidden
  28524. */
  28525. private _posToShape;
  28526. /**
  28527. * Returns a shapeUV array from a float uvs (array deep copy)
  28528. * @param uvs as a float array
  28529. * @returns a shapeUV array
  28530. * @hidden
  28531. */
  28532. private _uvsToShapeUV;
  28533. /**
  28534. * Adds a new particle object in the particles array
  28535. * @param idx particle index in particles array
  28536. * @param id particle id
  28537. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28538. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28539. * @param model particle ModelShape object
  28540. * @param shapeId model shape identifier
  28541. * @param idxInShape index of the particle in the current model
  28542. * @param bInfo model bounding info object
  28543. * @param storage target storage array, if any
  28544. * @hidden
  28545. */
  28546. private _addParticle;
  28547. /**
  28548. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28549. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28550. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28551. * @param nb (positive integer) the number of particles to be created from this model
  28552. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28553. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28554. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28555. * @returns the number of shapes in the system
  28556. */
  28557. addShape(mesh: Mesh, nb: number, options?: {
  28558. positionFunction?: any;
  28559. vertexFunction?: any;
  28560. storage?: [];
  28561. }): number;
  28562. /**
  28563. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28564. * @hidden
  28565. */
  28566. private _rebuildParticle;
  28567. /**
  28568. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28569. * @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.
  28570. * @returns the SPS.
  28571. */
  28572. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28573. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28574. * Returns an array with the removed particles.
  28575. * 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.
  28576. * The SPS can't be empty so at least one particle needs to remain in place.
  28577. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28578. * @param start index of the first particle to remove
  28579. * @param end index of the last particle to remove (included)
  28580. * @returns an array populated with the removed particles
  28581. */
  28582. removeParticles(start: number, end: number): SolidParticle[];
  28583. /**
  28584. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28585. * @param solidParticleArray an array populated with Solid Particles objects
  28586. * @returns the SPS
  28587. */
  28588. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28589. /**
  28590. * Creates a new particle and modifies the SPS mesh geometry :
  28591. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28592. * - calls _addParticle() to populate the particle array
  28593. * factorized code from addShape() and insertParticlesFromArray()
  28594. * @param idx particle index in the particles array
  28595. * @param i particle index in its shape
  28596. * @param modelShape particle ModelShape object
  28597. * @param shape shape vertex array
  28598. * @param meshInd shape indices array
  28599. * @param meshUV shape uv array
  28600. * @param meshCol shape color array
  28601. * @param meshNor shape normals array
  28602. * @param bbInfo shape bounding info
  28603. * @param storage target particle storage
  28604. * @options addShape() passed options
  28605. * @hidden
  28606. */
  28607. private _insertNewParticle;
  28608. /**
  28609. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28610. * This method calls `updateParticle()` for each particle of the SPS.
  28611. * For an animated SPS, it is usually called within the render loop.
  28612. * 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.
  28613. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28614. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28615. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28616. * @returns the SPS.
  28617. */
  28618. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28619. /**
  28620. * Disposes the SPS.
  28621. */
  28622. dispose(): void;
  28623. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28624. * idx is the particle index in the SPS
  28625. * faceId is the picked face index counted within this particle.
  28626. * Returns null if the pickInfo can't identify a picked particle.
  28627. * @param pickingInfo (PickingInfo object)
  28628. * @returns {idx: number, faceId: number} or null
  28629. */
  28630. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28631. idx: number;
  28632. faceId: number;
  28633. }>;
  28634. /**
  28635. * Returns a SolidParticle object from its identifier : particle.id
  28636. * @param id (integer) the particle Id
  28637. * @returns the searched particle or null if not found in the SPS.
  28638. */
  28639. getParticleById(id: number): Nullable<SolidParticle>;
  28640. /**
  28641. * Returns a new array populated with the particles having the passed shapeId.
  28642. * @param shapeId (integer) the shape identifier
  28643. * @returns a new solid particle array
  28644. */
  28645. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28646. /**
  28647. * Populates the passed array "ref" with the particles having the passed shapeId.
  28648. * @param shapeId the shape identifier
  28649. * @returns the SPS
  28650. * @param ref
  28651. */
  28652. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28653. /**
  28654. * Computes the required SubMeshes according the materials assigned to the particles.
  28655. * @returns the solid particle system.
  28656. * Does nothing if called before the SPS mesh is built.
  28657. */
  28658. computeSubMeshes(): SolidParticleSystem;
  28659. /**
  28660. * Sorts the solid particles by material when MultiMaterial is enabled.
  28661. * Updates the indices32 array.
  28662. * Updates the indicesByMaterial array.
  28663. * Updates the mesh indices array.
  28664. * @returns the SPS
  28665. * @hidden
  28666. */
  28667. private _sortParticlesByMaterial;
  28668. /**
  28669. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28670. * @hidden
  28671. */
  28672. private _setMaterialIndexesById;
  28673. /**
  28674. * Returns an array with unique values of Materials from the passed array
  28675. * @param array the material array to be checked and filtered
  28676. * @hidden
  28677. */
  28678. private _filterUniqueMaterialId;
  28679. /**
  28680. * Sets a new Standard Material as _defaultMaterial if not already set.
  28681. * @hidden
  28682. */
  28683. private _setDefaultMaterial;
  28684. /**
  28685. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28686. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28687. * @returns the SPS.
  28688. */
  28689. refreshVisibleSize(): SolidParticleSystem;
  28690. /**
  28691. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28692. * @param size the size (float) of the visibility box
  28693. * note : this doesn't lock the SPS mesh bounding box.
  28694. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28695. */
  28696. setVisibilityBox(size: number): void;
  28697. /**
  28698. * Gets whether the SPS as always visible or not
  28699. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28700. */
  28701. get isAlwaysVisible(): boolean;
  28702. /**
  28703. * Sets the SPS as always visible or not
  28704. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28705. */
  28706. set isAlwaysVisible(val: boolean);
  28707. /**
  28708. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28709. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28710. */
  28711. set isVisibilityBoxLocked(val: boolean);
  28712. /**
  28713. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28714. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28715. */
  28716. get isVisibilityBoxLocked(): boolean;
  28717. /**
  28718. * Tells to `setParticles()` to compute the particle rotations or not.
  28719. * Default value : true. The SPS is faster when it's set to false.
  28720. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28721. */
  28722. set computeParticleRotation(val: boolean);
  28723. /**
  28724. * Tells to `setParticles()` to compute the particle colors or not.
  28725. * Default value : true. The SPS is faster when it's set to false.
  28726. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28727. */
  28728. set computeParticleColor(val: boolean);
  28729. set computeParticleTexture(val: boolean);
  28730. /**
  28731. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28732. * Default value : false. The SPS is faster when it's set to false.
  28733. * Note : the particle custom vertex positions aren't stored values.
  28734. */
  28735. set computeParticleVertex(val: boolean);
  28736. /**
  28737. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28738. */
  28739. set computeBoundingBox(val: boolean);
  28740. /**
  28741. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28742. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28743. * Default : `true`
  28744. */
  28745. set depthSortParticles(val: boolean);
  28746. /**
  28747. * Gets if `setParticles()` computes the particle rotations or not.
  28748. * Default value : true. The SPS is faster when it's set to false.
  28749. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28750. */
  28751. get computeParticleRotation(): boolean;
  28752. /**
  28753. * Gets if `setParticles()` computes the particle colors or not.
  28754. * Default value : true. The SPS is faster when it's set to false.
  28755. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28756. */
  28757. get computeParticleColor(): boolean;
  28758. /**
  28759. * Gets if `setParticles()` computes the particle textures or not.
  28760. * Default value : true. The SPS is faster when it's set to false.
  28761. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28762. */
  28763. get computeParticleTexture(): boolean;
  28764. /**
  28765. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28766. * Default value : false. The SPS is faster when it's set to false.
  28767. * Note : the particle custom vertex positions aren't stored values.
  28768. */
  28769. get computeParticleVertex(): boolean;
  28770. /**
  28771. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28772. */
  28773. get computeBoundingBox(): boolean;
  28774. /**
  28775. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28776. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28777. * Default : `true`
  28778. */
  28779. get depthSortParticles(): boolean;
  28780. /**
  28781. * Gets if the SPS is created as expandable at construction time.
  28782. * Default : `false`
  28783. */
  28784. get expandable(): boolean;
  28785. /**
  28786. * Gets if the SPS supports the Multi Materials
  28787. */
  28788. get multimaterialEnabled(): boolean;
  28789. /**
  28790. * Gets if the SPS uses the model materials for its own multimaterial.
  28791. */
  28792. get useModelMaterial(): boolean;
  28793. /**
  28794. * The SPS used material array.
  28795. */
  28796. get materials(): Material[];
  28797. /**
  28798. * Sets the SPS MultiMaterial from the passed materials.
  28799. * Note : the passed array is internally copied and not used then by reference.
  28800. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28801. */
  28802. setMultiMaterial(materials: Material[]): void;
  28803. /**
  28804. * The SPS computed multimaterial object
  28805. */
  28806. get multimaterial(): MultiMaterial;
  28807. set multimaterial(mm: MultiMaterial);
  28808. /**
  28809. * If the subMeshes must be updated on the next call to setParticles()
  28810. */
  28811. get autoUpdateSubMeshes(): boolean;
  28812. set autoUpdateSubMeshes(val: boolean);
  28813. /**
  28814. * This function does nothing. It may be overwritten to set all the particle first values.
  28815. * The SPS doesn't call this function, you may have to call it by your own.
  28816. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28817. */
  28818. initParticles(): void;
  28819. /**
  28820. * This function does nothing. It may be overwritten to recycle a particle.
  28821. * The SPS doesn't call this function, you may have to call it by your own.
  28822. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28823. * @param particle The particle to recycle
  28824. * @returns the recycled particle
  28825. */
  28826. recycleParticle(particle: SolidParticle): SolidParticle;
  28827. /**
  28828. * Updates a particle : this function should be overwritten by the user.
  28829. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28830. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28831. * @example : just set a particle position or velocity and recycle conditions
  28832. * @param particle The particle to update
  28833. * @returns the updated particle
  28834. */
  28835. updateParticle(particle: SolidParticle): SolidParticle;
  28836. /**
  28837. * Updates a vertex of a particle : it can be overwritten by the user.
  28838. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28839. * @param particle the current particle
  28840. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  28841. * @param pt the index of the current vertex in the particle shape
  28842. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28843. * @example : just set a vertex particle position or color
  28844. * @returns the sps
  28845. */
  28846. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  28847. /**
  28848. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28849. * This does nothing and may be overwritten by the user.
  28850. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28851. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28852. * @param update the boolean update value actually passed to setParticles()
  28853. */
  28854. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28855. /**
  28856. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28857. * This will be passed three parameters.
  28858. * This does nothing and may be overwritten by the user.
  28859. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28860. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28861. * @param update the boolean update value actually passed to setParticles()
  28862. */
  28863. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28864. }
  28865. }
  28866. declare module "babylonjs/Particles/solidParticle" {
  28867. import { Nullable } from "babylonjs/types";
  28868. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  28869. import { Color4 } from "babylonjs/Maths/math.color";
  28870. import { Mesh } from "babylonjs/Meshes/mesh";
  28871. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28872. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28873. import { Plane } from "babylonjs/Maths/math.plane";
  28874. import { Material } from "babylonjs/Materials/material";
  28875. /**
  28876. * Represents one particle of a solid particle system.
  28877. */
  28878. export class SolidParticle {
  28879. /**
  28880. * particle global index
  28881. */
  28882. idx: number;
  28883. /**
  28884. * particle identifier
  28885. */
  28886. id: number;
  28887. /**
  28888. * The color of the particle
  28889. */
  28890. color: Nullable<Color4>;
  28891. /**
  28892. * The world space position of the particle.
  28893. */
  28894. position: Vector3;
  28895. /**
  28896. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28897. */
  28898. rotation: Vector3;
  28899. /**
  28900. * The world space rotation quaternion of the particle.
  28901. */
  28902. rotationQuaternion: Nullable<Quaternion>;
  28903. /**
  28904. * The scaling of the particle.
  28905. */
  28906. scaling: Vector3;
  28907. /**
  28908. * The uvs of the particle.
  28909. */
  28910. uvs: Vector4;
  28911. /**
  28912. * The current speed of the particle.
  28913. */
  28914. velocity: Vector3;
  28915. /**
  28916. * The pivot point in the particle local space.
  28917. */
  28918. pivot: Vector3;
  28919. /**
  28920. * Must the particle be translated from its pivot point in its local space ?
  28921. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28922. * Default : false
  28923. */
  28924. translateFromPivot: boolean;
  28925. /**
  28926. * Is the particle active or not ?
  28927. */
  28928. alive: boolean;
  28929. /**
  28930. * Is the particle visible or not ?
  28931. */
  28932. isVisible: boolean;
  28933. /**
  28934. * Index of this particle in the global "positions" array (Internal use)
  28935. * @hidden
  28936. */
  28937. _pos: number;
  28938. /**
  28939. * @hidden Index of this particle in the global "indices" array (Internal use)
  28940. */
  28941. _ind: number;
  28942. /**
  28943. * @hidden ModelShape of this particle (Internal use)
  28944. */
  28945. _model: ModelShape;
  28946. /**
  28947. * ModelShape id of this particle
  28948. */
  28949. shapeId: number;
  28950. /**
  28951. * Index of the particle in its shape id
  28952. */
  28953. idxInShape: number;
  28954. /**
  28955. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28956. */
  28957. _modelBoundingInfo: BoundingInfo;
  28958. /**
  28959. * @hidden Particle BoundingInfo object (Internal use)
  28960. */
  28961. _boundingInfo: BoundingInfo;
  28962. /**
  28963. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28964. */
  28965. _sps: SolidParticleSystem;
  28966. /**
  28967. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28968. */
  28969. _stillInvisible: boolean;
  28970. /**
  28971. * @hidden Last computed particle rotation matrix
  28972. */
  28973. _rotationMatrix: number[];
  28974. /**
  28975. * Parent particle Id, if any.
  28976. * Default null.
  28977. */
  28978. parentId: Nullable<number>;
  28979. /**
  28980. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28981. */
  28982. materialIndex: Nullable<number>;
  28983. /**
  28984. * Custom object or properties.
  28985. */
  28986. props: Nullable<any>;
  28987. /**
  28988. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28989. * The possible values are :
  28990. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28991. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28992. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28993. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28994. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28995. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28996. * */
  28997. cullingStrategy: number;
  28998. /**
  28999. * @hidden Internal global position in the SPS.
  29000. */
  29001. _globalPosition: Vector3;
  29002. /**
  29003. * Creates a Solid Particle object.
  29004. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  29005. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  29006. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  29007. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  29008. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  29009. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  29010. * @param shapeId (integer) is the model shape identifier in the SPS.
  29011. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  29012. * @param sps defines the sps it is associated to
  29013. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  29014. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  29015. */
  29016. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  29017. /**
  29018. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  29019. * @param target the particle target
  29020. * @returns the current particle
  29021. */
  29022. copyToRef(target: SolidParticle): SolidParticle;
  29023. /**
  29024. * Legacy support, changed scale to scaling
  29025. */
  29026. get scale(): Vector3;
  29027. /**
  29028. * Legacy support, changed scale to scaling
  29029. */
  29030. set scale(scale: Vector3);
  29031. /**
  29032. * Legacy support, changed quaternion to rotationQuaternion
  29033. */
  29034. get quaternion(): Nullable<Quaternion>;
  29035. /**
  29036. * Legacy support, changed quaternion to rotationQuaternion
  29037. */
  29038. set quaternion(q: Nullable<Quaternion>);
  29039. /**
  29040. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  29041. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  29042. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  29043. * @returns true if it intersects
  29044. */
  29045. intersectsMesh(target: Mesh | SolidParticle): boolean;
  29046. /**
  29047. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  29048. * A particle is in the frustum if its bounding box intersects the frustum
  29049. * @param frustumPlanes defines the frustum to test
  29050. * @returns true if the particle is in the frustum planes
  29051. */
  29052. isInFrustum(frustumPlanes: Plane[]): boolean;
  29053. /**
  29054. * get the rotation matrix of the particle
  29055. * @hidden
  29056. */
  29057. getRotationMatrix(m: Matrix): void;
  29058. }
  29059. /**
  29060. * Represents the shape of the model used by one particle of a solid particle system.
  29061. * SPS internal tool, don't use it manually.
  29062. */
  29063. export class ModelShape {
  29064. /**
  29065. * The shape id
  29066. * @hidden
  29067. */
  29068. shapeID: number;
  29069. /**
  29070. * flat array of model positions (internal use)
  29071. * @hidden
  29072. */
  29073. _shape: Vector3[];
  29074. /**
  29075. * flat array of model UVs (internal use)
  29076. * @hidden
  29077. */
  29078. _shapeUV: number[];
  29079. /**
  29080. * color array of the model
  29081. * @hidden
  29082. */
  29083. _shapeColors: number[];
  29084. /**
  29085. * indices array of the model
  29086. * @hidden
  29087. */
  29088. _indices: number[];
  29089. /**
  29090. * normals array of the model
  29091. * @hidden
  29092. */
  29093. _normals: number[];
  29094. /**
  29095. * length of the shape in the model indices array (internal use)
  29096. * @hidden
  29097. */
  29098. _indicesLength: number;
  29099. /**
  29100. * Custom position function (internal use)
  29101. * @hidden
  29102. */
  29103. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  29104. /**
  29105. * Custom vertex function (internal use)
  29106. * @hidden
  29107. */
  29108. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  29109. /**
  29110. * Model material (internal use)
  29111. * @hidden
  29112. */
  29113. _material: Nullable<Material>;
  29114. /**
  29115. * 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.
  29116. * SPS internal tool, don't use it manually.
  29117. * @hidden
  29118. */
  29119. 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>);
  29120. }
  29121. /**
  29122. * Represents a Depth Sorted Particle in the solid particle system.
  29123. * @hidden
  29124. */
  29125. export class DepthSortedParticle {
  29126. /**
  29127. * Particle index
  29128. */
  29129. idx: number;
  29130. /**
  29131. * Index of the particle in the "indices" array
  29132. */
  29133. ind: number;
  29134. /**
  29135. * Length of the particle shape in the "indices" array
  29136. */
  29137. indicesLength: number;
  29138. /**
  29139. * Squared distance from the particle to the camera
  29140. */
  29141. sqDistance: number;
  29142. /**
  29143. * Material index when used with MultiMaterials
  29144. */
  29145. materialIndex: number;
  29146. /**
  29147. * Creates a new sorted particle
  29148. * @param materialIndex
  29149. */
  29150. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  29151. }
  29152. /**
  29153. * Represents a solid particle vertex
  29154. */
  29155. export class SolidParticleVertex {
  29156. /**
  29157. * Vertex position
  29158. */
  29159. position: Vector3;
  29160. /**
  29161. * Vertex color
  29162. */
  29163. color: Color4;
  29164. /**
  29165. * Vertex UV
  29166. */
  29167. uv: Vector2;
  29168. /**
  29169. * Creates a new solid particle vertex
  29170. */
  29171. constructor();
  29172. /** Vertex x coordinate */
  29173. get x(): number;
  29174. set x(val: number);
  29175. /** Vertex y coordinate */
  29176. get y(): number;
  29177. set y(val: number);
  29178. /** Vertex z coordinate */
  29179. get z(): number;
  29180. set z(val: number);
  29181. }
  29182. }
  29183. declare module "babylonjs/Collisions/meshCollisionData" {
  29184. import { Collider } from "babylonjs/Collisions/collider";
  29185. import { Vector3 } from "babylonjs/Maths/math.vector";
  29186. import { Nullable } from "babylonjs/types";
  29187. import { Observer } from "babylonjs/Misc/observable";
  29188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29189. /**
  29190. * @hidden
  29191. */
  29192. export class _MeshCollisionData {
  29193. _checkCollisions: boolean;
  29194. _collisionMask: number;
  29195. _collisionGroup: number;
  29196. _surroundingMeshes: Nullable<AbstractMesh[]>;
  29197. _collider: Nullable<Collider>;
  29198. _oldPositionForCollisions: Vector3;
  29199. _diffPositionForCollisions: Vector3;
  29200. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  29201. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  29202. }
  29203. }
  29204. declare module "babylonjs/Meshes/abstractMesh" {
  29205. import { Observable } from "babylonjs/Misc/observable";
  29206. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  29207. import { Camera } from "babylonjs/Cameras/camera";
  29208. import { Scene, IDisposable } from "babylonjs/scene";
  29209. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  29210. import { Node } from "babylonjs/node";
  29211. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29212. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29213. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29214. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  29215. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  29216. import { Material } from "babylonjs/Materials/material";
  29217. import { Light } from "babylonjs/Lights/light";
  29218. import { Skeleton } from "babylonjs/Bones/skeleton";
  29219. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29220. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  29221. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29222. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  29223. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29224. import { Plane } from "babylonjs/Maths/math.plane";
  29225. import { Ray } from "babylonjs/Culling/ray";
  29226. import { Collider } from "babylonjs/Collisions/collider";
  29227. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  29228. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  29229. /** @hidden */
  29230. class _FacetDataStorage {
  29231. facetPositions: Vector3[];
  29232. facetNormals: Vector3[];
  29233. facetPartitioning: number[][];
  29234. facetNb: number;
  29235. partitioningSubdivisions: number;
  29236. partitioningBBoxRatio: number;
  29237. facetDataEnabled: boolean;
  29238. facetParameters: any;
  29239. bbSize: Vector3;
  29240. subDiv: {
  29241. max: number;
  29242. X: number;
  29243. Y: number;
  29244. Z: number;
  29245. };
  29246. facetDepthSort: boolean;
  29247. facetDepthSortEnabled: boolean;
  29248. depthSortedIndices: IndicesArray;
  29249. depthSortedFacets: {
  29250. ind: number;
  29251. sqDistance: number;
  29252. }[];
  29253. facetDepthSortFunction: (f1: {
  29254. ind: number;
  29255. sqDistance: number;
  29256. }, f2: {
  29257. ind: number;
  29258. sqDistance: number;
  29259. }) => number;
  29260. facetDepthSortFrom: Vector3;
  29261. facetDepthSortOrigin: Vector3;
  29262. invertedMatrix: Matrix;
  29263. }
  29264. /**
  29265. * @hidden
  29266. **/
  29267. class _InternalAbstractMeshDataInfo {
  29268. _hasVertexAlpha: boolean;
  29269. _useVertexColors: boolean;
  29270. _numBoneInfluencers: number;
  29271. _applyFog: boolean;
  29272. _receiveShadows: boolean;
  29273. _facetData: _FacetDataStorage;
  29274. _visibility: number;
  29275. _skeleton: Nullable<Skeleton>;
  29276. _layerMask: number;
  29277. _computeBonesUsingShaders: boolean;
  29278. _isActive: boolean;
  29279. _onlyForInstances: boolean;
  29280. _isActiveIntermediate: boolean;
  29281. _onlyForInstancesIntermediate: boolean;
  29282. _actAsRegularMesh: boolean;
  29283. }
  29284. /**
  29285. * Class used to store all common mesh properties
  29286. */
  29287. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  29288. /** No occlusion */
  29289. static OCCLUSION_TYPE_NONE: number;
  29290. /** Occlusion set to optimisitic */
  29291. static OCCLUSION_TYPE_OPTIMISTIC: number;
  29292. /** Occlusion set to strict */
  29293. static OCCLUSION_TYPE_STRICT: number;
  29294. /** Use an accurante occlusion algorithm */
  29295. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  29296. /** Use a conservative occlusion algorithm */
  29297. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29298. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29299. * Test order :
  29300. * Is the bounding sphere outside the frustum ?
  29301. * If not, are the bounding box vertices outside the frustum ?
  29302. * It not, then the cullable object is in the frustum.
  29303. */
  29304. static readonly CULLINGSTRATEGY_STANDARD: number;
  29305. /** Culling strategy : Bounding Sphere Only.
  29306. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29307. * It's also less accurate than the standard because some not visible objects can still be selected.
  29308. * Test : is the bounding sphere outside the frustum ?
  29309. * If not, then the cullable object is in the frustum.
  29310. */
  29311. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29312. /** Culling strategy : Optimistic Inclusion.
  29313. * This in an inclusion test first, then the standard exclusion test.
  29314. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29315. * 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.
  29316. * Anyway, it's as accurate as the standard strategy.
  29317. * Test :
  29318. * Is the cullable object bounding sphere center in the frustum ?
  29319. * If not, apply the default culling strategy.
  29320. */
  29321. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29322. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29323. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29324. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29325. * 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.
  29326. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29327. * Test :
  29328. * Is the cullable object bounding sphere center in the frustum ?
  29329. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29330. */
  29331. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29332. /**
  29333. * No billboard
  29334. */
  29335. static get BILLBOARDMODE_NONE(): number;
  29336. /** Billboard on X axis */
  29337. static get BILLBOARDMODE_X(): number;
  29338. /** Billboard on Y axis */
  29339. static get BILLBOARDMODE_Y(): number;
  29340. /** Billboard on Z axis */
  29341. static get BILLBOARDMODE_Z(): number;
  29342. /** Billboard on all axes */
  29343. static get BILLBOARDMODE_ALL(): number;
  29344. /** Billboard on using position instead of orientation */
  29345. static get BILLBOARDMODE_USE_POSITION(): number;
  29346. /** @hidden */
  29347. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29348. /**
  29349. * The culling strategy to use to check whether the mesh must be rendered or not.
  29350. * This value can be changed at any time and will be used on the next render mesh selection.
  29351. * The possible values are :
  29352. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29353. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29354. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29355. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29356. * Please read each static variable documentation to get details about the culling process.
  29357. * */
  29358. cullingStrategy: number;
  29359. /**
  29360. * Gets the number of facets in the mesh
  29361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29362. */
  29363. get facetNb(): number;
  29364. /**
  29365. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29367. */
  29368. get partitioningSubdivisions(): number;
  29369. set partitioningSubdivisions(nb: number);
  29370. /**
  29371. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29372. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29374. */
  29375. get partitioningBBoxRatio(): number;
  29376. set partitioningBBoxRatio(ratio: number);
  29377. /**
  29378. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29379. * Works only for updatable meshes.
  29380. * Doesn't work with multi-materials
  29381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29382. */
  29383. get mustDepthSortFacets(): boolean;
  29384. set mustDepthSortFacets(sort: boolean);
  29385. /**
  29386. * The location (Vector3) where the facet depth sort must be computed from.
  29387. * By default, the active camera position.
  29388. * Used only when facet depth sort is enabled
  29389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29390. */
  29391. get facetDepthSortFrom(): Vector3;
  29392. set facetDepthSortFrom(location: Vector3);
  29393. /**
  29394. * gets a boolean indicating if facetData is enabled
  29395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29396. */
  29397. get isFacetDataEnabled(): boolean;
  29398. /** @hidden */
  29399. _updateNonUniformScalingState(value: boolean): boolean;
  29400. /**
  29401. * An event triggered when this mesh collides with another one
  29402. */
  29403. onCollideObservable: Observable<AbstractMesh>;
  29404. /** Set a function to call when this mesh collides with another one */
  29405. set onCollide(callback: () => void);
  29406. /**
  29407. * An event triggered when the collision's position changes
  29408. */
  29409. onCollisionPositionChangeObservable: Observable<Vector3>;
  29410. /** Set a function to call when the collision's position changes */
  29411. set onCollisionPositionChange(callback: () => void);
  29412. /**
  29413. * An event triggered when material is changed
  29414. */
  29415. onMaterialChangedObservable: Observable<AbstractMesh>;
  29416. /**
  29417. * Gets or sets the orientation for POV movement & rotation
  29418. */
  29419. definedFacingForward: boolean;
  29420. /** @hidden */
  29421. _occlusionQuery: Nullable<WebGLQuery>;
  29422. /** @hidden */
  29423. _renderingGroup: Nullable<RenderingGroup>;
  29424. /**
  29425. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29426. */
  29427. get visibility(): number;
  29428. /**
  29429. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29430. */
  29431. set visibility(value: number);
  29432. /** Gets or sets the alpha index used to sort transparent meshes
  29433. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29434. */
  29435. alphaIndex: number;
  29436. /**
  29437. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29438. */
  29439. isVisible: boolean;
  29440. /**
  29441. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29442. */
  29443. isPickable: boolean;
  29444. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29445. showSubMeshesBoundingBox: boolean;
  29446. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29447. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29448. */
  29449. isBlocker: boolean;
  29450. /**
  29451. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29452. */
  29453. enablePointerMoveEvents: boolean;
  29454. /**
  29455. * Specifies the rendering group id for this mesh (0 by default)
  29456. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29457. */
  29458. renderingGroupId: number;
  29459. private _material;
  29460. /** Gets or sets current material */
  29461. get material(): Nullable<Material>;
  29462. set material(value: Nullable<Material>);
  29463. /**
  29464. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29465. * @see http://doc.babylonjs.com/babylon101/shadows
  29466. */
  29467. get receiveShadows(): boolean;
  29468. set receiveShadows(value: boolean);
  29469. /** Defines color to use when rendering outline */
  29470. outlineColor: Color3;
  29471. /** Define width to use when rendering outline */
  29472. outlineWidth: number;
  29473. /** Defines color to use when rendering overlay */
  29474. overlayColor: Color3;
  29475. /** Defines alpha to use when rendering overlay */
  29476. overlayAlpha: number;
  29477. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29478. get hasVertexAlpha(): boolean;
  29479. set hasVertexAlpha(value: boolean);
  29480. /** 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) */
  29481. get useVertexColors(): boolean;
  29482. set useVertexColors(value: boolean);
  29483. /**
  29484. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29485. */
  29486. get computeBonesUsingShaders(): boolean;
  29487. set computeBonesUsingShaders(value: boolean);
  29488. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29489. get numBoneInfluencers(): number;
  29490. set numBoneInfluencers(value: number);
  29491. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29492. get applyFog(): boolean;
  29493. set applyFog(value: boolean);
  29494. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29495. useOctreeForRenderingSelection: boolean;
  29496. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29497. useOctreeForPicking: boolean;
  29498. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29499. useOctreeForCollisions: boolean;
  29500. /**
  29501. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29502. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29503. */
  29504. get layerMask(): number;
  29505. set layerMask(value: number);
  29506. /**
  29507. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29508. */
  29509. alwaysSelectAsActiveMesh: boolean;
  29510. /**
  29511. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29512. */
  29513. doNotSyncBoundingInfo: boolean;
  29514. /**
  29515. * Gets or sets the current action manager
  29516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29517. */
  29518. actionManager: Nullable<AbstractActionManager>;
  29519. private _meshCollisionData;
  29520. /**
  29521. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29522. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29523. */
  29524. ellipsoid: Vector3;
  29525. /**
  29526. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29527. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29528. */
  29529. ellipsoidOffset: Vector3;
  29530. /**
  29531. * Gets or sets a collision mask used to mask collisions (default is -1).
  29532. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29533. */
  29534. get collisionMask(): number;
  29535. set collisionMask(mask: number);
  29536. /**
  29537. * Gets or sets the current collision group mask (-1 by default).
  29538. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29539. */
  29540. get collisionGroup(): number;
  29541. set collisionGroup(mask: number);
  29542. /**
  29543. * Gets or sets current surrounding meshes (null by default).
  29544. *
  29545. * By default collision detection is tested against every mesh in the scene.
  29546. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29547. * meshes will be tested for the collision.
  29548. *
  29549. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29550. */
  29551. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29552. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29553. /**
  29554. * Defines edge width used when edgesRenderer is enabled
  29555. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29556. */
  29557. edgesWidth: number;
  29558. /**
  29559. * Defines edge color used when edgesRenderer is enabled
  29560. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29561. */
  29562. edgesColor: Color4;
  29563. /** @hidden */
  29564. _edgesRenderer: Nullable<IEdgesRenderer>;
  29565. /** @hidden */
  29566. _masterMesh: Nullable<AbstractMesh>;
  29567. /** @hidden */
  29568. _boundingInfo: Nullable<BoundingInfo>;
  29569. /** @hidden */
  29570. _renderId: number;
  29571. /**
  29572. * Gets or sets the list of subMeshes
  29573. * @see http://doc.babylonjs.com/how_to/multi_materials
  29574. */
  29575. subMeshes: SubMesh[];
  29576. /** @hidden */
  29577. _intersectionsInProgress: AbstractMesh[];
  29578. /** @hidden */
  29579. _unIndexed: boolean;
  29580. /** @hidden */
  29581. _lightSources: Light[];
  29582. /** Gets the list of lights affecting that mesh */
  29583. get lightSources(): Light[];
  29584. /** @hidden */
  29585. get _positions(): Nullable<Vector3[]>;
  29586. /** @hidden */
  29587. _waitingData: {
  29588. lods: Nullable<any>;
  29589. actions: Nullable<any>;
  29590. freezeWorldMatrix: Nullable<boolean>;
  29591. };
  29592. /** @hidden */
  29593. _bonesTransformMatrices: Nullable<Float32Array>;
  29594. /** @hidden */
  29595. _transformMatrixTexture: Nullable<RawTexture>;
  29596. /**
  29597. * Gets or sets a skeleton to apply skining transformations
  29598. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29599. */
  29600. set skeleton(value: Nullable<Skeleton>);
  29601. get skeleton(): Nullable<Skeleton>;
  29602. /**
  29603. * An event triggered when the mesh is rebuilt.
  29604. */
  29605. onRebuildObservable: Observable<AbstractMesh>;
  29606. /**
  29607. * Creates a new AbstractMesh
  29608. * @param name defines the name of the mesh
  29609. * @param scene defines the hosting scene
  29610. */
  29611. constructor(name: string, scene?: Nullable<Scene>);
  29612. /**
  29613. * Returns the string "AbstractMesh"
  29614. * @returns "AbstractMesh"
  29615. */
  29616. getClassName(): string;
  29617. /**
  29618. * Gets a string representation of the current mesh
  29619. * @param fullDetails defines a boolean indicating if full details must be included
  29620. * @returns a string representation of the current mesh
  29621. */
  29622. toString(fullDetails?: boolean): string;
  29623. /**
  29624. * @hidden
  29625. */
  29626. protected _getEffectiveParent(): Nullable<Node>;
  29627. /** @hidden */
  29628. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29629. /** @hidden */
  29630. _rebuild(): void;
  29631. /** @hidden */
  29632. _resyncLightSources(): void;
  29633. /** @hidden */
  29634. _resyncLightSource(light: Light): void;
  29635. /** @hidden */
  29636. _unBindEffect(): void;
  29637. /** @hidden */
  29638. _removeLightSource(light: Light, dispose: boolean): void;
  29639. private _markSubMeshesAsDirty;
  29640. /** @hidden */
  29641. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29642. /** @hidden */
  29643. _markSubMeshesAsAttributesDirty(): void;
  29644. /** @hidden */
  29645. _markSubMeshesAsMiscDirty(): void;
  29646. /**
  29647. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29648. */
  29649. get scaling(): Vector3;
  29650. set scaling(newScaling: Vector3);
  29651. /**
  29652. * Returns true if the mesh is blocked. Implemented by child classes
  29653. */
  29654. get isBlocked(): boolean;
  29655. /**
  29656. * Returns the mesh itself by default. Implemented by child classes
  29657. * @param camera defines the camera to use to pick the right LOD level
  29658. * @returns the currentAbstractMesh
  29659. */
  29660. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29661. /**
  29662. * Returns 0 by default. Implemented by child classes
  29663. * @returns an integer
  29664. */
  29665. getTotalVertices(): number;
  29666. /**
  29667. * Returns a positive integer : the total number of indices in this mesh geometry.
  29668. * @returns the numner of indices or zero if the mesh has no geometry.
  29669. */
  29670. getTotalIndices(): number;
  29671. /**
  29672. * Returns null by default. Implemented by child classes
  29673. * @returns null
  29674. */
  29675. getIndices(): Nullable<IndicesArray>;
  29676. /**
  29677. * Returns the array of the requested vertex data kind. Implemented by child classes
  29678. * @param kind defines the vertex data kind to use
  29679. * @returns null
  29680. */
  29681. getVerticesData(kind: string): Nullable<FloatArray>;
  29682. /**
  29683. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29684. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29685. * Note that a new underlying VertexBuffer object is created each call.
  29686. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29687. * @param kind defines vertex data kind:
  29688. * * VertexBuffer.PositionKind
  29689. * * VertexBuffer.UVKind
  29690. * * VertexBuffer.UV2Kind
  29691. * * VertexBuffer.UV3Kind
  29692. * * VertexBuffer.UV4Kind
  29693. * * VertexBuffer.UV5Kind
  29694. * * VertexBuffer.UV6Kind
  29695. * * VertexBuffer.ColorKind
  29696. * * VertexBuffer.MatricesIndicesKind
  29697. * * VertexBuffer.MatricesIndicesExtraKind
  29698. * * VertexBuffer.MatricesWeightsKind
  29699. * * VertexBuffer.MatricesWeightsExtraKind
  29700. * @param data defines the data source
  29701. * @param updatable defines if the data must be flagged as updatable (or static)
  29702. * @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
  29703. * @returns the current mesh
  29704. */
  29705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29706. /**
  29707. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29708. * If the mesh has no geometry, it is simply returned as it is.
  29709. * @param kind defines vertex data kind:
  29710. * * VertexBuffer.PositionKind
  29711. * * VertexBuffer.UVKind
  29712. * * VertexBuffer.UV2Kind
  29713. * * VertexBuffer.UV3Kind
  29714. * * VertexBuffer.UV4Kind
  29715. * * VertexBuffer.UV5Kind
  29716. * * VertexBuffer.UV6Kind
  29717. * * VertexBuffer.ColorKind
  29718. * * VertexBuffer.MatricesIndicesKind
  29719. * * VertexBuffer.MatricesIndicesExtraKind
  29720. * * VertexBuffer.MatricesWeightsKind
  29721. * * VertexBuffer.MatricesWeightsExtraKind
  29722. * @param data defines the data source
  29723. * @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
  29724. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29725. * @returns the current mesh
  29726. */
  29727. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29728. /**
  29729. * Sets the mesh indices,
  29730. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29731. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29732. * @param totalVertices Defines the total number of vertices
  29733. * @returns the current mesh
  29734. */
  29735. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29736. /**
  29737. * Gets a boolean indicating if specific vertex data is present
  29738. * @param kind defines the vertex data kind to use
  29739. * @returns true is data kind is present
  29740. */
  29741. isVerticesDataPresent(kind: string): boolean;
  29742. /**
  29743. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29744. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29745. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29746. * @returns a BoundingInfo
  29747. */
  29748. getBoundingInfo(): BoundingInfo;
  29749. /**
  29750. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29751. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29752. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29753. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29754. * @returns the current mesh
  29755. */
  29756. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29757. /**
  29758. * Overwrite the current bounding info
  29759. * @param boundingInfo defines the new bounding info
  29760. * @returns the current mesh
  29761. */
  29762. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29763. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29764. get useBones(): boolean;
  29765. /** @hidden */
  29766. _preActivate(): void;
  29767. /** @hidden */
  29768. _preActivateForIntermediateRendering(renderId: number): void;
  29769. /** @hidden */
  29770. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29771. /** @hidden */
  29772. _postActivate(): void;
  29773. /** @hidden */
  29774. _freeze(): void;
  29775. /** @hidden */
  29776. _unFreeze(): void;
  29777. /**
  29778. * Gets the current world matrix
  29779. * @returns a Matrix
  29780. */
  29781. getWorldMatrix(): Matrix;
  29782. /** @hidden */
  29783. _getWorldMatrixDeterminant(): number;
  29784. /**
  29785. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29786. */
  29787. get isAnInstance(): boolean;
  29788. /**
  29789. * Gets a boolean indicating if this mesh has instances
  29790. */
  29791. get hasInstances(): boolean;
  29792. /**
  29793. * Perform relative position change from the point of view of behind the front of the mesh.
  29794. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29795. * Supports definition of mesh facing forward or backward
  29796. * @param amountRight defines the distance on the right axis
  29797. * @param amountUp defines the distance on the up axis
  29798. * @param amountForward defines the distance on the forward axis
  29799. * @returns the current mesh
  29800. */
  29801. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29802. /**
  29803. * Calculate relative position change from the point of view of behind the front of the mesh.
  29804. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29805. * Supports definition of mesh facing forward or backward
  29806. * @param amountRight defines the distance on the right axis
  29807. * @param amountUp defines the distance on the up axis
  29808. * @param amountForward defines the distance on the forward axis
  29809. * @returns the new displacement vector
  29810. */
  29811. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29812. /**
  29813. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29814. * Supports definition of mesh facing forward or backward
  29815. * @param flipBack defines the flip
  29816. * @param twirlClockwise defines the twirl
  29817. * @param tiltRight defines the tilt
  29818. * @returns the current mesh
  29819. */
  29820. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29821. /**
  29822. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29823. * Supports definition of mesh facing forward or backward.
  29824. * @param flipBack defines the flip
  29825. * @param twirlClockwise defines the twirl
  29826. * @param tiltRight defines the tilt
  29827. * @returns the new rotation vector
  29828. */
  29829. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29830. /**
  29831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29832. * This means the mesh underlying bounding box and sphere are recomputed.
  29833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29834. * @returns the current mesh
  29835. */
  29836. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29837. /** @hidden */
  29838. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29839. /** @hidden */
  29840. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29841. /** @hidden */
  29842. _updateBoundingInfo(): AbstractMesh;
  29843. /** @hidden */
  29844. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29845. /** @hidden */
  29846. protected _afterComputeWorldMatrix(): void;
  29847. /** @hidden */
  29848. get _effectiveMesh(): AbstractMesh;
  29849. /**
  29850. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29851. * A mesh is in the frustum if its bounding box intersects the frustum
  29852. * @param frustumPlanes defines the frustum to test
  29853. * @returns true if the mesh is in the frustum planes
  29854. */
  29855. isInFrustum(frustumPlanes: Plane[]): boolean;
  29856. /**
  29857. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29858. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29859. * @param frustumPlanes defines the frustum to test
  29860. * @returns true if the mesh is completely in the frustum planes
  29861. */
  29862. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29863. /**
  29864. * True if the mesh intersects another mesh or a SolidParticle object
  29865. * @param mesh defines a target mesh or SolidParticle to test
  29866. * @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)
  29867. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29868. * @returns true if there is an intersection
  29869. */
  29870. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29871. /**
  29872. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29873. * @param point defines the point to test
  29874. * @returns true if there is an intersection
  29875. */
  29876. intersectsPoint(point: Vector3): boolean;
  29877. /**
  29878. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29880. */
  29881. get checkCollisions(): boolean;
  29882. set checkCollisions(collisionEnabled: boolean);
  29883. /**
  29884. * Gets Collider object used to compute collisions (not physics)
  29885. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29886. */
  29887. get collider(): Nullable<Collider>;
  29888. /**
  29889. * Move the mesh using collision engine
  29890. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29891. * @param displacement defines the requested displacement vector
  29892. * @returns the current mesh
  29893. */
  29894. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29895. private _onCollisionPositionChange;
  29896. /** @hidden */
  29897. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29898. /** @hidden */
  29899. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29900. /** @hidden */
  29901. _checkCollision(collider: Collider): AbstractMesh;
  29902. /** @hidden */
  29903. _generatePointsArray(): boolean;
  29904. /**
  29905. * Checks if the passed Ray intersects with the mesh
  29906. * @param ray defines the ray to use
  29907. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29908. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29909. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29910. * @returns the picking info
  29911. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29912. */
  29913. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29914. /**
  29915. * Clones the current mesh
  29916. * @param name defines the mesh name
  29917. * @param newParent defines the new mesh parent
  29918. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29919. * @returns the new mesh
  29920. */
  29921. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29922. /**
  29923. * Disposes all the submeshes of the current meshnp
  29924. * @returns the current mesh
  29925. */
  29926. releaseSubMeshes(): AbstractMesh;
  29927. /**
  29928. * Releases resources associated with this abstract mesh.
  29929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29931. */
  29932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29933. /**
  29934. * Adds the passed mesh as a child to the current mesh
  29935. * @param mesh defines the child mesh
  29936. * @returns the current mesh
  29937. */
  29938. addChild(mesh: AbstractMesh): AbstractMesh;
  29939. /**
  29940. * Removes the passed mesh from the current mesh children list
  29941. * @param mesh defines the child mesh
  29942. * @returns the current mesh
  29943. */
  29944. removeChild(mesh: AbstractMesh): AbstractMesh;
  29945. /** @hidden */
  29946. private _initFacetData;
  29947. /**
  29948. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29949. * This method can be called within the render loop.
  29950. * 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
  29951. * @returns the current mesh
  29952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29953. */
  29954. updateFacetData(): AbstractMesh;
  29955. /**
  29956. * Returns the facetLocalNormals array.
  29957. * The normals are expressed in the mesh local spac
  29958. * @returns an array of Vector3
  29959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29960. */
  29961. getFacetLocalNormals(): Vector3[];
  29962. /**
  29963. * Returns the facetLocalPositions array.
  29964. * The facet positions are expressed in the mesh local space
  29965. * @returns an array of Vector3
  29966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29967. */
  29968. getFacetLocalPositions(): Vector3[];
  29969. /**
  29970. * Returns the facetLocalPartioning array
  29971. * @returns an array of array of numbers
  29972. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29973. */
  29974. getFacetLocalPartitioning(): number[][];
  29975. /**
  29976. * Returns the i-th facet position in the world system.
  29977. * This method allocates a new Vector3 per call
  29978. * @param i defines the facet index
  29979. * @returns a new Vector3
  29980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29981. */
  29982. getFacetPosition(i: number): Vector3;
  29983. /**
  29984. * Sets the reference Vector3 with the i-th facet position in the world system
  29985. * @param i defines the facet index
  29986. * @param ref defines the target vector
  29987. * @returns the current mesh
  29988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29989. */
  29990. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29991. /**
  29992. * Returns the i-th facet normal in the world system.
  29993. * This method allocates a new Vector3 per call
  29994. * @param i defines the facet index
  29995. * @returns a new Vector3
  29996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29997. */
  29998. getFacetNormal(i: number): Vector3;
  29999. /**
  30000. * Sets the reference Vector3 with the i-th facet normal in the world system
  30001. * @param i defines the facet index
  30002. * @param ref defines the target vector
  30003. * @returns the current mesh
  30004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30005. */
  30006. getFacetNormalToRef(i: number, ref: Vector3): this;
  30007. /**
  30008. * 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)
  30009. * @param x defines x coordinate
  30010. * @param y defines y coordinate
  30011. * @param z defines z coordinate
  30012. * @returns the array of facet indexes
  30013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30014. */
  30015. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  30016. /**
  30017. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  30018. * @param projected sets as the (x,y,z) world projection on the facet
  30019. * @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
  30020. * @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
  30021. * @param x defines x coordinate
  30022. * @param y defines y coordinate
  30023. * @param z defines z coordinate
  30024. * @returns the face index if found (or null instead)
  30025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30026. */
  30027. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  30028. /**
  30029. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  30030. * @param projected sets as the (x,y,z) local projection on the facet
  30031. * @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
  30032. * @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
  30033. * @param x defines x coordinate
  30034. * @param y defines y coordinate
  30035. * @param z defines z coordinate
  30036. * @returns the face index if found (or null instead)
  30037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30038. */
  30039. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  30040. /**
  30041. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  30042. * @returns the parameters
  30043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30044. */
  30045. getFacetDataParameters(): any;
  30046. /**
  30047. * Disables the feature FacetData and frees the related memory
  30048. * @returns the current mesh
  30049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30050. */
  30051. disableFacetData(): AbstractMesh;
  30052. /**
  30053. * Updates the AbstractMesh indices array
  30054. * @param indices defines the data source
  30055. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  30056. * @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)
  30057. * @returns the current mesh
  30058. */
  30059. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  30060. /**
  30061. * Creates new normals data for the mesh
  30062. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  30063. * @returns the current mesh
  30064. */
  30065. createNormals(updatable: boolean): AbstractMesh;
  30066. /**
  30067. * Align the mesh with a normal
  30068. * @param normal defines the normal to use
  30069. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  30070. * @returns the current mesh
  30071. */
  30072. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  30073. /** @hidden */
  30074. _checkOcclusionQuery(): boolean;
  30075. /**
  30076. * Disables the mesh edge rendering mode
  30077. * @returns the currentAbstractMesh
  30078. */
  30079. disableEdgesRendering(): AbstractMesh;
  30080. /**
  30081. * Enables the edge rendering mode on the mesh.
  30082. * This mode makes the mesh edges visible
  30083. * @param epsilon defines the maximal distance between two angles to detect a face
  30084. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30085. * @returns the currentAbstractMesh
  30086. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30087. */
  30088. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30089. }
  30090. }
  30091. declare module "babylonjs/Actions/actionEvent" {
  30092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30093. import { Nullable } from "babylonjs/types";
  30094. import { Sprite } from "babylonjs/Sprites/sprite";
  30095. import { Scene } from "babylonjs/scene";
  30096. import { Vector2 } from "babylonjs/Maths/math.vector";
  30097. /**
  30098. * Interface used to define ActionEvent
  30099. */
  30100. export interface IActionEvent {
  30101. /** The mesh or sprite that triggered the action */
  30102. source: any;
  30103. /** The X mouse cursor position at the time of the event */
  30104. pointerX: number;
  30105. /** The Y mouse cursor position at the time of the event */
  30106. pointerY: number;
  30107. /** The mesh that is currently pointed at (can be null) */
  30108. meshUnderPointer: Nullable<AbstractMesh>;
  30109. /** the original (browser) event that triggered the ActionEvent */
  30110. sourceEvent?: any;
  30111. /** additional data for the event */
  30112. additionalData?: any;
  30113. }
  30114. /**
  30115. * ActionEvent is the event being sent when an action is triggered.
  30116. */
  30117. export class ActionEvent implements IActionEvent {
  30118. /** The mesh or sprite that triggered the action */
  30119. source: any;
  30120. /** The X mouse cursor position at the time of the event */
  30121. pointerX: number;
  30122. /** The Y mouse cursor position at the time of the event */
  30123. pointerY: number;
  30124. /** The mesh that is currently pointed at (can be null) */
  30125. meshUnderPointer: Nullable<AbstractMesh>;
  30126. /** the original (browser) event that triggered the ActionEvent */
  30127. sourceEvent?: any;
  30128. /** additional data for the event */
  30129. additionalData?: any;
  30130. /**
  30131. * Creates a new ActionEvent
  30132. * @param source The mesh or sprite that triggered the action
  30133. * @param pointerX The X mouse cursor position at the time of the event
  30134. * @param pointerY The Y mouse cursor position at the time of the event
  30135. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  30136. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  30137. * @param additionalData additional data for the event
  30138. */
  30139. constructor(
  30140. /** The mesh or sprite that triggered the action */
  30141. source: any,
  30142. /** The X mouse cursor position at the time of the event */
  30143. pointerX: number,
  30144. /** The Y mouse cursor position at the time of the event */
  30145. pointerY: number,
  30146. /** The mesh that is currently pointed at (can be null) */
  30147. meshUnderPointer: Nullable<AbstractMesh>,
  30148. /** the original (browser) event that triggered the ActionEvent */
  30149. sourceEvent?: any,
  30150. /** additional data for the event */
  30151. additionalData?: any);
  30152. /**
  30153. * Helper function to auto-create an ActionEvent from a source mesh.
  30154. * @param source The source mesh that triggered the event
  30155. * @param evt The original (browser) event
  30156. * @param additionalData additional data for the event
  30157. * @returns the new ActionEvent
  30158. */
  30159. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  30160. /**
  30161. * Helper function to auto-create an ActionEvent from a source sprite
  30162. * @param source The source sprite that triggered the event
  30163. * @param scene Scene associated with the sprite
  30164. * @param evt The original (browser) event
  30165. * @param additionalData additional data for the event
  30166. * @returns the new ActionEvent
  30167. */
  30168. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  30169. /**
  30170. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  30171. * @param scene the scene where the event occurred
  30172. * @param evt The original (browser) event
  30173. * @returns the new ActionEvent
  30174. */
  30175. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  30176. /**
  30177. * Helper function to auto-create an ActionEvent from a primitive
  30178. * @param prim defines the target primitive
  30179. * @param pointerPos defines the pointer position
  30180. * @param evt The original (browser) event
  30181. * @param additionalData additional data for the event
  30182. * @returns the new ActionEvent
  30183. */
  30184. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  30185. }
  30186. }
  30187. declare module "babylonjs/Actions/abstractActionManager" {
  30188. import { IDisposable } from "babylonjs/scene";
  30189. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  30190. import { IAction } from "babylonjs/Actions/action";
  30191. import { Nullable } from "babylonjs/types";
  30192. /**
  30193. * Abstract class used to decouple action Manager from scene and meshes.
  30194. * Do not instantiate.
  30195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30196. */
  30197. export abstract class AbstractActionManager implements IDisposable {
  30198. /** Gets the list of active triggers */
  30199. static Triggers: {
  30200. [key: string]: number;
  30201. };
  30202. /** Gets the cursor to use when hovering items */
  30203. hoverCursor: string;
  30204. /** Gets the list of actions */
  30205. actions: IAction[];
  30206. /**
  30207. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  30208. */
  30209. isRecursive: boolean;
  30210. /**
  30211. * Releases all associated resources
  30212. */
  30213. abstract dispose(): void;
  30214. /**
  30215. * Does this action manager has pointer triggers
  30216. */
  30217. abstract get hasPointerTriggers(): boolean;
  30218. /**
  30219. * Does this action manager has pick triggers
  30220. */
  30221. abstract get hasPickTriggers(): boolean;
  30222. /**
  30223. * Process a specific trigger
  30224. * @param trigger defines the trigger to process
  30225. * @param evt defines the event details to be processed
  30226. */
  30227. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  30228. /**
  30229. * Does this action manager handles actions of any of the given triggers
  30230. * @param triggers defines the triggers to be tested
  30231. * @return a boolean indicating whether one (or more) of the triggers is handled
  30232. */
  30233. abstract hasSpecificTriggers(triggers: number[]): boolean;
  30234. /**
  30235. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  30236. * speed.
  30237. * @param triggerA defines the trigger to be tested
  30238. * @param triggerB defines the trigger to be tested
  30239. * @return a boolean indicating whether one (or more) of the triggers is handled
  30240. */
  30241. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  30242. /**
  30243. * Does this action manager handles actions of a given trigger
  30244. * @param trigger defines the trigger to be tested
  30245. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  30246. * @return whether the trigger is handled
  30247. */
  30248. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  30249. /**
  30250. * Serialize this manager to a JSON object
  30251. * @param name defines the property name to store this manager
  30252. * @returns a JSON representation of this manager
  30253. */
  30254. abstract serialize(name: string): any;
  30255. /**
  30256. * Registers an action to this action manager
  30257. * @param action defines the action to be registered
  30258. * @return the action amended (prepared) after registration
  30259. */
  30260. abstract registerAction(action: IAction): Nullable<IAction>;
  30261. /**
  30262. * Unregisters an action to this action manager
  30263. * @param action defines the action to be unregistered
  30264. * @return a boolean indicating whether the action has been unregistered
  30265. */
  30266. abstract unregisterAction(action: IAction): Boolean;
  30267. /**
  30268. * Does exist one action manager with at least one trigger
  30269. **/
  30270. static get HasTriggers(): boolean;
  30271. /**
  30272. * Does exist one action manager with at least one pick trigger
  30273. **/
  30274. static get HasPickTriggers(): boolean;
  30275. /**
  30276. * Does exist one action manager that handles actions of a given trigger
  30277. * @param trigger defines the trigger to be tested
  30278. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  30279. **/
  30280. static HasSpecificTrigger(trigger: number): boolean;
  30281. }
  30282. }
  30283. declare module "babylonjs/node" {
  30284. import { Scene } from "babylonjs/scene";
  30285. import { Nullable } from "babylonjs/types";
  30286. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30287. import { Engine } from "babylonjs/Engines/engine";
  30288. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  30289. import { Observable } from "babylonjs/Misc/observable";
  30290. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  30291. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30292. import { Animatable } from "babylonjs/Animations/animatable";
  30293. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  30294. import { Animation } from "babylonjs/Animations/animation";
  30295. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30297. /**
  30298. * Defines how a node can be built from a string name.
  30299. */
  30300. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30301. /**
  30302. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30303. */
  30304. export class Node implements IBehaviorAware<Node> {
  30305. /** @hidden */
  30306. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30307. private static _NodeConstructors;
  30308. /**
  30309. * Add a new node constructor
  30310. * @param type defines the type name of the node to construct
  30311. * @param constructorFunc defines the constructor function
  30312. */
  30313. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30314. /**
  30315. * Returns a node constructor based on type name
  30316. * @param type defines the type name
  30317. * @param name defines the new node name
  30318. * @param scene defines the hosting scene
  30319. * @param options defines optional options to transmit to constructors
  30320. * @returns the new constructor or null
  30321. */
  30322. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30323. /**
  30324. * Gets or sets the name of the node
  30325. */
  30326. name: string;
  30327. /**
  30328. * Gets or sets the id of the node
  30329. */
  30330. id: string;
  30331. /**
  30332. * Gets or sets the unique id of the node
  30333. */
  30334. uniqueId: number;
  30335. /**
  30336. * Gets or sets a string used to store user defined state for the node
  30337. */
  30338. state: string;
  30339. /**
  30340. * Gets or sets an object used to store user defined information for the node
  30341. */
  30342. metadata: any;
  30343. /**
  30344. * For internal use only. Please do not use.
  30345. */
  30346. reservedDataStore: any;
  30347. /**
  30348. * List of inspectable custom properties (used by the Inspector)
  30349. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30350. */
  30351. inspectableCustomProperties: IInspectable[];
  30352. private _doNotSerialize;
  30353. /**
  30354. * Gets or sets a boolean used to define if the node must be serialized
  30355. */
  30356. get doNotSerialize(): boolean;
  30357. set doNotSerialize(value: boolean);
  30358. /** @hidden */
  30359. _isDisposed: boolean;
  30360. /**
  30361. * Gets a list of Animations associated with the node
  30362. */
  30363. animations: import("babylonjs/Animations/animation").Animation[];
  30364. protected _ranges: {
  30365. [name: string]: Nullable<AnimationRange>;
  30366. };
  30367. /**
  30368. * Callback raised when the node is ready to be used
  30369. */
  30370. onReady: Nullable<(node: Node) => void>;
  30371. private _isEnabled;
  30372. private _isParentEnabled;
  30373. private _isReady;
  30374. /** @hidden */
  30375. _currentRenderId: number;
  30376. private _parentUpdateId;
  30377. /** @hidden */
  30378. _childUpdateId: number;
  30379. /** @hidden */
  30380. _waitingParentId: Nullable<string>;
  30381. /** @hidden */
  30382. _scene: Scene;
  30383. /** @hidden */
  30384. _cache: any;
  30385. private _parentNode;
  30386. private _children;
  30387. /** @hidden */
  30388. _worldMatrix: Matrix;
  30389. /** @hidden */
  30390. _worldMatrixDeterminant: number;
  30391. /** @hidden */
  30392. _worldMatrixDeterminantIsDirty: boolean;
  30393. /** @hidden */
  30394. private _sceneRootNodesIndex;
  30395. /**
  30396. * Gets a boolean indicating if the node has been disposed
  30397. * @returns true if the node was disposed
  30398. */
  30399. isDisposed(): boolean;
  30400. /**
  30401. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30402. * @see https://doc.babylonjs.com/how_to/parenting
  30403. */
  30404. set parent(parent: Nullable<Node>);
  30405. get parent(): Nullable<Node>;
  30406. /** @hidden */
  30407. _addToSceneRootNodes(): void;
  30408. /** @hidden */
  30409. _removeFromSceneRootNodes(): void;
  30410. private _animationPropertiesOverride;
  30411. /**
  30412. * Gets or sets the animation properties override
  30413. */
  30414. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30415. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30416. /**
  30417. * Gets a string idenfifying the name of the class
  30418. * @returns "Node" string
  30419. */
  30420. getClassName(): string;
  30421. /** @hidden */
  30422. readonly _isNode: boolean;
  30423. /**
  30424. * An event triggered when the mesh is disposed
  30425. */
  30426. onDisposeObservable: Observable<Node>;
  30427. private _onDisposeObserver;
  30428. /**
  30429. * Sets a callback that will be raised when the node will be disposed
  30430. */
  30431. set onDispose(callback: () => void);
  30432. /**
  30433. * Creates a new Node
  30434. * @param name the name and id to be given to this node
  30435. * @param scene the scene this node will be added to
  30436. */
  30437. constructor(name: string, scene?: Nullable<Scene>);
  30438. /**
  30439. * Gets the scene of the node
  30440. * @returns a scene
  30441. */
  30442. getScene(): Scene;
  30443. /**
  30444. * Gets the engine of the node
  30445. * @returns a Engine
  30446. */
  30447. getEngine(): Engine;
  30448. private _behaviors;
  30449. /**
  30450. * Attach a behavior to the node
  30451. * @see http://doc.babylonjs.com/features/behaviour
  30452. * @param behavior defines the behavior to attach
  30453. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30454. * @returns the current Node
  30455. */
  30456. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30457. /**
  30458. * Remove an attached behavior
  30459. * @see http://doc.babylonjs.com/features/behaviour
  30460. * @param behavior defines the behavior to attach
  30461. * @returns the current Node
  30462. */
  30463. removeBehavior(behavior: Behavior<Node>): Node;
  30464. /**
  30465. * Gets the list of attached behaviors
  30466. * @see http://doc.babylonjs.com/features/behaviour
  30467. */
  30468. get behaviors(): Behavior<Node>[];
  30469. /**
  30470. * Gets an attached behavior by name
  30471. * @param name defines the name of the behavior to look for
  30472. * @see http://doc.babylonjs.com/features/behaviour
  30473. * @returns null if behavior was not found else the requested behavior
  30474. */
  30475. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30476. /**
  30477. * Returns the latest update of the World matrix
  30478. * @returns a Matrix
  30479. */
  30480. getWorldMatrix(): Matrix;
  30481. /** @hidden */
  30482. _getWorldMatrixDeterminant(): number;
  30483. /**
  30484. * Returns directly the latest state of the mesh World matrix.
  30485. * A Matrix is returned.
  30486. */
  30487. get worldMatrixFromCache(): Matrix;
  30488. /** @hidden */
  30489. _initCache(): void;
  30490. /** @hidden */
  30491. updateCache(force?: boolean): void;
  30492. /** @hidden */
  30493. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30494. /** @hidden */
  30495. _updateCache(ignoreParentClass?: boolean): void;
  30496. /** @hidden */
  30497. _isSynchronized(): boolean;
  30498. /** @hidden */
  30499. _markSyncedWithParent(): void;
  30500. /** @hidden */
  30501. isSynchronizedWithParent(): boolean;
  30502. /** @hidden */
  30503. isSynchronized(): boolean;
  30504. /**
  30505. * Is this node ready to be used/rendered
  30506. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30507. * @return true if the node is ready
  30508. */
  30509. isReady(completeCheck?: boolean): boolean;
  30510. /**
  30511. * Is this node enabled?
  30512. * 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
  30513. * @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
  30514. * @return whether this node (and its parent) is enabled
  30515. */
  30516. isEnabled(checkAncestors?: boolean): boolean;
  30517. /** @hidden */
  30518. protected _syncParentEnabledState(): void;
  30519. /**
  30520. * Set the enabled state of this node
  30521. * @param value defines the new enabled state
  30522. */
  30523. setEnabled(value: boolean): void;
  30524. /**
  30525. * Is this node a descendant of the given node?
  30526. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30527. * @param ancestor defines the parent node to inspect
  30528. * @returns a boolean indicating if this node is a descendant of the given node
  30529. */
  30530. isDescendantOf(ancestor: Node): boolean;
  30531. /** @hidden */
  30532. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30533. /**
  30534. * Will return all nodes that have this node as ascendant
  30535. * @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
  30536. * @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
  30537. * @return all children nodes of all types
  30538. */
  30539. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30540. /**
  30541. * Get all child-meshes of this node
  30542. * @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)
  30543. * @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
  30544. * @returns an array of AbstractMesh
  30545. */
  30546. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30547. /**
  30548. * Get all direct children of this node
  30549. * @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
  30550. * @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)
  30551. * @returns an array of Node
  30552. */
  30553. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30554. /** @hidden */
  30555. _setReady(state: boolean): void;
  30556. /**
  30557. * Get an animation by name
  30558. * @param name defines the name of the animation to look for
  30559. * @returns null if not found else the requested animation
  30560. */
  30561. getAnimationByName(name: string): Nullable<Animation>;
  30562. /**
  30563. * Creates an animation range for this node
  30564. * @param name defines the name of the range
  30565. * @param from defines the starting key
  30566. * @param to defines the end key
  30567. */
  30568. createAnimationRange(name: string, from: number, to: number): void;
  30569. /**
  30570. * Delete a specific animation range
  30571. * @param name defines the name of the range to delete
  30572. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30573. */
  30574. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30575. /**
  30576. * Get an animation range by name
  30577. * @param name defines the name of the animation range to look for
  30578. * @returns null if not found else the requested animation range
  30579. */
  30580. getAnimationRange(name: string): Nullable<AnimationRange>;
  30581. /**
  30582. * Gets the list of all animation ranges defined on this node
  30583. * @returns an array
  30584. */
  30585. getAnimationRanges(): Nullable<AnimationRange>[];
  30586. /**
  30587. * Will start the animation sequence
  30588. * @param name defines the range frames for animation sequence
  30589. * @param loop defines if the animation should loop (false by default)
  30590. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30591. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30592. * @returns the object created for this animation. If range does not exist, it will return null
  30593. */
  30594. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30595. /**
  30596. * Serialize animation ranges into a JSON compatible object
  30597. * @returns serialization object
  30598. */
  30599. serializeAnimationRanges(): any;
  30600. /**
  30601. * Computes the world matrix of the node
  30602. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30603. * @returns the world matrix
  30604. */
  30605. computeWorldMatrix(force?: boolean): Matrix;
  30606. /**
  30607. * Releases resources associated with this node.
  30608. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30609. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30610. */
  30611. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30612. /**
  30613. * Parse animation range data from a serialization object and store them into a given node
  30614. * @param node defines where to store the animation ranges
  30615. * @param parsedNode defines the serialization object to read data from
  30616. * @param scene defines the hosting scene
  30617. */
  30618. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30619. /**
  30620. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30621. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30622. * @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
  30623. * @returns the new bounding vectors
  30624. */
  30625. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30626. min: Vector3;
  30627. max: Vector3;
  30628. };
  30629. }
  30630. }
  30631. declare module "babylonjs/Animations/animation" {
  30632. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30633. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30634. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30635. import { Nullable } from "babylonjs/types";
  30636. import { Scene } from "babylonjs/scene";
  30637. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30638. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30639. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30640. import { Node } from "babylonjs/node";
  30641. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30642. import { Size } from "babylonjs/Maths/math.size";
  30643. import { Animatable } from "babylonjs/Animations/animatable";
  30644. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30645. /**
  30646. * @hidden
  30647. */
  30648. export class _IAnimationState {
  30649. key: number;
  30650. repeatCount: number;
  30651. workValue?: any;
  30652. loopMode?: number;
  30653. offsetValue?: any;
  30654. highLimitValue?: any;
  30655. }
  30656. /**
  30657. * Class used to store any kind of animation
  30658. */
  30659. export class Animation {
  30660. /**Name of the animation */
  30661. name: string;
  30662. /**Property to animate */
  30663. targetProperty: string;
  30664. /**The frames per second of the animation */
  30665. framePerSecond: number;
  30666. /**The data type of the animation */
  30667. dataType: number;
  30668. /**The loop mode of the animation */
  30669. loopMode?: number | undefined;
  30670. /**Specifies if blending should be enabled */
  30671. enableBlending?: boolean | undefined;
  30672. /**
  30673. * Use matrix interpolation instead of using direct key value when animating matrices
  30674. */
  30675. static AllowMatricesInterpolation: boolean;
  30676. /**
  30677. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30678. */
  30679. static AllowMatrixDecomposeForInterpolation: boolean;
  30680. /**
  30681. * Stores the key frames of the animation
  30682. */
  30683. private _keys;
  30684. /**
  30685. * Stores the easing function of the animation
  30686. */
  30687. private _easingFunction;
  30688. /**
  30689. * @hidden Internal use only
  30690. */
  30691. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30692. /**
  30693. * The set of event that will be linked to this animation
  30694. */
  30695. private _events;
  30696. /**
  30697. * Stores an array of target property paths
  30698. */
  30699. targetPropertyPath: string[];
  30700. /**
  30701. * Stores the blending speed of the animation
  30702. */
  30703. blendingSpeed: number;
  30704. /**
  30705. * Stores the animation ranges for the animation
  30706. */
  30707. private _ranges;
  30708. /**
  30709. * @hidden Internal use
  30710. */
  30711. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30712. /**
  30713. * Sets up an animation
  30714. * @param property The property to animate
  30715. * @param animationType The animation type to apply
  30716. * @param framePerSecond The frames per second of the animation
  30717. * @param easingFunction The easing function used in the animation
  30718. * @returns The created animation
  30719. */
  30720. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30721. /**
  30722. * Create and start an animation on a node
  30723. * @param name defines the name of the global animation that will be run on all nodes
  30724. * @param node defines the root node where the animation will take place
  30725. * @param targetProperty defines property to animate
  30726. * @param framePerSecond defines the number of frame per second yo use
  30727. * @param totalFrame defines the number of frames in total
  30728. * @param from defines the initial value
  30729. * @param to defines the final value
  30730. * @param loopMode defines which loop mode you want to use (off by default)
  30731. * @param easingFunction defines the easing function to use (linear by default)
  30732. * @param onAnimationEnd defines the callback to call when animation end
  30733. * @returns the animatable created for this animation
  30734. */
  30735. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30736. /**
  30737. * Create and start an animation on a node and its descendants
  30738. * @param name defines the name of the global animation that will be run on all nodes
  30739. * @param node defines the root node where the animation will take place
  30740. * @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
  30741. * @param targetProperty defines property to animate
  30742. * @param framePerSecond defines the number of frame per second to use
  30743. * @param totalFrame defines the number of frames in total
  30744. * @param from defines the initial value
  30745. * @param to defines the final value
  30746. * @param loopMode defines which loop mode you want to use (off by default)
  30747. * @param easingFunction defines the easing function to use (linear by default)
  30748. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30749. * @returns the list of animatables created for all nodes
  30750. * @example https://www.babylonjs-playground.com/#MH0VLI
  30751. */
  30752. 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[]>;
  30753. /**
  30754. * Creates a new animation, merges it with the existing animations and starts it
  30755. * @param name Name of the animation
  30756. * @param node Node which contains the scene that begins the animations
  30757. * @param targetProperty Specifies which property to animate
  30758. * @param framePerSecond The frames per second of the animation
  30759. * @param totalFrame The total number of frames
  30760. * @param from The frame at the beginning of the animation
  30761. * @param to The frame at the end of the animation
  30762. * @param loopMode Specifies the loop mode of the animation
  30763. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30764. * @param onAnimationEnd Callback to run once the animation is complete
  30765. * @returns Nullable animation
  30766. */
  30767. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30768. /**
  30769. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30770. * @param sourceAnimation defines the Animation containing keyframes to convert
  30771. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30772. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30773. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30774. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30775. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30776. */
  30777. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30778. /**
  30779. * Transition property of an host to the target Value
  30780. * @param property The property to transition
  30781. * @param targetValue The target Value of the property
  30782. * @param host The object where the property to animate belongs
  30783. * @param scene Scene used to run the animation
  30784. * @param frameRate Framerate (in frame/s) to use
  30785. * @param transition The transition type we want to use
  30786. * @param duration The duration of the animation, in milliseconds
  30787. * @param onAnimationEnd Callback trigger at the end of the animation
  30788. * @returns Nullable animation
  30789. */
  30790. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30791. /**
  30792. * Return the array of runtime animations currently using this animation
  30793. */
  30794. get runtimeAnimations(): RuntimeAnimation[];
  30795. /**
  30796. * Specifies if any of the runtime animations are currently running
  30797. */
  30798. get hasRunningRuntimeAnimations(): boolean;
  30799. /**
  30800. * Initializes the animation
  30801. * @param name Name of the animation
  30802. * @param targetProperty Property to animate
  30803. * @param framePerSecond The frames per second of the animation
  30804. * @param dataType The data type of the animation
  30805. * @param loopMode The loop mode of the animation
  30806. * @param enableBlending Specifies if blending should be enabled
  30807. */
  30808. constructor(
  30809. /**Name of the animation */
  30810. name: string,
  30811. /**Property to animate */
  30812. targetProperty: string,
  30813. /**The frames per second of the animation */
  30814. framePerSecond: number,
  30815. /**The data type of the animation */
  30816. dataType: number,
  30817. /**The loop mode of the animation */
  30818. loopMode?: number | undefined,
  30819. /**Specifies if blending should be enabled */
  30820. enableBlending?: boolean | undefined);
  30821. /**
  30822. * Converts the animation to a string
  30823. * @param fullDetails support for multiple levels of logging within scene loading
  30824. * @returns String form of the animation
  30825. */
  30826. toString(fullDetails?: boolean): string;
  30827. /**
  30828. * Add an event to this animation
  30829. * @param event Event to add
  30830. */
  30831. addEvent(event: AnimationEvent): void;
  30832. /**
  30833. * Remove all events found at the given frame
  30834. * @param frame The frame to remove events from
  30835. */
  30836. removeEvents(frame: number): void;
  30837. /**
  30838. * Retrieves all the events from the animation
  30839. * @returns Events from the animation
  30840. */
  30841. getEvents(): AnimationEvent[];
  30842. /**
  30843. * Creates an animation range
  30844. * @param name Name of the animation range
  30845. * @param from Starting frame of the animation range
  30846. * @param to Ending frame of the animation
  30847. */
  30848. createRange(name: string, from: number, to: number): void;
  30849. /**
  30850. * Deletes an animation range by name
  30851. * @param name Name of the animation range to delete
  30852. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30853. */
  30854. deleteRange(name: string, deleteFrames?: boolean): void;
  30855. /**
  30856. * Gets the animation range by name, or null if not defined
  30857. * @param name Name of the animation range
  30858. * @returns Nullable animation range
  30859. */
  30860. getRange(name: string): Nullable<AnimationRange>;
  30861. /**
  30862. * Gets the key frames from the animation
  30863. * @returns The key frames of the animation
  30864. */
  30865. getKeys(): Array<IAnimationKey>;
  30866. /**
  30867. * Gets the highest frame rate of the animation
  30868. * @returns Highest frame rate of the animation
  30869. */
  30870. getHighestFrame(): number;
  30871. /**
  30872. * Gets the easing function of the animation
  30873. * @returns Easing function of the animation
  30874. */
  30875. getEasingFunction(): IEasingFunction;
  30876. /**
  30877. * Sets the easing function of the animation
  30878. * @param easingFunction A custom mathematical formula for animation
  30879. */
  30880. setEasingFunction(easingFunction: EasingFunction): void;
  30881. /**
  30882. * Interpolates a scalar linearly
  30883. * @param startValue Start value of the animation curve
  30884. * @param endValue End value of the animation curve
  30885. * @param gradient Scalar amount to interpolate
  30886. * @returns Interpolated scalar value
  30887. */
  30888. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30889. /**
  30890. * Interpolates a scalar cubically
  30891. * @param startValue Start value of the animation curve
  30892. * @param outTangent End tangent of the animation
  30893. * @param endValue End value of the animation curve
  30894. * @param inTangent Start tangent of the animation curve
  30895. * @param gradient Scalar amount to interpolate
  30896. * @returns Interpolated scalar value
  30897. */
  30898. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30899. /**
  30900. * Interpolates a quaternion using a spherical linear interpolation
  30901. * @param startValue Start value of the animation curve
  30902. * @param endValue End value of the animation curve
  30903. * @param gradient Scalar amount to interpolate
  30904. * @returns Interpolated quaternion value
  30905. */
  30906. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30907. /**
  30908. * Interpolates a quaternion cubically
  30909. * @param startValue Start value of the animation curve
  30910. * @param outTangent End tangent of the animation curve
  30911. * @param endValue End value of the animation curve
  30912. * @param inTangent Start tangent of the animation curve
  30913. * @param gradient Scalar amount to interpolate
  30914. * @returns Interpolated quaternion value
  30915. */
  30916. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30917. /**
  30918. * Interpolates a Vector3 linearl
  30919. * @param startValue Start value of the animation curve
  30920. * @param endValue End value of the animation curve
  30921. * @param gradient Scalar amount to interpolate
  30922. * @returns Interpolated scalar value
  30923. */
  30924. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30925. /**
  30926. * Interpolates a Vector3 cubically
  30927. * @param startValue Start value of the animation curve
  30928. * @param outTangent End tangent of the animation
  30929. * @param endValue End value of the animation curve
  30930. * @param inTangent Start tangent of the animation curve
  30931. * @param gradient Scalar amount to interpolate
  30932. * @returns InterpolatedVector3 value
  30933. */
  30934. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30935. /**
  30936. * Interpolates a Vector2 linearly
  30937. * @param startValue Start value of the animation curve
  30938. * @param endValue End value of the animation curve
  30939. * @param gradient Scalar amount to interpolate
  30940. * @returns Interpolated Vector2 value
  30941. */
  30942. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30943. /**
  30944. * Interpolates a Vector2 cubically
  30945. * @param startValue Start value of the animation curve
  30946. * @param outTangent End tangent of the animation
  30947. * @param endValue End value of the animation curve
  30948. * @param inTangent Start tangent of the animation curve
  30949. * @param gradient Scalar amount to interpolate
  30950. * @returns Interpolated Vector2 value
  30951. */
  30952. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30953. /**
  30954. * Interpolates a size linearly
  30955. * @param startValue Start value of the animation curve
  30956. * @param endValue End value of the animation curve
  30957. * @param gradient Scalar amount to interpolate
  30958. * @returns Interpolated Size value
  30959. */
  30960. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30961. /**
  30962. * Interpolates a Color3 linearly
  30963. * @param startValue Start value of the animation curve
  30964. * @param endValue End value of the animation curve
  30965. * @param gradient Scalar amount to interpolate
  30966. * @returns Interpolated Color3 value
  30967. */
  30968. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30969. /**
  30970. * Interpolates a Color4 linearly
  30971. * @param startValue Start value of the animation curve
  30972. * @param endValue End value of the animation curve
  30973. * @param gradient Scalar amount to interpolate
  30974. * @returns Interpolated Color3 value
  30975. */
  30976. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30977. /**
  30978. * @hidden Internal use only
  30979. */
  30980. _getKeyValue(value: any): any;
  30981. /**
  30982. * @hidden Internal use only
  30983. */
  30984. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30985. /**
  30986. * Defines the function to use to interpolate matrices
  30987. * @param startValue defines the start matrix
  30988. * @param endValue defines the end matrix
  30989. * @param gradient defines the gradient between both matrices
  30990. * @param result defines an optional target matrix where to store the interpolation
  30991. * @returns the interpolated matrix
  30992. */
  30993. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30994. /**
  30995. * Makes a copy of the animation
  30996. * @returns Cloned animation
  30997. */
  30998. clone(): Animation;
  30999. /**
  31000. * Sets the key frames of the animation
  31001. * @param values The animation key frames to set
  31002. */
  31003. setKeys(values: Array<IAnimationKey>): void;
  31004. /**
  31005. * Serializes the animation to an object
  31006. * @returns Serialized object
  31007. */
  31008. serialize(): any;
  31009. /**
  31010. * Float animation type
  31011. */
  31012. static readonly ANIMATIONTYPE_FLOAT: number;
  31013. /**
  31014. * Vector3 animation type
  31015. */
  31016. static readonly ANIMATIONTYPE_VECTOR3: number;
  31017. /**
  31018. * Quaternion animation type
  31019. */
  31020. static readonly ANIMATIONTYPE_QUATERNION: number;
  31021. /**
  31022. * Matrix animation type
  31023. */
  31024. static readonly ANIMATIONTYPE_MATRIX: number;
  31025. /**
  31026. * Color3 animation type
  31027. */
  31028. static readonly ANIMATIONTYPE_COLOR3: number;
  31029. /**
  31030. * Color3 animation type
  31031. */
  31032. static readonly ANIMATIONTYPE_COLOR4: number;
  31033. /**
  31034. * Vector2 animation type
  31035. */
  31036. static readonly ANIMATIONTYPE_VECTOR2: number;
  31037. /**
  31038. * Size animation type
  31039. */
  31040. static readonly ANIMATIONTYPE_SIZE: number;
  31041. /**
  31042. * Relative Loop Mode
  31043. */
  31044. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  31045. /**
  31046. * Cycle Loop Mode
  31047. */
  31048. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  31049. /**
  31050. * Constant Loop Mode
  31051. */
  31052. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  31053. /** @hidden */
  31054. static _UniversalLerp(left: any, right: any, amount: number): any;
  31055. /**
  31056. * Parses an animation object and creates an animation
  31057. * @param parsedAnimation Parsed animation object
  31058. * @returns Animation object
  31059. */
  31060. static Parse(parsedAnimation: any): Animation;
  31061. /**
  31062. * Appends the serialized animations from the source animations
  31063. * @param source Source containing the animations
  31064. * @param destination Target to store the animations
  31065. */
  31066. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31067. }
  31068. }
  31069. declare module "babylonjs/Animations/animatable.interface" {
  31070. import { Nullable } from "babylonjs/types";
  31071. import { Animation } from "babylonjs/Animations/animation";
  31072. /**
  31073. * Interface containing an array of animations
  31074. */
  31075. export interface IAnimatable {
  31076. /**
  31077. * Array of animations
  31078. */
  31079. animations: Nullable<Array<Animation>>;
  31080. }
  31081. }
  31082. declare module "babylonjs/Misc/decorators" {
  31083. import { Nullable } from "babylonjs/types";
  31084. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31085. import { Scene } from "babylonjs/scene";
  31086. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31087. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31088. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31089. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31090. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31091. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31092. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31093. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31094. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31095. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31096. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31097. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31098. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31099. /**
  31100. * Decorator used to define property that can be serialized as reference to a camera
  31101. * @param sourceName defines the name of the property to decorate
  31102. */
  31103. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31104. /**
  31105. * Class used to help serialization objects
  31106. */
  31107. export class SerializationHelper {
  31108. /** @hidden */
  31109. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31110. /** @hidden */
  31111. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31112. /** @hidden */
  31113. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31114. /** @hidden */
  31115. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31116. /**
  31117. * Appends the serialized animations from the source animations
  31118. * @param source Source containing the animations
  31119. * @param destination Target to store the animations
  31120. */
  31121. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31122. /**
  31123. * Static function used to serialized a specific entity
  31124. * @param entity defines the entity to serialize
  31125. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31126. * @returns a JSON compatible object representing the serialization of the entity
  31127. */
  31128. static Serialize<T>(entity: T, serializationObject?: any): any;
  31129. /**
  31130. * Creates a new entity from a serialization data object
  31131. * @param creationFunction defines a function used to instanciated the new entity
  31132. * @param source defines the source serialization data
  31133. * @param scene defines the hosting scene
  31134. * @param rootUrl defines the root url for resources
  31135. * @returns a new entity
  31136. */
  31137. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31138. /**
  31139. * Clones an object
  31140. * @param creationFunction defines the function used to instanciate the new object
  31141. * @param source defines the source object
  31142. * @returns the cloned object
  31143. */
  31144. static Clone<T>(creationFunction: () => T, source: T): T;
  31145. /**
  31146. * Instanciates a new object based on a source one (some data will be shared between both object)
  31147. * @param creationFunction defines the function used to instanciate the new object
  31148. * @param source defines the source object
  31149. * @returns the new object
  31150. */
  31151. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31152. }
  31153. }
  31154. declare module "babylonjs/Materials/Textures/baseTexture" {
  31155. import { Observable } from "babylonjs/Misc/observable";
  31156. import { Nullable } from "babylonjs/types";
  31157. import { Scene } from "babylonjs/scene";
  31158. import { Matrix } from "babylonjs/Maths/math.vector";
  31159. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31160. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31161. import { ISize } from "babylonjs/Maths/math.size";
  31162. import "babylonjs/Misc/fileTools";
  31163. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31164. /**
  31165. * Base class of all the textures in babylon.
  31166. * It groups all the common properties the materials, post process, lights... might need
  31167. * in order to make a correct use of the texture.
  31168. */
  31169. export class BaseTexture implements IAnimatable {
  31170. /**
  31171. * Default anisotropic filtering level for the application.
  31172. * It is set to 4 as a good tradeoff between perf and quality.
  31173. */
  31174. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31175. /**
  31176. * Gets or sets the unique id of the texture
  31177. */
  31178. uniqueId: number;
  31179. /**
  31180. * Define the name of the texture.
  31181. */
  31182. name: string;
  31183. /**
  31184. * Gets or sets an object used to store user defined information.
  31185. */
  31186. metadata: any;
  31187. /**
  31188. * For internal use only. Please do not use.
  31189. */
  31190. reservedDataStore: any;
  31191. private _hasAlpha;
  31192. /**
  31193. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  31194. */
  31195. set hasAlpha(value: boolean);
  31196. get hasAlpha(): boolean;
  31197. /**
  31198. * Defines if the alpha value should be determined via the rgb values.
  31199. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  31200. */
  31201. getAlphaFromRGB: boolean;
  31202. /**
  31203. * Intensity or strength of the texture.
  31204. * It is commonly used by materials to fine tune the intensity of the texture
  31205. */
  31206. level: number;
  31207. /**
  31208. * Define the UV chanel to use starting from 0 and defaulting to 0.
  31209. * This is part of the texture as textures usually maps to one uv set.
  31210. */
  31211. coordinatesIndex: number;
  31212. private _coordinatesMode;
  31213. /**
  31214. * How a texture is mapped.
  31215. *
  31216. * | Value | Type | Description |
  31217. * | ----- | ----------------------------------- | ----------- |
  31218. * | 0 | EXPLICIT_MODE | |
  31219. * | 1 | SPHERICAL_MODE | |
  31220. * | 2 | PLANAR_MODE | |
  31221. * | 3 | CUBIC_MODE | |
  31222. * | 4 | PROJECTION_MODE | |
  31223. * | 5 | SKYBOX_MODE | |
  31224. * | 6 | INVCUBIC_MODE | |
  31225. * | 7 | EQUIRECTANGULAR_MODE | |
  31226. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31227. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31228. */
  31229. set coordinatesMode(value: number);
  31230. get coordinatesMode(): number;
  31231. /**
  31232. * | Value | Type | Description |
  31233. * | ----- | ------------------ | ----------- |
  31234. * | 0 | CLAMP_ADDRESSMODE | |
  31235. * | 1 | WRAP_ADDRESSMODE | |
  31236. * | 2 | MIRROR_ADDRESSMODE | |
  31237. */
  31238. wrapU: number;
  31239. /**
  31240. * | Value | Type | Description |
  31241. * | ----- | ------------------ | ----------- |
  31242. * | 0 | CLAMP_ADDRESSMODE | |
  31243. * | 1 | WRAP_ADDRESSMODE | |
  31244. * | 2 | MIRROR_ADDRESSMODE | |
  31245. */
  31246. wrapV: number;
  31247. /**
  31248. * | Value | Type | Description |
  31249. * | ----- | ------------------ | ----------- |
  31250. * | 0 | CLAMP_ADDRESSMODE | |
  31251. * | 1 | WRAP_ADDRESSMODE | |
  31252. * | 2 | MIRROR_ADDRESSMODE | |
  31253. */
  31254. wrapR: number;
  31255. /**
  31256. * With compliant hardware and browser (supporting anisotropic filtering)
  31257. * this defines the level of anisotropic filtering in the texture.
  31258. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  31259. */
  31260. anisotropicFilteringLevel: number;
  31261. /**
  31262. * Define if the texture is a cube texture or if false a 2d texture.
  31263. */
  31264. get isCube(): boolean;
  31265. set isCube(value: boolean);
  31266. /**
  31267. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  31268. */
  31269. get is3D(): boolean;
  31270. set is3D(value: boolean);
  31271. /**
  31272. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  31273. */
  31274. get is2DArray(): boolean;
  31275. set is2DArray(value: boolean);
  31276. /**
  31277. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  31278. * HDR texture are usually stored in linear space.
  31279. * This only impacts the PBR and Background materials
  31280. */
  31281. gammaSpace: boolean;
  31282. /**
  31283. * Gets or sets whether or not the texture contains RGBD data.
  31284. */
  31285. get isRGBD(): boolean;
  31286. set isRGBD(value: boolean);
  31287. /**
  31288. * Is Z inverted in the texture (useful in a cube texture).
  31289. */
  31290. invertZ: boolean;
  31291. /**
  31292. * Are mip maps generated for this texture or not.
  31293. */
  31294. get noMipmap(): boolean;
  31295. /**
  31296. * @hidden
  31297. */
  31298. lodLevelInAlpha: boolean;
  31299. /**
  31300. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31301. */
  31302. get lodGenerationOffset(): number;
  31303. set lodGenerationOffset(value: number);
  31304. /**
  31305. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31306. */
  31307. get lodGenerationScale(): number;
  31308. set lodGenerationScale(value: number);
  31309. /**
  31310. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31311. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31312. * average roughness values.
  31313. */
  31314. get linearSpecularLOD(): boolean;
  31315. set linearSpecularLOD(value: boolean);
  31316. /**
  31317. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31318. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31319. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31320. */
  31321. get irradianceTexture(): Nullable<BaseTexture>;
  31322. set irradianceTexture(value: Nullable<BaseTexture>);
  31323. /**
  31324. * Define if the texture is a render target.
  31325. */
  31326. isRenderTarget: boolean;
  31327. /**
  31328. * Define the unique id of the texture in the scene.
  31329. */
  31330. get uid(): string;
  31331. /**
  31332. * Return a string representation of the texture.
  31333. * @returns the texture as a string
  31334. */
  31335. toString(): string;
  31336. /**
  31337. * Get the class name of the texture.
  31338. * @returns "BaseTexture"
  31339. */
  31340. getClassName(): string;
  31341. /**
  31342. * Define the list of animation attached to the texture.
  31343. */
  31344. animations: import("babylonjs/Animations/animation").Animation[];
  31345. /**
  31346. * An event triggered when the texture is disposed.
  31347. */
  31348. onDisposeObservable: Observable<BaseTexture>;
  31349. private _onDisposeObserver;
  31350. /**
  31351. * Callback triggered when the texture has been disposed.
  31352. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31353. */
  31354. set onDispose(callback: () => void);
  31355. /**
  31356. * Define the current state of the loading sequence when in delayed load mode.
  31357. */
  31358. delayLoadState: number;
  31359. private _scene;
  31360. private _engine;
  31361. /** @hidden */
  31362. _texture: Nullable<InternalTexture>;
  31363. private _uid;
  31364. /**
  31365. * Define if the texture is preventinga material to render or not.
  31366. * If not and the texture is not ready, the engine will use a default black texture instead.
  31367. */
  31368. get isBlocking(): boolean;
  31369. /**
  31370. * Instantiates a new BaseTexture.
  31371. * Base class of all the textures in babylon.
  31372. * It groups all the common properties the materials, post process, lights... might need
  31373. * in order to make a correct use of the texture.
  31374. * @param sceneOrEngine Define the scene or engine the texture blongs to
  31375. */
  31376. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  31377. /**
  31378. * Get the scene the texture belongs to.
  31379. * @returns the scene or null if undefined
  31380. */
  31381. getScene(): Nullable<Scene>;
  31382. /** @hidden */
  31383. protected _getEngine(): Nullable<ThinEngine>;
  31384. /**
  31385. * Get the texture transform matrix used to offset tile the texture for istance.
  31386. * @returns the transformation matrix
  31387. */
  31388. getTextureMatrix(): Matrix;
  31389. /**
  31390. * Get the texture reflection matrix used to rotate/transform the reflection.
  31391. * @returns the reflection matrix
  31392. */
  31393. getReflectionTextureMatrix(): Matrix;
  31394. /**
  31395. * Get the underlying lower level texture from Babylon.
  31396. * @returns the insternal texture
  31397. */
  31398. getInternalTexture(): Nullable<InternalTexture>;
  31399. /**
  31400. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31401. * @returns true if ready or not blocking
  31402. */
  31403. isReadyOrNotBlocking(): boolean;
  31404. /**
  31405. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31406. * @returns true if fully ready
  31407. */
  31408. isReady(): boolean;
  31409. private _cachedSize;
  31410. /**
  31411. * Get the size of the texture.
  31412. * @returns the texture size.
  31413. */
  31414. getSize(): ISize;
  31415. /**
  31416. * Get the base size of the texture.
  31417. * It can be different from the size if the texture has been resized for POT for instance
  31418. * @returns the base size
  31419. */
  31420. getBaseSize(): ISize;
  31421. /**
  31422. * Update the sampling mode of the texture.
  31423. * Default is Trilinear mode.
  31424. *
  31425. * | Value | Type | Description |
  31426. * | ----- | ------------------ | ----------- |
  31427. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31428. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31429. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31430. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31431. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31432. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31433. * | 7 | NEAREST_LINEAR | |
  31434. * | 8 | NEAREST_NEAREST | |
  31435. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31436. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31437. * | 11 | LINEAR_LINEAR | |
  31438. * | 12 | LINEAR_NEAREST | |
  31439. *
  31440. * > _mag_: magnification filter (close to the viewer)
  31441. * > _min_: minification filter (far from the viewer)
  31442. * > _mip_: filter used between mip map levels
  31443. *@param samplingMode Define the new sampling mode of the texture
  31444. */
  31445. updateSamplingMode(samplingMode: number): void;
  31446. /**
  31447. * Scales the texture if is `canRescale()`
  31448. * @param ratio the resize factor we want to use to rescale
  31449. */
  31450. scale(ratio: number): void;
  31451. /**
  31452. * Get if the texture can rescale.
  31453. */
  31454. get canRescale(): boolean;
  31455. /** @hidden */
  31456. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31457. /** @hidden */
  31458. _rebuild(): void;
  31459. /**
  31460. * Triggers the load sequence in delayed load mode.
  31461. */
  31462. delayLoad(): void;
  31463. /**
  31464. * Clones the texture.
  31465. * @returns the cloned texture
  31466. */
  31467. clone(): Nullable<BaseTexture>;
  31468. /**
  31469. * Get the texture underlying type (INT, FLOAT...)
  31470. */
  31471. get textureType(): number;
  31472. /**
  31473. * Get the texture underlying format (RGB, RGBA...)
  31474. */
  31475. get textureFormat(): number;
  31476. /**
  31477. * Indicates that textures need to be re-calculated for all materials
  31478. */
  31479. protected _markAllSubMeshesAsTexturesDirty(): void;
  31480. /**
  31481. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31482. * This will returns an RGBA array buffer containing either in values (0-255) or
  31483. * float values (0-1) depending of the underlying buffer type.
  31484. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31485. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31486. * @param buffer defines a user defined buffer to fill with data (can be null)
  31487. * @returns The Array buffer containing the pixels data.
  31488. */
  31489. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31490. /**
  31491. * Release and destroy the underlying lower level texture aka internalTexture.
  31492. */
  31493. releaseInternalTexture(): void;
  31494. /** @hidden */
  31495. get _lodTextureHigh(): Nullable<BaseTexture>;
  31496. /** @hidden */
  31497. get _lodTextureMid(): Nullable<BaseTexture>;
  31498. /** @hidden */
  31499. get _lodTextureLow(): Nullable<BaseTexture>;
  31500. /**
  31501. * Dispose the texture and release its associated resources.
  31502. */
  31503. dispose(): void;
  31504. /**
  31505. * Serialize the texture into a JSON representation that can be parsed later on.
  31506. * @returns the JSON representation of the texture
  31507. */
  31508. serialize(): any;
  31509. /**
  31510. * Helper function to be called back once a list of texture contains only ready textures.
  31511. * @param textures Define the list of textures to wait for
  31512. * @param callback Define the callback triggered once the entire list will be ready
  31513. */
  31514. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31515. private static _isScene;
  31516. }
  31517. }
  31518. declare module "babylonjs/Materials/effect" {
  31519. import { Observable } from "babylonjs/Misc/observable";
  31520. import { Nullable } from "babylonjs/types";
  31521. import { IDisposable } from "babylonjs/scene";
  31522. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31523. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31524. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31525. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31526. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31527. import { Engine } from "babylonjs/Engines/engine";
  31528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31532. /**
  31533. * Options to be used when creating an effect.
  31534. */
  31535. export interface IEffectCreationOptions {
  31536. /**
  31537. * Atrributes that will be used in the shader.
  31538. */
  31539. attributes: string[];
  31540. /**
  31541. * Uniform varible names that will be set in the shader.
  31542. */
  31543. uniformsNames: string[];
  31544. /**
  31545. * Uniform buffer variable names that will be set in the shader.
  31546. */
  31547. uniformBuffersNames: string[];
  31548. /**
  31549. * Sampler texture variable names that will be set in the shader.
  31550. */
  31551. samplers: string[];
  31552. /**
  31553. * Define statements that will be set in the shader.
  31554. */
  31555. defines: any;
  31556. /**
  31557. * Possible fallbacks for this effect to improve performance when needed.
  31558. */
  31559. fallbacks: Nullable<IEffectFallbacks>;
  31560. /**
  31561. * Callback that will be called when the shader is compiled.
  31562. */
  31563. onCompiled: Nullable<(effect: Effect) => void>;
  31564. /**
  31565. * Callback that will be called if an error occurs during shader compilation.
  31566. */
  31567. onError: Nullable<(effect: Effect, errors: string) => void>;
  31568. /**
  31569. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31570. */
  31571. indexParameters?: any;
  31572. /**
  31573. * Max number of lights that can be used in the shader.
  31574. */
  31575. maxSimultaneousLights?: number;
  31576. /**
  31577. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31578. */
  31579. transformFeedbackVaryings?: Nullable<string[]>;
  31580. }
  31581. /**
  31582. * Effect containing vertex and fragment shader that can be executed on an object.
  31583. */
  31584. export class Effect implements IDisposable {
  31585. /**
  31586. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31587. */
  31588. static ShadersRepository: string;
  31589. /**
  31590. * Enable logging of the shader code when a compilation error occurs
  31591. */
  31592. static LogShaderCodeOnCompilationError: boolean;
  31593. /**
  31594. * Name of the effect.
  31595. */
  31596. name: any;
  31597. /**
  31598. * String container all the define statements that should be set on the shader.
  31599. */
  31600. defines: string;
  31601. /**
  31602. * Callback that will be called when the shader is compiled.
  31603. */
  31604. onCompiled: Nullable<(effect: Effect) => void>;
  31605. /**
  31606. * Callback that will be called if an error occurs during shader compilation.
  31607. */
  31608. onError: Nullable<(effect: Effect, errors: string) => void>;
  31609. /**
  31610. * Callback that will be called when effect is bound.
  31611. */
  31612. onBind: Nullable<(effect: Effect) => void>;
  31613. /**
  31614. * Unique ID of the effect.
  31615. */
  31616. uniqueId: number;
  31617. /**
  31618. * Observable that will be called when the shader is compiled.
  31619. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31620. */
  31621. onCompileObservable: Observable<Effect>;
  31622. /**
  31623. * Observable that will be called if an error occurs during shader compilation.
  31624. */
  31625. onErrorObservable: Observable<Effect>;
  31626. /** @hidden */
  31627. _onBindObservable: Nullable<Observable<Effect>>;
  31628. /**
  31629. * @hidden
  31630. * Specifies if the effect was previously ready
  31631. */
  31632. _wasPreviouslyReady: boolean;
  31633. /**
  31634. * Observable that will be called when effect is bound.
  31635. */
  31636. get onBindObservable(): Observable<Effect>;
  31637. /** @hidden */
  31638. _bonesComputationForcedToCPU: boolean;
  31639. private static _uniqueIdSeed;
  31640. private _engine;
  31641. private _uniformBuffersNames;
  31642. private _uniformBuffersNamesList;
  31643. private _uniformsNames;
  31644. private _samplerList;
  31645. private _samplers;
  31646. private _isReady;
  31647. private _compilationError;
  31648. private _allFallbacksProcessed;
  31649. private _attributesNames;
  31650. private _attributes;
  31651. private _attributeLocationByName;
  31652. private _uniforms;
  31653. /**
  31654. * Key for the effect.
  31655. * @hidden
  31656. */
  31657. _key: string;
  31658. private _indexParameters;
  31659. private _fallbacks;
  31660. private _vertexSourceCode;
  31661. private _fragmentSourceCode;
  31662. private _vertexSourceCodeOverride;
  31663. private _fragmentSourceCodeOverride;
  31664. private _transformFeedbackVaryings;
  31665. /**
  31666. * Compiled shader to webGL program.
  31667. * @hidden
  31668. */
  31669. _pipelineContext: Nullable<IPipelineContext>;
  31670. private _valueCache;
  31671. private static _baseCache;
  31672. /**
  31673. * Instantiates an effect.
  31674. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31675. * @param baseName Name of the effect.
  31676. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31677. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31678. * @param samplers List of sampler variables that will be passed to the shader.
  31679. * @param engine Engine to be used to render the effect
  31680. * @param defines Define statements to be added to the shader.
  31681. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31682. * @param onCompiled Callback that will be called when the shader is compiled.
  31683. * @param onError Callback that will be called if an error occurs during shader compilation.
  31684. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31685. */
  31686. 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);
  31687. private _useFinalCode;
  31688. /**
  31689. * Unique key for this effect
  31690. */
  31691. get key(): string;
  31692. /**
  31693. * If the effect has been compiled and prepared.
  31694. * @returns if the effect is compiled and prepared.
  31695. */
  31696. isReady(): boolean;
  31697. private _isReadyInternal;
  31698. /**
  31699. * The engine the effect was initialized with.
  31700. * @returns the engine.
  31701. */
  31702. getEngine(): Engine;
  31703. /**
  31704. * The pipeline context for this effect
  31705. * @returns the associated pipeline context
  31706. */
  31707. getPipelineContext(): Nullable<IPipelineContext>;
  31708. /**
  31709. * The set of names of attribute variables for the shader.
  31710. * @returns An array of attribute names.
  31711. */
  31712. getAttributesNames(): string[];
  31713. /**
  31714. * Returns the attribute at the given index.
  31715. * @param index The index of the attribute.
  31716. * @returns The location of the attribute.
  31717. */
  31718. getAttributeLocation(index: number): number;
  31719. /**
  31720. * Returns the attribute based on the name of the variable.
  31721. * @param name of the attribute to look up.
  31722. * @returns the attribute location.
  31723. */
  31724. getAttributeLocationByName(name: string): number;
  31725. /**
  31726. * The number of attributes.
  31727. * @returns the numnber of attributes.
  31728. */
  31729. getAttributesCount(): number;
  31730. /**
  31731. * Gets the index of a uniform variable.
  31732. * @param uniformName of the uniform to look up.
  31733. * @returns the index.
  31734. */
  31735. getUniformIndex(uniformName: string): number;
  31736. /**
  31737. * Returns the attribute based on the name of the variable.
  31738. * @param uniformName of the uniform to look up.
  31739. * @returns the location of the uniform.
  31740. */
  31741. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31742. /**
  31743. * Returns an array of sampler variable names
  31744. * @returns The array of sampler variable names.
  31745. */
  31746. getSamplers(): string[];
  31747. /**
  31748. * Returns an array of uniform variable names
  31749. * @returns The array of uniform variable names.
  31750. */
  31751. getUniformNames(): string[];
  31752. /**
  31753. * Returns an array of uniform buffer variable names
  31754. * @returns The array of uniform buffer variable names.
  31755. */
  31756. getUniformBuffersNames(): string[];
  31757. /**
  31758. * Returns the index parameters used to create the effect
  31759. * @returns The index parameters object
  31760. */
  31761. getIndexParameters(): any;
  31762. /**
  31763. * The error from the last compilation.
  31764. * @returns the error string.
  31765. */
  31766. getCompilationError(): string;
  31767. /**
  31768. * Gets a boolean indicating that all fallbacks were used during compilation
  31769. * @returns true if all fallbacks were used
  31770. */
  31771. allFallbacksProcessed(): boolean;
  31772. /**
  31773. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31774. * @param func The callback to be used.
  31775. */
  31776. executeWhenCompiled(func: (effect: Effect) => void): void;
  31777. private _checkIsReady;
  31778. private _loadShader;
  31779. /**
  31780. * Gets the vertex shader source code of this effect
  31781. */
  31782. get vertexSourceCode(): string;
  31783. /**
  31784. * Gets the fragment shader source code of this effect
  31785. */
  31786. get fragmentSourceCode(): string;
  31787. /**
  31788. * Recompiles the webGL program
  31789. * @param vertexSourceCode The source code for the vertex shader.
  31790. * @param fragmentSourceCode The source code for the fragment shader.
  31791. * @param onCompiled Callback called when completed.
  31792. * @param onError Callback called on error.
  31793. * @hidden
  31794. */
  31795. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31796. /**
  31797. * Prepares the effect
  31798. * @hidden
  31799. */
  31800. _prepareEffect(): void;
  31801. private _getShaderCodeAndErrorLine;
  31802. private _processCompilationErrors;
  31803. /**
  31804. * Checks if the effect is supported. (Must be called after compilation)
  31805. */
  31806. get isSupported(): boolean;
  31807. /**
  31808. * Binds a texture to the engine to be used as output of the shader.
  31809. * @param channel Name of the output variable.
  31810. * @param texture Texture to bind.
  31811. * @hidden
  31812. */
  31813. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31814. /**
  31815. * Sets a texture on the engine to be used in the shader.
  31816. * @param channel Name of the sampler variable.
  31817. * @param texture Texture to set.
  31818. */
  31819. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31820. /**
  31821. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31822. * @param channel Name of the sampler variable.
  31823. * @param texture Texture to set.
  31824. */
  31825. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31826. /**
  31827. * Sets an array of textures on the engine to be used in the shader.
  31828. * @param channel Name of the variable.
  31829. * @param textures Textures to set.
  31830. */
  31831. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31832. /**
  31833. * 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)
  31834. * @param channel Name of the sampler variable.
  31835. * @param postProcess Post process to get the input texture from.
  31836. */
  31837. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31838. /**
  31839. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31840. * 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)
  31841. * @param channel Name of the sampler variable.
  31842. * @param postProcess Post process to get the output texture from.
  31843. */
  31844. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31845. /** @hidden */
  31846. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31847. /** @hidden */
  31848. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31849. /** @hidden */
  31850. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31851. /** @hidden */
  31852. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31853. /**
  31854. * Binds a buffer to a uniform.
  31855. * @param buffer Buffer to bind.
  31856. * @param name Name of the uniform variable to bind to.
  31857. */
  31858. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31859. /**
  31860. * Binds block to a uniform.
  31861. * @param blockName Name of the block to bind.
  31862. * @param index Index to bind.
  31863. */
  31864. bindUniformBlock(blockName: string, index: number): void;
  31865. /**
  31866. * Sets an interger value on a uniform variable.
  31867. * @param uniformName Name of the variable.
  31868. * @param value Value to be set.
  31869. * @returns this effect.
  31870. */
  31871. setInt(uniformName: string, value: number): Effect;
  31872. /**
  31873. * Sets an int array on a uniform variable.
  31874. * @param uniformName Name of the variable.
  31875. * @param array array to be set.
  31876. * @returns this effect.
  31877. */
  31878. setIntArray(uniformName: string, array: Int32Array): Effect;
  31879. /**
  31880. * 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)
  31881. * @param uniformName Name of the variable.
  31882. * @param array array to be set.
  31883. * @returns this effect.
  31884. */
  31885. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31886. /**
  31887. * 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)
  31888. * @param uniformName Name of the variable.
  31889. * @param array array to be set.
  31890. * @returns this effect.
  31891. */
  31892. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31893. /**
  31894. * 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)
  31895. * @param uniformName Name of the variable.
  31896. * @param array array to be set.
  31897. * @returns this effect.
  31898. */
  31899. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31900. /**
  31901. * Sets an float array on a uniform variable.
  31902. * @param uniformName Name of the variable.
  31903. * @param array array to be set.
  31904. * @returns this effect.
  31905. */
  31906. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31907. /**
  31908. * 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)
  31909. * @param uniformName Name of the variable.
  31910. * @param array array to be set.
  31911. * @returns this effect.
  31912. */
  31913. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31914. /**
  31915. * 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)
  31916. * @param uniformName Name of the variable.
  31917. * @param array array to be set.
  31918. * @returns this effect.
  31919. */
  31920. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31921. /**
  31922. * 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)
  31923. * @param uniformName Name of the variable.
  31924. * @param array array to be set.
  31925. * @returns this effect.
  31926. */
  31927. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31928. /**
  31929. * Sets an array on a uniform variable.
  31930. * @param uniformName Name of the variable.
  31931. * @param array array to be set.
  31932. * @returns this effect.
  31933. */
  31934. setArray(uniformName: string, array: number[]): Effect;
  31935. /**
  31936. * 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)
  31937. * @param uniformName Name of the variable.
  31938. * @param array array to be set.
  31939. * @returns this effect.
  31940. */
  31941. setArray2(uniformName: string, array: number[]): Effect;
  31942. /**
  31943. * 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)
  31944. * @param uniformName Name of the variable.
  31945. * @param array array to be set.
  31946. * @returns this effect.
  31947. */
  31948. setArray3(uniformName: string, array: number[]): Effect;
  31949. /**
  31950. * 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)
  31951. * @param uniformName Name of the variable.
  31952. * @param array array to be set.
  31953. * @returns this effect.
  31954. */
  31955. setArray4(uniformName: string, array: number[]): Effect;
  31956. /**
  31957. * Sets matrices on a uniform variable.
  31958. * @param uniformName Name of the variable.
  31959. * @param matrices matrices to be set.
  31960. * @returns this effect.
  31961. */
  31962. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31963. /**
  31964. * Sets matrix on a uniform variable.
  31965. * @param uniformName Name of the variable.
  31966. * @param matrix matrix to be set.
  31967. * @returns this effect.
  31968. */
  31969. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31970. /**
  31971. * 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)
  31972. * @param uniformName Name of the variable.
  31973. * @param matrix matrix to be set.
  31974. * @returns this effect.
  31975. */
  31976. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31977. /**
  31978. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31979. * @param uniformName Name of the variable.
  31980. * @param matrix matrix to be set.
  31981. * @returns this effect.
  31982. */
  31983. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31984. /**
  31985. * Sets a float on a uniform variable.
  31986. * @param uniformName Name of the variable.
  31987. * @param value value to be set.
  31988. * @returns this effect.
  31989. */
  31990. setFloat(uniformName: string, value: number): Effect;
  31991. /**
  31992. * Sets a boolean on a uniform variable.
  31993. * @param uniformName Name of the variable.
  31994. * @param bool value to be set.
  31995. * @returns this effect.
  31996. */
  31997. setBool(uniformName: string, bool: boolean): Effect;
  31998. /**
  31999. * Sets a Vector2 on a uniform variable.
  32000. * @param uniformName Name of the variable.
  32001. * @param vector2 vector2 to be set.
  32002. * @returns this effect.
  32003. */
  32004. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  32005. /**
  32006. * Sets a float2 on a uniform variable.
  32007. * @param uniformName Name of the variable.
  32008. * @param x First float in float2.
  32009. * @param y Second float in float2.
  32010. * @returns this effect.
  32011. */
  32012. setFloat2(uniformName: string, x: number, y: number): Effect;
  32013. /**
  32014. * Sets a Vector3 on a uniform variable.
  32015. * @param uniformName Name of the variable.
  32016. * @param vector3 Value to be set.
  32017. * @returns this effect.
  32018. */
  32019. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  32020. /**
  32021. * Sets a float3 on a uniform variable.
  32022. * @param uniformName Name of the variable.
  32023. * @param x First float in float3.
  32024. * @param y Second float in float3.
  32025. * @param z Third float in float3.
  32026. * @returns this effect.
  32027. */
  32028. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  32029. /**
  32030. * Sets a Vector4 on a uniform variable.
  32031. * @param uniformName Name of the variable.
  32032. * @param vector4 Value to be set.
  32033. * @returns this effect.
  32034. */
  32035. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  32036. /**
  32037. * Sets a float4 on a uniform variable.
  32038. * @param uniformName Name of the variable.
  32039. * @param x First float in float4.
  32040. * @param y Second float in float4.
  32041. * @param z Third float in float4.
  32042. * @param w Fourth float in float4.
  32043. * @returns this effect.
  32044. */
  32045. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  32046. /**
  32047. * Sets a Color3 on a uniform variable.
  32048. * @param uniformName Name of the variable.
  32049. * @param color3 Value to be set.
  32050. * @returns this effect.
  32051. */
  32052. setColor3(uniformName: string, color3: IColor3Like): Effect;
  32053. /**
  32054. * Sets a Color4 on a uniform variable.
  32055. * @param uniformName Name of the variable.
  32056. * @param color3 Value to be set.
  32057. * @param alpha Alpha value to be set.
  32058. * @returns this effect.
  32059. */
  32060. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  32061. /**
  32062. * Sets a Color4 on a uniform variable
  32063. * @param uniformName defines the name of the variable
  32064. * @param color4 defines the value to be set
  32065. * @returns this effect.
  32066. */
  32067. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  32068. /** Release all associated resources */
  32069. dispose(): void;
  32070. /**
  32071. * This function will add a new shader to the shader store
  32072. * @param name the name of the shader
  32073. * @param pixelShader optional pixel shader content
  32074. * @param vertexShader optional vertex shader content
  32075. */
  32076. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  32077. /**
  32078. * Store of each shader (The can be looked up using effect.key)
  32079. */
  32080. static ShadersStore: {
  32081. [key: string]: string;
  32082. };
  32083. /**
  32084. * Store of each included file for a shader (The can be looked up using effect.key)
  32085. */
  32086. static IncludesShadersStore: {
  32087. [key: string]: string;
  32088. };
  32089. /**
  32090. * Resets the cache of effects.
  32091. */
  32092. static ResetCache(): void;
  32093. }
  32094. }
  32095. declare module "babylonjs/Engines/engineCapabilities" {
  32096. /**
  32097. * Interface used to describe the capabilities of the engine relatively to the current browser
  32098. */
  32099. export interface EngineCapabilities {
  32100. /** Maximum textures units per fragment shader */
  32101. maxTexturesImageUnits: number;
  32102. /** Maximum texture units per vertex shader */
  32103. maxVertexTextureImageUnits: number;
  32104. /** Maximum textures units in the entire pipeline */
  32105. maxCombinedTexturesImageUnits: number;
  32106. /** Maximum texture size */
  32107. maxTextureSize: number;
  32108. /** Maximum texture samples */
  32109. maxSamples?: number;
  32110. /** Maximum cube texture size */
  32111. maxCubemapTextureSize: number;
  32112. /** Maximum render texture size */
  32113. maxRenderTextureSize: number;
  32114. /** Maximum number of vertex attributes */
  32115. maxVertexAttribs: number;
  32116. /** Maximum number of varyings */
  32117. maxVaryingVectors: number;
  32118. /** Maximum number of uniforms per vertex shader */
  32119. maxVertexUniformVectors: number;
  32120. /** Maximum number of uniforms per fragment shader */
  32121. maxFragmentUniformVectors: number;
  32122. /** Defines if standard derivates (dx/dy) are supported */
  32123. standardDerivatives: boolean;
  32124. /** Defines if s3tc texture compression is supported */
  32125. s3tc?: WEBGL_compressed_texture_s3tc;
  32126. /** Defines if pvrtc texture compression is supported */
  32127. pvrtc: any;
  32128. /** Defines if etc1 texture compression is supported */
  32129. etc1: any;
  32130. /** Defines if etc2 texture compression is supported */
  32131. etc2: any;
  32132. /** Defines if astc texture compression is supported */
  32133. astc: any;
  32134. /** Defines if float textures are supported */
  32135. textureFloat: boolean;
  32136. /** Defines if vertex array objects are supported */
  32137. vertexArrayObject: boolean;
  32138. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  32139. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  32140. /** Gets the maximum level of anisotropy supported */
  32141. maxAnisotropy: number;
  32142. /** Defines if instancing is supported */
  32143. instancedArrays: boolean;
  32144. /** Defines if 32 bits indices are supported */
  32145. uintIndices: boolean;
  32146. /** Defines if high precision shaders are supported */
  32147. highPrecisionShaderSupported: boolean;
  32148. /** Defines if depth reading in the fragment shader is supported */
  32149. fragmentDepthSupported: boolean;
  32150. /** Defines if float texture linear filtering is supported*/
  32151. textureFloatLinearFiltering: boolean;
  32152. /** Defines if rendering to float textures is supported */
  32153. textureFloatRender: boolean;
  32154. /** Defines if half float textures are supported*/
  32155. textureHalfFloat: boolean;
  32156. /** Defines if half float texture linear filtering is supported*/
  32157. textureHalfFloatLinearFiltering: boolean;
  32158. /** Defines if rendering to half float textures is supported */
  32159. textureHalfFloatRender: boolean;
  32160. /** Defines if textureLOD shader command is supported */
  32161. textureLOD: boolean;
  32162. /** Defines if draw buffers extension is supported */
  32163. drawBuffersExtension: boolean;
  32164. /** Defines if depth textures are supported */
  32165. depthTextureExtension: boolean;
  32166. /** Defines if float color buffer are supported */
  32167. colorBufferFloat: boolean;
  32168. /** Gets disjoint timer query extension (null if not supported) */
  32169. timerQuery?: EXT_disjoint_timer_query;
  32170. /** Defines if timestamp can be used with timer query */
  32171. canUseTimestampForTimerQuery: boolean;
  32172. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  32173. multiview?: any;
  32174. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  32175. oculusMultiview?: any;
  32176. /** Function used to let the system compiles shaders in background */
  32177. parallelShaderCompile?: {
  32178. COMPLETION_STATUS_KHR: number;
  32179. };
  32180. /** Max number of texture samples for MSAA */
  32181. maxMSAASamples: number;
  32182. /** Defines if the blend min max extension is supported */
  32183. blendMinMax: boolean;
  32184. }
  32185. }
  32186. declare module "babylonjs/States/depthCullingState" {
  32187. import { Nullable } from "babylonjs/types";
  32188. /**
  32189. * @hidden
  32190. **/
  32191. export class DepthCullingState {
  32192. private _isDepthTestDirty;
  32193. private _isDepthMaskDirty;
  32194. private _isDepthFuncDirty;
  32195. private _isCullFaceDirty;
  32196. private _isCullDirty;
  32197. private _isZOffsetDirty;
  32198. private _isFrontFaceDirty;
  32199. private _depthTest;
  32200. private _depthMask;
  32201. private _depthFunc;
  32202. private _cull;
  32203. private _cullFace;
  32204. private _zOffset;
  32205. private _frontFace;
  32206. /**
  32207. * Initializes the state.
  32208. */
  32209. constructor();
  32210. get isDirty(): boolean;
  32211. get zOffset(): number;
  32212. set zOffset(value: number);
  32213. get cullFace(): Nullable<number>;
  32214. set cullFace(value: Nullable<number>);
  32215. get cull(): Nullable<boolean>;
  32216. set cull(value: Nullable<boolean>);
  32217. get depthFunc(): Nullable<number>;
  32218. set depthFunc(value: Nullable<number>);
  32219. get depthMask(): boolean;
  32220. set depthMask(value: boolean);
  32221. get depthTest(): boolean;
  32222. set depthTest(value: boolean);
  32223. get frontFace(): Nullable<number>;
  32224. set frontFace(value: Nullable<number>);
  32225. reset(): void;
  32226. apply(gl: WebGLRenderingContext): void;
  32227. }
  32228. }
  32229. declare module "babylonjs/States/stencilState" {
  32230. /**
  32231. * @hidden
  32232. **/
  32233. export class StencilState {
  32234. /** 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 */
  32235. static readonly ALWAYS: number;
  32236. /** Passed to stencilOperation to specify that stencil value must be kept */
  32237. static readonly KEEP: number;
  32238. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32239. static readonly REPLACE: number;
  32240. private _isStencilTestDirty;
  32241. private _isStencilMaskDirty;
  32242. private _isStencilFuncDirty;
  32243. private _isStencilOpDirty;
  32244. private _stencilTest;
  32245. private _stencilMask;
  32246. private _stencilFunc;
  32247. private _stencilFuncRef;
  32248. private _stencilFuncMask;
  32249. private _stencilOpStencilFail;
  32250. private _stencilOpDepthFail;
  32251. private _stencilOpStencilDepthPass;
  32252. get isDirty(): boolean;
  32253. get stencilFunc(): number;
  32254. set stencilFunc(value: number);
  32255. get stencilFuncRef(): number;
  32256. set stencilFuncRef(value: number);
  32257. get stencilFuncMask(): number;
  32258. set stencilFuncMask(value: number);
  32259. get stencilOpStencilFail(): number;
  32260. set stencilOpStencilFail(value: number);
  32261. get stencilOpDepthFail(): number;
  32262. set stencilOpDepthFail(value: number);
  32263. get stencilOpStencilDepthPass(): number;
  32264. set stencilOpStencilDepthPass(value: number);
  32265. get stencilMask(): number;
  32266. set stencilMask(value: number);
  32267. get stencilTest(): boolean;
  32268. set stencilTest(value: boolean);
  32269. constructor();
  32270. reset(): void;
  32271. apply(gl: WebGLRenderingContext): void;
  32272. }
  32273. }
  32274. declare module "babylonjs/States/alphaCullingState" {
  32275. /**
  32276. * @hidden
  32277. **/
  32278. export class AlphaState {
  32279. private _isAlphaBlendDirty;
  32280. private _isBlendFunctionParametersDirty;
  32281. private _isBlendEquationParametersDirty;
  32282. private _isBlendConstantsDirty;
  32283. private _alphaBlend;
  32284. private _blendFunctionParameters;
  32285. private _blendEquationParameters;
  32286. private _blendConstants;
  32287. /**
  32288. * Initializes the state.
  32289. */
  32290. constructor();
  32291. get isDirty(): boolean;
  32292. get alphaBlend(): boolean;
  32293. set alphaBlend(value: boolean);
  32294. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  32295. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  32296. setAlphaEquationParameters(rgb: number, alpha: number): void;
  32297. reset(): void;
  32298. apply(gl: WebGLRenderingContext): void;
  32299. }
  32300. }
  32301. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  32302. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32303. /** @hidden */
  32304. export class WebGL2ShaderProcessor implements IShaderProcessor {
  32305. attributeProcessor(attribute: string): string;
  32306. varyingProcessor(varying: string, isFragment: boolean): string;
  32307. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  32308. }
  32309. }
  32310. declare module "babylonjs/Engines/instancingAttributeInfo" {
  32311. /**
  32312. * Interface for attribute information associated with buffer instanciation
  32313. */
  32314. export interface InstancingAttributeInfo {
  32315. /**
  32316. * Name of the GLSL attribute
  32317. * if attribute index is not specified, this is used to retrieve the index from the effect
  32318. */
  32319. attributeName: string;
  32320. /**
  32321. * Index/offset of the attribute in the vertex shader
  32322. * if not specified, this will be computes from the name.
  32323. */
  32324. index?: number;
  32325. /**
  32326. * size of the attribute, 1, 2, 3 or 4
  32327. */
  32328. attributeSize: number;
  32329. /**
  32330. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32331. */
  32332. offset: number;
  32333. /**
  32334. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32335. * default to 1
  32336. */
  32337. divisor?: number;
  32338. /**
  32339. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32340. * default is FLOAT
  32341. */
  32342. attributeType?: number;
  32343. /**
  32344. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32345. */
  32346. normalized?: boolean;
  32347. }
  32348. }
  32349. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32351. import { Nullable } from "babylonjs/types";
  32352. module "babylonjs/Engines/thinEngine" {
  32353. interface ThinEngine {
  32354. /**
  32355. * Update a video texture
  32356. * @param texture defines the texture to update
  32357. * @param video defines the video element to use
  32358. * @param invertY defines if data must be stored with Y axis inverted
  32359. */
  32360. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32361. }
  32362. }
  32363. }
  32364. declare module "babylonjs/Materials/Textures/videoTexture" {
  32365. import { Observable } from "babylonjs/Misc/observable";
  32366. import { Nullable } from "babylonjs/types";
  32367. import { Scene } from "babylonjs/scene";
  32368. import { Texture } from "babylonjs/Materials/Textures/texture";
  32369. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32370. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32371. /**
  32372. * Settings for finer control over video usage
  32373. */
  32374. export interface VideoTextureSettings {
  32375. /**
  32376. * Applies `autoplay` to video, if specified
  32377. */
  32378. autoPlay?: boolean;
  32379. /**
  32380. * Applies `loop` to video, if specified
  32381. */
  32382. loop?: boolean;
  32383. /**
  32384. * Automatically updates internal texture from video at every frame in the render loop
  32385. */
  32386. autoUpdateTexture: boolean;
  32387. /**
  32388. * Image src displayed during the video loading or until the user interacts with the video.
  32389. */
  32390. poster?: string;
  32391. }
  32392. /**
  32393. * If you want to display a video in your scene, this is the special texture for that.
  32394. * This special texture works similar to other textures, with the exception of a few parameters.
  32395. * @see https://doc.babylonjs.com/how_to/video_texture
  32396. */
  32397. export class VideoTexture extends Texture {
  32398. /**
  32399. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32400. */
  32401. readonly autoUpdateTexture: boolean;
  32402. /**
  32403. * The video instance used by the texture internally
  32404. */
  32405. readonly video: HTMLVideoElement;
  32406. private _onUserActionRequestedObservable;
  32407. /**
  32408. * Event triggerd when a dom action is required by the user to play the video.
  32409. * This happens due to recent changes in browser policies preventing video to auto start.
  32410. */
  32411. get onUserActionRequestedObservable(): Observable<Texture>;
  32412. private _generateMipMaps;
  32413. private _stillImageCaptured;
  32414. private _displayingPosterTexture;
  32415. private _settings;
  32416. private _createInternalTextureOnEvent;
  32417. private _frameId;
  32418. private _currentSrc;
  32419. /**
  32420. * Creates a video texture.
  32421. * If you want to display a video in your scene, this is the special texture for that.
  32422. * This special texture works similar to other textures, with the exception of a few parameters.
  32423. * @see https://doc.babylonjs.com/how_to/video_texture
  32424. * @param name optional name, will detect from video source, if not defined
  32425. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32426. * @param scene is obviously the current scene.
  32427. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32428. * @param invertY is false by default but can be used to invert video on Y axis
  32429. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32430. * @param settings allows finer control over video usage
  32431. */
  32432. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32433. private _getName;
  32434. private _getVideo;
  32435. private _createInternalTexture;
  32436. private reset;
  32437. /**
  32438. * @hidden Internal method to initiate `update`.
  32439. */
  32440. _rebuild(): void;
  32441. /**
  32442. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32443. */
  32444. update(): void;
  32445. /**
  32446. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32447. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32448. */
  32449. updateTexture(isVisible: boolean): void;
  32450. protected _updateInternalTexture: () => void;
  32451. /**
  32452. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32453. * @param url New url.
  32454. */
  32455. updateURL(url: string): void;
  32456. /**
  32457. * Clones the texture.
  32458. * @returns the cloned texture
  32459. */
  32460. clone(): VideoTexture;
  32461. /**
  32462. * Dispose the texture and release its associated resources.
  32463. */
  32464. dispose(): void;
  32465. /**
  32466. * Creates a video texture straight from a stream.
  32467. * @param scene Define the scene the texture should be created in
  32468. * @param stream Define the stream the texture should be created from
  32469. * @returns The created video texture as a promise
  32470. */
  32471. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32472. /**
  32473. * Creates a video texture straight from your WebCam video feed.
  32474. * @param scene Define the scene the texture should be created in
  32475. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32476. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32477. * @returns The created video texture as a promise
  32478. */
  32479. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32480. minWidth: number;
  32481. maxWidth: number;
  32482. minHeight: number;
  32483. maxHeight: number;
  32484. deviceId: string;
  32485. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32486. /**
  32487. * Creates a video texture straight from your WebCam video feed.
  32488. * @param scene Define the scene the texture should be created in
  32489. * @param onReady Define a callback to triggered once the texture will be ready
  32490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32492. */
  32493. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32494. minWidth: number;
  32495. maxWidth: number;
  32496. minHeight: number;
  32497. maxHeight: number;
  32498. deviceId: string;
  32499. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32500. }
  32501. }
  32502. declare module "babylonjs/Engines/thinEngine" {
  32503. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32504. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32505. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32506. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32507. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32508. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32509. import { Observable } from "babylonjs/Misc/observable";
  32510. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32511. import { StencilState } from "babylonjs/States/stencilState";
  32512. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32514. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32515. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32516. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32517. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32518. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32519. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32520. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32522. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32523. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32524. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32525. import { WebRequest } from "babylonjs/Misc/webRequest";
  32526. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32527. /**
  32528. * Defines the interface used by objects working like Scene
  32529. * @hidden
  32530. */
  32531. export interface ISceneLike {
  32532. _addPendingData(data: any): void;
  32533. _removePendingData(data: any): void;
  32534. offlineProvider: IOfflineProvider;
  32535. }
  32536. /** Interface defining initialization parameters for Engine class */
  32537. export interface EngineOptions extends WebGLContextAttributes {
  32538. /**
  32539. * Defines if the engine should no exceed a specified device ratio
  32540. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32541. */
  32542. limitDeviceRatio?: number;
  32543. /**
  32544. * Defines if webvr should be enabled automatically
  32545. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32546. */
  32547. autoEnableWebVR?: boolean;
  32548. /**
  32549. * Defines if webgl2 should be turned off even if supported
  32550. * @see http://doc.babylonjs.com/features/webgl2
  32551. */
  32552. disableWebGL2Support?: boolean;
  32553. /**
  32554. * Defines if webaudio should be initialized as well
  32555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32556. */
  32557. audioEngine?: boolean;
  32558. /**
  32559. * Defines if animations should run using a deterministic lock step
  32560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32561. */
  32562. deterministicLockstep?: boolean;
  32563. /** Defines the maximum steps to use with deterministic lock step mode */
  32564. lockstepMaxSteps?: number;
  32565. /** Defines the seconds between each deterministic lock step */
  32566. timeStep?: number;
  32567. /**
  32568. * Defines that engine should ignore context lost events
  32569. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32570. */
  32571. doNotHandleContextLost?: boolean;
  32572. /**
  32573. * Defines that engine should ignore modifying touch action attribute and style
  32574. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32575. */
  32576. doNotHandleTouchAction?: boolean;
  32577. /**
  32578. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32579. */
  32580. useHighPrecisionFloats?: boolean;
  32581. }
  32582. /**
  32583. * The base engine class (root of all engines)
  32584. */
  32585. export class ThinEngine {
  32586. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32587. static ExceptionList: ({
  32588. key: string;
  32589. capture: string;
  32590. captureConstraint: number;
  32591. targets: string[];
  32592. } | {
  32593. key: string;
  32594. capture: null;
  32595. captureConstraint: null;
  32596. targets: string[];
  32597. })[];
  32598. /** @hidden */
  32599. static _TextureLoaders: IInternalTextureLoader[];
  32600. /**
  32601. * Returns the current npm package of the sdk
  32602. */
  32603. static get NpmPackage(): string;
  32604. /**
  32605. * Returns the current version of the framework
  32606. */
  32607. static get Version(): string;
  32608. /**
  32609. * Returns a string describing the current engine
  32610. */
  32611. get description(): string;
  32612. /**
  32613. * Gets or sets the epsilon value used by collision engine
  32614. */
  32615. static CollisionsEpsilon: number;
  32616. /**
  32617. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32618. */
  32619. static get ShadersRepository(): string;
  32620. static set ShadersRepository(value: string);
  32621. /** @hidden */
  32622. _shaderProcessor: IShaderProcessor;
  32623. /**
  32624. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32625. */
  32626. forcePOTTextures: boolean;
  32627. /**
  32628. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32629. */
  32630. isFullscreen: boolean;
  32631. /**
  32632. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32633. */
  32634. cullBackFaces: boolean;
  32635. /**
  32636. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32637. */
  32638. renderEvenInBackground: boolean;
  32639. /**
  32640. * Gets or sets a boolean indicating that cache can be kept between frames
  32641. */
  32642. preventCacheWipeBetweenFrames: boolean;
  32643. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32644. validateShaderPrograms: boolean;
  32645. /**
  32646. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32647. * This can provide greater z depth for distant objects.
  32648. */
  32649. useReverseDepthBuffer: boolean;
  32650. /**
  32651. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32652. */
  32653. disableUniformBuffers: boolean;
  32654. /** @hidden */
  32655. _uniformBuffers: UniformBuffer[];
  32656. /**
  32657. * Gets a boolean indicating that the engine supports uniform buffers
  32658. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32659. */
  32660. get supportsUniformBuffers(): boolean;
  32661. /** @hidden */
  32662. _gl: WebGLRenderingContext;
  32663. /** @hidden */
  32664. _webGLVersion: number;
  32665. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32666. protected _windowIsBackground: boolean;
  32667. protected _creationOptions: EngineOptions;
  32668. protected _highPrecisionShadersAllowed: boolean;
  32669. /** @hidden */
  32670. get _shouldUseHighPrecisionShader(): boolean;
  32671. /**
  32672. * Gets a boolean indicating that only power of 2 textures are supported
  32673. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32674. */
  32675. get needPOTTextures(): boolean;
  32676. /** @hidden */
  32677. _badOS: boolean;
  32678. /** @hidden */
  32679. _badDesktopOS: boolean;
  32680. private _hardwareScalingLevel;
  32681. /** @hidden */
  32682. _caps: EngineCapabilities;
  32683. private _isStencilEnable;
  32684. private _glVersion;
  32685. private _glRenderer;
  32686. private _glVendor;
  32687. /** @hidden */
  32688. _videoTextureSupported: boolean;
  32689. protected _renderingQueueLaunched: boolean;
  32690. protected _activeRenderLoops: (() => void)[];
  32691. /**
  32692. * Observable signaled when a context lost event is raised
  32693. */
  32694. onContextLostObservable: Observable<ThinEngine>;
  32695. /**
  32696. * Observable signaled when a context restored event is raised
  32697. */
  32698. onContextRestoredObservable: Observable<ThinEngine>;
  32699. private _onContextLost;
  32700. private _onContextRestored;
  32701. protected _contextWasLost: boolean;
  32702. /** @hidden */
  32703. _doNotHandleContextLost: boolean;
  32704. /**
  32705. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32707. */
  32708. get doNotHandleContextLost(): boolean;
  32709. set doNotHandleContextLost(value: boolean);
  32710. /**
  32711. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32712. */
  32713. disableVertexArrayObjects: boolean;
  32714. /** @hidden */
  32715. protected _colorWrite: boolean;
  32716. /** @hidden */
  32717. protected _colorWriteChanged: boolean;
  32718. /** @hidden */
  32719. protected _depthCullingState: DepthCullingState;
  32720. /** @hidden */
  32721. protected _stencilState: StencilState;
  32722. /** @hidden */
  32723. _alphaState: AlphaState;
  32724. /** @hidden */
  32725. _alphaMode: number;
  32726. /** @hidden */
  32727. _alphaEquation: number;
  32728. /** @hidden */
  32729. _internalTexturesCache: InternalTexture[];
  32730. /** @hidden */
  32731. protected _activeChannel: number;
  32732. private _currentTextureChannel;
  32733. /** @hidden */
  32734. protected _boundTexturesCache: {
  32735. [key: string]: Nullable<InternalTexture>;
  32736. };
  32737. /** @hidden */
  32738. protected _currentEffect: Nullable<Effect>;
  32739. /** @hidden */
  32740. protected _currentProgram: Nullable<WebGLProgram>;
  32741. private _compiledEffects;
  32742. private _vertexAttribArraysEnabled;
  32743. /** @hidden */
  32744. protected _cachedViewport: Nullable<IViewportLike>;
  32745. private _cachedVertexArrayObject;
  32746. /** @hidden */
  32747. protected _cachedVertexBuffers: any;
  32748. /** @hidden */
  32749. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32750. /** @hidden */
  32751. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32752. /** @hidden */
  32753. _currentRenderTarget: Nullable<InternalTexture>;
  32754. private _uintIndicesCurrentlySet;
  32755. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32756. /** @hidden */
  32757. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32758. /** @hidden */
  32759. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  32760. private _currentBufferPointers;
  32761. private _currentInstanceLocations;
  32762. private _currentInstanceBuffers;
  32763. private _textureUnits;
  32764. /** @hidden */
  32765. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32766. /** @hidden */
  32767. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32768. /** @hidden */
  32769. _boundRenderFunction: any;
  32770. private _vaoRecordInProgress;
  32771. private _mustWipeVertexAttributes;
  32772. private _emptyTexture;
  32773. private _emptyCubeTexture;
  32774. private _emptyTexture3D;
  32775. private _emptyTexture2DArray;
  32776. /** @hidden */
  32777. _frameHandler: number;
  32778. private _nextFreeTextureSlots;
  32779. private _maxSimultaneousTextures;
  32780. private _activeRequests;
  32781. /** @hidden */
  32782. _transformTextureUrl: Nullable<(url: string) => string>;
  32783. protected get _supportsHardwareTextureRescaling(): boolean;
  32784. private _framebufferDimensionsObject;
  32785. /**
  32786. * sets the object from which width and height will be taken from when getting render width and height
  32787. * Will fallback to the gl object
  32788. * @param dimensions the framebuffer width and height that will be used.
  32789. */
  32790. set framebufferDimensionsObject(dimensions: Nullable<{
  32791. framebufferWidth: number;
  32792. framebufferHeight: number;
  32793. }>);
  32794. /**
  32795. * Gets the current viewport
  32796. */
  32797. get currentViewport(): Nullable<IViewportLike>;
  32798. /**
  32799. * Gets the default empty texture
  32800. */
  32801. get emptyTexture(): InternalTexture;
  32802. /**
  32803. * Gets the default empty 3D texture
  32804. */
  32805. get emptyTexture3D(): InternalTexture;
  32806. /**
  32807. * Gets the default empty 2D array texture
  32808. */
  32809. get emptyTexture2DArray(): InternalTexture;
  32810. /**
  32811. * Gets the default empty cube texture
  32812. */
  32813. get emptyCubeTexture(): InternalTexture;
  32814. /**
  32815. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32816. */
  32817. readonly premultipliedAlpha: boolean;
  32818. /**
  32819. * Observable event triggered before each texture is initialized
  32820. */
  32821. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32822. /**
  32823. * Creates a new engine
  32824. * @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
  32825. * @param antialias defines enable antialiasing (default: false)
  32826. * @param options defines further options to be sent to the getContext() function
  32827. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32828. */
  32829. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32830. private _rebuildInternalTextures;
  32831. private _rebuildEffects;
  32832. /**
  32833. * Gets a boolean indicating if all created effects are ready
  32834. * @returns true if all effects are ready
  32835. */
  32836. areAllEffectsReady(): boolean;
  32837. protected _rebuildBuffers(): void;
  32838. protected _initGLContext(): void;
  32839. /**
  32840. * Gets version of the current webGL context
  32841. */
  32842. get webGLVersion(): number;
  32843. /**
  32844. * Gets a string idenfifying the name of the class
  32845. * @returns "Engine" string
  32846. */
  32847. getClassName(): string;
  32848. /**
  32849. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32850. */
  32851. get isStencilEnable(): boolean;
  32852. /** @hidden */
  32853. _prepareWorkingCanvas(): void;
  32854. /**
  32855. * Reset the texture cache to empty state
  32856. */
  32857. resetTextureCache(): void;
  32858. /**
  32859. * Gets an object containing information about the current webGL context
  32860. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32861. */
  32862. getGlInfo(): {
  32863. vendor: string;
  32864. renderer: string;
  32865. version: string;
  32866. };
  32867. /**
  32868. * Defines the hardware scaling level.
  32869. * By default the hardware scaling level is computed from the window device ratio.
  32870. * 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.
  32871. * @param level defines the level to use
  32872. */
  32873. setHardwareScalingLevel(level: number): void;
  32874. /**
  32875. * Gets the current hardware scaling level.
  32876. * By default the hardware scaling level is computed from the window device ratio.
  32877. * 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.
  32878. * @returns a number indicating the current hardware scaling level
  32879. */
  32880. getHardwareScalingLevel(): number;
  32881. /**
  32882. * Gets the list of loaded textures
  32883. * @returns an array containing all loaded textures
  32884. */
  32885. getLoadedTexturesCache(): InternalTexture[];
  32886. /**
  32887. * Gets the object containing all engine capabilities
  32888. * @returns the EngineCapabilities object
  32889. */
  32890. getCaps(): EngineCapabilities;
  32891. /**
  32892. * stop executing a render loop function and remove it from the execution array
  32893. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32894. */
  32895. stopRenderLoop(renderFunction?: () => void): void;
  32896. /** @hidden */
  32897. _renderLoop(): void;
  32898. /**
  32899. * Gets the HTML canvas attached with the current webGL context
  32900. * @returns a HTML canvas
  32901. */
  32902. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32903. /**
  32904. * Gets host window
  32905. * @returns the host window object
  32906. */
  32907. getHostWindow(): Nullable<Window>;
  32908. /**
  32909. * Gets the current render width
  32910. * @param useScreen defines if screen size must be used (or the current render target if any)
  32911. * @returns a number defining the current render width
  32912. */
  32913. getRenderWidth(useScreen?: boolean): number;
  32914. /**
  32915. * Gets the current render height
  32916. * @param useScreen defines if screen size must be used (or the current render target if any)
  32917. * @returns a number defining the current render height
  32918. */
  32919. getRenderHeight(useScreen?: boolean): number;
  32920. /**
  32921. * Can be used to override the current requestAnimationFrame requester.
  32922. * @hidden
  32923. */
  32924. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32925. /**
  32926. * Register and execute a render loop. The engine can have more than one render function
  32927. * @param renderFunction defines the function to continuously execute
  32928. */
  32929. runRenderLoop(renderFunction: () => void): void;
  32930. /**
  32931. * Clear the current render buffer or the current render target (if any is set up)
  32932. * @param color defines the color to use
  32933. * @param backBuffer defines if the back buffer must be cleared
  32934. * @param depth defines if the depth buffer must be cleared
  32935. * @param stencil defines if the stencil buffer must be cleared
  32936. */
  32937. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32938. private _viewportCached;
  32939. /** @hidden */
  32940. _viewport(x: number, y: number, width: number, height: number): void;
  32941. /**
  32942. * Set the WebGL's viewport
  32943. * @param viewport defines the viewport element to be used
  32944. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32945. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32946. */
  32947. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32948. /**
  32949. * Begin a new frame
  32950. */
  32951. beginFrame(): void;
  32952. /**
  32953. * Enf the current frame
  32954. */
  32955. endFrame(): void;
  32956. /**
  32957. * Resize the view according to the canvas' size
  32958. */
  32959. resize(): void;
  32960. /**
  32961. * Force a specific size of the canvas
  32962. * @param width defines the new canvas' width
  32963. * @param height defines the new canvas' height
  32964. */
  32965. setSize(width: number, height: number): void;
  32966. /**
  32967. * Binds the frame buffer to the specified texture.
  32968. * @param texture The texture to render to or null for the default canvas
  32969. * @param faceIndex The face of the texture to render to in case of cube texture
  32970. * @param requiredWidth The width of the target to render to
  32971. * @param requiredHeight The height of the target to render to
  32972. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32973. * @param lodLevel defines the lod level to bind to the frame buffer
  32974. * @param layer defines the 2d array index to bind to frame buffer to
  32975. */
  32976. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32977. /** @hidden */
  32978. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32979. /**
  32980. * Unbind the current render target texture from the webGL context
  32981. * @param texture defines the render target texture to unbind
  32982. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32983. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32984. */
  32985. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32986. /**
  32987. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32988. */
  32989. flushFramebuffer(): void;
  32990. /**
  32991. * Unbind the current render target and bind the default framebuffer
  32992. */
  32993. restoreDefaultFramebuffer(): void;
  32994. /** @hidden */
  32995. protected _resetVertexBufferBinding(): void;
  32996. /**
  32997. * Creates a vertex buffer
  32998. * @param data the data for the vertex buffer
  32999. * @returns the new WebGL static buffer
  33000. */
  33001. createVertexBuffer(data: DataArray): DataBuffer;
  33002. private _createVertexBuffer;
  33003. /**
  33004. * Creates a dynamic vertex buffer
  33005. * @param data the data for the dynamic vertex buffer
  33006. * @returns the new WebGL dynamic buffer
  33007. */
  33008. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  33009. protected _resetIndexBufferBinding(): void;
  33010. /**
  33011. * Creates a new index buffer
  33012. * @param indices defines the content of the index buffer
  33013. * @param updatable defines if the index buffer must be updatable
  33014. * @returns a new webGL buffer
  33015. */
  33016. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  33017. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  33018. /**
  33019. * Bind a webGL buffer to the webGL context
  33020. * @param buffer defines the buffer to bind
  33021. */
  33022. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  33023. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  33024. private bindBuffer;
  33025. /**
  33026. * update the bound buffer with the given data
  33027. * @param data defines the data to update
  33028. */
  33029. updateArrayBuffer(data: Float32Array): void;
  33030. private _vertexAttribPointer;
  33031. /** @hidden */
  33032. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  33033. private _bindVertexBuffersAttributes;
  33034. /**
  33035. * Records a vertex array object
  33036. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33037. * @param vertexBuffers defines the list of vertex buffers to store
  33038. * @param indexBuffer defines the index buffer to store
  33039. * @param effect defines the effect to store
  33040. * @returns the new vertex array object
  33041. */
  33042. recordVertexArrayObject(vertexBuffers: {
  33043. [key: string]: VertexBuffer;
  33044. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  33045. /**
  33046. * Bind a specific vertex array object
  33047. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33048. * @param vertexArrayObject defines the vertex array object to bind
  33049. * @param indexBuffer defines the index buffer to bind
  33050. */
  33051. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  33052. /**
  33053. * Bind webGl buffers directly to the webGL context
  33054. * @param vertexBuffer defines the vertex buffer to bind
  33055. * @param indexBuffer defines the index buffer to bind
  33056. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  33057. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  33058. * @param effect defines the effect associated with the vertex buffer
  33059. */
  33060. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  33061. private _unbindVertexArrayObject;
  33062. /**
  33063. * Bind a list of vertex buffers to the webGL context
  33064. * @param vertexBuffers defines the list of vertex buffers to bind
  33065. * @param indexBuffer defines the index buffer to bind
  33066. * @param effect defines the effect associated with the vertex buffers
  33067. */
  33068. bindBuffers(vertexBuffers: {
  33069. [key: string]: Nullable<VertexBuffer>;
  33070. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  33071. /**
  33072. * Unbind all instance attributes
  33073. */
  33074. unbindInstanceAttributes(): void;
  33075. /**
  33076. * Release and free the memory of a vertex array object
  33077. * @param vao defines the vertex array object to delete
  33078. */
  33079. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  33080. /** @hidden */
  33081. _releaseBuffer(buffer: DataBuffer): boolean;
  33082. protected _deleteBuffer(buffer: DataBuffer): void;
  33083. /**
  33084. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  33085. * @param instancesBuffer defines the webGL buffer to update and bind
  33086. * @param data defines the data to store in the buffer
  33087. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  33088. */
  33089. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  33090. /**
  33091. * Bind the content of a webGL buffer used with instantiation
  33092. * @param instancesBuffer defines the webGL buffer to bind
  33093. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  33094. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  33095. */
  33096. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  33097. /**
  33098. * Disable the instance attribute corresponding to the name in parameter
  33099. * @param name defines the name of the attribute to disable
  33100. */
  33101. disableInstanceAttributeByName(name: string): void;
  33102. /**
  33103. * Disable the instance attribute corresponding to the location in parameter
  33104. * @param attributeLocation defines the attribute location of the attribute to disable
  33105. */
  33106. disableInstanceAttribute(attributeLocation: number): void;
  33107. /**
  33108. * Disable the attribute corresponding to the location in parameter
  33109. * @param attributeLocation defines the attribute location of the attribute to disable
  33110. */
  33111. disableAttributeByIndex(attributeLocation: number): void;
  33112. /**
  33113. * Send a draw order
  33114. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33115. * @param indexStart defines the starting index
  33116. * @param indexCount defines the number of index to draw
  33117. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33118. */
  33119. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  33120. /**
  33121. * Draw a list of points
  33122. * @param verticesStart defines the index of first vertex to draw
  33123. * @param verticesCount defines the count of vertices to draw
  33124. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33125. */
  33126. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33127. /**
  33128. * Draw a list of unindexed primitives
  33129. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33130. * @param verticesStart defines the index of first vertex to draw
  33131. * @param verticesCount defines the count of vertices to draw
  33132. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33133. */
  33134. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33135. /**
  33136. * Draw a list of indexed primitives
  33137. * @param fillMode defines the primitive to use
  33138. * @param indexStart defines the starting index
  33139. * @param indexCount defines the number of index to draw
  33140. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33141. */
  33142. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  33143. /**
  33144. * Draw a list of unindexed primitives
  33145. * @param fillMode defines the primitive to use
  33146. * @param verticesStart defines the index of first vertex to draw
  33147. * @param verticesCount defines the count of vertices to draw
  33148. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33149. */
  33150. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33151. private _drawMode;
  33152. /** @hidden */
  33153. protected _reportDrawCall(): void;
  33154. /** @hidden */
  33155. _releaseEffect(effect: Effect): void;
  33156. /** @hidden */
  33157. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33158. /**
  33159. * Create a new effect (used to store vertex/fragment shaders)
  33160. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33161. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  33162. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33163. * @param samplers defines an array of string used to represent textures
  33164. * @param defines defines the string containing the defines to use to compile the shaders
  33165. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33166. * @param onCompiled defines a function to call when the effect creation is successful
  33167. * @param onError defines a function to call when the effect creation has failed
  33168. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33169. * @returns the new Effect
  33170. */
  33171. 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;
  33172. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  33173. private _compileShader;
  33174. private _compileRawShader;
  33175. /** @hidden */
  33176. _getShaderSource(shader: WebGLShader): Nullable<string>;
  33177. /**
  33178. * Directly creates a webGL program
  33179. * @param pipelineContext defines the pipeline context to attach to
  33180. * @param vertexCode defines the vertex shader code to use
  33181. * @param fragmentCode defines the fragment shader code to use
  33182. * @param context defines the webGL context to use (if not set, the current one will be used)
  33183. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33184. * @returns the new webGL program
  33185. */
  33186. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33187. /**
  33188. * Creates a webGL program
  33189. * @param pipelineContext defines the pipeline context to attach to
  33190. * @param vertexCode defines the vertex shader code to use
  33191. * @param fragmentCode defines the fragment shader code to use
  33192. * @param defines defines the string containing the defines to use to compile the shaders
  33193. * @param context defines the webGL context to use (if not set, the current one will be used)
  33194. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33195. * @returns the new webGL program
  33196. */
  33197. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33198. /**
  33199. * Creates a new pipeline context
  33200. * @returns the new pipeline
  33201. */
  33202. createPipelineContext(): IPipelineContext;
  33203. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33204. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  33205. /** @hidden */
  33206. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  33207. /** @hidden */
  33208. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  33209. /** @hidden */
  33210. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  33211. /**
  33212. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33213. * @param pipelineContext defines the pipeline context to use
  33214. * @param uniformsNames defines the list of uniform names
  33215. * @returns an array of webGL uniform locations
  33216. */
  33217. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  33218. /**
  33219. * Gets the lsit of active attributes for a given webGL program
  33220. * @param pipelineContext defines the pipeline context to use
  33221. * @param attributesNames defines the list of attribute names to get
  33222. * @returns an array of indices indicating the offset of each attribute
  33223. */
  33224. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  33225. /**
  33226. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33227. * @param effect defines the effect to activate
  33228. */
  33229. enableEffect(effect: Nullable<Effect>): void;
  33230. /**
  33231. * Set the value of an uniform to a number (int)
  33232. * @param uniform defines the webGL uniform location where to store the value
  33233. * @param value defines the int number to store
  33234. */
  33235. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33236. /**
  33237. * Set the value of an uniform to an array of int32
  33238. * @param uniform defines the webGL uniform location where to store the value
  33239. * @param array defines the array of int32 to store
  33240. */
  33241. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33242. /**
  33243. * Set the value of an uniform to an array of int32 (stored as vec2)
  33244. * @param uniform defines the webGL uniform location where to store the value
  33245. * @param array defines the array of int32 to store
  33246. */
  33247. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33248. /**
  33249. * Set the value of an uniform to an array of int32 (stored as vec3)
  33250. * @param uniform defines the webGL uniform location where to store the value
  33251. * @param array defines the array of int32 to store
  33252. */
  33253. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33254. /**
  33255. * Set the value of an uniform to an array of int32 (stored as vec4)
  33256. * @param uniform defines the webGL uniform location where to store the value
  33257. * @param array defines the array of int32 to store
  33258. */
  33259. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33260. /**
  33261. * Set the value of an uniform to an array of number
  33262. * @param uniform defines the webGL uniform location where to store the value
  33263. * @param array defines the array of number to store
  33264. */
  33265. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33266. /**
  33267. * Set the value of an uniform to an array of number (stored as vec2)
  33268. * @param uniform defines the webGL uniform location where to store the value
  33269. * @param array defines the array of number to store
  33270. */
  33271. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33272. /**
  33273. * Set the value of an uniform to an array of number (stored as vec3)
  33274. * @param uniform defines the webGL uniform location where to store the value
  33275. * @param array defines the array of number to store
  33276. */
  33277. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33278. /**
  33279. * Set the value of an uniform to an array of number (stored as vec4)
  33280. * @param uniform defines the webGL uniform location where to store the value
  33281. * @param array defines the array of number to store
  33282. */
  33283. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33284. /**
  33285. * Set the value of an uniform to an array of float32 (stored as matrices)
  33286. * @param uniform defines the webGL uniform location where to store the value
  33287. * @param matrices defines the array of float32 to store
  33288. */
  33289. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  33290. /**
  33291. * Set the value of an uniform to a matrix (3x3)
  33292. * @param uniform defines the webGL uniform location where to store the value
  33293. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33294. */
  33295. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33296. /**
  33297. * Set the value of an uniform to a matrix (2x2)
  33298. * @param uniform defines the webGL uniform location where to store the value
  33299. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33300. */
  33301. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33302. /**
  33303. * Set the value of an uniform to a number (float)
  33304. * @param uniform defines the webGL uniform location where to store the value
  33305. * @param value defines the float number to store
  33306. */
  33307. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33308. /**
  33309. * Set the value of an uniform to a vec2
  33310. * @param uniform defines the webGL uniform location where to store the value
  33311. * @param x defines the 1st component of the value
  33312. * @param y defines the 2nd component of the value
  33313. */
  33314. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33315. /**
  33316. * Set the value of an uniform to a vec3
  33317. * @param uniform defines the webGL uniform location where to store the value
  33318. * @param x defines the 1st component of the value
  33319. * @param y defines the 2nd component of the value
  33320. * @param z defines the 3rd component of the value
  33321. */
  33322. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33323. /**
  33324. * Set the value of an uniform to a vec4
  33325. * @param uniform defines the webGL uniform location where to store the value
  33326. * @param x defines the 1st component of the value
  33327. * @param y defines the 2nd component of the value
  33328. * @param z defines the 3rd component of the value
  33329. * @param w defines the 4th component of the value
  33330. */
  33331. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33332. /**
  33333. * Apply all cached states (depth, culling, stencil and alpha)
  33334. */
  33335. applyStates(): void;
  33336. /**
  33337. * Enable or disable color writing
  33338. * @param enable defines the state to set
  33339. */
  33340. setColorWrite(enable: boolean): void;
  33341. /**
  33342. * Gets a boolean indicating if color writing is enabled
  33343. * @returns the current color writing state
  33344. */
  33345. getColorWrite(): boolean;
  33346. /**
  33347. * Gets the depth culling state manager
  33348. */
  33349. get depthCullingState(): DepthCullingState;
  33350. /**
  33351. * Gets the alpha state manager
  33352. */
  33353. get alphaState(): AlphaState;
  33354. /**
  33355. * Gets the stencil state manager
  33356. */
  33357. get stencilState(): StencilState;
  33358. /**
  33359. * Clears the list of texture accessible through engine.
  33360. * This can help preventing texture load conflict due to name collision.
  33361. */
  33362. clearInternalTexturesCache(): void;
  33363. /**
  33364. * Force the entire cache to be cleared
  33365. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33366. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33367. */
  33368. wipeCaches(bruteForce?: boolean): void;
  33369. /** @hidden */
  33370. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33371. min: number;
  33372. mag: number;
  33373. };
  33374. /** @hidden */
  33375. _createTexture(): WebGLTexture;
  33376. /**
  33377. * Usually called from Texture.ts.
  33378. * Passed information to create a WebGLTexture
  33379. * @param url defines a value which contains one of the following:
  33380. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33381. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33382. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33383. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33384. * @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)
  33385. * @param scene needed for loading to the correct scene
  33386. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33387. * @param onLoad optional callback to be called upon successful completion
  33388. * @param onError optional callback to be called upon failure
  33389. * @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
  33390. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33391. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33392. * @param forcedExtension defines the extension to use to pick the right loader
  33393. * @param mimeType defines an optional mime type
  33394. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33395. */
  33396. 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;
  33397. /**
  33398. * Loads an image as an HTMLImageElement.
  33399. * @param input url string, ArrayBuffer, or Blob to load
  33400. * @param onLoad callback called when the image successfully loads
  33401. * @param onError callback called when the image fails to load
  33402. * @param offlineProvider offline provider for caching
  33403. * @param mimeType optional mime type
  33404. * @returns the HTMLImageElement of the loaded image
  33405. * @hidden
  33406. */
  33407. 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>;
  33408. /**
  33409. * @hidden
  33410. */
  33411. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33412. private _unpackFlipYCached;
  33413. /**
  33414. * In case you are sharing the context with other applications, it might
  33415. * be interested to not cache the unpack flip y state to ensure a consistent
  33416. * value would be set.
  33417. */
  33418. enableUnpackFlipYCached: boolean;
  33419. /** @hidden */
  33420. _unpackFlipY(value: boolean): void;
  33421. /** @hidden */
  33422. _getUnpackAlignement(): number;
  33423. private _getTextureTarget;
  33424. /**
  33425. * Update the sampling mode of a given texture
  33426. * @param samplingMode defines the required sampling mode
  33427. * @param texture defines the texture to update
  33428. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33429. */
  33430. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33431. /**
  33432. * Update the sampling mode of a given texture
  33433. * @param texture defines the texture to update
  33434. * @param wrapU defines the texture wrap mode of the u coordinates
  33435. * @param wrapV defines the texture wrap mode of the v coordinates
  33436. * @param wrapR defines the texture wrap mode of the r coordinates
  33437. */
  33438. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33439. /** @hidden */
  33440. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33441. width: number;
  33442. height: number;
  33443. layers?: number;
  33444. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33445. /** @hidden */
  33446. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33447. /** @hidden */
  33448. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33449. /**
  33450. * Update a portion of an internal texture
  33451. * @param texture defines the texture to update
  33452. * @param imageData defines the data to store into the texture
  33453. * @param xOffset defines the x coordinates of the update rectangle
  33454. * @param yOffset defines the y coordinates of the update rectangle
  33455. * @param width defines the width of the update rectangle
  33456. * @param height defines the height of the update rectangle
  33457. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33458. * @param lod defines the lod level to update (0 by default)
  33459. */
  33460. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33461. /** @hidden */
  33462. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33463. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33464. private _prepareWebGLTexture;
  33465. /** @hidden */
  33466. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33467. private _getDepthStencilBuffer;
  33468. /** @hidden */
  33469. _releaseFramebufferObjects(texture: InternalTexture): void;
  33470. /** @hidden */
  33471. _releaseTexture(texture: InternalTexture): void;
  33472. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33473. protected _setProgram(program: WebGLProgram): void;
  33474. protected _boundUniforms: {
  33475. [key: number]: WebGLUniformLocation;
  33476. };
  33477. /**
  33478. * Binds an effect to the webGL context
  33479. * @param effect defines the effect to bind
  33480. */
  33481. bindSamplers(effect: Effect): void;
  33482. private _activateCurrentTexture;
  33483. /** @hidden */
  33484. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33485. /** @hidden */
  33486. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33487. /**
  33488. * Unbind all textures from the webGL context
  33489. */
  33490. unbindAllTextures(): void;
  33491. /**
  33492. * Sets a texture to the according uniform.
  33493. * @param channel The texture channel
  33494. * @param uniform The uniform to set
  33495. * @param texture The texture to apply
  33496. */
  33497. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33498. private _bindSamplerUniformToChannel;
  33499. private _getTextureWrapMode;
  33500. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33501. /**
  33502. * Sets an array of texture to the webGL context
  33503. * @param channel defines the channel where the texture array must be set
  33504. * @param uniform defines the associated uniform location
  33505. * @param textures defines the array of textures to bind
  33506. */
  33507. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33508. /** @hidden */
  33509. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33510. private _setTextureParameterFloat;
  33511. private _setTextureParameterInteger;
  33512. /**
  33513. * Unbind all vertex attributes from the webGL context
  33514. */
  33515. unbindAllAttributes(): void;
  33516. /**
  33517. * 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
  33518. */
  33519. releaseEffects(): void;
  33520. /**
  33521. * Dispose and release all associated resources
  33522. */
  33523. dispose(): void;
  33524. /**
  33525. * Attach a new callback raised when context lost event is fired
  33526. * @param callback defines the callback to call
  33527. */
  33528. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33529. /**
  33530. * Attach a new callback raised when context restored event is fired
  33531. * @param callback defines the callback to call
  33532. */
  33533. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33534. /**
  33535. * Get the current error code of the webGL context
  33536. * @returns the error code
  33537. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33538. */
  33539. getError(): number;
  33540. private _canRenderToFloatFramebuffer;
  33541. private _canRenderToHalfFloatFramebuffer;
  33542. private _canRenderToFramebuffer;
  33543. /** @hidden */
  33544. _getWebGLTextureType(type: number): number;
  33545. /** @hidden */
  33546. _getInternalFormat(format: number): number;
  33547. /** @hidden */
  33548. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33549. /** @hidden */
  33550. _getRGBAMultiSampleBufferFormat(type: number): number;
  33551. /** @hidden */
  33552. _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;
  33553. /**
  33554. * Loads a file from a url
  33555. * @param url url to load
  33556. * @param onSuccess callback called when the file successfully loads
  33557. * @param onProgress callback called while file is loading (if the server supports this mode)
  33558. * @param offlineProvider defines the offline provider for caching
  33559. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33560. * @param onError callback called when the file fails to load
  33561. * @returns a file request object
  33562. * @hidden
  33563. */
  33564. 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;
  33565. /**
  33566. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33567. * @param x defines the x coordinate of the rectangle where pixels must be read
  33568. * @param y defines the y coordinate of the rectangle where pixels must be read
  33569. * @param width defines the width of the rectangle where pixels must be read
  33570. * @param height defines the height of the rectangle where pixels must be read
  33571. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33572. * @returns a Uint8Array containing RGBA colors
  33573. */
  33574. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33575. private static _isSupported;
  33576. /**
  33577. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33578. * @returns true if the engine can be created
  33579. * @ignorenaming
  33580. */
  33581. static isSupported(): boolean;
  33582. /**
  33583. * Find the next highest power of two.
  33584. * @param x Number to start search from.
  33585. * @return Next highest power of two.
  33586. */
  33587. static CeilingPOT(x: number): number;
  33588. /**
  33589. * Find the next lowest power of two.
  33590. * @param x Number to start search from.
  33591. * @return Next lowest power of two.
  33592. */
  33593. static FloorPOT(x: number): number;
  33594. /**
  33595. * Find the nearest power of two.
  33596. * @param x Number to start search from.
  33597. * @return Next nearest power of two.
  33598. */
  33599. static NearestPOT(x: number): number;
  33600. /**
  33601. * Get the closest exponent of two
  33602. * @param value defines the value to approximate
  33603. * @param max defines the maximum value to return
  33604. * @param mode defines how to define the closest value
  33605. * @returns closest exponent of two of the given value
  33606. */
  33607. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33608. /**
  33609. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33610. * @param func - the function to be called
  33611. * @param requester - the object that will request the next frame. Falls back to window.
  33612. * @returns frame number
  33613. */
  33614. static QueueNewFrame(func: () => void, requester?: any): number;
  33615. /**
  33616. * Gets host document
  33617. * @returns the host document object
  33618. */
  33619. getHostDocument(): Nullable<Document>;
  33620. }
  33621. }
  33622. declare module "babylonjs/Maths/sphericalPolynomial" {
  33623. import { Vector3 } from "babylonjs/Maths/math.vector";
  33624. import { Color3 } from "babylonjs/Maths/math.color";
  33625. /**
  33626. * Class representing spherical harmonics coefficients to the 3rd degree
  33627. */
  33628. export class SphericalHarmonics {
  33629. /**
  33630. * Defines whether or not the harmonics have been prescaled for rendering.
  33631. */
  33632. preScaled: boolean;
  33633. /**
  33634. * The l0,0 coefficients of the spherical harmonics
  33635. */
  33636. l00: Vector3;
  33637. /**
  33638. * The l1,-1 coefficients of the spherical harmonics
  33639. */
  33640. l1_1: Vector3;
  33641. /**
  33642. * The l1,0 coefficients of the spherical harmonics
  33643. */
  33644. l10: Vector3;
  33645. /**
  33646. * The l1,1 coefficients of the spherical harmonics
  33647. */
  33648. l11: Vector3;
  33649. /**
  33650. * The l2,-2 coefficients of the spherical harmonics
  33651. */
  33652. l2_2: Vector3;
  33653. /**
  33654. * The l2,-1 coefficients of the spherical harmonics
  33655. */
  33656. l2_1: Vector3;
  33657. /**
  33658. * The l2,0 coefficients of the spherical harmonics
  33659. */
  33660. l20: Vector3;
  33661. /**
  33662. * The l2,1 coefficients of the spherical harmonics
  33663. */
  33664. l21: Vector3;
  33665. /**
  33666. * The l2,2 coefficients of the spherical harmonics
  33667. */
  33668. l22: Vector3;
  33669. /**
  33670. * Adds a light to the spherical harmonics
  33671. * @param direction the direction of the light
  33672. * @param color the color of the light
  33673. * @param deltaSolidAngle the delta solid angle of the light
  33674. */
  33675. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33676. /**
  33677. * Scales the spherical harmonics by the given amount
  33678. * @param scale the amount to scale
  33679. */
  33680. scaleInPlace(scale: number): void;
  33681. /**
  33682. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33683. *
  33684. * ```
  33685. * E_lm = A_l * L_lm
  33686. * ```
  33687. *
  33688. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33689. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33690. * the scaling factors are given in equation 9.
  33691. */
  33692. convertIncidentRadianceToIrradiance(): void;
  33693. /**
  33694. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33695. *
  33696. * ```
  33697. * L = (1/pi) * E * rho
  33698. * ```
  33699. *
  33700. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33701. */
  33702. convertIrradianceToLambertianRadiance(): void;
  33703. /**
  33704. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33705. * required operations at run time.
  33706. *
  33707. * This is simply done by scaling back the SH with Ylm constants parameter.
  33708. * The trigonometric part being applied by the shader at run time.
  33709. */
  33710. preScaleForRendering(): void;
  33711. /**
  33712. * Constructs a spherical harmonics from an array.
  33713. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33714. * @returns the spherical harmonics
  33715. */
  33716. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33717. /**
  33718. * Gets the spherical harmonics from polynomial
  33719. * @param polynomial the spherical polynomial
  33720. * @returns the spherical harmonics
  33721. */
  33722. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33723. }
  33724. /**
  33725. * Class representing spherical polynomial coefficients to the 3rd degree
  33726. */
  33727. export class SphericalPolynomial {
  33728. private _harmonics;
  33729. /**
  33730. * The spherical harmonics used to create the polynomials.
  33731. */
  33732. get preScaledHarmonics(): SphericalHarmonics;
  33733. /**
  33734. * The x coefficients of the spherical polynomial
  33735. */
  33736. x: Vector3;
  33737. /**
  33738. * The y coefficients of the spherical polynomial
  33739. */
  33740. y: Vector3;
  33741. /**
  33742. * The z coefficients of the spherical polynomial
  33743. */
  33744. z: Vector3;
  33745. /**
  33746. * The xx coefficients of the spherical polynomial
  33747. */
  33748. xx: Vector3;
  33749. /**
  33750. * The yy coefficients of the spherical polynomial
  33751. */
  33752. yy: Vector3;
  33753. /**
  33754. * The zz coefficients of the spherical polynomial
  33755. */
  33756. zz: Vector3;
  33757. /**
  33758. * The xy coefficients of the spherical polynomial
  33759. */
  33760. xy: Vector3;
  33761. /**
  33762. * The yz coefficients of the spherical polynomial
  33763. */
  33764. yz: Vector3;
  33765. /**
  33766. * The zx coefficients of the spherical polynomial
  33767. */
  33768. zx: Vector3;
  33769. /**
  33770. * Adds an ambient color to the spherical polynomial
  33771. * @param color the color to add
  33772. */
  33773. addAmbient(color: Color3): void;
  33774. /**
  33775. * Scales the spherical polynomial by the given amount
  33776. * @param scale the amount to scale
  33777. */
  33778. scaleInPlace(scale: number): void;
  33779. /**
  33780. * Gets the spherical polynomial from harmonics
  33781. * @param harmonics the spherical harmonics
  33782. * @returns the spherical polynomial
  33783. */
  33784. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33785. /**
  33786. * Constructs a spherical polynomial from an array.
  33787. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33788. * @returns the spherical polynomial
  33789. */
  33790. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33791. }
  33792. }
  33793. declare module "babylonjs/Materials/Textures/internalTexture" {
  33794. import { Observable } from "babylonjs/Misc/observable";
  33795. import { Nullable, int } from "babylonjs/types";
  33796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33798. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33799. /**
  33800. * Defines the source of the internal texture
  33801. */
  33802. export enum InternalTextureSource {
  33803. /**
  33804. * The source of the texture data is unknown
  33805. */
  33806. Unknown = 0,
  33807. /**
  33808. * Texture data comes from an URL
  33809. */
  33810. Url = 1,
  33811. /**
  33812. * Texture data is only used for temporary storage
  33813. */
  33814. Temp = 2,
  33815. /**
  33816. * Texture data comes from raw data (ArrayBuffer)
  33817. */
  33818. Raw = 3,
  33819. /**
  33820. * Texture content is dynamic (video or dynamic texture)
  33821. */
  33822. Dynamic = 4,
  33823. /**
  33824. * Texture content is generated by rendering to it
  33825. */
  33826. RenderTarget = 5,
  33827. /**
  33828. * Texture content is part of a multi render target process
  33829. */
  33830. MultiRenderTarget = 6,
  33831. /**
  33832. * Texture data comes from a cube data file
  33833. */
  33834. Cube = 7,
  33835. /**
  33836. * Texture data comes from a raw cube data
  33837. */
  33838. CubeRaw = 8,
  33839. /**
  33840. * Texture data come from a prefiltered cube data file
  33841. */
  33842. CubePrefiltered = 9,
  33843. /**
  33844. * Texture content is raw 3D data
  33845. */
  33846. Raw3D = 10,
  33847. /**
  33848. * Texture content is raw 2D array data
  33849. */
  33850. Raw2DArray = 11,
  33851. /**
  33852. * Texture content is a depth texture
  33853. */
  33854. Depth = 12,
  33855. /**
  33856. * Texture data comes from a raw cube data encoded with RGBD
  33857. */
  33858. CubeRawRGBD = 13
  33859. }
  33860. /**
  33861. * Class used to store data associated with WebGL texture data for the engine
  33862. * This class should not be used directly
  33863. */
  33864. export class InternalTexture {
  33865. /** @hidden */
  33866. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33867. /**
  33868. * Defines if the texture is ready
  33869. */
  33870. isReady: boolean;
  33871. /**
  33872. * Defines if the texture is a cube texture
  33873. */
  33874. isCube: boolean;
  33875. /**
  33876. * Defines if the texture contains 3D data
  33877. */
  33878. is3D: boolean;
  33879. /**
  33880. * Defines if the texture contains 2D array data
  33881. */
  33882. is2DArray: boolean;
  33883. /**
  33884. * Defines if the texture contains multiview data
  33885. */
  33886. isMultiview: boolean;
  33887. /**
  33888. * Gets the URL used to load this texture
  33889. */
  33890. url: string;
  33891. /**
  33892. * Gets the sampling mode of the texture
  33893. */
  33894. samplingMode: number;
  33895. /**
  33896. * Gets a boolean indicating if the texture needs mipmaps generation
  33897. */
  33898. generateMipMaps: boolean;
  33899. /**
  33900. * Gets the number of samples used by the texture (WebGL2+ only)
  33901. */
  33902. samples: number;
  33903. /**
  33904. * Gets the type of the texture (int, float...)
  33905. */
  33906. type: number;
  33907. /**
  33908. * Gets the format of the texture (RGB, RGBA...)
  33909. */
  33910. format: number;
  33911. /**
  33912. * Observable called when the texture is loaded
  33913. */
  33914. onLoadedObservable: Observable<InternalTexture>;
  33915. /**
  33916. * Gets the width of the texture
  33917. */
  33918. width: number;
  33919. /**
  33920. * Gets the height of the texture
  33921. */
  33922. height: number;
  33923. /**
  33924. * Gets the depth of the texture
  33925. */
  33926. depth: number;
  33927. /**
  33928. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33929. */
  33930. baseWidth: number;
  33931. /**
  33932. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33933. */
  33934. baseHeight: number;
  33935. /**
  33936. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33937. */
  33938. baseDepth: number;
  33939. /**
  33940. * Gets a boolean indicating if the texture is inverted on Y axis
  33941. */
  33942. invertY: boolean;
  33943. /** @hidden */
  33944. _invertVScale: boolean;
  33945. /** @hidden */
  33946. _associatedChannel: number;
  33947. /** @hidden */
  33948. _source: InternalTextureSource;
  33949. /** @hidden */
  33950. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33951. /** @hidden */
  33952. _bufferView: Nullable<ArrayBufferView>;
  33953. /** @hidden */
  33954. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33955. /** @hidden */
  33956. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33957. /** @hidden */
  33958. _size: number;
  33959. /** @hidden */
  33960. _extension: string;
  33961. /** @hidden */
  33962. _files: Nullable<string[]>;
  33963. /** @hidden */
  33964. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33965. /** @hidden */
  33966. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33967. /** @hidden */
  33968. _framebuffer: Nullable<WebGLFramebuffer>;
  33969. /** @hidden */
  33970. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33971. /** @hidden */
  33972. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33973. /** @hidden */
  33974. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33975. /** @hidden */
  33976. _attachments: Nullable<number[]>;
  33977. /** @hidden */
  33978. _cachedCoordinatesMode: Nullable<number>;
  33979. /** @hidden */
  33980. _cachedWrapU: Nullable<number>;
  33981. /** @hidden */
  33982. _cachedWrapV: Nullable<number>;
  33983. /** @hidden */
  33984. _cachedWrapR: Nullable<number>;
  33985. /** @hidden */
  33986. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33987. /** @hidden */
  33988. _isDisabled: boolean;
  33989. /** @hidden */
  33990. _compression: Nullable<string>;
  33991. /** @hidden */
  33992. _generateStencilBuffer: boolean;
  33993. /** @hidden */
  33994. _generateDepthBuffer: boolean;
  33995. /** @hidden */
  33996. _comparisonFunction: number;
  33997. /** @hidden */
  33998. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33999. /** @hidden */
  34000. _lodGenerationScale: number;
  34001. /** @hidden */
  34002. _lodGenerationOffset: number;
  34003. /** @hidden */
  34004. _depthStencilTexture: Nullable<InternalTexture>;
  34005. /** @hidden */
  34006. _colorTextureArray: Nullable<WebGLTexture>;
  34007. /** @hidden */
  34008. _depthStencilTextureArray: Nullable<WebGLTexture>;
  34009. /** @hidden */
  34010. _lodTextureHigh: Nullable<BaseTexture>;
  34011. /** @hidden */
  34012. _lodTextureMid: Nullable<BaseTexture>;
  34013. /** @hidden */
  34014. _lodTextureLow: Nullable<BaseTexture>;
  34015. /** @hidden */
  34016. _isRGBD: boolean;
  34017. /** @hidden */
  34018. _linearSpecularLOD: boolean;
  34019. /** @hidden */
  34020. _irradianceTexture: Nullable<BaseTexture>;
  34021. /** @hidden */
  34022. _webGLTexture: Nullable<WebGLTexture>;
  34023. /** @hidden */
  34024. _references: number;
  34025. private _engine;
  34026. /**
  34027. * Gets the Engine the texture belongs to.
  34028. * @returns The babylon engine
  34029. */
  34030. getEngine(): ThinEngine;
  34031. /**
  34032. * Gets the data source type of the texture
  34033. */
  34034. get source(): InternalTextureSource;
  34035. /**
  34036. * Creates a new InternalTexture
  34037. * @param engine defines the engine to use
  34038. * @param source defines the type of data that will be used
  34039. * @param delayAllocation if the texture allocation should be delayed (default: false)
  34040. */
  34041. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  34042. /**
  34043. * Increments the number of references (ie. the number of Texture that point to it)
  34044. */
  34045. incrementReferences(): void;
  34046. /**
  34047. * Change the size of the texture (not the size of the content)
  34048. * @param width defines the new width
  34049. * @param height defines the new height
  34050. * @param depth defines the new depth (1 by default)
  34051. */
  34052. updateSize(width: int, height: int, depth?: int): void;
  34053. /** @hidden */
  34054. _rebuild(): void;
  34055. /** @hidden */
  34056. _swapAndDie(target: InternalTexture): void;
  34057. /**
  34058. * Dispose the current allocated resources
  34059. */
  34060. dispose(): void;
  34061. }
  34062. }
  34063. declare module "babylonjs/Audio/analyser" {
  34064. import { Scene } from "babylonjs/scene";
  34065. /**
  34066. * Class used to work with sound analyzer using fast fourier transform (FFT)
  34067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34068. */
  34069. export class Analyser {
  34070. /**
  34071. * Gets or sets the smoothing
  34072. * @ignorenaming
  34073. */
  34074. SMOOTHING: number;
  34075. /**
  34076. * Gets or sets the FFT table size
  34077. * @ignorenaming
  34078. */
  34079. FFT_SIZE: number;
  34080. /**
  34081. * Gets or sets the bar graph amplitude
  34082. * @ignorenaming
  34083. */
  34084. BARGRAPHAMPLITUDE: number;
  34085. /**
  34086. * Gets or sets the position of the debug canvas
  34087. * @ignorenaming
  34088. */
  34089. DEBUGCANVASPOS: {
  34090. x: number;
  34091. y: number;
  34092. };
  34093. /**
  34094. * Gets or sets the debug canvas size
  34095. * @ignorenaming
  34096. */
  34097. DEBUGCANVASSIZE: {
  34098. width: number;
  34099. height: number;
  34100. };
  34101. private _byteFreqs;
  34102. private _byteTime;
  34103. private _floatFreqs;
  34104. private _webAudioAnalyser;
  34105. private _debugCanvas;
  34106. private _debugCanvasContext;
  34107. private _scene;
  34108. private _registerFunc;
  34109. private _audioEngine;
  34110. /**
  34111. * Creates a new analyser
  34112. * @param scene defines hosting scene
  34113. */
  34114. constructor(scene: Scene);
  34115. /**
  34116. * Get the number of data values you will have to play with for the visualization
  34117. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  34118. * @returns a number
  34119. */
  34120. getFrequencyBinCount(): number;
  34121. /**
  34122. * Gets the current frequency data as a byte array
  34123. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34124. * @returns a Uint8Array
  34125. */
  34126. getByteFrequencyData(): Uint8Array;
  34127. /**
  34128. * Gets the current waveform as a byte array
  34129. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  34130. * @returns a Uint8Array
  34131. */
  34132. getByteTimeDomainData(): Uint8Array;
  34133. /**
  34134. * Gets the current frequency data as a float array
  34135. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34136. * @returns a Float32Array
  34137. */
  34138. getFloatFrequencyData(): Float32Array;
  34139. /**
  34140. * Renders the debug canvas
  34141. */
  34142. drawDebugCanvas(): void;
  34143. /**
  34144. * Stops rendering the debug canvas and removes it
  34145. */
  34146. stopDebugCanvas(): void;
  34147. /**
  34148. * Connects two audio nodes
  34149. * @param inputAudioNode defines first node to connect
  34150. * @param outputAudioNode defines second node to connect
  34151. */
  34152. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  34153. /**
  34154. * Releases all associated resources
  34155. */
  34156. dispose(): void;
  34157. }
  34158. }
  34159. declare module "babylonjs/Audio/audioEngine" {
  34160. import { IDisposable } from "babylonjs/scene";
  34161. import { Analyser } from "babylonjs/Audio/analyser";
  34162. import { Nullable } from "babylonjs/types";
  34163. import { Observable } from "babylonjs/Misc/observable";
  34164. /**
  34165. * This represents an audio engine and it is responsible
  34166. * to play, synchronize and analyse sounds throughout the application.
  34167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34168. */
  34169. export interface IAudioEngine extends IDisposable {
  34170. /**
  34171. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34172. */
  34173. readonly canUseWebAudio: boolean;
  34174. /**
  34175. * Gets the current AudioContext if available.
  34176. */
  34177. readonly audioContext: Nullable<AudioContext>;
  34178. /**
  34179. * The master gain node defines the global audio volume of your audio engine.
  34180. */
  34181. readonly masterGain: GainNode;
  34182. /**
  34183. * Gets whether or not mp3 are supported by your browser.
  34184. */
  34185. readonly isMP3supported: boolean;
  34186. /**
  34187. * Gets whether or not ogg are supported by your browser.
  34188. */
  34189. readonly isOGGsupported: boolean;
  34190. /**
  34191. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34192. * @ignoreNaming
  34193. */
  34194. WarnedWebAudioUnsupported: boolean;
  34195. /**
  34196. * Defines if the audio engine relies on a custom unlocked button.
  34197. * In this case, the embedded button will not be displayed.
  34198. */
  34199. useCustomUnlockedButton: boolean;
  34200. /**
  34201. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  34202. */
  34203. readonly unlocked: boolean;
  34204. /**
  34205. * Event raised when audio has been unlocked on the browser.
  34206. */
  34207. onAudioUnlockedObservable: Observable<AudioEngine>;
  34208. /**
  34209. * Event raised when audio has been locked on the browser.
  34210. */
  34211. onAudioLockedObservable: Observable<AudioEngine>;
  34212. /**
  34213. * Flags the audio engine in Locked state.
  34214. * This happens due to new browser policies preventing audio to autoplay.
  34215. */
  34216. lock(): void;
  34217. /**
  34218. * Unlocks the audio engine once a user action has been done on the dom.
  34219. * This is helpful to resume play once browser policies have been satisfied.
  34220. */
  34221. unlock(): void;
  34222. /**
  34223. * Gets the global volume sets on the master gain.
  34224. * @returns the global volume if set or -1 otherwise
  34225. */
  34226. getGlobalVolume(): number;
  34227. /**
  34228. * Sets the global volume of your experience (sets on the master gain).
  34229. * @param newVolume Defines the new global volume of the application
  34230. */
  34231. setGlobalVolume(newVolume: number): void;
  34232. /**
  34233. * Connect the audio engine to an audio analyser allowing some amazing
  34234. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34236. * @param analyser The analyser to connect to the engine
  34237. */
  34238. connectToAnalyser(analyser: Analyser): void;
  34239. }
  34240. /**
  34241. * This represents the default audio engine used in babylon.
  34242. * It is responsible to play, synchronize and analyse sounds throughout the application.
  34243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34244. */
  34245. export class AudioEngine implements IAudioEngine {
  34246. private _audioContext;
  34247. private _audioContextInitialized;
  34248. private _muteButton;
  34249. private _hostElement;
  34250. /**
  34251. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34252. */
  34253. canUseWebAudio: boolean;
  34254. /**
  34255. * The master gain node defines the global audio volume of your audio engine.
  34256. */
  34257. masterGain: GainNode;
  34258. /**
  34259. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34260. * @ignoreNaming
  34261. */
  34262. WarnedWebAudioUnsupported: boolean;
  34263. /**
  34264. * Gets whether or not mp3 are supported by your browser.
  34265. */
  34266. isMP3supported: boolean;
  34267. /**
  34268. * Gets whether or not ogg are supported by your browser.
  34269. */
  34270. isOGGsupported: boolean;
  34271. /**
  34272. * Gets whether audio has been unlocked on the device.
  34273. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34274. * a user interaction has happened.
  34275. */
  34276. unlocked: boolean;
  34277. /**
  34278. * Defines if the audio engine relies on a custom unlocked button.
  34279. * In this case, the embedded button will not be displayed.
  34280. */
  34281. useCustomUnlockedButton: boolean;
  34282. /**
  34283. * Event raised when audio has been unlocked on the browser.
  34284. */
  34285. onAudioUnlockedObservable: Observable<AudioEngine>;
  34286. /**
  34287. * Event raised when audio has been locked on the browser.
  34288. */
  34289. onAudioLockedObservable: Observable<AudioEngine>;
  34290. /**
  34291. * Gets the current AudioContext if available.
  34292. */
  34293. get audioContext(): Nullable<AudioContext>;
  34294. private _connectedAnalyser;
  34295. /**
  34296. * Instantiates a new audio engine.
  34297. *
  34298. * There should be only one per page as some browsers restrict the number
  34299. * of audio contexts you can create.
  34300. * @param hostElement defines the host element where to display the mute icon if necessary
  34301. */
  34302. constructor(hostElement?: Nullable<HTMLElement>);
  34303. /**
  34304. * Flags the audio engine in Locked state.
  34305. * This happens due to new browser policies preventing audio to autoplay.
  34306. */
  34307. lock(): void;
  34308. /**
  34309. * Unlocks the audio engine once a user action has been done on the dom.
  34310. * This is helpful to resume play once browser policies have been satisfied.
  34311. */
  34312. unlock(): void;
  34313. private _resumeAudioContext;
  34314. private _initializeAudioContext;
  34315. private _tryToRun;
  34316. private _triggerRunningState;
  34317. private _triggerSuspendedState;
  34318. private _displayMuteButton;
  34319. private _moveButtonToTopLeft;
  34320. private _onResize;
  34321. private _hideMuteButton;
  34322. /**
  34323. * Destroy and release the resources associated with the audio ccontext.
  34324. */
  34325. dispose(): void;
  34326. /**
  34327. * Gets the global volume sets on the master gain.
  34328. * @returns the global volume if set or -1 otherwise
  34329. */
  34330. getGlobalVolume(): number;
  34331. /**
  34332. * Sets the global volume of your experience (sets on the master gain).
  34333. * @param newVolume Defines the new global volume of the application
  34334. */
  34335. setGlobalVolume(newVolume: number): void;
  34336. /**
  34337. * Connect the audio engine to an audio analyser allowing some amazing
  34338. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34339. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34340. * @param analyser The analyser to connect to the engine
  34341. */
  34342. connectToAnalyser(analyser: Analyser): void;
  34343. }
  34344. }
  34345. declare module "babylonjs/Loading/loadingScreen" {
  34346. /**
  34347. * Interface used to present a loading screen while loading a scene
  34348. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34349. */
  34350. export interface ILoadingScreen {
  34351. /**
  34352. * Function called to display the loading screen
  34353. */
  34354. displayLoadingUI: () => void;
  34355. /**
  34356. * Function called to hide the loading screen
  34357. */
  34358. hideLoadingUI: () => void;
  34359. /**
  34360. * Gets or sets the color to use for the background
  34361. */
  34362. loadingUIBackgroundColor: string;
  34363. /**
  34364. * Gets or sets the text to display while loading
  34365. */
  34366. loadingUIText: string;
  34367. }
  34368. /**
  34369. * Class used for the default loading screen
  34370. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34371. */
  34372. export class DefaultLoadingScreen implements ILoadingScreen {
  34373. private _renderingCanvas;
  34374. private _loadingText;
  34375. private _loadingDivBackgroundColor;
  34376. private _loadingDiv;
  34377. private _loadingTextDiv;
  34378. /** Gets or sets the logo url to use for the default loading screen */
  34379. static DefaultLogoUrl: string;
  34380. /** Gets or sets the spinner url to use for the default loading screen */
  34381. static DefaultSpinnerUrl: string;
  34382. /**
  34383. * Creates a new default loading screen
  34384. * @param _renderingCanvas defines the canvas used to render the scene
  34385. * @param _loadingText defines the default text to display
  34386. * @param _loadingDivBackgroundColor defines the default background color
  34387. */
  34388. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  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 text to display while loading
  34399. */
  34400. set loadingUIText(text: string);
  34401. get loadingUIText(): string;
  34402. /**
  34403. * Gets or sets the color to use for the background
  34404. */
  34405. get loadingUIBackgroundColor(): string;
  34406. set loadingUIBackgroundColor(color: string);
  34407. private _resizeLoadingUI;
  34408. }
  34409. }
  34410. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34411. /**
  34412. * Interface for any object that can request an animation frame
  34413. */
  34414. export interface ICustomAnimationFrameRequester {
  34415. /**
  34416. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34417. */
  34418. renderFunction?: Function;
  34419. /**
  34420. * Called to request the next frame to render to
  34421. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34422. */
  34423. requestAnimationFrame: Function;
  34424. /**
  34425. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34426. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34427. */
  34428. requestID?: number;
  34429. }
  34430. }
  34431. declare module "babylonjs/Misc/performanceMonitor" {
  34432. /**
  34433. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34434. */
  34435. export class PerformanceMonitor {
  34436. private _enabled;
  34437. private _rollingFrameTime;
  34438. private _lastFrameTimeMs;
  34439. /**
  34440. * constructor
  34441. * @param frameSampleSize The number of samples required to saturate the sliding window
  34442. */
  34443. constructor(frameSampleSize?: number);
  34444. /**
  34445. * Samples current frame
  34446. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34447. */
  34448. sampleFrame(timeMs?: number): void;
  34449. /**
  34450. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34451. */
  34452. get averageFrameTime(): number;
  34453. /**
  34454. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34455. */
  34456. get averageFrameTimeVariance(): number;
  34457. /**
  34458. * Returns the frame time of the most recent frame
  34459. */
  34460. get instantaneousFrameTime(): number;
  34461. /**
  34462. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34463. */
  34464. get averageFPS(): number;
  34465. /**
  34466. * Returns the average framerate in frames per second using the most recent frame time
  34467. */
  34468. get instantaneousFPS(): number;
  34469. /**
  34470. * Returns true if enough samples have been taken to completely fill the sliding window
  34471. */
  34472. get isSaturated(): boolean;
  34473. /**
  34474. * Enables contributions to the sliding window sample set
  34475. */
  34476. enable(): void;
  34477. /**
  34478. * Disables contributions to the sliding window sample set
  34479. * Samples will not be interpolated over the disabled period
  34480. */
  34481. disable(): void;
  34482. /**
  34483. * Returns true if sampling is enabled
  34484. */
  34485. get isEnabled(): boolean;
  34486. /**
  34487. * Resets performance monitor
  34488. */
  34489. reset(): void;
  34490. }
  34491. /**
  34492. * RollingAverage
  34493. *
  34494. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34495. */
  34496. export class RollingAverage {
  34497. /**
  34498. * Current average
  34499. */
  34500. average: number;
  34501. /**
  34502. * Current variance
  34503. */
  34504. variance: number;
  34505. protected _samples: Array<number>;
  34506. protected _sampleCount: number;
  34507. protected _pos: number;
  34508. protected _m2: number;
  34509. /**
  34510. * constructor
  34511. * @param length The number of samples required to saturate the sliding window
  34512. */
  34513. constructor(length: number);
  34514. /**
  34515. * Adds a sample to the sample set
  34516. * @param v The sample value
  34517. */
  34518. add(v: number): void;
  34519. /**
  34520. * Returns previously added values or null if outside of history or outside the sliding window domain
  34521. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34522. * @return Value previously recorded with add() or null if outside of range
  34523. */
  34524. history(i: number): number;
  34525. /**
  34526. * Returns true if enough samples have been taken to completely fill the sliding window
  34527. * @return true if sample-set saturated
  34528. */
  34529. isSaturated(): boolean;
  34530. /**
  34531. * Resets the rolling average (equivalent to 0 samples taken so far)
  34532. */
  34533. reset(): void;
  34534. /**
  34535. * Wraps a value around the sample range boundaries
  34536. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34537. * @return Wrapped position in sample range
  34538. */
  34539. protected _wrapPosition(i: number): number;
  34540. }
  34541. }
  34542. declare module "babylonjs/Misc/perfCounter" {
  34543. /**
  34544. * This class is used to track a performance counter which is number based.
  34545. * The user has access to many properties which give statistics of different nature.
  34546. *
  34547. * The implementer can track two kinds of Performance Counter: time and count.
  34548. * 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.
  34549. * 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.
  34550. */
  34551. export class PerfCounter {
  34552. /**
  34553. * Gets or sets a global boolean to turn on and off all the counters
  34554. */
  34555. static Enabled: boolean;
  34556. /**
  34557. * Returns the smallest value ever
  34558. */
  34559. get min(): number;
  34560. /**
  34561. * Returns the biggest value ever
  34562. */
  34563. get max(): number;
  34564. /**
  34565. * Returns the average value since the performance counter is running
  34566. */
  34567. get average(): number;
  34568. /**
  34569. * Returns the average value of the last second the counter was monitored
  34570. */
  34571. get lastSecAverage(): number;
  34572. /**
  34573. * Returns the current value
  34574. */
  34575. get current(): number;
  34576. /**
  34577. * Gets the accumulated total
  34578. */
  34579. get total(): number;
  34580. /**
  34581. * Gets the total value count
  34582. */
  34583. get count(): number;
  34584. /**
  34585. * Creates a new counter
  34586. */
  34587. constructor();
  34588. /**
  34589. * Call this method to start monitoring a new frame.
  34590. * 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.
  34591. */
  34592. fetchNewFrame(): void;
  34593. /**
  34594. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34595. * @param newCount the count value to add to the monitored count
  34596. * @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.
  34597. */
  34598. addCount(newCount: number, fetchResult: boolean): void;
  34599. /**
  34600. * Start monitoring this performance counter
  34601. */
  34602. beginMonitoring(): void;
  34603. /**
  34604. * Compute the time lapsed since the previous beginMonitoring() call.
  34605. * @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
  34606. */
  34607. endMonitoring(newFrame?: boolean): void;
  34608. private _fetchResult;
  34609. private _startMonitoringTime;
  34610. private _min;
  34611. private _max;
  34612. private _average;
  34613. private _current;
  34614. private _totalValueCount;
  34615. private _totalAccumulated;
  34616. private _lastSecAverage;
  34617. private _lastSecAccumulated;
  34618. private _lastSecTime;
  34619. private _lastSecValueCount;
  34620. }
  34621. }
  34622. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34623. module "babylonjs/Engines/thinEngine" {
  34624. interface ThinEngine {
  34625. /**
  34626. * Sets alpha constants used by some alpha blending modes
  34627. * @param r defines the red component
  34628. * @param g defines the green component
  34629. * @param b defines the blue component
  34630. * @param a defines the alpha component
  34631. */
  34632. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34633. /**
  34634. * Sets the current alpha mode
  34635. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34636. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34637. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34638. */
  34639. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34640. /**
  34641. * Gets the current alpha mode
  34642. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34643. * @returns the current alpha mode
  34644. */
  34645. getAlphaMode(): number;
  34646. /**
  34647. * Sets the current alpha equation
  34648. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34649. */
  34650. setAlphaEquation(equation: number): void;
  34651. /**
  34652. * Gets the current alpha equation.
  34653. * @returns the current alpha equation
  34654. */
  34655. getAlphaEquation(): number;
  34656. }
  34657. }
  34658. }
  34659. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  34660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34661. import { Nullable } from "babylonjs/types";
  34662. module "babylonjs/Engines/thinEngine" {
  34663. interface ThinEngine {
  34664. /** @hidden */
  34665. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34666. }
  34667. }
  34668. }
  34669. declare module "babylonjs/Engines/engine" {
  34670. import { Observable } from "babylonjs/Misc/observable";
  34671. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34672. import { Scene } from "babylonjs/scene";
  34673. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34674. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34675. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34676. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34677. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34678. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34679. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34680. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34681. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34682. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34683. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34684. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34685. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34686. import "babylonjs/Engines/Extensions/engine.alpha";
  34687. import "babylonjs/Engines/Extensions/engine.readTexture";
  34688. import { Material } from "babylonjs/Materials/material";
  34689. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34690. /**
  34691. * Defines the interface used by display changed events
  34692. */
  34693. export interface IDisplayChangedEventArgs {
  34694. /** Gets the vrDisplay object (if any) */
  34695. vrDisplay: Nullable<any>;
  34696. /** Gets a boolean indicating if webVR is supported */
  34697. vrSupported: boolean;
  34698. }
  34699. /**
  34700. * Defines the interface used by objects containing a viewport (like a camera)
  34701. */
  34702. interface IViewportOwnerLike {
  34703. /**
  34704. * Gets or sets the viewport
  34705. */
  34706. viewport: IViewportLike;
  34707. }
  34708. /**
  34709. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34710. */
  34711. export class Engine extends ThinEngine {
  34712. /** Defines that alpha blending is disabled */
  34713. static readonly ALPHA_DISABLE: number;
  34714. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34715. static readonly ALPHA_ADD: number;
  34716. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34717. static readonly ALPHA_COMBINE: number;
  34718. /** Defines that alpha blending to DEST - SRC * DEST */
  34719. static readonly ALPHA_SUBTRACT: number;
  34720. /** Defines that alpha blending to SRC * DEST */
  34721. static readonly ALPHA_MULTIPLY: number;
  34722. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34723. static readonly ALPHA_MAXIMIZED: number;
  34724. /** Defines that alpha blending to SRC + DEST */
  34725. static readonly ALPHA_ONEONE: number;
  34726. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34727. static readonly ALPHA_PREMULTIPLIED: number;
  34728. /**
  34729. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34730. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34731. */
  34732. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34733. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34734. static readonly ALPHA_INTERPOLATE: number;
  34735. /**
  34736. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34737. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34738. */
  34739. static readonly ALPHA_SCREENMODE: number;
  34740. /** Defines that the ressource is not delayed*/
  34741. static readonly DELAYLOADSTATE_NONE: number;
  34742. /** Defines that the ressource was successfully delay loaded */
  34743. static readonly DELAYLOADSTATE_LOADED: number;
  34744. /** Defines that the ressource is currently delay loading */
  34745. static readonly DELAYLOADSTATE_LOADING: number;
  34746. /** Defines that the ressource is delayed and has not started loading */
  34747. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34748. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34749. static readonly NEVER: number;
  34750. /** 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 */
  34751. static readonly ALWAYS: number;
  34752. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34753. static readonly LESS: number;
  34754. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34755. static readonly EQUAL: number;
  34756. /** 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 */
  34757. static readonly LEQUAL: number;
  34758. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34759. static readonly GREATER: number;
  34760. /** 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 */
  34761. static readonly GEQUAL: number;
  34762. /** 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 */
  34763. static readonly NOTEQUAL: number;
  34764. /** Passed to stencilOperation to specify that stencil value must be kept */
  34765. static readonly KEEP: number;
  34766. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34767. static readonly REPLACE: number;
  34768. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34769. static readonly INCR: number;
  34770. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34771. static readonly DECR: number;
  34772. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34773. static readonly INVERT: number;
  34774. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34775. static readonly INCR_WRAP: number;
  34776. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34777. static readonly DECR_WRAP: number;
  34778. /** Texture is not repeating outside of 0..1 UVs */
  34779. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34780. /** Texture is repeating outside of 0..1 UVs */
  34781. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34782. /** Texture is repeating and mirrored */
  34783. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34784. /** ALPHA */
  34785. static readonly TEXTUREFORMAT_ALPHA: number;
  34786. /** LUMINANCE */
  34787. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34788. /** LUMINANCE_ALPHA */
  34789. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34790. /** RGB */
  34791. static readonly TEXTUREFORMAT_RGB: number;
  34792. /** RGBA */
  34793. static readonly TEXTUREFORMAT_RGBA: number;
  34794. /** RED */
  34795. static readonly TEXTUREFORMAT_RED: number;
  34796. /** RED (2nd reference) */
  34797. static readonly TEXTUREFORMAT_R: number;
  34798. /** RG */
  34799. static readonly TEXTUREFORMAT_RG: number;
  34800. /** RED_INTEGER */
  34801. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34802. /** RED_INTEGER (2nd reference) */
  34803. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34804. /** RG_INTEGER */
  34805. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34806. /** RGB_INTEGER */
  34807. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34808. /** RGBA_INTEGER */
  34809. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34810. /** UNSIGNED_BYTE */
  34811. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34812. /** UNSIGNED_BYTE (2nd reference) */
  34813. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34814. /** FLOAT */
  34815. static readonly TEXTURETYPE_FLOAT: number;
  34816. /** HALF_FLOAT */
  34817. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34818. /** BYTE */
  34819. static readonly TEXTURETYPE_BYTE: number;
  34820. /** SHORT */
  34821. static readonly TEXTURETYPE_SHORT: number;
  34822. /** UNSIGNED_SHORT */
  34823. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34824. /** INT */
  34825. static readonly TEXTURETYPE_INT: number;
  34826. /** UNSIGNED_INT */
  34827. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34828. /** UNSIGNED_SHORT_4_4_4_4 */
  34829. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34830. /** UNSIGNED_SHORT_5_5_5_1 */
  34831. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34832. /** UNSIGNED_SHORT_5_6_5 */
  34833. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34834. /** UNSIGNED_INT_2_10_10_10_REV */
  34835. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34836. /** UNSIGNED_INT_24_8 */
  34837. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34838. /** UNSIGNED_INT_10F_11F_11F_REV */
  34839. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34840. /** UNSIGNED_INT_5_9_9_9_REV */
  34841. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34842. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34843. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34844. /** nearest is mag = nearest and min = nearest and mip = linear */
  34845. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34846. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34847. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34848. /** Trilinear is mag = linear and min = linear and mip = linear */
  34849. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34850. /** nearest is mag = nearest and min = nearest and mip = linear */
  34851. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34852. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34853. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34854. /** Trilinear is mag = linear and min = linear and mip = linear */
  34855. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34856. /** mag = nearest and min = nearest and mip = nearest */
  34857. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34858. /** mag = nearest and min = linear and mip = nearest */
  34859. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34860. /** mag = nearest and min = linear and mip = linear */
  34861. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34862. /** mag = nearest and min = linear and mip = none */
  34863. static readonly TEXTURE_NEAREST_LINEAR: number;
  34864. /** mag = nearest and min = nearest and mip = none */
  34865. static readonly TEXTURE_NEAREST_NEAREST: number;
  34866. /** mag = linear and min = nearest and mip = nearest */
  34867. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34868. /** mag = linear and min = nearest and mip = linear */
  34869. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34870. /** mag = linear and min = linear and mip = none */
  34871. static readonly TEXTURE_LINEAR_LINEAR: number;
  34872. /** mag = linear and min = nearest and mip = none */
  34873. static readonly TEXTURE_LINEAR_NEAREST: number;
  34874. /** Explicit coordinates mode */
  34875. static readonly TEXTURE_EXPLICIT_MODE: number;
  34876. /** Spherical coordinates mode */
  34877. static readonly TEXTURE_SPHERICAL_MODE: number;
  34878. /** Planar coordinates mode */
  34879. static readonly TEXTURE_PLANAR_MODE: number;
  34880. /** Cubic coordinates mode */
  34881. static readonly TEXTURE_CUBIC_MODE: number;
  34882. /** Projection coordinates mode */
  34883. static readonly TEXTURE_PROJECTION_MODE: number;
  34884. /** Skybox coordinates mode */
  34885. static readonly TEXTURE_SKYBOX_MODE: number;
  34886. /** Inverse Cubic coordinates mode */
  34887. static readonly TEXTURE_INVCUBIC_MODE: number;
  34888. /** Equirectangular coordinates mode */
  34889. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34890. /** Equirectangular Fixed coordinates mode */
  34891. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34892. /** Equirectangular Fixed Mirrored coordinates mode */
  34893. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34894. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34895. static readonly SCALEMODE_FLOOR: number;
  34896. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34897. static readonly SCALEMODE_NEAREST: number;
  34898. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34899. static readonly SCALEMODE_CEILING: number;
  34900. /**
  34901. * Returns the current npm package of the sdk
  34902. */
  34903. static get NpmPackage(): string;
  34904. /**
  34905. * Returns the current version of the framework
  34906. */
  34907. static get Version(): string;
  34908. /** Gets the list of created engines */
  34909. static get Instances(): Engine[];
  34910. /**
  34911. * Gets the latest created engine
  34912. */
  34913. static get LastCreatedEngine(): Nullable<Engine>;
  34914. /**
  34915. * Gets the latest created scene
  34916. */
  34917. static get LastCreatedScene(): Nullable<Scene>;
  34918. /**
  34919. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34920. * @param flag defines which part of the materials must be marked as dirty
  34921. * @param predicate defines a predicate used to filter which materials should be affected
  34922. */
  34923. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34924. /**
  34925. * Method called to create the default loading screen.
  34926. * This can be overriden in your own app.
  34927. * @param canvas The rendering canvas element
  34928. * @returns The loading screen
  34929. */
  34930. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34931. /**
  34932. * Method called to create the default rescale post process on each engine.
  34933. */
  34934. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34935. /**
  34936. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34937. **/
  34938. enableOfflineSupport: boolean;
  34939. /**
  34940. * 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)
  34941. **/
  34942. disableManifestCheck: boolean;
  34943. /**
  34944. * Gets the list of created scenes
  34945. */
  34946. scenes: Scene[];
  34947. /**
  34948. * Event raised when a new scene is created
  34949. */
  34950. onNewSceneAddedObservable: Observable<Scene>;
  34951. /**
  34952. * Gets the list of created postprocesses
  34953. */
  34954. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34955. /**
  34956. * Gets a boolean indicating if the pointer is currently locked
  34957. */
  34958. isPointerLock: boolean;
  34959. /**
  34960. * Observable event triggered each time the rendering canvas is resized
  34961. */
  34962. onResizeObservable: Observable<Engine>;
  34963. /**
  34964. * Observable event triggered each time the canvas loses focus
  34965. */
  34966. onCanvasBlurObservable: Observable<Engine>;
  34967. /**
  34968. * Observable event triggered each time the canvas gains focus
  34969. */
  34970. onCanvasFocusObservable: Observable<Engine>;
  34971. /**
  34972. * Observable event triggered each time the canvas receives pointerout event
  34973. */
  34974. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34975. /**
  34976. * Observable raised when the engine begins a new frame
  34977. */
  34978. onBeginFrameObservable: Observable<Engine>;
  34979. /**
  34980. * If set, will be used to request the next animation frame for the render loop
  34981. */
  34982. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34983. /**
  34984. * Observable raised when the engine ends the current frame
  34985. */
  34986. onEndFrameObservable: Observable<Engine>;
  34987. /**
  34988. * Observable raised when the engine is about to compile a shader
  34989. */
  34990. onBeforeShaderCompilationObservable: Observable<Engine>;
  34991. /**
  34992. * Observable raised when the engine has jsut compiled a shader
  34993. */
  34994. onAfterShaderCompilationObservable: Observable<Engine>;
  34995. /**
  34996. * Gets the audio engine
  34997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34998. * @ignorenaming
  34999. */
  35000. static audioEngine: IAudioEngine;
  35001. /**
  35002. * Default AudioEngine factory responsible of creating the Audio Engine.
  35003. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  35004. */
  35005. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  35006. /**
  35007. * Default offline support factory responsible of creating a tool used to store data locally.
  35008. * By default, this will create a Database object if the workload has been embedded.
  35009. */
  35010. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  35011. private _loadingScreen;
  35012. private _pointerLockRequested;
  35013. private _rescalePostProcess;
  35014. private _deterministicLockstep;
  35015. private _lockstepMaxSteps;
  35016. private _timeStep;
  35017. protected get _supportsHardwareTextureRescaling(): boolean;
  35018. private _fps;
  35019. private _deltaTime;
  35020. /** @hidden */
  35021. _drawCalls: PerfCounter;
  35022. /** 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 */
  35023. canvasTabIndex: number;
  35024. /**
  35025. * Turn this value on if you want to pause FPS computation when in background
  35026. */
  35027. disablePerformanceMonitorInBackground: boolean;
  35028. private _performanceMonitor;
  35029. /**
  35030. * Gets the performance monitor attached to this engine
  35031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  35032. */
  35033. get performanceMonitor(): PerformanceMonitor;
  35034. private _onFocus;
  35035. private _onBlur;
  35036. private _onCanvasPointerOut;
  35037. private _onCanvasBlur;
  35038. private _onCanvasFocus;
  35039. private _onFullscreenChange;
  35040. private _onPointerLockChange;
  35041. /**
  35042. * Gets the HTML element used to attach event listeners
  35043. * @returns a HTML element
  35044. */
  35045. getInputElement(): Nullable<HTMLElement>;
  35046. /**
  35047. * Creates a new engine
  35048. * @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
  35049. * @param antialias defines enable antialiasing (default: false)
  35050. * @param options defines further options to be sent to the getContext() function
  35051. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35052. */
  35053. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35054. /**
  35055. * Gets current aspect ratio
  35056. * @param viewportOwner defines the camera to use to get the aspect ratio
  35057. * @param useScreen defines if screen size must be used (or the current render target if any)
  35058. * @returns a number defining the aspect ratio
  35059. */
  35060. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  35061. /**
  35062. * Gets current screen aspect ratio
  35063. * @returns a number defining the aspect ratio
  35064. */
  35065. getScreenAspectRatio(): number;
  35066. /**
  35067. * Gets the client rect of the HTML canvas attached with the current webGL context
  35068. * @returns a client rectanglee
  35069. */
  35070. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  35071. /**
  35072. * Gets the client rect of the HTML element used for events
  35073. * @returns a client rectanglee
  35074. */
  35075. getInputElementClientRect(): Nullable<ClientRect>;
  35076. /**
  35077. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  35078. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35079. * @returns true if engine is in deterministic lock step mode
  35080. */
  35081. isDeterministicLockStep(): boolean;
  35082. /**
  35083. * Gets the max steps when engine is running in deterministic lock step
  35084. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35085. * @returns the max steps
  35086. */
  35087. getLockstepMaxSteps(): number;
  35088. /**
  35089. * Returns the time in ms between steps when using deterministic lock step.
  35090. * @returns time step in (ms)
  35091. */
  35092. getTimeStep(): number;
  35093. /**
  35094. * Force the mipmap generation for the given render target texture
  35095. * @param texture defines the render target texture to use
  35096. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  35097. */
  35098. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  35099. /** States */
  35100. /**
  35101. * Set various states to the webGL context
  35102. * @param culling defines backface culling state
  35103. * @param zOffset defines the value to apply to zOffset (0 by default)
  35104. * @param force defines if states must be applied even if cache is up to date
  35105. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  35106. */
  35107. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  35108. /**
  35109. * Set the z offset to apply to current rendering
  35110. * @param value defines the offset to apply
  35111. */
  35112. setZOffset(value: number): void;
  35113. /**
  35114. * Gets the current value of the zOffset
  35115. * @returns the current zOffset state
  35116. */
  35117. getZOffset(): number;
  35118. /**
  35119. * Enable or disable depth buffering
  35120. * @param enable defines the state to set
  35121. */
  35122. setDepthBuffer(enable: boolean): void;
  35123. /**
  35124. * Gets a boolean indicating if depth writing is enabled
  35125. * @returns the current depth writing state
  35126. */
  35127. getDepthWrite(): boolean;
  35128. /**
  35129. * Enable or disable depth writing
  35130. * @param enable defines the state to set
  35131. */
  35132. setDepthWrite(enable: boolean): void;
  35133. /**
  35134. * Gets a boolean indicating if stencil buffer is enabled
  35135. * @returns the current stencil buffer state
  35136. */
  35137. getStencilBuffer(): boolean;
  35138. /**
  35139. * Enable or disable the stencil buffer
  35140. * @param enable defines if the stencil buffer must be enabled or disabled
  35141. */
  35142. setStencilBuffer(enable: boolean): void;
  35143. /**
  35144. * Gets the current stencil mask
  35145. * @returns a number defining the new stencil mask to use
  35146. */
  35147. getStencilMask(): number;
  35148. /**
  35149. * Sets the current stencil mask
  35150. * @param mask defines the new stencil mask to use
  35151. */
  35152. setStencilMask(mask: number): void;
  35153. /**
  35154. * Gets the current stencil function
  35155. * @returns a number defining the stencil function to use
  35156. */
  35157. getStencilFunction(): number;
  35158. /**
  35159. * Gets the current stencil reference value
  35160. * @returns a number defining the stencil reference value to use
  35161. */
  35162. getStencilFunctionReference(): number;
  35163. /**
  35164. * Gets the current stencil mask
  35165. * @returns a number defining the stencil mask to use
  35166. */
  35167. getStencilFunctionMask(): number;
  35168. /**
  35169. * Sets the current stencil function
  35170. * @param stencilFunc defines the new stencil function to use
  35171. */
  35172. setStencilFunction(stencilFunc: number): void;
  35173. /**
  35174. * Sets the current stencil reference
  35175. * @param reference defines the new stencil reference to use
  35176. */
  35177. setStencilFunctionReference(reference: number): void;
  35178. /**
  35179. * Sets the current stencil mask
  35180. * @param mask defines the new stencil mask to use
  35181. */
  35182. setStencilFunctionMask(mask: number): void;
  35183. /**
  35184. * Gets the current stencil operation when stencil fails
  35185. * @returns a number defining stencil operation to use when stencil fails
  35186. */
  35187. getStencilOperationFail(): number;
  35188. /**
  35189. * Gets the current stencil operation when depth fails
  35190. * @returns a number defining stencil operation to use when depth fails
  35191. */
  35192. getStencilOperationDepthFail(): number;
  35193. /**
  35194. * Gets the current stencil operation when stencil passes
  35195. * @returns a number defining stencil operation to use when stencil passes
  35196. */
  35197. getStencilOperationPass(): number;
  35198. /**
  35199. * Sets the stencil operation to use when stencil fails
  35200. * @param operation defines the stencil operation to use when stencil fails
  35201. */
  35202. setStencilOperationFail(operation: number): void;
  35203. /**
  35204. * Sets the stencil operation to use when depth fails
  35205. * @param operation defines the stencil operation to use when depth fails
  35206. */
  35207. setStencilOperationDepthFail(operation: number): void;
  35208. /**
  35209. * Sets the stencil operation to use when stencil passes
  35210. * @param operation defines the stencil operation to use when stencil passes
  35211. */
  35212. setStencilOperationPass(operation: number): void;
  35213. /**
  35214. * Sets a boolean indicating if the dithering state is enabled or disabled
  35215. * @param value defines the dithering state
  35216. */
  35217. setDitheringState(value: boolean): void;
  35218. /**
  35219. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  35220. * @param value defines the rasterizer state
  35221. */
  35222. setRasterizerState(value: boolean): void;
  35223. /**
  35224. * Gets the current depth function
  35225. * @returns a number defining the depth function
  35226. */
  35227. getDepthFunction(): Nullable<number>;
  35228. /**
  35229. * Sets the current depth function
  35230. * @param depthFunc defines the function to use
  35231. */
  35232. setDepthFunction(depthFunc: number): void;
  35233. /**
  35234. * Sets the current depth function to GREATER
  35235. */
  35236. setDepthFunctionToGreater(): void;
  35237. /**
  35238. * Sets the current depth function to GEQUAL
  35239. */
  35240. setDepthFunctionToGreaterOrEqual(): void;
  35241. /**
  35242. * Sets the current depth function to LESS
  35243. */
  35244. setDepthFunctionToLess(): void;
  35245. /**
  35246. * Sets the current depth function to LEQUAL
  35247. */
  35248. setDepthFunctionToLessOrEqual(): void;
  35249. private _cachedStencilBuffer;
  35250. private _cachedStencilFunction;
  35251. private _cachedStencilMask;
  35252. private _cachedStencilOperationPass;
  35253. private _cachedStencilOperationFail;
  35254. private _cachedStencilOperationDepthFail;
  35255. private _cachedStencilReference;
  35256. /**
  35257. * Caches the the state of the stencil buffer
  35258. */
  35259. cacheStencilState(): void;
  35260. /**
  35261. * Restores the state of the stencil buffer
  35262. */
  35263. restoreStencilState(): void;
  35264. /**
  35265. * Directly set the WebGL Viewport
  35266. * @param x defines the x coordinate of the viewport (in screen space)
  35267. * @param y defines the y coordinate of the viewport (in screen space)
  35268. * @param width defines the width of the viewport (in screen space)
  35269. * @param height defines the height of the viewport (in screen space)
  35270. * @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
  35271. */
  35272. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35273. /**
  35274. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35275. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35276. * @param y defines the y-coordinate of the corner of the clear rectangle
  35277. * @param width defines the width of the clear rectangle
  35278. * @param height defines the height of the clear rectangle
  35279. * @param clearColor defines the clear color
  35280. */
  35281. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35282. /**
  35283. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35284. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35285. * @param y defines the y-coordinate of the corner of the clear rectangle
  35286. * @param width defines the width of the clear rectangle
  35287. * @param height defines the height of the clear rectangle
  35288. */
  35289. enableScissor(x: number, y: number, width: number, height: number): void;
  35290. /**
  35291. * Disable previously set scissor test rectangle
  35292. */
  35293. disableScissor(): void;
  35294. protected _reportDrawCall(): void;
  35295. /**
  35296. * Initializes a webVR display and starts listening to display change events
  35297. * The onVRDisplayChangedObservable will be notified upon these changes
  35298. * @returns The onVRDisplayChangedObservable
  35299. */
  35300. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35301. /** @hidden */
  35302. _prepareVRComponent(): void;
  35303. /** @hidden */
  35304. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35305. /** @hidden */
  35306. _submitVRFrame(): void;
  35307. /**
  35308. * Call this function to leave webVR mode
  35309. * Will do nothing if webVR is not supported or if there is no webVR device
  35310. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35311. */
  35312. disableVR(): void;
  35313. /**
  35314. * Gets a boolean indicating that the system is in VR mode and is presenting
  35315. * @returns true if VR mode is engaged
  35316. */
  35317. isVRPresenting(): boolean;
  35318. /** @hidden */
  35319. _requestVRFrame(): void;
  35320. /** @hidden */
  35321. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35322. /**
  35323. * Gets the source code of the vertex shader associated with a specific webGL program
  35324. * @param program defines the program to use
  35325. * @returns a string containing the source code of the vertex shader associated with the program
  35326. */
  35327. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35328. /**
  35329. * Gets the source code of the fragment shader associated with a specific webGL program
  35330. * @param program defines the program to use
  35331. * @returns a string containing the source code of the fragment shader associated with the program
  35332. */
  35333. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35334. /**
  35335. * Sets a depth stencil texture from a render target to the according uniform.
  35336. * @param channel The texture channel
  35337. * @param uniform The uniform to set
  35338. * @param texture The render target texture containing the depth stencil texture to apply
  35339. */
  35340. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35341. /**
  35342. * Sets a texture to the webGL context from a postprocess
  35343. * @param channel defines the channel to use
  35344. * @param postProcess defines the source postprocess
  35345. */
  35346. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35347. /**
  35348. * Binds the output of the passed in post process to the texture channel specified
  35349. * @param channel The channel the texture should be bound to
  35350. * @param postProcess The post process which's output should be bound
  35351. */
  35352. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35353. protected _rebuildBuffers(): void;
  35354. /** @hidden */
  35355. _renderFrame(): void;
  35356. _renderLoop(): void;
  35357. /** @hidden */
  35358. _renderViews(): boolean;
  35359. /**
  35360. * Toggle full screen mode
  35361. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35362. */
  35363. switchFullscreen(requestPointerLock: boolean): void;
  35364. /**
  35365. * Enters full screen mode
  35366. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35367. */
  35368. enterFullscreen(requestPointerLock: boolean): void;
  35369. /**
  35370. * Exits full screen mode
  35371. */
  35372. exitFullscreen(): void;
  35373. /**
  35374. * Enters Pointerlock mode
  35375. */
  35376. enterPointerlock(): void;
  35377. /**
  35378. * Exits Pointerlock mode
  35379. */
  35380. exitPointerlock(): void;
  35381. /**
  35382. * Begin a new frame
  35383. */
  35384. beginFrame(): void;
  35385. /**
  35386. * Enf the current frame
  35387. */
  35388. endFrame(): void;
  35389. resize(): void;
  35390. /**
  35391. * Force a specific size of the canvas
  35392. * @param width defines the new canvas' width
  35393. * @param height defines the new canvas' height
  35394. */
  35395. setSize(width: number, height: number): void;
  35396. /**
  35397. * Updates a dynamic vertex buffer.
  35398. * @param vertexBuffer the vertex buffer to update
  35399. * @param data the data used to update the vertex buffer
  35400. * @param byteOffset the byte offset of the data
  35401. * @param byteLength the byte length of the data
  35402. */
  35403. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35404. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35405. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35406. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35407. _releaseTexture(texture: InternalTexture): void;
  35408. /**
  35409. * @hidden
  35410. * Rescales a texture
  35411. * @param source input texutre
  35412. * @param destination destination texture
  35413. * @param scene scene to use to render the resize
  35414. * @param internalFormat format to use when resizing
  35415. * @param onComplete callback to be called when resize has completed
  35416. */
  35417. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35418. /**
  35419. * Gets the current framerate
  35420. * @returns a number representing the framerate
  35421. */
  35422. getFps(): number;
  35423. /**
  35424. * Gets the time spent between current and previous frame
  35425. * @returns a number representing the delta time in ms
  35426. */
  35427. getDeltaTime(): number;
  35428. private _measureFps;
  35429. /** @hidden */
  35430. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35431. /**
  35432. * Update a dynamic index buffer
  35433. * @param indexBuffer defines the target index buffer
  35434. * @param indices defines the data to update
  35435. * @param offset defines the offset in the target index buffer where update should start
  35436. */
  35437. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35438. /**
  35439. * Updates the sample count of a render target texture
  35440. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35441. * @param texture defines the texture to update
  35442. * @param samples defines the sample count to set
  35443. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35444. */
  35445. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35446. /**
  35447. * Updates a depth texture Comparison Mode and Function.
  35448. * If the comparison Function is equal to 0, the mode will be set to none.
  35449. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35450. * @param texture The texture to set the comparison function for
  35451. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35452. */
  35453. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35454. /**
  35455. * Creates a webGL buffer to use with instanciation
  35456. * @param capacity defines the size of the buffer
  35457. * @returns the webGL buffer
  35458. */
  35459. createInstancesBuffer(capacity: number): DataBuffer;
  35460. /**
  35461. * Delete a webGL buffer used with instanciation
  35462. * @param buffer defines the webGL buffer to delete
  35463. */
  35464. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35465. private _clientWaitAsync;
  35466. /** @hidden */
  35467. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35468. dispose(): void;
  35469. private _disableTouchAction;
  35470. /**
  35471. * Display the loading screen
  35472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35473. */
  35474. displayLoadingUI(): void;
  35475. /**
  35476. * Hide the loading screen
  35477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35478. */
  35479. hideLoadingUI(): void;
  35480. /**
  35481. * Gets the current loading screen object
  35482. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35483. */
  35484. get loadingScreen(): ILoadingScreen;
  35485. /**
  35486. * Sets the current loading screen object
  35487. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35488. */
  35489. set loadingScreen(loadingScreen: ILoadingScreen);
  35490. /**
  35491. * Sets the current loading screen text
  35492. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35493. */
  35494. set loadingUIText(text: string);
  35495. /**
  35496. * Sets the current loading screen background color
  35497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35498. */
  35499. set loadingUIBackgroundColor(color: string);
  35500. /** Pointerlock and fullscreen */
  35501. /**
  35502. * Ask the browser to promote the current element to pointerlock mode
  35503. * @param element defines the DOM element to promote
  35504. */
  35505. static _RequestPointerlock(element: HTMLElement): void;
  35506. /**
  35507. * Asks the browser to exit pointerlock mode
  35508. */
  35509. static _ExitPointerlock(): void;
  35510. /**
  35511. * Ask the browser to promote the current element to fullscreen rendering mode
  35512. * @param element defines the DOM element to promote
  35513. */
  35514. static _RequestFullscreen(element: HTMLElement): void;
  35515. /**
  35516. * Asks the browser to exit fullscreen mode
  35517. */
  35518. static _ExitFullscreen(): void;
  35519. }
  35520. }
  35521. declare module "babylonjs/Engines/engineStore" {
  35522. import { Nullable } from "babylonjs/types";
  35523. import { Engine } from "babylonjs/Engines/engine";
  35524. import { Scene } from "babylonjs/scene";
  35525. /**
  35526. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35527. * during the life time of the application.
  35528. */
  35529. export class EngineStore {
  35530. /** Gets the list of created engines */
  35531. static Instances: import("babylonjs/Engines/engine").Engine[];
  35532. /** @hidden */
  35533. static _LastCreatedScene: Nullable<Scene>;
  35534. /**
  35535. * Gets the latest created engine
  35536. */
  35537. static get LastCreatedEngine(): Nullable<Engine>;
  35538. /**
  35539. * Gets the latest created scene
  35540. */
  35541. static get LastCreatedScene(): Nullable<Scene>;
  35542. /**
  35543. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35544. * @ignorenaming
  35545. */
  35546. static UseFallbackTexture: boolean;
  35547. /**
  35548. * Texture content used if a texture cannot loaded
  35549. * @ignorenaming
  35550. */
  35551. static FallbackTexture: string;
  35552. }
  35553. }
  35554. declare module "babylonjs/Misc/promise" {
  35555. /**
  35556. * Helper class that provides a small promise polyfill
  35557. */
  35558. export class PromisePolyfill {
  35559. /**
  35560. * Static function used to check if the polyfill is required
  35561. * If this is the case then the function will inject the polyfill to window.Promise
  35562. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35563. */
  35564. static Apply(force?: boolean): void;
  35565. }
  35566. }
  35567. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35568. /**
  35569. * Interface for screenshot methods with describe argument called `size` as object with options
  35570. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35571. */
  35572. export interface IScreenshotSize {
  35573. /**
  35574. * number in pixels for canvas height
  35575. */
  35576. height?: number;
  35577. /**
  35578. * multiplier allowing render at a higher or lower resolution
  35579. * If value is defined then height and width will be ignored and taken from camera
  35580. */
  35581. precision?: number;
  35582. /**
  35583. * number in pixels for canvas width
  35584. */
  35585. width?: number;
  35586. }
  35587. }
  35588. declare module "babylonjs/Misc/tools" {
  35589. import { Nullable, float } from "babylonjs/types";
  35590. import { DomManagement } from "babylonjs/Misc/domManagement";
  35591. import { WebRequest } from "babylonjs/Misc/webRequest";
  35592. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35593. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35594. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35595. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35596. import { Camera } from "babylonjs/Cameras/camera";
  35597. import { Engine } from "babylonjs/Engines/engine";
  35598. interface IColor4Like {
  35599. r: float;
  35600. g: float;
  35601. b: float;
  35602. a: float;
  35603. }
  35604. /**
  35605. * Class containing a set of static utilities functions
  35606. */
  35607. export class Tools {
  35608. /**
  35609. * Gets or sets the base URL to use to load assets
  35610. */
  35611. static get BaseUrl(): string;
  35612. static set BaseUrl(value: string);
  35613. /**
  35614. * Enable/Disable Custom HTTP Request Headers globally.
  35615. * default = false
  35616. * @see CustomRequestHeaders
  35617. */
  35618. static UseCustomRequestHeaders: boolean;
  35619. /**
  35620. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35621. * i.e. when loading files, where the server/service expects an Authorization header
  35622. */
  35623. static CustomRequestHeaders: {
  35624. [key: string]: string;
  35625. };
  35626. /**
  35627. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35628. */
  35629. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35630. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35631. /**
  35632. * Default behaviour for cors in the application.
  35633. * It can be a string if the expected behavior is identical in the entire app.
  35634. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35635. */
  35636. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35637. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35638. /**
  35639. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35640. * @ignorenaming
  35641. */
  35642. static get UseFallbackTexture(): boolean;
  35643. static set UseFallbackTexture(value: boolean);
  35644. /**
  35645. * Use this object to register external classes like custom textures or material
  35646. * to allow the laoders to instantiate them
  35647. */
  35648. static get RegisteredExternalClasses(): {
  35649. [key: string]: Object;
  35650. };
  35651. static set RegisteredExternalClasses(classes: {
  35652. [key: string]: Object;
  35653. });
  35654. /**
  35655. * Texture content used if a texture cannot loaded
  35656. * @ignorenaming
  35657. */
  35658. static get fallbackTexture(): string;
  35659. static set fallbackTexture(value: string);
  35660. /**
  35661. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35662. * @param u defines the coordinate on X axis
  35663. * @param v defines the coordinate on Y axis
  35664. * @param width defines the width of the source data
  35665. * @param height defines the height of the source data
  35666. * @param pixels defines the source byte array
  35667. * @param color defines the output color
  35668. */
  35669. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35670. /**
  35671. * Interpolates between a and b via alpha
  35672. * @param a The lower value (returned when alpha = 0)
  35673. * @param b The upper value (returned when alpha = 1)
  35674. * @param alpha The interpolation-factor
  35675. * @return The mixed value
  35676. */
  35677. static Mix(a: number, b: number, alpha: number): number;
  35678. /**
  35679. * Tries to instantiate a new object from a given class name
  35680. * @param className defines the class name to instantiate
  35681. * @returns the new object or null if the system was not able to do the instantiation
  35682. */
  35683. static Instantiate(className: string): any;
  35684. /**
  35685. * Provides a slice function that will work even on IE
  35686. * @param data defines the array to slice
  35687. * @param start defines the start of the data (optional)
  35688. * @param end defines the end of the data (optional)
  35689. * @returns the new sliced array
  35690. */
  35691. static Slice<T>(data: T, start?: number, end?: number): T;
  35692. /**
  35693. * Polyfill for setImmediate
  35694. * @param action defines the action to execute after the current execution block
  35695. */
  35696. static SetImmediate(action: () => void): void;
  35697. /**
  35698. * Function indicating if a number is an exponent of 2
  35699. * @param value defines the value to test
  35700. * @returns true if the value is an exponent of 2
  35701. */
  35702. static IsExponentOfTwo(value: number): boolean;
  35703. private static _tmpFloatArray;
  35704. /**
  35705. * Returns the nearest 32-bit single precision float representation of a Number
  35706. * @param value A Number. If the parameter is of a different type, it will get converted
  35707. * to a number or to NaN if it cannot be converted
  35708. * @returns number
  35709. */
  35710. static FloatRound(value: number): number;
  35711. /**
  35712. * Extracts the filename from a path
  35713. * @param path defines the path to use
  35714. * @returns the filename
  35715. */
  35716. static GetFilename(path: string): string;
  35717. /**
  35718. * Extracts the "folder" part of a path (everything before the filename).
  35719. * @param uri The URI to extract the info from
  35720. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35721. * @returns The "folder" part of the path
  35722. */
  35723. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35724. /**
  35725. * Extracts text content from a DOM element hierarchy
  35726. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35727. */
  35728. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35729. /**
  35730. * Convert an angle in radians to degrees
  35731. * @param angle defines the angle to convert
  35732. * @returns the angle in degrees
  35733. */
  35734. static ToDegrees(angle: number): number;
  35735. /**
  35736. * Convert an angle in degrees to radians
  35737. * @param angle defines the angle to convert
  35738. * @returns the angle in radians
  35739. */
  35740. static ToRadians(angle: number): number;
  35741. /**
  35742. * Returns an array if obj is not an array
  35743. * @param obj defines the object to evaluate as an array
  35744. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35745. * @returns either obj directly if obj is an array or a new array containing obj
  35746. */
  35747. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35748. /**
  35749. * Gets the pointer prefix to use
  35750. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35751. */
  35752. static GetPointerPrefix(): string;
  35753. /**
  35754. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35755. * @param url define the url we are trying
  35756. * @param element define the dom element where to configure the cors policy
  35757. */
  35758. static SetCorsBehavior(url: string | string[], element: {
  35759. crossOrigin: string | null;
  35760. }): void;
  35761. /**
  35762. * Removes unwanted characters from an url
  35763. * @param url defines the url to clean
  35764. * @returns the cleaned url
  35765. */
  35766. static CleanUrl(url: string): string;
  35767. /**
  35768. * Gets or sets a function used to pre-process url before using them to load assets
  35769. */
  35770. static get PreprocessUrl(): (url: string) => string;
  35771. static set PreprocessUrl(processor: (url: string) => string);
  35772. /**
  35773. * Loads an image as an HTMLImageElement.
  35774. * @param input url string, ArrayBuffer, or Blob to load
  35775. * @param onLoad callback called when the image successfully loads
  35776. * @param onError callback called when the image fails to load
  35777. * @param offlineProvider offline provider for caching
  35778. * @param mimeType optional mime type
  35779. * @returns the HTMLImageElement of the loaded image
  35780. */
  35781. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35782. /**
  35783. * Loads a file from a url
  35784. * @param url url string, ArrayBuffer, or Blob to load
  35785. * @param onSuccess callback called when the file successfully loads
  35786. * @param onProgress callback called while file is loading (if the server supports this mode)
  35787. * @param offlineProvider defines the offline provider for caching
  35788. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35789. * @param onError callback called when the file fails to load
  35790. * @returns a file request object
  35791. */
  35792. 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;
  35793. /**
  35794. * Loads a file from a url
  35795. * @param url the file url to load
  35796. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35797. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35798. */
  35799. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35800. /**
  35801. * Load a script (identified by an url). When the url returns, the
  35802. * content of this file is added into a new script element, attached to the DOM (body element)
  35803. * @param scriptUrl defines the url of the script to laod
  35804. * @param onSuccess defines the callback called when the script is loaded
  35805. * @param onError defines the callback to call if an error occurs
  35806. * @param scriptId defines the id of the script element
  35807. */
  35808. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35809. /**
  35810. * Load an asynchronous script (identified by an url). When the url returns, the
  35811. * content of this file is added into a new script element, attached to the DOM (body element)
  35812. * @param scriptUrl defines the url of the script to laod
  35813. * @param scriptId defines the id of the script element
  35814. * @returns a promise request object
  35815. */
  35816. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35817. /**
  35818. * Loads a file from a blob
  35819. * @param fileToLoad defines the blob to use
  35820. * @param callback defines the callback to call when data is loaded
  35821. * @param progressCallback defines the callback to call during loading process
  35822. * @returns a file request object
  35823. */
  35824. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35825. /**
  35826. * Reads a file from a File object
  35827. * @param file defines the file to load
  35828. * @param onSuccess defines the callback to call when data is loaded
  35829. * @param onProgress defines the callback to call during loading process
  35830. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35831. * @param onError defines the callback to call when an error occurs
  35832. * @returns a file request object
  35833. */
  35834. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35835. /**
  35836. * Creates a data url from a given string content
  35837. * @param content defines the content to convert
  35838. * @returns the new data url link
  35839. */
  35840. static FileAsURL(content: string): string;
  35841. /**
  35842. * Format the given number to a specific decimal format
  35843. * @param value defines the number to format
  35844. * @param decimals defines the number of decimals to use
  35845. * @returns the formatted string
  35846. */
  35847. static Format(value: number, decimals?: number): string;
  35848. /**
  35849. * Tries to copy an object by duplicating every property
  35850. * @param source defines the source object
  35851. * @param destination defines the target object
  35852. * @param doNotCopyList defines a list of properties to avoid
  35853. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35854. */
  35855. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35856. /**
  35857. * Gets a boolean indicating if the given object has no own property
  35858. * @param obj defines the object to test
  35859. * @returns true if object has no own property
  35860. */
  35861. static IsEmpty(obj: any): boolean;
  35862. /**
  35863. * Function used to register events at window level
  35864. * @param windowElement defines the Window object to use
  35865. * @param events defines the events to register
  35866. */
  35867. static RegisterTopRootEvents(windowElement: Window, events: {
  35868. name: string;
  35869. handler: Nullable<(e: FocusEvent) => any>;
  35870. }[]): void;
  35871. /**
  35872. * Function used to unregister events from window level
  35873. * @param windowElement defines the Window object to use
  35874. * @param events defines the events to unregister
  35875. */
  35876. static UnregisterTopRootEvents(windowElement: Window, events: {
  35877. name: string;
  35878. handler: Nullable<(e: FocusEvent) => any>;
  35879. }[]): void;
  35880. /**
  35881. * @ignore
  35882. */
  35883. static _ScreenshotCanvas: HTMLCanvasElement;
  35884. /**
  35885. * Dumps the current bound framebuffer
  35886. * @param width defines the rendering width
  35887. * @param height defines the rendering height
  35888. * @param engine defines the hosting engine
  35889. * @param successCallback defines the callback triggered once the data are available
  35890. * @param mimeType defines the mime type of the result
  35891. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35892. */
  35893. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35894. /**
  35895. * Converts the canvas data to blob.
  35896. * This acts as a polyfill for browsers not supporting the to blob function.
  35897. * @param canvas Defines the canvas to extract the data from
  35898. * @param successCallback Defines the callback triggered once the data are available
  35899. * @param mimeType Defines the mime type of the result
  35900. */
  35901. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35902. /**
  35903. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35904. * @param successCallback defines the callback triggered once the data are available
  35905. * @param mimeType defines the mime type of the result
  35906. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35907. */
  35908. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35909. /**
  35910. * Downloads a blob in the browser
  35911. * @param blob defines the blob to download
  35912. * @param fileName defines the name of the downloaded file
  35913. */
  35914. static Download(blob: Blob, fileName: string): void;
  35915. /**
  35916. * Captures a screenshot of the current rendering
  35917. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35918. * @param engine defines the rendering engine
  35919. * @param camera defines the source camera
  35920. * @param size This parameter can be set to a single number or to an object with the
  35921. * following (optional) properties: precision, width, height. If a single number is passed,
  35922. * it will be used for both width and height. If an object is passed, the screenshot size
  35923. * will be derived from the parameters. The precision property is a multiplier allowing
  35924. * rendering at a higher or lower resolution
  35925. * @param successCallback defines the callback receives a single parameter which contains the
  35926. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35927. * src parameter of an <img> to display it
  35928. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35929. * Check your browser for supported MIME types
  35930. */
  35931. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35932. /**
  35933. * Captures a screenshot of the current rendering
  35934. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35935. * @param engine defines the rendering engine
  35936. * @param camera defines the source camera
  35937. * @param size This parameter can be set to a single number or to an object with the
  35938. * following (optional) properties: precision, width, height. If a single number is passed,
  35939. * it will be used for both width and height. If an object is passed, the screenshot size
  35940. * will be derived from the parameters. The precision property is a multiplier allowing
  35941. * rendering at a higher or lower resolution
  35942. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35943. * Check your browser for supported MIME types
  35944. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35945. * to the src parameter of an <img> to display it
  35946. */
  35947. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35948. /**
  35949. * Generates an image screenshot from the specified camera.
  35950. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35951. * @param engine The engine to use for rendering
  35952. * @param camera The camera to use for rendering
  35953. * @param size This parameter can be set to a single number or to an object with the
  35954. * following (optional) properties: precision, width, height. If a single number is passed,
  35955. * it will be used for both width and height. If an object is passed, the screenshot size
  35956. * will be derived from the parameters. The precision property is a multiplier allowing
  35957. * rendering at a higher or lower resolution
  35958. * @param successCallback The callback receives a single parameter which contains the
  35959. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35960. * src parameter of an <img> to display it
  35961. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35962. * Check your browser for supported MIME types
  35963. * @param samples Texture samples (default: 1)
  35964. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35965. * @param fileName A name for for the downloaded file.
  35966. */
  35967. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35968. /**
  35969. * Generates an image screenshot from the specified camera.
  35970. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35971. * @param engine The engine to use for rendering
  35972. * @param camera The camera to use for rendering
  35973. * @param size This parameter can be set to a single number or to an object with the
  35974. * following (optional) properties: precision, width, height. If a single number is passed,
  35975. * it will be used for both width and height. If an object is passed, the screenshot size
  35976. * will be derived from the parameters. The precision property is a multiplier allowing
  35977. * rendering at a higher or lower resolution
  35978. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35979. * Check your browser for supported MIME types
  35980. * @param samples Texture samples (default: 1)
  35981. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35982. * @param fileName A name for for the downloaded file.
  35983. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35984. * to the src parameter of an <img> to display it
  35985. */
  35986. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35987. /**
  35988. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35989. * Be aware Math.random() could cause collisions, but:
  35990. * "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"
  35991. * @returns a pseudo random id
  35992. */
  35993. static RandomId(): string;
  35994. /**
  35995. * Test if the given uri is a base64 string
  35996. * @param uri The uri to test
  35997. * @return True if the uri is a base64 string or false otherwise
  35998. */
  35999. static IsBase64(uri: string): boolean;
  36000. /**
  36001. * Decode the given base64 uri.
  36002. * @param uri The uri to decode
  36003. * @return The decoded base64 data.
  36004. */
  36005. static DecodeBase64(uri: string): ArrayBuffer;
  36006. /**
  36007. * Gets the absolute url.
  36008. * @param url the input url
  36009. * @return the absolute url
  36010. */
  36011. static GetAbsoluteUrl(url: string): string;
  36012. /**
  36013. * No log
  36014. */
  36015. static readonly NoneLogLevel: number;
  36016. /**
  36017. * Only message logs
  36018. */
  36019. static readonly MessageLogLevel: number;
  36020. /**
  36021. * Only warning logs
  36022. */
  36023. static readonly WarningLogLevel: number;
  36024. /**
  36025. * Only error logs
  36026. */
  36027. static readonly ErrorLogLevel: number;
  36028. /**
  36029. * All logs
  36030. */
  36031. static readonly AllLogLevel: number;
  36032. /**
  36033. * Gets a value indicating the number of loading errors
  36034. * @ignorenaming
  36035. */
  36036. static get errorsCount(): number;
  36037. /**
  36038. * Callback called when a new log is added
  36039. */
  36040. static OnNewCacheEntry: (entry: string) => void;
  36041. /**
  36042. * Log a message to the console
  36043. * @param message defines the message to log
  36044. */
  36045. static Log(message: string): void;
  36046. /**
  36047. * Write a warning message to the console
  36048. * @param message defines the message to log
  36049. */
  36050. static Warn(message: string): void;
  36051. /**
  36052. * Write an error message to the console
  36053. * @param message defines the message to log
  36054. */
  36055. static Error(message: string): void;
  36056. /**
  36057. * Gets current log cache (list of logs)
  36058. */
  36059. static get LogCache(): string;
  36060. /**
  36061. * Clears the log cache
  36062. */
  36063. static ClearLogCache(): void;
  36064. /**
  36065. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  36066. */
  36067. static set LogLevels(level: number);
  36068. /**
  36069. * Checks if the window object exists
  36070. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  36071. */
  36072. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  36073. /**
  36074. * No performance log
  36075. */
  36076. static readonly PerformanceNoneLogLevel: number;
  36077. /**
  36078. * Use user marks to log performance
  36079. */
  36080. static readonly PerformanceUserMarkLogLevel: number;
  36081. /**
  36082. * Log performance to the console
  36083. */
  36084. static readonly PerformanceConsoleLogLevel: number;
  36085. private static _performance;
  36086. /**
  36087. * Sets the current performance log level
  36088. */
  36089. static set PerformanceLogLevel(level: number);
  36090. private static _StartPerformanceCounterDisabled;
  36091. private static _EndPerformanceCounterDisabled;
  36092. private static _StartUserMark;
  36093. private static _EndUserMark;
  36094. private static _StartPerformanceConsole;
  36095. private static _EndPerformanceConsole;
  36096. /**
  36097. * Starts a performance counter
  36098. */
  36099. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36100. /**
  36101. * Ends a specific performance coutner
  36102. */
  36103. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36104. /**
  36105. * Gets either window.performance.now() if supported or Date.now() else
  36106. */
  36107. static get Now(): number;
  36108. /**
  36109. * This method will return the name of the class used to create the instance of the given object.
  36110. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  36111. * @param object the object to get the class name from
  36112. * @param isType defines if the object is actually a type
  36113. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  36114. */
  36115. static GetClassName(object: any, isType?: boolean): string;
  36116. /**
  36117. * Gets the first element of an array satisfying a given predicate
  36118. * @param array defines the array to browse
  36119. * @param predicate defines the predicate to use
  36120. * @returns null if not found or the element
  36121. */
  36122. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  36123. /**
  36124. * This method will return the name of the full name of the class, including its owning module (if any).
  36125. * 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).
  36126. * @param object the object to get the class name from
  36127. * @param isType defines if the object is actually a type
  36128. * @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.
  36129. * @ignorenaming
  36130. */
  36131. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  36132. /**
  36133. * Returns a promise that resolves after the given amount of time.
  36134. * @param delay Number of milliseconds to delay
  36135. * @returns Promise that resolves after the given amount of time
  36136. */
  36137. static DelayAsync(delay: number): Promise<void>;
  36138. /**
  36139. * Utility function to detect if the current user agent is Safari
  36140. * @returns whether or not the current user agent is safari
  36141. */
  36142. static IsSafari(): boolean;
  36143. }
  36144. /**
  36145. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  36146. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  36147. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  36148. * @param name The name of the class, case should be preserved
  36149. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  36150. */
  36151. export function className(name: string, module?: string): (target: Object) => void;
  36152. /**
  36153. * An implementation of a loop for asynchronous functions.
  36154. */
  36155. export class AsyncLoop {
  36156. /**
  36157. * Defines the number of iterations for the loop
  36158. */
  36159. iterations: number;
  36160. /**
  36161. * Defines the current index of the loop.
  36162. */
  36163. index: number;
  36164. private _done;
  36165. private _fn;
  36166. private _successCallback;
  36167. /**
  36168. * Constructor.
  36169. * @param iterations the number of iterations.
  36170. * @param func the function to run each iteration
  36171. * @param successCallback the callback that will be called upon succesful execution
  36172. * @param offset starting offset.
  36173. */
  36174. constructor(
  36175. /**
  36176. * Defines the number of iterations for the loop
  36177. */
  36178. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  36179. /**
  36180. * Execute the next iteration. Must be called after the last iteration was finished.
  36181. */
  36182. executeNext(): void;
  36183. /**
  36184. * Break the loop and run the success callback.
  36185. */
  36186. breakLoop(): void;
  36187. /**
  36188. * Create and run an async loop.
  36189. * @param iterations the number of iterations.
  36190. * @param fn the function to run each iteration
  36191. * @param successCallback the callback that will be called upon succesful execution
  36192. * @param offset starting offset.
  36193. * @returns the created async loop object
  36194. */
  36195. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  36196. /**
  36197. * A for-loop that will run a given number of iterations synchronous and the rest async.
  36198. * @param iterations total number of iterations
  36199. * @param syncedIterations number of synchronous iterations in each async iteration.
  36200. * @param fn the function to call each iteration.
  36201. * @param callback a success call back that will be called when iterating stops.
  36202. * @param breakFunction a break condition (optional)
  36203. * @param timeout timeout settings for the setTimeout function. default - 0.
  36204. * @returns the created async loop object
  36205. */
  36206. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  36207. }
  36208. }
  36209. declare module "babylonjs/Misc/stringDictionary" {
  36210. import { Nullable } from "babylonjs/types";
  36211. /**
  36212. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36213. * The underlying implementation relies on an associative array to ensure the best performances.
  36214. * The value can be anything including 'null' but except 'undefined'
  36215. */
  36216. export class StringDictionary<T> {
  36217. /**
  36218. * This will clear this dictionary and copy the content from the 'source' one.
  36219. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36220. * @param source the dictionary to take the content from and copy to this dictionary
  36221. */
  36222. copyFrom(source: StringDictionary<T>): void;
  36223. /**
  36224. * Get a value based from its key
  36225. * @param key the given key to get the matching value from
  36226. * @return the value if found, otherwise undefined is returned
  36227. */
  36228. get(key: string): T | undefined;
  36229. /**
  36230. * Get a value from its key or add it if it doesn't exist.
  36231. * This method will ensure you that a given key/data will be present in the dictionary.
  36232. * @param key the given key to get the matching value from
  36233. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36234. * The factory will only be invoked if there's no data for the given key.
  36235. * @return the value corresponding to the key.
  36236. */
  36237. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36238. /**
  36239. * Get a value from its key if present in the dictionary otherwise add it
  36240. * @param key the key to get the value from
  36241. * @param val if there's no such key/value pair in the dictionary add it with this value
  36242. * @return the value corresponding to the key
  36243. */
  36244. getOrAdd(key: string, val: T): T;
  36245. /**
  36246. * Check if there's a given key in the dictionary
  36247. * @param key the key to check for
  36248. * @return true if the key is present, false otherwise
  36249. */
  36250. contains(key: string): boolean;
  36251. /**
  36252. * Add a new key and its corresponding value
  36253. * @param key the key to add
  36254. * @param value the value corresponding to the key
  36255. * @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
  36256. */
  36257. add(key: string, value: T): boolean;
  36258. /**
  36259. * Update a specific value associated to a key
  36260. * @param key defines the key to use
  36261. * @param value defines the value to store
  36262. * @returns true if the value was updated (or false if the key was not found)
  36263. */
  36264. set(key: string, value: T): boolean;
  36265. /**
  36266. * Get the element of the given key and remove it from the dictionary
  36267. * @param key defines the key to search
  36268. * @returns the value associated with the key or null if not found
  36269. */
  36270. getAndRemove(key: string): Nullable<T>;
  36271. /**
  36272. * Remove a key/value from the dictionary.
  36273. * @param key the key to remove
  36274. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36275. */
  36276. remove(key: string): boolean;
  36277. /**
  36278. * Clear the whole content of the dictionary
  36279. */
  36280. clear(): void;
  36281. /**
  36282. * Gets the current count
  36283. */
  36284. get count(): number;
  36285. /**
  36286. * Execute a callback on each key/val of the dictionary.
  36287. * Note that you can remove any element in this dictionary in the callback implementation
  36288. * @param callback the callback to execute on a given key/value pair
  36289. */
  36290. forEach(callback: (key: string, val: T) => void): void;
  36291. /**
  36292. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36293. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36294. * Note that you can remove any element in this dictionary in the callback implementation
  36295. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36296. * @returns the first item
  36297. */
  36298. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36299. private _count;
  36300. private _data;
  36301. }
  36302. }
  36303. declare module "babylonjs/Collisions/collisionCoordinator" {
  36304. import { Nullable } from "babylonjs/types";
  36305. import { Scene } from "babylonjs/scene";
  36306. import { Vector3 } from "babylonjs/Maths/math.vector";
  36307. import { Collider } from "babylonjs/Collisions/collider";
  36308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36309. /** @hidden */
  36310. export interface ICollisionCoordinator {
  36311. createCollider(): Collider;
  36312. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36313. init(scene: Scene): void;
  36314. }
  36315. /** @hidden */
  36316. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36317. private _scene;
  36318. private _scaledPosition;
  36319. private _scaledVelocity;
  36320. private _finalPosition;
  36321. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36322. createCollider(): Collider;
  36323. init(scene: Scene): void;
  36324. private _collideWithWorld;
  36325. }
  36326. }
  36327. declare module "babylonjs/Inputs/scene.inputManager" {
  36328. import { Nullable } from "babylonjs/types";
  36329. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36330. import { Vector2 } from "babylonjs/Maths/math.vector";
  36331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36332. import { Scene } from "babylonjs/scene";
  36333. /**
  36334. * Class used to manage all inputs for the scene.
  36335. */
  36336. export class InputManager {
  36337. /** The distance in pixel that you have to move to prevent some events */
  36338. static DragMovementThreshold: number;
  36339. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36340. static LongPressDelay: number;
  36341. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36342. static DoubleClickDelay: number;
  36343. /** If you need to check double click without raising a single click at first click, enable this flag */
  36344. static ExclusiveDoubleClickMode: boolean;
  36345. private _wheelEventName;
  36346. private _onPointerMove;
  36347. private _onPointerDown;
  36348. private _onPointerUp;
  36349. private _initClickEvent;
  36350. private _initActionManager;
  36351. private _delayedSimpleClick;
  36352. private _delayedSimpleClickTimeout;
  36353. private _previousDelayedSimpleClickTimeout;
  36354. private _meshPickProceed;
  36355. private _previousButtonPressed;
  36356. private _currentPickResult;
  36357. private _previousPickResult;
  36358. private _totalPointersPressed;
  36359. private _doubleClickOccured;
  36360. private _pointerOverMesh;
  36361. private _pickedDownMesh;
  36362. private _pickedUpMesh;
  36363. private _pointerX;
  36364. private _pointerY;
  36365. private _unTranslatedPointerX;
  36366. private _unTranslatedPointerY;
  36367. private _startingPointerPosition;
  36368. private _previousStartingPointerPosition;
  36369. private _startingPointerTime;
  36370. private _previousStartingPointerTime;
  36371. private _pointerCaptures;
  36372. private _onKeyDown;
  36373. private _onKeyUp;
  36374. private _onCanvasFocusObserver;
  36375. private _onCanvasBlurObserver;
  36376. private _scene;
  36377. /**
  36378. * Creates a new InputManager
  36379. * @param scene defines the hosting scene
  36380. */
  36381. constructor(scene: Scene);
  36382. /**
  36383. * Gets the mesh that is currently under the pointer
  36384. */
  36385. get meshUnderPointer(): Nullable<AbstractMesh>;
  36386. /**
  36387. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36388. */
  36389. get unTranslatedPointer(): Vector2;
  36390. /**
  36391. * Gets or sets the current on-screen X position of the pointer
  36392. */
  36393. get pointerX(): number;
  36394. set pointerX(value: number);
  36395. /**
  36396. * Gets or sets the current on-screen Y position of the pointer
  36397. */
  36398. get pointerY(): number;
  36399. set pointerY(value: number);
  36400. private _updatePointerPosition;
  36401. private _processPointerMove;
  36402. private _setRayOnPointerInfo;
  36403. private _checkPrePointerObservable;
  36404. /**
  36405. * Use this method to simulate a pointer move on a mesh
  36406. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36407. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36408. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36409. */
  36410. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36411. /**
  36412. * Use this method to simulate a pointer down on a mesh
  36413. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36414. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36415. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36416. */
  36417. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36418. private _processPointerDown;
  36419. /** @hidden */
  36420. _isPointerSwiping(): boolean;
  36421. /**
  36422. * Use this method to simulate a pointer up on a mesh
  36423. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36424. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36425. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36426. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36427. */
  36428. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36429. private _processPointerUp;
  36430. /**
  36431. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36432. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36433. * @returns true if the pointer was captured
  36434. */
  36435. isPointerCaptured(pointerId?: number): boolean;
  36436. /**
  36437. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36438. * @param attachUp defines if you want to attach events to pointerup
  36439. * @param attachDown defines if you want to attach events to pointerdown
  36440. * @param attachMove defines if you want to attach events to pointermove
  36441. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36442. */
  36443. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36444. /**
  36445. * Detaches all event handlers
  36446. */
  36447. detachControl(): void;
  36448. /**
  36449. * Force the value of meshUnderPointer
  36450. * @param mesh defines the mesh to use
  36451. */
  36452. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36453. /**
  36454. * Gets the mesh under the pointer
  36455. * @returns a Mesh or null if no mesh is under the pointer
  36456. */
  36457. getPointerOverMesh(): Nullable<AbstractMesh>;
  36458. }
  36459. }
  36460. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36461. /**
  36462. * Helper class used to generate session unique ID
  36463. */
  36464. export class UniqueIdGenerator {
  36465. private static _UniqueIdCounter;
  36466. /**
  36467. * Gets an unique (relatively to the current scene) Id
  36468. */
  36469. static get UniqueId(): number;
  36470. }
  36471. }
  36472. declare module "babylonjs/Animations/animationGroup" {
  36473. import { Animatable } from "babylonjs/Animations/animatable";
  36474. import { Animation } from "babylonjs/Animations/animation";
  36475. import { Scene, IDisposable } from "babylonjs/scene";
  36476. import { Observable } from "babylonjs/Misc/observable";
  36477. import { Nullable } from "babylonjs/types";
  36478. import "babylonjs/Animations/animatable";
  36479. /**
  36480. * This class defines the direct association between an animation and a target
  36481. */
  36482. export class TargetedAnimation {
  36483. /**
  36484. * Animation to perform
  36485. */
  36486. animation: Animation;
  36487. /**
  36488. * Target to animate
  36489. */
  36490. target: any;
  36491. /**
  36492. * Serialize the object
  36493. * @returns the JSON object representing the current entity
  36494. */
  36495. serialize(): any;
  36496. }
  36497. /**
  36498. * Use this class to create coordinated animations on multiple targets
  36499. */
  36500. export class AnimationGroup implements IDisposable {
  36501. /** The name of the animation group */
  36502. name: string;
  36503. private _scene;
  36504. private _targetedAnimations;
  36505. private _animatables;
  36506. private _from;
  36507. private _to;
  36508. private _isStarted;
  36509. private _isPaused;
  36510. private _speedRatio;
  36511. private _loopAnimation;
  36512. private _isAdditive;
  36513. /**
  36514. * Gets or sets the unique id of the node
  36515. */
  36516. uniqueId: number;
  36517. /**
  36518. * This observable will notify when one animation have ended
  36519. */
  36520. onAnimationEndObservable: Observable<TargetedAnimation>;
  36521. /**
  36522. * Observer raised when one animation loops
  36523. */
  36524. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36525. /**
  36526. * Observer raised when all animations have looped
  36527. */
  36528. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36529. /**
  36530. * This observable will notify when all animations have ended.
  36531. */
  36532. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36533. /**
  36534. * This observable will notify when all animations have paused.
  36535. */
  36536. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36537. /**
  36538. * This observable will notify when all animations are playing.
  36539. */
  36540. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36541. /**
  36542. * Gets the first frame
  36543. */
  36544. get from(): number;
  36545. /**
  36546. * Gets the last frame
  36547. */
  36548. get to(): number;
  36549. /**
  36550. * Define if the animations are started
  36551. */
  36552. get isStarted(): boolean;
  36553. /**
  36554. * Gets a value indicating that the current group is playing
  36555. */
  36556. get isPlaying(): boolean;
  36557. /**
  36558. * Gets or sets the speed ratio to use for all animations
  36559. */
  36560. get speedRatio(): number;
  36561. /**
  36562. * Gets or sets the speed ratio to use for all animations
  36563. */
  36564. set speedRatio(value: number);
  36565. /**
  36566. * Gets or sets if all animations should loop or not
  36567. */
  36568. get loopAnimation(): boolean;
  36569. set loopAnimation(value: boolean);
  36570. /**
  36571. * Gets or sets if all animations should be evaluated additively
  36572. */
  36573. get isAdditive(): boolean;
  36574. set isAdditive(value: boolean);
  36575. /**
  36576. * Gets the targeted animations for this animation group
  36577. */
  36578. get targetedAnimations(): Array<TargetedAnimation>;
  36579. /**
  36580. * returning the list of animatables controlled by this animation group.
  36581. */
  36582. get animatables(): Array<Animatable>;
  36583. /**
  36584. * Instantiates a new Animation Group.
  36585. * This helps managing several animations at once.
  36586. * @see http://doc.babylonjs.com/how_to/group
  36587. * @param name Defines the name of the group
  36588. * @param scene Defines the scene the group belongs to
  36589. */
  36590. constructor(
  36591. /** The name of the animation group */
  36592. name: string, scene?: Nullable<Scene>);
  36593. /**
  36594. * Add an animation (with its target) in the group
  36595. * @param animation defines the animation we want to add
  36596. * @param target defines the target of the animation
  36597. * @returns the TargetedAnimation object
  36598. */
  36599. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36600. /**
  36601. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36602. * It can add constant keys at begin or end
  36603. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36604. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36605. * @returns the animation group
  36606. */
  36607. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36608. private _animationLoopCount;
  36609. private _animationLoopFlags;
  36610. private _processLoop;
  36611. /**
  36612. * Start all animations on given targets
  36613. * @param loop defines if animations must loop
  36614. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36615. * @param from defines the from key (optional)
  36616. * @param to defines the to key (optional)
  36617. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36618. * @returns the current animation group
  36619. */
  36620. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36621. /**
  36622. * Pause all animations
  36623. * @returns the animation group
  36624. */
  36625. pause(): AnimationGroup;
  36626. /**
  36627. * Play all animations to initial state
  36628. * This function will start() the animations if they were not started or will restart() them if they were paused
  36629. * @param loop defines if animations must loop
  36630. * @returns the animation group
  36631. */
  36632. play(loop?: boolean): AnimationGroup;
  36633. /**
  36634. * Reset all animations to initial state
  36635. * @returns the animation group
  36636. */
  36637. reset(): AnimationGroup;
  36638. /**
  36639. * Restart animations from key 0
  36640. * @returns the animation group
  36641. */
  36642. restart(): AnimationGroup;
  36643. /**
  36644. * Stop all animations
  36645. * @returns the animation group
  36646. */
  36647. stop(): AnimationGroup;
  36648. /**
  36649. * Set animation weight for all animatables
  36650. * @param weight defines the weight to use
  36651. * @return the animationGroup
  36652. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36653. */
  36654. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36655. /**
  36656. * Synchronize and normalize all animatables with a source animatable
  36657. * @param root defines the root animatable to synchronize with
  36658. * @return the animationGroup
  36659. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36660. */
  36661. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36662. /**
  36663. * Goes to a specific frame in this animation group
  36664. * @param frame the frame number to go to
  36665. * @return the animationGroup
  36666. */
  36667. goToFrame(frame: number): AnimationGroup;
  36668. /**
  36669. * Dispose all associated resources
  36670. */
  36671. dispose(): void;
  36672. private _checkAnimationGroupEnded;
  36673. /**
  36674. * Clone the current animation group and returns a copy
  36675. * @param newName defines the name of the new group
  36676. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36677. * @returns the new aniamtion group
  36678. */
  36679. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36680. /**
  36681. * Serializes the animationGroup to an object
  36682. * @returns Serialized object
  36683. */
  36684. serialize(): any;
  36685. /**
  36686. * Returns a new AnimationGroup object parsed from the source provided.
  36687. * @param parsedAnimationGroup defines the source
  36688. * @param scene defines the scene that will receive the animationGroup
  36689. * @returns a new AnimationGroup
  36690. */
  36691. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36692. /**
  36693. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36694. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36695. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36696. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36697. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36698. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36699. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36700. */
  36701. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36702. /**
  36703. * Returns the string "AnimationGroup"
  36704. * @returns "AnimationGroup"
  36705. */
  36706. getClassName(): string;
  36707. /**
  36708. * Creates a detailled string about the object
  36709. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36710. * @returns a string representing the object
  36711. */
  36712. toString(fullDetails?: boolean): string;
  36713. }
  36714. }
  36715. declare module "babylonjs/scene" {
  36716. import { Nullable } from "babylonjs/types";
  36717. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36718. import { Observable } from "babylonjs/Misc/observable";
  36719. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36720. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36721. import { Geometry } from "babylonjs/Meshes/geometry";
  36722. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36725. import { Mesh } from "babylonjs/Meshes/mesh";
  36726. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36727. import { Bone } from "babylonjs/Bones/bone";
  36728. import { Skeleton } from "babylonjs/Bones/skeleton";
  36729. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36730. import { Camera } from "babylonjs/Cameras/camera";
  36731. import { AbstractScene } from "babylonjs/abstractScene";
  36732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36734. import { Material } from "babylonjs/Materials/material";
  36735. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36736. import { Effect } from "babylonjs/Materials/effect";
  36737. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36738. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36739. import { Light } from "babylonjs/Lights/light";
  36740. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36741. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36742. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36743. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36744. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36745. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36746. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36747. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36748. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36749. import { Engine } from "babylonjs/Engines/engine";
  36750. import { Node } from "babylonjs/node";
  36751. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36752. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36753. import { WebRequest } from "babylonjs/Misc/webRequest";
  36754. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36755. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36756. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36757. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36758. import { Plane } from "babylonjs/Maths/math.plane";
  36759. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36760. import { Ray } from "babylonjs/Culling/ray";
  36761. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36762. import { Animation } from "babylonjs/Animations/animation";
  36763. import { Animatable } from "babylonjs/Animations/animatable";
  36764. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36765. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36766. import { Collider } from "babylonjs/Collisions/collider";
  36767. /**
  36768. * Define an interface for all classes that will hold resources
  36769. */
  36770. export interface IDisposable {
  36771. /**
  36772. * Releases all held resources
  36773. */
  36774. dispose(): void;
  36775. }
  36776. /** Interface defining initialization parameters for Scene class */
  36777. export interface SceneOptions {
  36778. /**
  36779. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36780. * It will improve performance when the number of geometries becomes important.
  36781. */
  36782. useGeometryUniqueIdsMap?: boolean;
  36783. /**
  36784. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36785. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36786. */
  36787. useMaterialMeshMap?: boolean;
  36788. /**
  36789. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36790. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36791. */
  36792. useClonedMeshMap?: boolean;
  36793. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36794. virtual?: boolean;
  36795. }
  36796. /**
  36797. * Represents a scene to be rendered by the engine.
  36798. * @see http://doc.babylonjs.com/features/scene
  36799. */
  36800. export class Scene extends AbstractScene implements IAnimatable {
  36801. /** The fog is deactivated */
  36802. static readonly FOGMODE_NONE: number;
  36803. /** The fog density is following an exponential function */
  36804. static readonly FOGMODE_EXP: number;
  36805. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36806. static readonly FOGMODE_EXP2: number;
  36807. /** The fog density is following a linear function. */
  36808. static readonly FOGMODE_LINEAR: number;
  36809. /**
  36810. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36811. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36812. */
  36813. static MinDeltaTime: number;
  36814. /**
  36815. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36816. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36817. */
  36818. static MaxDeltaTime: number;
  36819. /**
  36820. * Factory used to create the default material.
  36821. * @param name The name of the material to create
  36822. * @param scene The scene to create the material for
  36823. * @returns The default material
  36824. */
  36825. static DefaultMaterialFactory(scene: Scene): Material;
  36826. /**
  36827. * Factory used to create the a collision coordinator.
  36828. * @returns The collision coordinator
  36829. */
  36830. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36831. /** @hidden */
  36832. _inputManager: InputManager;
  36833. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36834. cameraToUseForPointers: Nullable<Camera>;
  36835. /** @hidden */
  36836. readonly _isScene: boolean;
  36837. /** @hidden */
  36838. _blockEntityCollection: boolean;
  36839. /**
  36840. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36841. */
  36842. autoClear: boolean;
  36843. /**
  36844. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36845. */
  36846. autoClearDepthAndStencil: boolean;
  36847. /**
  36848. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36849. */
  36850. clearColor: Color4;
  36851. /**
  36852. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36853. */
  36854. ambientColor: Color3;
  36855. /**
  36856. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36857. * It should only be one of the following (if not the default embedded one):
  36858. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36859. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36860. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36861. * The material properties need to be setup according to the type of texture in use.
  36862. */
  36863. environmentBRDFTexture: BaseTexture;
  36864. /** @hidden */
  36865. protected _environmentTexture: Nullable<BaseTexture>;
  36866. /**
  36867. * Texture used in all pbr material as the reflection texture.
  36868. * As in the majority of the scene they are the same (exception for multi room and so on),
  36869. * this is easier to reference from here than from all the materials.
  36870. */
  36871. get environmentTexture(): Nullable<BaseTexture>;
  36872. /**
  36873. * Texture used in all pbr material as the reflection texture.
  36874. * As in the majority of the scene they are the same (exception for multi room and so on),
  36875. * this is easier to set here than in all the materials.
  36876. */
  36877. set environmentTexture(value: Nullable<BaseTexture>);
  36878. /** @hidden */
  36879. protected _environmentIntensity: number;
  36880. /**
  36881. * Intensity of the environment in all pbr material.
  36882. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36883. * As in the majority of the scene they are the same (exception for multi room and so on),
  36884. * this is easier to reference from here than from all the materials.
  36885. */
  36886. get environmentIntensity(): number;
  36887. /**
  36888. * Intensity of the environment in all pbr material.
  36889. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36890. * As in the majority of the scene they are the same (exception for multi room and so on),
  36891. * this is easier to set here than in all the materials.
  36892. */
  36893. set environmentIntensity(value: number);
  36894. /** @hidden */
  36895. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36896. /**
  36897. * Default image processing configuration used either in the rendering
  36898. * Forward main pass or through the imageProcessingPostProcess if present.
  36899. * As in the majority of the scene they are the same (exception for multi camera),
  36900. * this is easier to reference from here than from all the materials and post process.
  36901. *
  36902. * No setter as we it is a shared configuration, you can set the values instead.
  36903. */
  36904. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36905. private _forceWireframe;
  36906. /**
  36907. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36908. */
  36909. set forceWireframe(value: boolean);
  36910. get forceWireframe(): boolean;
  36911. private _skipFrustumClipping;
  36912. /**
  36913. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36914. */
  36915. set skipFrustumClipping(value: boolean);
  36916. get skipFrustumClipping(): boolean;
  36917. private _forcePointsCloud;
  36918. /**
  36919. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36920. */
  36921. set forcePointsCloud(value: boolean);
  36922. get forcePointsCloud(): boolean;
  36923. /**
  36924. * Gets or sets the active clipplane 1
  36925. */
  36926. clipPlane: Nullable<Plane>;
  36927. /**
  36928. * Gets or sets the active clipplane 2
  36929. */
  36930. clipPlane2: Nullable<Plane>;
  36931. /**
  36932. * Gets or sets the active clipplane 3
  36933. */
  36934. clipPlane3: Nullable<Plane>;
  36935. /**
  36936. * Gets or sets the active clipplane 4
  36937. */
  36938. clipPlane4: Nullable<Plane>;
  36939. /**
  36940. * Gets or sets the active clipplane 5
  36941. */
  36942. clipPlane5: Nullable<Plane>;
  36943. /**
  36944. * Gets or sets the active clipplane 6
  36945. */
  36946. clipPlane6: Nullable<Plane>;
  36947. /**
  36948. * Gets or sets a boolean indicating if animations are enabled
  36949. */
  36950. animationsEnabled: boolean;
  36951. private _animationPropertiesOverride;
  36952. /**
  36953. * Gets or sets the animation properties override
  36954. */
  36955. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36956. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36957. /**
  36958. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36959. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36960. */
  36961. useConstantAnimationDeltaTime: boolean;
  36962. /**
  36963. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36964. * Please note that it requires to run a ray cast through the scene on every frame
  36965. */
  36966. constantlyUpdateMeshUnderPointer: boolean;
  36967. /**
  36968. * Defines the HTML cursor to use when hovering over interactive elements
  36969. */
  36970. hoverCursor: string;
  36971. /**
  36972. * Defines the HTML default cursor to use (empty by default)
  36973. */
  36974. defaultCursor: string;
  36975. /**
  36976. * Defines whether cursors are handled by the scene.
  36977. */
  36978. doNotHandleCursors: boolean;
  36979. /**
  36980. * This is used to call preventDefault() on pointer down
  36981. * in order to block unwanted artifacts like system double clicks
  36982. */
  36983. preventDefaultOnPointerDown: boolean;
  36984. /**
  36985. * This is used to call preventDefault() on pointer up
  36986. * in order to block unwanted artifacts like system double clicks
  36987. */
  36988. preventDefaultOnPointerUp: boolean;
  36989. /**
  36990. * Gets or sets user defined metadata
  36991. */
  36992. metadata: any;
  36993. /**
  36994. * For internal use only. Please do not use.
  36995. */
  36996. reservedDataStore: any;
  36997. /**
  36998. * Gets the name of the plugin used to load this scene (null by default)
  36999. */
  37000. loadingPluginName: string;
  37001. /**
  37002. * Use this array to add regular expressions used to disable offline support for specific urls
  37003. */
  37004. disableOfflineSupportExceptionRules: RegExp[];
  37005. /**
  37006. * An event triggered when the scene is disposed.
  37007. */
  37008. onDisposeObservable: Observable<Scene>;
  37009. private _onDisposeObserver;
  37010. /** Sets a function to be executed when this scene is disposed. */
  37011. set onDispose(callback: () => void);
  37012. /**
  37013. * An event triggered before rendering the scene (right after animations and physics)
  37014. */
  37015. onBeforeRenderObservable: Observable<Scene>;
  37016. private _onBeforeRenderObserver;
  37017. /** Sets a function to be executed before rendering this scene */
  37018. set beforeRender(callback: Nullable<() => void>);
  37019. /**
  37020. * An event triggered after rendering the scene
  37021. */
  37022. onAfterRenderObservable: Observable<Scene>;
  37023. /**
  37024. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  37025. */
  37026. onAfterRenderCameraObservable: Observable<Camera>;
  37027. private _onAfterRenderObserver;
  37028. /** Sets a function to be executed after rendering this scene */
  37029. set afterRender(callback: Nullable<() => void>);
  37030. /**
  37031. * An event triggered before animating the scene
  37032. */
  37033. onBeforeAnimationsObservable: Observable<Scene>;
  37034. /**
  37035. * An event triggered after animations processing
  37036. */
  37037. onAfterAnimationsObservable: Observable<Scene>;
  37038. /**
  37039. * An event triggered before draw calls are ready to be sent
  37040. */
  37041. onBeforeDrawPhaseObservable: Observable<Scene>;
  37042. /**
  37043. * An event triggered after draw calls have been sent
  37044. */
  37045. onAfterDrawPhaseObservable: Observable<Scene>;
  37046. /**
  37047. * An event triggered when the scene is ready
  37048. */
  37049. onReadyObservable: Observable<Scene>;
  37050. /**
  37051. * An event triggered before rendering a camera
  37052. */
  37053. onBeforeCameraRenderObservable: Observable<Camera>;
  37054. private _onBeforeCameraRenderObserver;
  37055. /** Sets a function to be executed before rendering a camera*/
  37056. set beforeCameraRender(callback: () => void);
  37057. /**
  37058. * An event triggered after rendering a camera
  37059. */
  37060. onAfterCameraRenderObservable: Observable<Camera>;
  37061. private _onAfterCameraRenderObserver;
  37062. /** Sets a function to be executed after rendering a camera*/
  37063. set afterCameraRender(callback: () => void);
  37064. /**
  37065. * An event triggered when active meshes evaluation is about to start
  37066. */
  37067. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  37068. /**
  37069. * An event triggered when active meshes evaluation is done
  37070. */
  37071. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  37072. /**
  37073. * An event triggered when particles rendering is about to start
  37074. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37075. */
  37076. onBeforeParticlesRenderingObservable: Observable<Scene>;
  37077. /**
  37078. * An event triggered when particles rendering is done
  37079. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37080. */
  37081. onAfterParticlesRenderingObservable: Observable<Scene>;
  37082. /**
  37083. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  37084. */
  37085. onDataLoadedObservable: Observable<Scene>;
  37086. /**
  37087. * An event triggered when a camera is created
  37088. */
  37089. onNewCameraAddedObservable: Observable<Camera>;
  37090. /**
  37091. * An event triggered when a camera is removed
  37092. */
  37093. onCameraRemovedObservable: Observable<Camera>;
  37094. /**
  37095. * An event triggered when a light is created
  37096. */
  37097. onNewLightAddedObservable: Observable<Light>;
  37098. /**
  37099. * An event triggered when a light is removed
  37100. */
  37101. onLightRemovedObservable: Observable<Light>;
  37102. /**
  37103. * An event triggered when a geometry is created
  37104. */
  37105. onNewGeometryAddedObservable: Observable<Geometry>;
  37106. /**
  37107. * An event triggered when a geometry is removed
  37108. */
  37109. onGeometryRemovedObservable: Observable<Geometry>;
  37110. /**
  37111. * An event triggered when a transform node is created
  37112. */
  37113. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  37114. /**
  37115. * An event triggered when a transform node is removed
  37116. */
  37117. onTransformNodeRemovedObservable: Observable<TransformNode>;
  37118. /**
  37119. * An event triggered when a mesh is created
  37120. */
  37121. onNewMeshAddedObservable: Observable<AbstractMesh>;
  37122. /**
  37123. * An event triggered when a mesh is removed
  37124. */
  37125. onMeshRemovedObservable: Observable<AbstractMesh>;
  37126. /**
  37127. * An event triggered when a skeleton is created
  37128. */
  37129. onNewSkeletonAddedObservable: Observable<Skeleton>;
  37130. /**
  37131. * An event triggered when a skeleton is removed
  37132. */
  37133. onSkeletonRemovedObservable: Observable<Skeleton>;
  37134. /**
  37135. * An event triggered when a material is created
  37136. */
  37137. onNewMaterialAddedObservable: Observable<Material>;
  37138. /**
  37139. * An event triggered when a material is removed
  37140. */
  37141. onMaterialRemovedObservable: Observable<Material>;
  37142. /**
  37143. * An event triggered when a texture is created
  37144. */
  37145. onNewTextureAddedObservable: Observable<BaseTexture>;
  37146. /**
  37147. * An event triggered when a texture is removed
  37148. */
  37149. onTextureRemovedObservable: Observable<BaseTexture>;
  37150. /**
  37151. * An event triggered when render targets are about to be rendered
  37152. * Can happen multiple times per frame.
  37153. */
  37154. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  37155. /**
  37156. * An event triggered when render targets were rendered.
  37157. * Can happen multiple times per frame.
  37158. */
  37159. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  37160. /**
  37161. * An event triggered before calculating deterministic simulation step
  37162. */
  37163. onBeforeStepObservable: Observable<Scene>;
  37164. /**
  37165. * An event triggered after calculating deterministic simulation step
  37166. */
  37167. onAfterStepObservable: Observable<Scene>;
  37168. /**
  37169. * An event triggered when the activeCamera property is updated
  37170. */
  37171. onActiveCameraChanged: Observable<Scene>;
  37172. /**
  37173. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  37174. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37175. * 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)
  37176. */
  37177. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37178. /**
  37179. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  37180. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37181. * 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)
  37182. */
  37183. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37184. /**
  37185. * This Observable will when a mesh has been imported into the scene.
  37186. */
  37187. onMeshImportedObservable: Observable<AbstractMesh>;
  37188. /**
  37189. * This Observable will when an animation file has been imported into the scene.
  37190. */
  37191. onAnimationFileImportedObservable: Observable<Scene>;
  37192. /**
  37193. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  37194. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  37195. */
  37196. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  37197. /** @hidden */
  37198. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  37199. /**
  37200. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  37201. */
  37202. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  37203. /**
  37204. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  37205. */
  37206. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  37207. /**
  37208. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  37209. */
  37210. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  37211. /** Callback called when a pointer move is detected */
  37212. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37213. /** Callback called when a pointer down is detected */
  37214. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37215. /** Callback called when a pointer up is detected */
  37216. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  37217. /** Callback called when a pointer pick is detected */
  37218. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  37219. /**
  37220. * 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).
  37221. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  37222. */
  37223. onPrePointerObservable: Observable<PointerInfoPre>;
  37224. /**
  37225. * Observable event triggered each time an input event is received from the rendering canvas
  37226. */
  37227. onPointerObservable: Observable<PointerInfo>;
  37228. /**
  37229. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  37230. */
  37231. get unTranslatedPointer(): Vector2;
  37232. /**
  37233. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  37234. */
  37235. static get DragMovementThreshold(): number;
  37236. static set DragMovementThreshold(value: number);
  37237. /**
  37238. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  37239. */
  37240. static get LongPressDelay(): number;
  37241. static set LongPressDelay(value: number);
  37242. /**
  37243. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  37244. */
  37245. static get DoubleClickDelay(): number;
  37246. static set DoubleClickDelay(value: number);
  37247. /** If you need to check double click without raising a single click at first click, enable this flag */
  37248. static get ExclusiveDoubleClickMode(): boolean;
  37249. static set ExclusiveDoubleClickMode(value: boolean);
  37250. /** @hidden */
  37251. _mirroredCameraPosition: Nullable<Vector3>;
  37252. /**
  37253. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  37254. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  37255. */
  37256. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  37257. /**
  37258. * Observable event triggered each time an keyboard event is received from the hosting window
  37259. */
  37260. onKeyboardObservable: Observable<KeyboardInfo>;
  37261. private _useRightHandedSystem;
  37262. /**
  37263. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37264. */
  37265. set useRightHandedSystem(value: boolean);
  37266. get useRightHandedSystem(): boolean;
  37267. private _timeAccumulator;
  37268. private _currentStepId;
  37269. private _currentInternalStep;
  37270. /**
  37271. * Sets the step Id used by deterministic lock step
  37272. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37273. * @param newStepId defines the step Id
  37274. */
  37275. setStepId(newStepId: number): void;
  37276. /**
  37277. * Gets the step Id used by deterministic lock step
  37278. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37279. * @returns the step Id
  37280. */
  37281. getStepId(): number;
  37282. /**
  37283. * Gets the internal step used by deterministic lock step
  37284. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37285. * @returns the internal step
  37286. */
  37287. getInternalStep(): number;
  37288. private _fogEnabled;
  37289. /**
  37290. * Gets or sets a boolean indicating if fog is enabled on this scene
  37291. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37292. * (Default is true)
  37293. */
  37294. set fogEnabled(value: boolean);
  37295. get fogEnabled(): boolean;
  37296. private _fogMode;
  37297. /**
  37298. * Gets or sets the fog mode to use
  37299. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37300. * | mode | value |
  37301. * | --- | --- |
  37302. * | FOGMODE_NONE | 0 |
  37303. * | FOGMODE_EXP | 1 |
  37304. * | FOGMODE_EXP2 | 2 |
  37305. * | FOGMODE_LINEAR | 3 |
  37306. */
  37307. set fogMode(value: number);
  37308. get fogMode(): number;
  37309. /**
  37310. * Gets or sets the fog color to use
  37311. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37312. * (Default is Color3(0.2, 0.2, 0.3))
  37313. */
  37314. fogColor: Color3;
  37315. /**
  37316. * Gets or sets the fog density to use
  37317. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37318. * (Default is 0.1)
  37319. */
  37320. fogDensity: number;
  37321. /**
  37322. * Gets or sets the fog start distance to use
  37323. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37324. * (Default is 0)
  37325. */
  37326. fogStart: number;
  37327. /**
  37328. * Gets or sets the fog end distance to use
  37329. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37330. * (Default is 1000)
  37331. */
  37332. fogEnd: number;
  37333. private _shadowsEnabled;
  37334. /**
  37335. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37336. */
  37337. set shadowsEnabled(value: boolean);
  37338. get shadowsEnabled(): boolean;
  37339. private _lightsEnabled;
  37340. /**
  37341. * Gets or sets a boolean indicating if lights are enabled on this scene
  37342. */
  37343. set lightsEnabled(value: boolean);
  37344. get lightsEnabled(): boolean;
  37345. /** All of the active cameras added to this scene. */
  37346. activeCameras: Camera[];
  37347. /** @hidden */
  37348. _activeCamera: Nullable<Camera>;
  37349. /** Gets or sets the current active camera */
  37350. get activeCamera(): Nullable<Camera>;
  37351. set activeCamera(value: Nullable<Camera>);
  37352. private _defaultMaterial;
  37353. /** The default material used on meshes when no material is affected */
  37354. get defaultMaterial(): Material;
  37355. /** The default material used on meshes when no material is affected */
  37356. set defaultMaterial(value: Material);
  37357. private _texturesEnabled;
  37358. /**
  37359. * Gets or sets a boolean indicating if textures are enabled on this scene
  37360. */
  37361. set texturesEnabled(value: boolean);
  37362. get texturesEnabled(): boolean;
  37363. /**
  37364. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  37365. */
  37366. physicsEnabled: boolean;
  37367. /**
  37368. * Gets or sets a boolean indicating if particles are enabled on this scene
  37369. */
  37370. particlesEnabled: boolean;
  37371. /**
  37372. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37373. */
  37374. spritesEnabled: boolean;
  37375. private _skeletonsEnabled;
  37376. /**
  37377. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37378. */
  37379. set skeletonsEnabled(value: boolean);
  37380. get skeletonsEnabled(): boolean;
  37381. /**
  37382. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37383. */
  37384. lensFlaresEnabled: boolean;
  37385. /**
  37386. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37387. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37388. */
  37389. collisionsEnabled: boolean;
  37390. private _collisionCoordinator;
  37391. /** @hidden */
  37392. get collisionCoordinator(): ICollisionCoordinator;
  37393. /**
  37394. * Defines the gravity applied to this scene (used only for collisions)
  37395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37396. */
  37397. gravity: Vector3;
  37398. /**
  37399. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37400. */
  37401. postProcessesEnabled: boolean;
  37402. /**
  37403. * The list of postprocesses added to the scene
  37404. */
  37405. postProcesses: PostProcess[];
  37406. /**
  37407. * Gets the current postprocess manager
  37408. */
  37409. postProcessManager: PostProcessManager;
  37410. /**
  37411. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37412. */
  37413. renderTargetsEnabled: boolean;
  37414. /**
  37415. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37416. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37417. */
  37418. dumpNextRenderTargets: boolean;
  37419. /**
  37420. * The list of user defined render targets added to the scene
  37421. */
  37422. customRenderTargets: RenderTargetTexture[];
  37423. /**
  37424. * Defines if texture loading must be delayed
  37425. * If true, textures will only be loaded when they need to be rendered
  37426. */
  37427. useDelayedTextureLoading: boolean;
  37428. /**
  37429. * Gets the list of meshes imported to the scene through SceneLoader
  37430. */
  37431. importedMeshesFiles: String[];
  37432. /**
  37433. * Gets or sets a boolean indicating if probes are enabled on this scene
  37434. */
  37435. probesEnabled: boolean;
  37436. /**
  37437. * Gets or sets the current offline provider to use to store scene data
  37438. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37439. */
  37440. offlineProvider: IOfflineProvider;
  37441. /**
  37442. * Gets or sets the action manager associated with the scene
  37443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37444. */
  37445. actionManager: AbstractActionManager;
  37446. private _meshesForIntersections;
  37447. /**
  37448. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37449. */
  37450. proceduralTexturesEnabled: boolean;
  37451. private _engine;
  37452. private _totalVertices;
  37453. /** @hidden */
  37454. _activeIndices: PerfCounter;
  37455. /** @hidden */
  37456. _activeParticles: PerfCounter;
  37457. /** @hidden */
  37458. _activeBones: PerfCounter;
  37459. private _animationRatio;
  37460. /** @hidden */
  37461. _animationTimeLast: number;
  37462. /** @hidden */
  37463. _animationTime: number;
  37464. /**
  37465. * Gets or sets a general scale for animation speed
  37466. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37467. */
  37468. animationTimeScale: number;
  37469. /** @hidden */
  37470. _cachedMaterial: Nullable<Material>;
  37471. /** @hidden */
  37472. _cachedEffect: Nullable<Effect>;
  37473. /** @hidden */
  37474. _cachedVisibility: Nullable<number>;
  37475. private _renderId;
  37476. private _frameId;
  37477. private _executeWhenReadyTimeoutId;
  37478. private _intermediateRendering;
  37479. private _viewUpdateFlag;
  37480. private _projectionUpdateFlag;
  37481. /** @hidden */
  37482. _toBeDisposed: Nullable<IDisposable>[];
  37483. private _activeRequests;
  37484. /** @hidden */
  37485. _pendingData: any[];
  37486. private _isDisposed;
  37487. /**
  37488. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37489. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37490. */
  37491. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37492. private _activeMeshes;
  37493. private _processedMaterials;
  37494. private _renderTargets;
  37495. /** @hidden */
  37496. _activeParticleSystems: SmartArray<IParticleSystem>;
  37497. private _activeSkeletons;
  37498. private _softwareSkinnedMeshes;
  37499. private _renderingManager;
  37500. /** @hidden */
  37501. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37502. private _transformMatrix;
  37503. private _sceneUbo;
  37504. /** @hidden */
  37505. _viewMatrix: Matrix;
  37506. private _projectionMatrix;
  37507. /** @hidden */
  37508. _forcedViewPosition: Nullable<Vector3>;
  37509. /** @hidden */
  37510. _frustumPlanes: Plane[];
  37511. /**
  37512. * Gets the list of frustum planes (built from the active camera)
  37513. */
  37514. get frustumPlanes(): Plane[];
  37515. /**
  37516. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37517. * This is useful if there are more lights that the maximum simulteanous authorized
  37518. */
  37519. requireLightSorting: boolean;
  37520. /** @hidden */
  37521. readonly useMaterialMeshMap: boolean;
  37522. /** @hidden */
  37523. readonly useClonedMeshMap: boolean;
  37524. private _externalData;
  37525. private _uid;
  37526. /**
  37527. * @hidden
  37528. * Backing store of defined scene components.
  37529. */
  37530. _components: ISceneComponent[];
  37531. /**
  37532. * @hidden
  37533. * Backing store of defined scene components.
  37534. */
  37535. _serializableComponents: ISceneSerializableComponent[];
  37536. /**
  37537. * List of components to register on the next registration step.
  37538. */
  37539. private _transientComponents;
  37540. /**
  37541. * Registers the transient components if needed.
  37542. */
  37543. private _registerTransientComponents;
  37544. /**
  37545. * @hidden
  37546. * Add a component to the scene.
  37547. * Note that the ccomponent could be registered on th next frame if this is called after
  37548. * the register component stage.
  37549. * @param component Defines the component to add to the scene
  37550. */
  37551. _addComponent(component: ISceneComponent): void;
  37552. /**
  37553. * @hidden
  37554. * Gets a component from the scene.
  37555. * @param name defines the name of the component to retrieve
  37556. * @returns the component or null if not present
  37557. */
  37558. _getComponent(name: string): Nullable<ISceneComponent>;
  37559. /**
  37560. * @hidden
  37561. * Defines the actions happening before camera updates.
  37562. */
  37563. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37564. /**
  37565. * @hidden
  37566. * Defines the actions happening before clear the canvas.
  37567. */
  37568. _beforeClearStage: Stage<SimpleStageAction>;
  37569. /**
  37570. * @hidden
  37571. * Defines the actions when collecting render targets for the frame.
  37572. */
  37573. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37574. /**
  37575. * @hidden
  37576. * Defines the actions happening for one camera in the frame.
  37577. */
  37578. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37579. /**
  37580. * @hidden
  37581. * Defines the actions happening during the per mesh ready checks.
  37582. */
  37583. _isReadyForMeshStage: Stage<MeshStageAction>;
  37584. /**
  37585. * @hidden
  37586. * Defines the actions happening before evaluate active mesh checks.
  37587. */
  37588. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37589. /**
  37590. * @hidden
  37591. * Defines the actions happening during the evaluate sub mesh checks.
  37592. */
  37593. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37594. /**
  37595. * @hidden
  37596. * Defines the actions happening during the active mesh stage.
  37597. */
  37598. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37599. /**
  37600. * @hidden
  37601. * Defines the actions happening during the per camera render target step.
  37602. */
  37603. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37604. /**
  37605. * @hidden
  37606. * Defines the actions happening just before the active camera is drawing.
  37607. */
  37608. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37609. /**
  37610. * @hidden
  37611. * Defines the actions happening just before a render target is drawing.
  37612. */
  37613. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37614. /**
  37615. * @hidden
  37616. * Defines the actions happening just before a rendering group is drawing.
  37617. */
  37618. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37619. /**
  37620. * @hidden
  37621. * Defines the actions happening just before a mesh is drawing.
  37622. */
  37623. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37624. /**
  37625. * @hidden
  37626. * Defines the actions happening just after a mesh has been drawn.
  37627. */
  37628. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37629. /**
  37630. * @hidden
  37631. * Defines the actions happening just after a rendering group has been drawn.
  37632. */
  37633. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37634. /**
  37635. * @hidden
  37636. * Defines the actions happening just after the active camera has been drawn.
  37637. */
  37638. _afterCameraDrawStage: Stage<CameraStageAction>;
  37639. /**
  37640. * @hidden
  37641. * Defines the actions happening just after a render target has been drawn.
  37642. */
  37643. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37644. /**
  37645. * @hidden
  37646. * Defines the actions happening just after rendering all cameras and computing intersections.
  37647. */
  37648. _afterRenderStage: Stage<SimpleStageAction>;
  37649. /**
  37650. * @hidden
  37651. * Defines the actions happening when a pointer move event happens.
  37652. */
  37653. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37654. /**
  37655. * @hidden
  37656. * Defines the actions happening when a pointer down event happens.
  37657. */
  37658. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37659. /**
  37660. * @hidden
  37661. * Defines the actions happening when a pointer up event happens.
  37662. */
  37663. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37664. /**
  37665. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37666. */
  37667. private geometriesByUniqueId;
  37668. /**
  37669. * Creates a new Scene
  37670. * @param engine defines the engine to use to render this scene
  37671. * @param options defines the scene options
  37672. */
  37673. constructor(engine: Engine, options?: SceneOptions);
  37674. /**
  37675. * Gets a string idenfifying the name of the class
  37676. * @returns "Scene" string
  37677. */
  37678. getClassName(): string;
  37679. private _defaultMeshCandidates;
  37680. /**
  37681. * @hidden
  37682. */
  37683. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37684. private _defaultSubMeshCandidates;
  37685. /**
  37686. * @hidden
  37687. */
  37688. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37689. /**
  37690. * Sets the default candidate providers for the scene.
  37691. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37692. * and getCollidingSubMeshCandidates to their default function
  37693. */
  37694. setDefaultCandidateProviders(): void;
  37695. /**
  37696. * Gets the mesh that is currently under the pointer
  37697. */
  37698. get meshUnderPointer(): Nullable<AbstractMesh>;
  37699. /**
  37700. * Gets or sets the current on-screen X position of the pointer
  37701. */
  37702. get pointerX(): number;
  37703. set pointerX(value: number);
  37704. /**
  37705. * Gets or sets the current on-screen Y position of the pointer
  37706. */
  37707. get pointerY(): number;
  37708. set pointerY(value: number);
  37709. /**
  37710. * Gets the cached material (ie. the latest rendered one)
  37711. * @returns the cached material
  37712. */
  37713. getCachedMaterial(): Nullable<Material>;
  37714. /**
  37715. * Gets the cached effect (ie. the latest rendered one)
  37716. * @returns the cached effect
  37717. */
  37718. getCachedEffect(): Nullable<Effect>;
  37719. /**
  37720. * Gets the cached visibility state (ie. the latest rendered one)
  37721. * @returns the cached visibility state
  37722. */
  37723. getCachedVisibility(): Nullable<number>;
  37724. /**
  37725. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37726. * @param material defines the current material
  37727. * @param effect defines the current effect
  37728. * @param visibility defines the current visibility state
  37729. * @returns true if one parameter is not cached
  37730. */
  37731. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37732. /**
  37733. * Gets the engine associated with the scene
  37734. * @returns an Engine
  37735. */
  37736. getEngine(): Engine;
  37737. /**
  37738. * Gets the total number of vertices rendered per frame
  37739. * @returns the total number of vertices rendered per frame
  37740. */
  37741. getTotalVertices(): number;
  37742. /**
  37743. * Gets the performance counter for total vertices
  37744. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37745. */
  37746. get totalVerticesPerfCounter(): PerfCounter;
  37747. /**
  37748. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37749. * @returns the total number of active indices rendered per frame
  37750. */
  37751. getActiveIndices(): number;
  37752. /**
  37753. * Gets the performance counter for active indices
  37754. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37755. */
  37756. get totalActiveIndicesPerfCounter(): PerfCounter;
  37757. /**
  37758. * Gets the total number of active particles rendered per frame
  37759. * @returns the total number of active particles rendered per frame
  37760. */
  37761. getActiveParticles(): number;
  37762. /**
  37763. * Gets the performance counter for active particles
  37764. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37765. */
  37766. get activeParticlesPerfCounter(): PerfCounter;
  37767. /**
  37768. * Gets the total number of active bones rendered per frame
  37769. * @returns the total number of active bones rendered per frame
  37770. */
  37771. getActiveBones(): number;
  37772. /**
  37773. * Gets the performance counter for active bones
  37774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37775. */
  37776. get activeBonesPerfCounter(): PerfCounter;
  37777. /**
  37778. * Gets the array of active meshes
  37779. * @returns an array of AbstractMesh
  37780. */
  37781. getActiveMeshes(): SmartArray<AbstractMesh>;
  37782. /**
  37783. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37784. * @returns a number
  37785. */
  37786. getAnimationRatio(): number;
  37787. /**
  37788. * Gets an unique Id for the current render phase
  37789. * @returns a number
  37790. */
  37791. getRenderId(): number;
  37792. /**
  37793. * Gets an unique Id for the current frame
  37794. * @returns a number
  37795. */
  37796. getFrameId(): number;
  37797. /** Call this function if you want to manually increment the render Id*/
  37798. incrementRenderId(): void;
  37799. private _createUbo;
  37800. /**
  37801. * Use this method to simulate a pointer move on a mesh
  37802. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37803. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37804. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37805. * @returns the current scene
  37806. */
  37807. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37808. /**
  37809. * Use this method to simulate a pointer down on a mesh
  37810. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37811. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37812. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37813. * @returns the current scene
  37814. */
  37815. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37816. /**
  37817. * Use this method to simulate a pointer up on a mesh
  37818. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37819. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37820. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37821. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37822. * @returns the current scene
  37823. */
  37824. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37825. /**
  37826. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37827. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37828. * @returns true if the pointer was captured
  37829. */
  37830. isPointerCaptured(pointerId?: number): boolean;
  37831. /**
  37832. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37833. * @param attachUp defines if you want to attach events to pointerup
  37834. * @param attachDown defines if you want to attach events to pointerdown
  37835. * @param attachMove defines if you want to attach events to pointermove
  37836. */
  37837. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37838. /** Detaches all event handlers*/
  37839. detachControl(): void;
  37840. /**
  37841. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37842. * Delay loaded resources are not taking in account
  37843. * @return true if all required resources are ready
  37844. */
  37845. isReady(): boolean;
  37846. /** Resets all cached information relative to material (including effect and visibility) */
  37847. resetCachedMaterial(): void;
  37848. /**
  37849. * Registers a function to be called before every frame render
  37850. * @param func defines the function to register
  37851. */
  37852. registerBeforeRender(func: () => void): void;
  37853. /**
  37854. * Unregisters a function called before every frame render
  37855. * @param func defines the function to unregister
  37856. */
  37857. unregisterBeforeRender(func: () => void): void;
  37858. /**
  37859. * Registers a function to be called after every frame render
  37860. * @param func defines the function to register
  37861. */
  37862. registerAfterRender(func: () => void): void;
  37863. /**
  37864. * Unregisters a function called after every frame render
  37865. * @param func defines the function to unregister
  37866. */
  37867. unregisterAfterRender(func: () => void): void;
  37868. private _executeOnceBeforeRender;
  37869. /**
  37870. * The provided function will run before render once and will be disposed afterwards.
  37871. * A timeout delay can be provided so that the function will be executed in N ms.
  37872. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37873. * @param func The function to be executed.
  37874. * @param timeout optional delay in ms
  37875. */
  37876. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37877. /** @hidden */
  37878. _addPendingData(data: any): void;
  37879. /** @hidden */
  37880. _removePendingData(data: any): void;
  37881. /**
  37882. * Returns the number of items waiting to be loaded
  37883. * @returns the number of items waiting to be loaded
  37884. */
  37885. getWaitingItemsCount(): number;
  37886. /**
  37887. * Returns a boolean indicating if the scene is still loading data
  37888. */
  37889. get isLoading(): boolean;
  37890. /**
  37891. * Registers a function to be executed when the scene is ready
  37892. * @param {Function} func - the function to be executed
  37893. */
  37894. executeWhenReady(func: () => void): void;
  37895. /**
  37896. * Returns a promise that resolves when the scene is ready
  37897. * @returns A promise that resolves when the scene is ready
  37898. */
  37899. whenReadyAsync(): Promise<void>;
  37900. /** @hidden */
  37901. _checkIsReady(): void;
  37902. /**
  37903. * Gets all animatable attached to the scene
  37904. */
  37905. get animatables(): Animatable[];
  37906. /**
  37907. * Resets the last animation time frame.
  37908. * Useful to override when animations start running when loading a scene for the first time.
  37909. */
  37910. resetLastAnimationTimeFrame(): void;
  37911. /**
  37912. * Gets the current view matrix
  37913. * @returns a Matrix
  37914. */
  37915. getViewMatrix(): Matrix;
  37916. /**
  37917. * Gets the current projection matrix
  37918. * @returns a Matrix
  37919. */
  37920. getProjectionMatrix(): Matrix;
  37921. /**
  37922. * Gets the current transform matrix
  37923. * @returns a Matrix made of View * Projection
  37924. */
  37925. getTransformMatrix(): Matrix;
  37926. /**
  37927. * Sets the current transform matrix
  37928. * @param viewL defines the View matrix to use
  37929. * @param projectionL defines the Projection matrix to use
  37930. * @param viewR defines the right View matrix to use (if provided)
  37931. * @param projectionR defines the right Projection matrix to use (if provided)
  37932. */
  37933. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37934. /**
  37935. * Gets the uniform buffer used to store scene data
  37936. * @returns a UniformBuffer
  37937. */
  37938. getSceneUniformBuffer(): UniformBuffer;
  37939. /**
  37940. * Gets an unique (relatively to the current scene) Id
  37941. * @returns an unique number for the scene
  37942. */
  37943. getUniqueId(): number;
  37944. /**
  37945. * Add a mesh to the list of scene's meshes
  37946. * @param newMesh defines the mesh to add
  37947. * @param recursive if all child meshes should also be added to the scene
  37948. */
  37949. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37950. /**
  37951. * Remove a mesh for the list of scene's meshes
  37952. * @param toRemove defines the mesh to remove
  37953. * @param recursive if all child meshes should also be removed from the scene
  37954. * @returns the index where the mesh was in the mesh list
  37955. */
  37956. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37957. /**
  37958. * Add a transform node to the list of scene's transform nodes
  37959. * @param newTransformNode defines the transform node to add
  37960. */
  37961. addTransformNode(newTransformNode: TransformNode): void;
  37962. /**
  37963. * Remove a transform node for the list of scene's transform nodes
  37964. * @param toRemove defines the transform node to remove
  37965. * @returns the index where the transform node was in the transform node list
  37966. */
  37967. removeTransformNode(toRemove: TransformNode): number;
  37968. /**
  37969. * Remove a skeleton for the list of scene's skeletons
  37970. * @param toRemove defines the skeleton to remove
  37971. * @returns the index where the skeleton was in the skeleton list
  37972. */
  37973. removeSkeleton(toRemove: Skeleton): number;
  37974. /**
  37975. * Remove a morph target for the list of scene's morph targets
  37976. * @param toRemove defines the morph target to remove
  37977. * @returns the index where the morph target was in the morph target list
  37978. */
  37979. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37980. /**
  37981. * Remove a light for the list of scene's lights
  37982. * @param toRemove defines the light to remove
  37983. * @returns the index where the light was in the light list
  37984. */
  37985. removeLight(toRemove: Light): number;
  37986. /**
  37987. * Remove a camera for the list of scene's cameras
  37988. * @param toRemove defines the camera to remove
  37989. * @returns the index where the camera was in the camera list
  37990. */
  37991. removeCamera(toRemove: Camera): number;
  37992. /**
  37993. * Remove a particle system for the list of scene's particle systems
  37994. * @param toRemove defines the particle system to remove
  37995. * @returns the index where the particle system was in the particle system list
  37996. */
  37997. removeParticleSystem(toRemove: IParticleSystem): number;
  37998. /**
  37999. * Remove a animation for the list of scene's animations
  38000. * @param toRemove defines the animation to remove
  38001. * @returns the index where the animation was in the animation list
  38002. */
  38003. removeAnimation(toRemove: Animation): number;
  38004. /**
  38005. * Will stop the animation of the given target
  38006. * @param target - the target
  38007. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  38008. * @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)
  38009. */
  38010. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  38011. /**
  38012. * Removes the given animation group from this scene.
  38013. * @param toRemove The animation group to remove
  38014. * @returns The index of the removed animation group
  38015. */
  38016. removeAnimationGroup(toRemove: AnimationGroup): number;
  38017. /**
  38018. * Removes the given multi-material from this scene.
  38019. * @param toRemove The multi-material to remove
  38020. * @returns The index of the removed multi-material
  38021. */
  38022. removeMultiMaterial(toRemove: MultiMaterial): number;
  38023. /**
  38024. * Removes the given material from this scene.
  38025. * @param toRemove The material to remove
  38026. * @returns The index of the removed material
  38027. */
  38028. removeMaterial(toRemove: Material): number;
  38029. /**
  38030. * Removes the given action manager from this scene.
  38031. * @param toRemove The action manager to remove
  38032. * @returns The index of the removed action manager
  38033. */
  38034. removeActionManager(toRemove: AbstractActionManager): number;
  38035. /**
  38036. * Removes the given texture from this scene.
  38037. * @param toRemove The texture to remove
  38038. * @returns The index of the removed texture
  38039. */
  38040. removeTexture(toRemove: BaseTexture): number;
  38041. /**
  38042. * Adds the given light to this scene
  38043. * @param newLight The light to add
  38044. */
  38045. addLight(newLight: Light): void;
  38046. /**
  38047. * Sorts the list list based on light priorities
  38048. */
  38049. sortLightsByPriority(): void;
  38050. /**
  38051. * Adds the given camera to this scene
  38052. * @param newCamera The camera to add
  38053. */
  38054. addCamera(newCamera: Camera): void;
  38055. /**
  38056. * Adds the given skeleton to this scene
  38057. * @param newSkeleton The skeleton to add
  38058. */
  38059. addSkeleton(newSkeleton: Skeleton): void;
  38060. /**
  38061. * Adds the given particle system to this scene
  38062. * @param newParticleSystem The particle system to add
  38063. */
  38064. addParticleSystem(newParticleSystem: IParticleSystem): void;
  38065. /**
  38066. * Adds the given animation to this scene
  38067. * @param newAnimation The animation to add
  38068. */
  38069. addAnimation(newAnimation: Animation): void;
  38070. /**
  38071. * Adds the given animation group to this scene.
  38072. * @param newAnimationGroup The animation group to add
  38073. */
  38074. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  38075. /**
  38076. * Adds the given multi-material to this scene
  38077. * @param newMultiMaterial The multi-material to add
  38078. */
  38079. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  38080. /**
  38081. * Adds the given material to this scene
  38082. * @param newMaterial The material to add
  38083. */
  38084. addMaterial(newMaterial: Material): void;
  38085. /**
  38086. * Adds the given morph target to this scene
  38087. * @param newMorphTargetManager The morph target to add
  38088. */
  38089. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  38090. /**
  38091. * Adds the given geometry to this scene
  38092. * @param newGeometry The geometry to add
  38093. */
  38094. addGeometry(newGeometry: Geometry): void;
  38095. /**
  38096. * Adds the given action manager to this scene
  38097. * @param newActionManager The action manager to add
  38098. */
  38099. addActionManager(newActionManager: AbstractActionManager): void;
  38100. /**
  38101. * Adds the given texture to this scene.
  38102. * @param newTexture The texture to add
  38103. */
  38104. addTexture(newTexture: BaseTexture): void;
  38105. /**
  38106. * Switch active camera
  38107. * @param newCamera defines the new active camera
  38108. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  38109. */
  38110. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  38111. /**
  38112. * sets the active camera of the scene using its ID
  38113. * @param id defines the camera's ID
  38114. * @return the new active camera or null if none found.
  38115. */
  38116. setActiveCameraByID(id: string): Nullable<Camera>;
  38117. /**
  38118. * sets the active camera of the scene using its name
  38119. * @param name defines the camera's name
  38120. * @returns the new active camera or null if none found.
  38121. */
  38122. setActiveCameraByName(name: string): Nullable<Camera>;
  38123. /**
  38124. * get an animation group using its name
  38125. * @param name defines the material's name
  38126. * @return the animation group or null if none found.
  38127. */
  38128. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  38129. /**
  38130. * Get a material using its unique id
  38131. * @param uniqueId defines the material's unique id
  38132. * @return the material or null if none found.
  38133. */
  38134. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  38135. /**
  38136. * get a material using its id
  38137. * @param id defines the material's ID
  38138. * @return the material or null if none found.
  38139. */
  38140. getMaterialByID(id: string): Nullable<Material>;
  38141. /**
  38142. * Gets a the last added material using a given id
  38143. * @param id defines the material's ID
  38144. * @return the last material with the given id or null if none found.
  38145. */
  38146. getLastMaterialByID(id: string): Nullable<Material>;
  38147. /**
  38148. * Gets a material using its name
  38149. * @param name defines the material's name
  38150. * @return the material or null if none found.
  38151. */
  38152. getMaterialByName(name: string): Nullable<Material>;
  38153. /**
  38154. * Get a texture using its unique id
  38155. * @param uniqueId defines the texture's unique id
  38156. * @return the texture or null if none found.
  38157. */
  38158. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  38159. /**
  38160. * Gets a camera using its id
  38161. * @param id defines the id to look for
  38162. * @returns the camera or null if not found
  38163. */
  38164. getCameraByID(id: string): Nullable<Camera>;
  38165. /**
  38166. * Gets a camera using its unique id
  38167. * @param uniqueId defines the unique id to look for
  38168. * @returns the camera or null if not found
  38169. */
  38170. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  38171. /**
  38172. * Gets a camera using its name
  38173. * @param name defines the camera's name
  38174. * @return the camera or null if none found.
  38175. */
  38176. getCameraByName(name: string): Nullable<Camera>;
  38177. /**
  38178. * Gets a bone using its id
  38179. * @param id defines the bone's id
  38180. * @return the bone or null if not found
  38181. */
  38182. getBoneByID(id: string): Nullable<Bone>;
  38183. /**
  38184. * Gets a bone using its id
  38185. * @param name defines the bone's name
  38186. * @return the bone or null if not found
  38187. */
  38188. getBoneByName(name: string): Nullable<Bone>;
  38189. /**
  38190. * Gets a light node using its name
  38191. * @param name defines the the light's name
  38192. * @return the light or null if none found.
  38193. */
  38194. getLightByName(name: string): Nullable<Light>;
  38195. /**
  38196. * Gets a light node using its id
  38197. * @param id defines the light's id
  38198. * @return the light or null if none found.
  38199. */
  38200. getLightByID(id: string): Nullable<Light>;
  38201. /**
  38202. * Gets a light node using its scene-generated unique ID
  38203. * @param uniqueId defines the light's unique id
  38204. * @return the light or null if none found.
  38205. */
  38206. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  38207. /**
  38208. * Gets a particle system by id
  38209. * @param id defines the particle system id
  38210. * @return the corresponding system or null if none found
  38211. */
  38212. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  38213. /**
  38214. * Gets a geometry using its ID
  38215. * @param id defines the geometry's id
  38216. * @return the geometry or null if none found.
  38217. */
  38218. getGeometryByID(id: string): Nullable<Geometry>;
  38219. private _getGeometryByUniqueID;
  38220. /**
  38221. * Add a new geometry to this scene
  38222. * @param geometry defines the geometry to be added to the scene.
  38223. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  38224. * @return a boolean defining if the geometry was added or not
  38225. */
  38226. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  38227. /**
  38228. * Removes an existing geometry
  38229. * @param geometry defines the geometry to be removed from the scene
  38230. * @return a boolean defining if the geometry was removed or not
  38231. */
  38232. removeGeometry(geometry: Geometry): boolean;
  38233. /**
  38234. * Gets the list of geometries attached to the scene
  38235. * @returns an array of Geometry
  38236. */
  38237. getGeometries(): Geometry[];
  38238. /**
  38239. * Gets the first added mesh found of a given ID
  38240. * @param id defines the id to search for
  38241. * @return the mesh found or null if not found at all
  38242. */
  38243. getMeshByID(id: string): Nullable<AbstractMesh>;
  38244. /**
  38245. * Gets a list of meshes using their id
  38246. * @param id defines the id to search for
  38247. * @returns a list of meshes
  38248. */
  38249. getMeshesByID(id: string): Array<AbstractMesh>;
  38250. /**
  38251. * Gets the first added transform node found of a given ID
  38252. * @param id defines the id to search for
  38253. * @return the found transform node or null if not found at all.
  38254. */
  38255. getTransformNodeByID(id: string): Nullable<TransformNode>;
  38256. /**
  38257. * Gets a transform node with its auto-generated unique id
  38258. * @param uniqueId efines the unique id to search for
  38259. * @return the found transform node or null if not found at all.
  38260. */
  38261. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  38262. /**
  38263. * Gets a list of transform nodes using their id
  38264. * @param id defines the id to search for
  38265. * @returns a list of transform nodes
  38266. */
  38267. getTransformNodesByID(id: string): Array<TransformNode>;
  38268. /**
  38269. * Gets a mesh with its auto-generated unique id
  38270. * @param uniqueId defines the unique id to search for
  38271. * @return the found mesh or null if not found at all.
  38272. */
  38273. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38274. /**
  38275. * Gets a the last added mesh using a given id
  38276. * @param id defines the id to search for
  38277. * @return the found mesh or null if not found at all.
  38278. */
  38279. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38280. /**
  38281. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38282. * @param id defines the id to search for
  38283. * @return the found node or null if not found at all
  38284. */
  38285. getLastEntryByID(id: string): Nullable<Node>;
  38286. /**
  38287. * Gets a node (Mesh, Camera, Light) using a given id
  38288. * @param id defines the id to search for
  38289. * @return the found node or null if not found at all
  38290. */
  38291. getNodeByID(id: string): Nullable<Node>;
  38292. /**
  38293. * Gets a node (Mesh, Camera, Light) using a given name
  38294. * @param name defines the name to search for
  38295. * @return the found node or null if not found at all.
  38296. */
  38297. getNodeByName(name: string): Nullable<Node>;
  38298. /**
  38299. * Gets a mesh using a given name
  38300. * @param name defines the name to search for
  38301. * @return the found mesh or null if not found at all.
  38302. */
  38303. getMeshByName(name: string): Nullable<AbstractMesh>;
  38304. /**
  38305. * Gets a transform node using a given name
  38306. * @param name defines the name to search for
  38307. * @return the found transform node or null if not found at all.
  38308. */
  38309. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38310. /**
  38311. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38312. * @param id defines the id to search for
  38313. * @return the found skeleton or null if not found at all.
  38314. */
  38315. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38316. /**
  38317. * Gets a skeleton using a given auto generated unique id
  38318. * @param uniqueId defines the unique id to search for
  38319. * @return the found skeleton or null if not found at all.
  38320. */
  38321. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38322. /**
  38323. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38324. * @param id defines the id to search for
  38325. * @return the found skeleton or null if not found at all.
  38326. */
  38327. getSkeletonById(id: string): Nullable<Skeleton>;
  38328. /**
  38329. * Gets a skeleton using a given name
  38330. * @param name defines the name to search for
  38331. * @return the found skeleton or null if not found at all.
  38332. */
  38333. getSkeletonByName(name: string): Nullable<Skeleton>;
  38334. /**
  38335. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38336. * @param id defines the id to search for
  38337. * @return the found morph target manager or null if not found at all.
  38338. */
  38339. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38340. /**
  38341. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38342. * @param id defines the id to search for
  38343. * @return the found morph target or null if not found at all.
  38344. */
  38345. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38346. /**
  38347. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38348. * @param name defines the name to search for
  38349. * @return the found morph target or null if not found at all.
  38350. */
  38351. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38352. /**
  38353. * Gets a boolean indicating if the given mesh is active
  38354. * @param mesh defines the mesh to look for
  38355. * @returns true if the mesh is in the active list
  38356. */
  38357. isActiveMesh(mesh: AbstractMesh): boolean;
  38358. /**
  38359. * Return a unique id as a string which can serve as an identifier for the scene
  38360. */
  38361. get uid(): string;
  38362. /**
  38363. * Add an externaly attached data from its key.
  38364. * This method call will fail and return false, if such key already exists.
  38365. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38366. * @param key the unique key that identifies the data
  38367. * @param data the data object to associate to the key for this Engine instance
  38368. * @return true if no such key were already present and the data was added successfully, false otherwise
  38369. */
  38370. addExternalData<T>(key: string, data: T): boolean;
  38371. /**
  38372. * Get an externaly attached data from its key
  38373. * @param key the unique key that identifies the data
  38374. * @return the associated data, if present (can be null), or undefined if not present
  38375. */
  38376. getExternalData<T>(key: string): Nullable<T>;
  38377. /**
  38378. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38379. * @param key the unique key that identifies the data
  38380. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38381. * @return the associated data, can be null if the factory returned null.
  38382. */
  38383. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38384. /**
  38385. * Remove an externaly attached data from the Engine instance
  38386. * @param key the unique key that identifies the data
  38387. * @return true if the data was successfully removed, false if it doesn't exist
  38388. */
  38389. removeExternalData(key: string): boolean;
  38390. private _evaluateSubMesh;
  38391. /**
  38392. * Clear the processed materials smart array preventing retention point in material dispose.
  38393. */
  38394. freeProcessedMaterials(): void;
  38395. private _preventFreeActiveMeshesAndRenderingGroups;
  38396. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38397. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38398. * when disposing several meshes in a row or a hierarchy of meshes.
  38399. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38400. */
  38401. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38402. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38403. /**
  38404. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38405. */
  38406. freeActiveMeshes(): void;
  38407. /**
  38408. * Clear the info related to rendering groups preventing retention points during dispose.
  38409. */
  38410. freeRenderingGroups(): void;
  38411. /** @hidden */
  38412. _isInIntermediateRendering(): boolean;
  38413. /**
  38414. * Lambda returning the list of potentially active meshes.
  38415. */
  38416. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38417. /**
  38418. * Lambda returning the list of potentially active sub meshes.
  38419. */
  38420. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38421. /**
  38422. * Lambda returning the list of potentially intersecting sub meshes.
  38423. */
  38424. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38425. /**
  38426. * Lambda returning the list of potentially colliding sub meshes.
  38427. */
  38428. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38429. private _activeMeshesFrozen;
  38430. private _skipEvaluateActiveMeshesCompletely;
  38431. /**
  38432. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38433. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38434. * @returns the current scene
  38435. */
  38436. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38437. /**
  38438. * Use this function to restart evaluating active meshes on every frame
  38439. * @returns the current scene
  38440. */
  38441. unfreezeActiveMeshes(): Scene;
  38442. private _evaluateActiveMeshes;
  38443. private _activeMesh;
  38444. /**
  38445. * Update the transform matrix to update from the current active camera
  38446. * @param force defines a boolean used to force the update even if cache is up to date
  38447. */
  38448. updateTransformMatrix(force?: boolean): void;
  38449. private _bindFrameBuffer;
  38450. /** @hidden */
  38451. _allowPostProcessClearColor: boolean;
  38452. /** @hidden */
  38453. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38454. private _processSubCameras;
  38455. private _checkIntersections;
  38456. /** @hidden */
  38457. _advancePhysicsEngineStep(step: number): void;
  38458. /**
  38459. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38460. */
  38461. getDeterministicFrameTime: () => number;
  38462. /** @hidden */
  38463. _animate(): void;
  38464. /** Execute all animations (for a frame) */
  38465. animate(): void;
  38466. /**
  38467. * Render the scene
  38468. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38469. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38470. */
  38471. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38472. /**
  38473. * Freeze all materials
  38474. * A frozen material will not be updatable but should be faster to render
  38475. */
  38476. freezeMaterials(): void;
  38477. /**
  38478. * Unfreeze all materials
  38479. * A frozen material will not be updatable but should be faster to render
  38480. */
  38481. unfreezeMaterials(): void;
  38482. /**
  38483. * Releases all held ressources
  38484. */
  38485. dispose(): void;
  38486. /**
  38487. * Gets if the scene is already disposed
  38488. */
  38489. get isDisposed(): boolean;
  38490. /**
  38491. * Call this function to reduce memory footprint of the scene.
  38492. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38493. */
  38494. clearCachedVertexData(): void;
  38495. /**
  38496. * This function will remove the local cached buffer data from texture.
  38497. * It will save memory but will prevent the texture from being rebuilt
  38498. */
  38499. cleanCachedTextureBuffer(): void;
  38500. /**
  38501. * Get the world extend vectors with an optional filter
  38502. *
  38503. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38504. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38505. */
  38506. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38507. min: Vector3;
  38508. max: Vector3;
  38509. };
  38510. /**
  38511. * Creates a ray that can be used to pick in the scene
  38512. * @param x defines the x coordinate of the origin (on-screen)
  38513. * @param y defines the y coordinate of the origin (on-screen)
  38514. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38515. * @param camera defines the camera to use for the picking
  38516. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38517. * @returns a Ray
  38518. */
  38519. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38520. /**
  38521. * Creates a ray that can be used to pick in the scene
  38522. * @param x defines the x coordinate of the origin (on-screen)
  38523. * @param y defines the y coordinate of the origin (on-screen)
  38524. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38525. * @param result defines the ray where to store the picking ray
  38526. * @param camera defines the camera to use for the picking
  38527. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38528. * @returns the current scene
  38529. */
  38530. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38531. /**
  38532. * Creates a ray that can be used to pick in the scene
  38533. * @param x defines the x coordinate of the origin (on-screen)
  38534. * @param y defines the y coordinate of the origin (on-screen)
  38535. * @param camera defines the camera to use for the picking
  38536. * @returns a Ray
  38537. */
  38538. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38539. /**
  38540. * Creates a ray that can be used to pick in the scene
  38541. * @param x defines the x coordinate of the origin (on-screen)
  38542. * @param y defines the y coordinate of the origin (on-screen)
  38543. * @param result defines the ray where to store the picking ray
  38544. * @param camera defines the camera to use for the picking
  38545. * @returns the current scene
  38546. */
  38547. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38548. /** Launch a ray to try to pick a mesh in the scene
  38549. * @param x position on screen
  38550. * @param y position on screen
  38551. * @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
  38552. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38553. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38554. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38555. * @returns a PickingInfo
  38556. */
  38557. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38558. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  38559. * @param x position on screen
  38560. * @param y position on screen
  38561. * @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
  38562. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38563. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38564. * @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)
  38565. */
  38566. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  38567. /** Use the given ray to pick a mesh in the scene
  38568. * @param ray The ray to use to pick meshes
  38569. * @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
  38570. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38571. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38572. * @returns a PickingInfo
  38573. */
  38574. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38575. /**
  38576. * Launch a ray to try to pick a mesh in the scene
  38577. * @param x X position on screen
  38578. * @param y Y position on screen
  38579. * @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
  38580. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38581. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38582. * @returns an array of PickingInfo
  38583. */
  38584. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38585. /**
  38586. * Launch a ray to try to pick a mesh in the scene
  38587. * @param ray Ray to use
  38588. * @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
  38589. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38590. * @returns an array of PickingInfo
  38591. */
  38592. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38593. /**
  38594. * Force the value of meshUnderPointer
  38595. * @param mesh defines the mesh to use
  38596. */
  38597. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38598. /**
  38599. * Gets the mesh under the pointer
  38600. * @returns a Mesh or null if no mesh is under the pointer
  38601. */
  38602. getPointerOverMesh(): Nullable<AbstractMesh>;
  38603. /** @hidden */
  38604. _rebuildGeometries(): void;
  38605. /** @hidden */
  38606. _rebuildTextures(): void;
  38607. private _getByTags;
  38608. /**
  38609. * Get a list of meshes by tags
  38610. * @param tagsQuery defines the tags query to use
  38611. * @param forEach defines a predicate used to filter results
  38612. * @returns an array of Mesh
  38613. */
  38614. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38615. /**
  38616. * Get a list of cameras by tags
  38617. * @param tagsQuery defines the tags query to use
  38618. * @param forEach defines a predicate used to filter results
  38619. * @returns an array of Camera
  38620. */
  38621. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38622. /**
  38623. * Get a list of lights by tags
  38624. * @param tagsQuery defines the tags query to use
  38625. * @param forEach defines a predicate used to filter results
  38626. * @returns an array of Light
  38627. */
  38628. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38629. /**
  38630. * Get a list of materials by tags
  38631. * @param tagsQuery defines the tags query to use
  38632. * @param forEach defines a predicate used to filter results
  38633. * @returns an array of Material
  38634. */
  38635. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38636. /**
  38637. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38638. * This allowed control for front to back rendering or reversly depending of the special needs.
  38639. *
  38640. * @param renderingGroupId The rendering group id corresponding to its index
  38641. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38642. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38643. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38644. */
  38645. 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;
  38646. /**
  38647. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38648. *
  38649. * @param renderingGroupId The rendering group id corresponding to its index
  38650. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38651. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38652. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38653. */
  38654. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38655. /**
  38656. * Gets the current auto clear configuration for one rendering group of the rendering
  38657. * manager.
  38658. * @param index the rendering group index to get the information for
  38659. * @returns The auto clear setup for the requested rendering group
  38660. */
  38661. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38662. private _blockMaterialDirtyMechanism;
  38663. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38664. get blockMaterialDirtyMechanism(): boolean;
  38665. set blockMaterialDirtyMechanism(value: boolean);
  38666. /**
  38667. * Will flag all materials as dirty to trigger new shader compilation
  38668. * @param flag defines the flag used to specify which material part must be marked as dirty
  38669. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38670. */
  38671. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38672. /** @hidden */
  38673. _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;
  38674. /** @hidden */
  38675. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38676. /** @hidden */
  38677. _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;
  38678. /** @hidden */
  38679. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38680. /** @hidden */
  38681. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38682. /** @hidden */
  38683. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38684. }
  38685. }
  38686. declare module "babylonjs/assetContainer" {
  38687. import { AbstractScene } from "babylonjs/abstractScene";
  38688. import { Scene } from "babylonjs/scene";
  38689. import { Mesh } from "babylonjs/Meshes/mesh";
  38690. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38691. import { Skeleton } from "babylonjs/Bones/skeleton";
  38692. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38693. import { Animatable } from "babylonjs/Animations/animatable";
  38694. import { Nullable } from "babylonjs/types";
  38695. import { Node } from "babylonjs/node";
  38696. /**
  38697. * Set of assets to keep when moving a scene into an asset container.
  38698. */
  38699. export class KeepAssets extends AbstractScene {
  38700. }
  38701. /**
  38702. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38703. */
  38704. export class InstantiatedEntries {
  38705. /**
  38706. * List of new root nodes (eg. nodes with no parent)
  38707. */
  38708. rootNodes: TransformNode[];
  38709. /**
  38710. * List of new skeletons
  38711. */
  38712. skeletons: Skeleton[];
  38713. /**
  38714. * List of new animation groups
  38715. */
  38716. animationGroups: AnimationGroup[];
  38717. }
  38718. /**
  38719. * Container with a set of assets that can be added or removed from a scene.
  38720. */
  38721. export class AssetContainer extends AbstractScene {
  38722. private _wasAddedToScene;
  38723. /**
  38724. * The scene the AssetContainer belongs to.
  38725. */
  38726. scene: Scene;
  38727. /**
  38728. * Instantiates an AssetContainer.
  38729. * @param scene The scene the AssetContainer belongs to.
  38730. */
  38731. constructor(scene: Scene);
  38732. /**
  38733. * Instantiate or clone all meshes and add the new ones to the scene.
  38734. * Skeletons and animation groups will all be cloned
  38735. * @param nameFunction defines an optional function used to get new names for clones
  38736. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38737. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38738. */
  38739. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38740. /**
  38741. * Adds all the assets from the container to the scene.
  38742. */
  38743. addAllToScene(): void;
  38744. /**
  38745. * Removes all the assets in the container from the scene
  38746. */
  38747. removeAllFromScene(): void;
  38748. /**
  38749. * Disposes all the assets in the container
  38750. */
  38751. dispose(): void;
  38752. private _moveAssets;
  38753. /**
  38754. * Removes all the assets contained in the scene and adds them to the container.
  38755. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38756. */
  38757. moveAllFromScene(keepAssets?: KeepAssets): void;
  38758. /**
  38759. * 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.
  38760. * @returns the root mesh
  38761. */
  38762. createRootMesh(): Mesh;
  38763. /**
  38764. * Merge animations (direct and animation groups) from this asset container into a scene
  38765. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38766. * @param animatables set of animatables to retarget to a node from the scene
  38767. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38768. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  38769. */
  38770. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  38771. }
  38772. }
  38773. declare module "babylonjs/abstractScene" {
  38774. import { Scene } from "babylonjs/scene";
  38775. import { Nullable } from "babylonjs/types";
  38776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38778. import { Geometry } from "babylonjs/Meshes/geometry";
  38779. import { Skeleton } from "babylonjs/Bones/skeleton";
  38780. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38781. import { AssetContainer } from "babylonjs/assetContainer";
  38782. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38783. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38784. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38785. import { Material } from "babylonjs/Materials/material";
  38786. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38787. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38788. import { Camera } from "babylonjs/Cameras/camera";
  38789. import { Light } from "babylonjs/Lights/light";
  38790. import { Node } from "babylonjs/node";
  38791. import { Animation } from "babylonjs/Animations/animation";
  38792. /**
  38793. * Defines how the parser contract is defined.
  38794. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38795. */
  38796. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38797. /**
  38798. * Defines how the individual parser contract is defined.
  38799. * These parser can parse an individual asset
  38800. */
  38801. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38802. /**
  38803. * Base class of the scene acting as a container for the different elements composing a scene.
  38804. * This class is dynamically extended by the different components of the scene increasing
  38805. * flexibility and reducing coupling
  38806. */
  38807. export abstract class AbstractScene {
  38808. /**
  38809. * Stores the list of available parsers in the application.
  38810. */
  38811. private static _BabylonFileParsers;
  38812. /**
  38813. * Stores the list of available individual parsers in the application.
  38814. */
  38815. private static _IndividualBabylonFileParsers;
  38816. /**
  38817. * Adds a parser in the list of available ones
  38818. * @param name Defines the name of the parser
  38819. * @param parser Defines the parser to add
  38820. */
  38821. static AddParser(name: string, parser: BabylonFileParser): void;
  38822. /**
  38823. * Gets a general parser from the list of avaialble ones
  38824. * @param name Defines the name of the parser
  38825. * @returns the requested parser or null
  38826. */
  38827. static GetParser(name: string): Nullable<BabylonFileParser>;
  38828. /**
  38829. * Adds n individual parser in the list of available ones
  38830. * @param name Defines the name of the parser
  38831. * @param parser Defines the parser to add
  38832. */
  38833. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38834. /**
  38835. * Gets an individual parser from the list of avaialble ones
  38836. * @param name Defines the name of the parser
  38837. * @returns the requested parser or null
  38838. */
  38839. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38840. /**
  38841. * Parser json data and populate both a scene and its associated container object
  38842. * @param jsonData Defines the data to parse
  38843. * @param scene Defines the scene to parse the data for
  38844. * @param container Defines the container attached to the parsing sequence
  38845. * @param rootUrl Defines the root url of the data
  38846. */
  38847. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38848. /**
  38849. * Gets the list of root nodes (ie. nodes with no parent)
  38850. */
  38851. rootNodes: Node[];
  38852. /** All of the cameras added to this scene
  38853. * @see http://doc.babylonjs.com/babylon101/cameras
  38854. */
  38855. cameras: Camera[];
  38856. /**
  38857. * All of the lights added to this scene
  38858. * @see http://doc.babylonjs.com/babylon101/lights
  38859. */
  38860. lights: Light[];
  38861. /**
  38862. * All of the (abstract) meshes added to this scene
  38863. */
  38864. meshes: AbstractMesh[];
  38865. /**
  38866. * The list of skeletons added to the scene
  38867. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38868. */
  38869. skeletons: Skeleton[];
  38870. /**
  38871. * All of the particle systems added to this scene
  38872. * @see http://doc.babylonjs.com/babylon101/particles
  38873. */
  38874. particleSystems: IParticleSystem[];
  38875. /**
  38876. * Gets a list of Animations associated with the scene
  38877. */
  38878. animations: Animation[];
  38879. /**
  38880. * All of the animation groups added to this scene
  38881. * @see http://doc.babylonjs.com/how_to/group
  38882. */
  38883. animationGroups: AnimationGroup[];
  38884. /**
  38885. * All of the multi-materials added to this scene
  38886. * @see http://doc.babylonjs.com/how_to/multi_materials
  38887. */
  38888. multiMaterials: MultiMaterial[];
  38889. /**
  38890. * All of the materials added to this scene
  38891. * In the context of a Scene, it is not supposed to be modified manually.
  38892. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38893. * Note also that the order of the Material within the array is not significant and might change.
  38894. * @see http://doc.babylonjs.com/babylon101/materials
  38895. */
  38896. materials: Material[];
  38897. /**
  38898. * The list of morph target managers added to the scene
  38899. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38900. */
  38901. morphTargetManagers: MorphTargetManager[];
  38902. /**
  38903. * The list of geometries used in the scene.
  38904. */
  38905. geometries: Geometry[];
  38906. /**
  38907. * All of the tranform nodes added to this scene
  38908. * In the context of a Scene, it is not supposed to be modified manually.
  38909. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38910. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38911. * @see http://doc.babylonjs.com/how_to/transformnode
  38912. */
  38913. transformNodes: TransformNode[];
  38914. /**
  38915. * ActionManagers available on the scene.
  38916. */
  38917. actionManagers: AbstractActionManager[];
  38918. /**
  38919. * Textures to keep.
  38920. */
  38921. textures: BaseTexture[];
  38922. /**
  38923. * Environment texture for the scene
  38924. */
  38925. environmentTexture: Nullable<BaseTexture>;
  38926. /**
  38927. * @returns all meshes, lights, cameras, transformNodes and bones
  38928. */
  38929. getNodes(): Array<Node>;
  38930. }
  38931. }
  38932. declare module "babylonjs/Audio/sound" {
  38933. import { Observable } from "babylonjs/Misc/observable";
  38934. import { Vector3 } from "babylonjs/Maths/math.vector";
  38935. import { Nullable } from "babylonjs/types";
  38936. import { Scene } from "babylonjs/scene";
  38937. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38938. /**
  38939. * Interface used to define options for Sound class
  38940. */
  38941. export interface ISoundOptions {
  38942. /**
  38943. * Does the sound autoplay once loaded.
  38944. */
  38945. autoplay?: boolean;
  38946. /**
  38947. * Does the sound loop after it finishes playing once.
  38948. */
  38949. loop?: boolean;
  38950. /**
  38951. * Sound's volume
  38952. */
  38953. volume?: number;
  38954. /**
  38955. * Is it a spatial sound?
  38956. */
  38957. spatialSound?: boolean;
  38958. /**
  38959. * Maximum distance to hear that sound
  38960. */
  38961. maxDistance?: number;
  38962. /**
  38963. * Uses user defined attenuation function
  38964. */
  38965. useCustomAttenuation?: boolean;
  38966. /**
  38967. * Define the roll off factor of spatial sounds.
  38968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38969. */
  38970. rolloffFactor?: number;
  38971. /**
  38972. * Define the reference distance the sound should be heard perfectly.
  38973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38974. */
  38975. refDistance?: number;
  38976. /**
  38977. * Define the distance attenuation model the sound will follow.
  38978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38979. */
  38980. distanceModel?: string;
  38981. /**
  38982. * Defines the playback speed (1 by default)
  38983. */
  38984. playbackRate?: number;
  38985. /**
  38986. * Defines if the sound is from a streaming source
  38987. */
  38988. streaming?: boolean;
  38989. /**
  38990. * Defines an optional length (in seconds) inside the sound file
  38991. */
  38992. length?: number;
  38993. /**
  38994. * Defines an optional offset (in seconds) inside the sound file
  38995. */
  38996. offset?: number;
  38997. /**
  38998. * If true, URLs will not be required to state the audio file codec to use.
  38999. */
  39000. skipCodecCheck?: boolean;
  39001. }
  39002. /**
  39003. * Defines a sound that can be played in the application.
  39004. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  39005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39006. */
  39007. export class Sound {
  39008. /**
  39009. * The name of the sound in the scene.
  39010. */
  39011. name: string;
  39012. /**
  39013. * Does the sound autoplay once loaded.
  39014. */
  39015. autoplay: boolean;
  39016. /**
  39017. * Does the sound loop after it finishes playing once.
  39018. */
  39019. loop: boolean;
  39020. /**
  39021. * Does the sound use a custom attenuation curve to simulate the falloff
  39022. * happening when the source gets further away from the camera.
  39023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39024. */
  39025. useCustomAttenuation: boolean;
  39026. /**
  39027. * The sound track id this sound belongs to.
  39028. */
  39029. soundTrackId: number;
  39030. /**
  39031. * Is this sound currently played.
  39032. */
  39033. isPlaying: boolean;
  39034. /**
  39035. * Is this sound currently paused.
  39036. */
  39037. isPaused: boolean;
  39038. /**
  39039. * Does this sound enables spatial sound.
  39040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39041. */
  39042. spatialSound: boolean;
  39043. /**
  39044. * Define the reference distance the sound should be heard perfectly.
  39045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39046. */
  39047. refDistance: number;
  39048. /**
  39049. * Define the roll off factor of spatial sounds.
  39050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39051. */
  39052. rolloffFactor: number;
  39053. /**
  39054. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  39055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39056. */
  39057. maxDistance: number;
  39058. /**
  39059. * Define the distance attenuation model the sound will follow.
  39060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39061. */
  39062. distanceModel: string;
  39063. /**
  39064. * @hidden
  39065. * Back Compat
  39066. **/
  39067. onended: () => any;
  39068. /**
  39069. * Observable event when the current playing sound finishes.
  39070. */
  39071. onEndedObservable: Observable<Sound>;
  39072. private _panningModel;
  39073. private _playbackRate;
  39074. private _streaming;
  39075. private _startTime;
  39076. private _startOffset;
  39077. private _position;
  39078. /** @hidden */
  39079. _positionInEmitterSpace: boolean;
  39080. private _localDirection;
  39081. private _volume;
  39082. private _isReadyToPlay;
  39083. private _isDirectional;
  39084. private _readyToPlayCallback;
  39085. private _audioBuffer;
  39086. private _soundSource;
  39087. private _streamingSource;
  39088. private _soundPanner;
  39089. private _soundGain;
  39090. private _inputAudioNode;
  39091. private _outputAudioNode;
  39092. private _coneInnerAngle;
  39093. private _coneOuterAngle;
  39094. private _coneOuterGain;
  39095. private _scene;
  39096. private _connectedTransformNode;
  39097. private _customAttenuationFunction;
  39098. private _registerFunc;
  39099. private _isOutputConnected;
  39100. private _htmlAudioElement;
  39101. private _urlType;
  39102. private _length?;
  39103. private _offset?;
  39104. /** @hidden */
  39105. static _SceneComponentInitialization: (scene: Scene) => void;
  39106. /**
  39107. * Create a sound and attach it to a scene
  39108. * @param name Name of your sound
  39109. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  39110. * @param scene defines the scene the sound belongs to
  39111. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  39112. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  39113. */
  39114. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  39115. /**
  39116. * Release the sound and its associated resources
  39117. */
  39118. dispose(): void;
  39119. /**
  39120. * Gets if the sounds is ready to be played or not.
  39121. * @returns true if ready, otherwise false
  39122. */
  39123. isReady(): boolean;
  39124. private _soundLoaded;
  39125. /**
  39126. * Sets the data of the sound from an audiobuffer
  39127. * @param audioBuffer The audioBuffer containing the data
  39128. */
  39129. setAudioBuffer(audioBuffer: AudioBuffer): void;
  39130. /**
  39131. * Updates the current sounds options such as maxdistance, loop...
  39132. * @param options A JSON object containing values named as the object properties
  39133. */
  39134. updateOptions(options: ISoundOptions): void;
  39135. private _createSpatialParameters;
  39136. private _updateSpatialParameters;
  39137. /**
  39138. * Switch the panning model to HRTF:
  39139. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39141. */
  39142. switchPanningModelToHRTF(): void;
  39143. /**
  39144. * Switch the panning model to Equal Power:
  39145. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39147. */
  39148. switchPanningModelToEqualPower(): void;
  39149. private _switchPanningModel;
  39150. /**
  39151. * Connect this sound to a sound track audio node like gain...
  39152. * @param soundTrackAudioNode the sound track audio node to connect to
  39153. */
  39154. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  39155. /**
  39156. * Transform this sound into a directional source
  39157. * @param coneInnerAngle Size of the inner cone in degree
  39158. * @param coneOuterAngle Size of the outer cone in degree
  39159. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  39160. */
  39161. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  39162. /**
  39163. * Gets or sets the inner angle for the directional cone.
  39164. */
  39165. get directionalConeInnerAngle(): number;
  39166. /**
  39167. * Gets or sets the inner angle for the directional cone.
  39168. */
  39169. set directionalConeInnerAngle(value: number);
  39170. /**
  39171. * Gets or sets the outer angle for the directional cone.
  39172. */
  39173. get directionalConeOuterAngle(): number;
  39174. /**
  39175. * Gets or sets the outer angle for the directional cone.
  39176. */
  39177. set directionalConeOuterAngle(value: number);
  39178. /**
  39179. * Sets the position of the emitter if spatial sound is enabled
  39180. * @param newPosition Defines the new posisiton
  39181. */
  39182. setPosition(newPosition: Vector3): void;
  39183. /**
  39184. * Sets the local direction of the emitter if spatial sound is enabled
  39185. * @param newLocalDirection Defines the new local direction
  39186. */
  39187. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  39188. private _updateDirection;
  39189. /** @hidden */
  39190. updateDistanceFromListener(): void;
  39191. /**
  39192. * Sets a new custom attenuation function for the sound.
  39193. * @param callback Defines the function used for the attenuation
  39194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39195. */
  39196. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  39197. /**
  39198. * Play the sound
  39199. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  39200. * @param offset (optional) Start the sound at a specific time in seconds
  39201. * @param length (optional) Sound duration (in seconds)
  39202. */
  39203. play(time?: number, offset?: number, length?: number): void;
  39204. private _onended;
  39205. /**
  39206. * Stop the sound
  39207. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  39208. */
  39209. stop(time?: number): void;
  39210. /**
  39211. * Put the sound in pause
  39212. */
  39213. pause(): void;
  39214. /**
  39215. * Sets a dedicated volume for this sounds
  39216. * @param newVolume Define the new volume of the sound
  39217. * @param time Define time for gradual change to new volume
  39218. */
  39219. setVolume(newVolume: number, time?: number): void;
  39220. /**
  39221. * Set the sound play back rate
  39222. * @param newPlaybackRate Define the playback rate the sound should be played at
  39223. */
  39224. setPlaybackRate(newPlaybackRate: number): void;
  39225. /**
  39226. * Gets the volume of the sound.
  39227. * @returns the volume of the sound
  39228. */
  39229. getVolume(): number;
  39230. /**
  39231. * Attach the sound to a dedicated mesh
  39232. * @param transformNode The transform node to connect the sound with
  39233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39234. */
  39235. attachToMesh(transformNode: TransformNode): void;
  39236. /**
  39237. * Detach the sound from the previously attached mesh
  39238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39239. */
  39240. detachFromMesh(): void;
  39241. private _onRegisterAfterWorldMatrixUpdate;
  39242. /**
  39243. * Clone the current sound in the scene.
  39244. * @returns the new sound clone
  39245. */
  39246. clone(): Nullable<Sound>;
  39247. /**
  39248. * Gets the current underlying audio buffer containing the data
  39249. * @returns the audio buffer
  39250. */
  39251. getAudioBuffer(): Nullable<AudioBuffer>;
  39252. /**
  39253. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  39254. * @returns the source node
  39255. */
  39256. getSoundSource(): Nullable<AudioBufferSourceNode>;
  39257. /**
  39258. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  39259. * @returns the gain node
  39260. */
  39261. getSoundGain(): Nullable<GainNode>;
  39262. /**
  39263. * Serializes the Sound in a JSON representation
  39264. * @returns the JSON representation of the sound
  39265. */
  39266. serialize(): any;
  39267. /**
  39268. * Parse a JSON representation of a sound to innstantiate in a given scene
  39269. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  39270. * @param scene Define the scene the new parsed sound should be created in
  39271. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  39272. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  39273. * @returns the newly parsed sound
  39274. */
  39275. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  39276. }
  39277. }
  39278. declare module "babylonjs/Actions/directAudioActions" {
  39279. import { Action } from "babylonjs/Actions/action";
  39280. import { Condition } from "babylonjs/Actions/condition";
  39281. import { Sound } from "babylonjs/Audio/sound";
  39282. /**
  39283. * This defines an action helpful to play a defined sound on a triggered action.
  39284. */
  39285. export class PlaySoundAction extends Action {
  39286. private _sound;
  39287. /**
  39288. * Instantiate the action
  39289. * @param triggerOptions defines the trigger options
  39290. * @param sound defines the sound to play
  39291. * @param condition defines the trigger related conditions
  39292. */
  39293. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39294. /** @hidden */
  39295. _prepare(): void;
  39296. /**
  39297. * Execute the action and play the sound.
  39298. */
  39299. execute(): void;
  39300. /**
  39301. * Serializes the actions and its related information.
  39302. * @param parent defines the object to serialize in
  39303. * @returns the serialized object
  39304. */
  39305. serialize(parent: any): any;
  39306. }
  39307. /**
  39308. * This defines an action helpful to stop a defined sound on a triggered action.
  39309. */
  39310. export class StopSoundAction extends Action {
  39311. private _sound;
  39312. /**
  39313. * Instantiate the action
  39314. * @param triggerOptions defines the trigger options
  39315. * @param sound defines the sound to stop
  39316. * @param condition defines the trigger related conditions
  39317. */
  39318. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39319. /** @hidden */
  39320. _prepare(): void;
  39321. /**
  39322. * Execute the action and stop the sound.
  39323. */
  39324. execute(): void;
  39325. /**
  39326. * Serializes the actions and its related information.
  39327. * @param parent defines the object to serialize in
  39328. * @returns the serialized object
  39329. */
  39330. serialize(parent: any): any;
  39331. }
  39332. }
  39333. declare module "babylonjs/Actions/interpolateValueAction" {
  39334. import { Action } from "babylonjs/Actions/action";
  39335. import { Condition } from "babylonjs/Actions/condition";
  39336. import { Observable } from "babylonjs/Misc/observable";
  39337. /**
  39338. * This defines an action responsible to change the value of a property
  39339. * by interpolating between its current value and the newly set one once triggered.
  39340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39341. */
  39342. export class InterpolateValueAction extends Action {
  39343. /**
  39344. * Defines the path of the property where the value should be interpolated
  39345. */
  39346. propertyPath: string;
  39347. /**
  39348. * Defines the target value at the end of the interpolation.
  39349. */
  39350. value: any;
  39351. /**
  39352. * Defines the time it will take for the property to interpolate to the value.
  39353. */
  39354. duration: number;
  39355. /**
  39356. * Defines if the other scene animations should be stopped when the action has been triggered
  39357. */
  39358. stopOtherAnimations?: boolean;
  39359. /**
  39360. * Defines a callback raised once the interpolation animation has been done.
  39361. */
  39362. onInterpolationDone?: () => void;
  39363. /**
  39364. * Observable triggered once the interpolation animation has been done.
  39365. */
  39366. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39367. private _target;
  39368. private _effectiveTarget;
  39369. private _property;
  39370. /**
  39371. * Instantiate the action
  39372. * @param triggerOptions defines the trigger options
  39373. * @param target defines the object containing the value to interpolate
  39374. * @param propertyPath defines the path to the property in the target object
  39375. * @param value defines the target value at the end of the interpolation
  39376. * @param duration deines the time it will take for the property to interpolate to the value.
  39377. * @param condition defines the trigger related conditions
  39378. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39379. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39380. */
  39381. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39382. /** @hidden */
  39383. _prepare(): void;
  39384. /**
  39385. * Execute the action starts the value interpolation.
  39386. */
  39387. execute(): void;
  39388. /**
  39389. * Serializes the actions and its related information.
  39390. * @param parent defines the object to serialize in
  39391. * @returns the serialized object
  39392. */
  39393. serialize(parent: any): any;
  39394. }
  39395. }
  39396. declare module "babylonjs/Actions/index" {
  39397. export * from "babylonjs/Actions/abstractActionManager";
  39398. export * from "babylonjs/Actions/action";
  39399. export * from "babylonjs/Actions/actionEvent";
  39400. export * from "babylonjs/Actions/actionManager";
  39401. export * from "babylonjs/Actions/condition";
  39402. export * from "babylonjs/Actions/directActions";
  39403. export * from "babylonjs/Actions/directAudioActions";
  39404. export * from "babylonjs/Actions/interpolateValueAction";
  39405. }
  39406. declare module "babylonjs/Animations/index" {
  39407. export * from "babylonjs/Animations/animatable";
  39408. export * from "babylonjs/Animations/animation";
  39409. export * from "babylonjs/Animations/animationGroup";
  39410. export * from "babylonjs/Animations/animationPropertiesOverride";
  39411. export * from "babylonjs/Animations/easing";
  39412. export * from "babylonjs/Animations/runtimeAnimation";
  39413. export * from "babylonjs/Animations/animationEvent";
  39414. export * from "babylonjs/Animations/animationGroup";
  39415. export * from "babylonjs/Animations/animationKey";
  39416. export * from "babylonjs/Animations/animationRange";
  39417. export * from "babylonjs/Animations/animatable.interface";
  39418. }
  39419. declare module "babylonjs/Audio/soundTrack" {
  39420. import { Sound } from "babylonjs/Audio/sound";
  39421. import { Analyser } from "babylonjs/Audio/analyser";
  39422. import { Scene } from "babylonjs/scene";
  39423. /**
  39424. * Options allowed during the creation of a sound track.
  39425. */
  39426. export interface ISoundTrackOptions {
  39427. /**
  39428. * The volume the sound track should take during creation
  39429. */
  39430. volume?: number;
  39431. /**
  39432. * Define if the sound track is the main sound track of the scene
  39433. */
  39434. mainTrack?: boolean;
  39435. }
  39436. /**
  39437. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39438. * It will be also used in a future release to apply effects on a specific track.
  39439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39440. */
  39441. export class SoundTrack {
  39442. /**
  39443. * The unique identifier of the sound track in the scene.
  39444. */
  39445. id: number;
  39446. /**
  39447. * The list of sounds included in the sound track.
  39448. */
  39449. soundCollection: Array<Sound>;
  39450. private _outputAudioNode;
  39451. private _scene;
  39452. private _connectedAnalyser;
  39453. private _options;
  39454. private _isInitialized;
  39455. /**
  39456. * Creates a new sound track.
  39457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39458. * @param scene Define the scene the sound track belongs to
  39459. * @param options
  39460. */
  39461. constructor(scene: Scene, options?: ISoundTrackOptions);
  39462. private _initializeSoundTrackAudioGraph;
  39463. /**
  39464. * Release the sound track and its associated resources
  39465. */
  39466. dispose(): void;
  39467. /**
  39468. * Adds a sound to this sound track
  39469. * @param sound define the cound to add
  39470. * @ignoreNaming
  39471. */
  39472. AddSound(sound: Sound): void;
  39473. /**
  39474. * Removes a sound to this sound track
  39475. * @param sound define the cound to remove
  39476. * @ignoreNaming
  39477. */
  39478. RemoveSound(sound: Sound): void;
  39479. /**
  39480. * Set a global volume for the full sound track.
  39481. * @param newVolume Define the new volume of the sound track
  39482. */
  39483. setVolume(newVolume: number): void;
  39484. /**
  39485. * Switch the panning model to HRTF:
  39486. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39488. */
  39489. switchPanningModelToHRTF(): void;
  39490. /**
  39491. * Switch the panning model to Equal Power:
  39492. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39494. */
  39495. switchPanningModelToEqualPower(): void;
  39496. /**
  39497. * Connect the sound track to an audio analyser allowing some amazing
  39498. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39500. * @param analyser The analyser to connect to the engine
  39501. */
  39502. connectToAnalyser(analyser: Analyser): void;
  39503. }
  39504. }
  39505. declare module "babylonjs/Audio/audioSceneComponent" {
  39506. import { Sound } from "babylonjs/Audio/sound";
  39507. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39508. import { Nullable } from "babylonjs/types";
  39509. import { Vector3 } from "babylonjs/Maths/math.vector";
  39510. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39511. import { Scene } from "babylonjs/scene";
  39512. import { AbstractScene } from "babylonjs/abstractScene";
  39513. import "babylonjs/Audio/audioEngine";
  39514. module "babylonjs/abstractScene" {
  39515. interface AbstractScene {
  39516. /**
  39517. * The list of sounds used in the scene.
  39518. */
  39519. sounds: Nullable<Array<Sound>>;
  39520. }
  39521. }
  39522. module "babylonjs/scene" {
  39523. interface Scene {
  39524. /**
  39525. * @hidden
  39526. * Backing field
  39527. */
  39528. _mainSoundTrack: SoundTrack;
  39529. /**
  39530. * The main sound track played by the scene.
  39531. * It cotains your primary collection of sounds.
  39532. */
  39533. mainSoundTrack: SoundTrack;
  39534. /**
  39535. * The list of sound tracks added to the scene
  39536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39537. */
  39538. soundTracks: Nullable<Array<SoundTrack>>;
  39539. /**
  39540. * Gets a sound using a given name
  39541. * @param name defines the name to search for
  39542. * @return the found sound or null if not found at all.
  39543. */
  39544. getSoundByName(name: string): Nullable<Sound>;
  39545. /**
  39546. * Gets or sets if audio support is enabled
  39547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39548. */
  39549. audioEnabled: boolean;
  39550. /**
  39551. * Gets or sets if audio will be output to headphones
  39552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39553. */
  39554. headphone: boolean;
  39555. /**
  39556. * Gets or sets custom audio listener position provider
  39557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39558. */
  39559. audioListenerPositionProvider: Nullable<() => Vector3>;
  39560. /**
  39561. * Gets or sets a refresh rate when using 3D audio positioning
  39562. */
  39563. audioPositioningRefreshRate: number;
  39564. }
  39565. }
  39566. /**
  39567. * Defines the sound scene component responsible to manage any sounds
  39568. * in a given scene.
  39569. */
  39570. export class AudioSceneComponent implements ISceneSerializableComponent {
  39571. /**
  39572. * The component name helpfull to identify the component in the list of scene components.
  39573. */
  39574. readonly name: string;
  39575. /**
  39576. * The scene the component belongs to.
  39577. */
  39578. scene: Scene;
  39579. private _audioEnabled;
  39580. /**
  39581. * Gets whether audio is enabled or not.
  39582. * Please use related enable/disable method to switch state.
  39583. */
  39584. get audioEnabled(): boolean;
  39585. private _headphone;
  39586. /**
  39587. * Gets whether audio is outputing to headphone or not.
  39588. * Please use the according Switch methods to change output.
  39589. */
  39590. get headphone(): boolean;
  39591. /**
  39592. * Gets or sets a refresh rate when using 3D audio positioning
  39593. */
  39594. audioPositioningRefreshRate: number;
  39595. private _audioListenerPositionProvider;
  39596. /**
  39597. * Gets the current audio listener position provider
  39598. */
  39599. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39600. /**
  39601. * Sets a custom listener position for all sounds in the scene
  39602. * By default, this is the position of the first active camera
  39603. */
  39604. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39605. /**
  39606. * Creates a new instance of the component for the given scene
  39607. * @param scene Defines the scene to register the component in
  39608. */
  39609. constructor(scene: Scene);
  39610. /**
  39611. * Registers the component in a given scene
  39612. */
  39613. register(): void;
  39614. /**
  39615. * Rebuilds the elements related to this component in case of
  39616. * context lost for instance.
  39617. */
  39618. rebuild(): void;
  39619. /**
  39620. * Serializes the component data to the specified json object
  39621. * @param serializationObject The object to serialize to
  39622. */
  39623. serialize(serializationObject: any): void;
  39624. /**
  39625. * Adds all the elements from the container to the scene
  39626. * @param container the container holding the elements
  39627. */
  39628. addFromContainer(container: AbstractScene): void;
  39629. /**
  39630. * Removes all the elements in the container from the scene
  39631. * @param container contains the elements to remove
  39632. * @param dispose if the removed element should be disposed (default: false)
  39633. */
  39634. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39635. /**
  39636. * Disposes the component and the associated ressources.
  39637. */
  39638. dispose(): void;
  39639. /**
  39640. * Disables audio in the associated scene.
  39641. */
  39642. disableAudio(): void;
  39643. /**
  39644. * Enables audio in the associated scene.
  39645. */
  39646. enableAudio(): void;
  39647. /**
  39648. * Switch audio to headphone output.
  39649. */
  39650. switchAudioModeForHeadphones(): void;
  39651. /**
  39652. * Switch audio to normal speakers.
  39653. */
  39654. switchAudioModeForNormalSpeakers(): void;
  39655. private _cachedCameraDirection;
  39656. private _cachedCameraPosition;
  39657. private _lastCheck;
  39658. private _afterRender;
  39659. }
  39660. }
  39661. declare module "babylonjs/Audio/weightedsound" {
  39662. import { Sound } from "babylonjs/Audio/sound";
  39663. /**
  39664. * Wraps one or more Sound objects and selects one with random weight for playback.
  39665. */
  39666. export class WeightedSound {
  39667. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39668. loop: boolean;
  39669. private _coneInnerAngle;
  39670. private _coneOuterAngle;
  39671. private _volume;
  39672. /** A Sound is currently playing. */
  39673. isPlaying: boolean;
  39674. /** A Sound is currently paused. */
  39675. isPaused: boolean;
  39676. private _sounds;
  39677. private _weights;
  39678. private _currentIndex?;
  39679. /**
  39680. * Creates a new WeightedSound from the list of sounds given.
  39681. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39682. * @param sounds Array of Sounds that will be selected from.
  39683. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39684. */
  39685. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39686. /**
  39687. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39688. */
  39689. get directionalConeInnerAngle(): number;
  39690. /**
  39691. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39692. */
  39693. set directionalConeInnerAngle(value: number);
  39694. /**
  39695. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39696. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39697. */
  39698. get directionalConeOuterAngle(): number;
  39699. /**
  39700. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39701. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39702. */
  39703. set directionalConeOuterAngle(value: number);
  39704. /**
  39705. * Playback volume.
  39706. */
  39707. get volume(): number;
  39708. /**
  39709. * Playback volume.
  39710. */
  39711. set volume(value: number);
  39712. private _onended;
  39713. /**
  39714. * Suspend playback
  39715. */
  39716. pause(): void;
  39717. /**
  39718. * Stop playback
  39719. */
  39720. stop(): void;
  39721. /**
  39722. * Start playback.
  39723. * @param startOffset Position the clip head at a specific time in seconds.
  39724. */
  39725. play(startOffset?: number): void;
  39726. }
  39727. }
  39728. declare module "babylonjs/Audio/index" {
  39729. export * from "babylonjs/Audio/analyser";
  39730. export * from "babylonjs/Audio/audioEngine";
  39731. export * from "babylonjs/Audio/audioSceneComponent";
  39732. export * from "babylonjs/Audio/sound";
  39733. export * from "babylonjs/Audio/soundTrack";
  39734. export * from "babylonjs/Audio/weightedsound";
  39735. }
  39736. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39737. import { Behavior } from "babylonjs/Behaviors/behavior";
  39738. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39739. import { BackEase } from "babylonjs/Animations/easing";
  39740. /**
  39741. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39742. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39743. */
  39744. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39745. /**
  39746. * Gets the name of the behavior.
  39747. */
  39748. get name(): string;
  39749. /**
  39750. * The easing function used by animations
  39751. */
  39752. static EasingFunction: BackEase;
  39753. /**
  39754. * The easing mode used by animations
  39755. */
  39756. static EasingMode: number;
  39757. /**
  39758. * The duration of the animation, in milliseconds
  39759. */
  39760. transitionDuration: number;
  39761. /**
  39762. * Length of the distance animated by the transition when lower radius is reached
  39763. */
  39764. lowerRadiusTransitionRange: number;
  39765. /**
  39766. * Length of the distance animated by the transition when upper radius is reached
  39767. */
  39768. upperRadiusTransitionRange: number;
  39769. private _autoTransitionRange;
  39770. /**
  39771. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39772. */
  39773. get autoTransitionRange(): boolean;
  39774. /**
  39775. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39776. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39777. */
  39778. set autoTransitionRange(value: boolean);
  39779. private _attachedCamera;
  39780. private _onAfterCheckInputsObserver;
  39781. private _onMeshTargetChangedObserver;
  39782. /**
  39783. * Initializes the behavior.
  39784. */
  39785. init(): void;
  39786. /**
  39787. * Attaches the behavior to its arc rotate camera.
  39788. * @param camera Defines the camera to attach the behavior to
  39789. */
  39790. attach(camera: ArcRotateCamera): void;
  39791. /**
  39792. * Detaches the behavior from its current arc rotate camera.
  39793. */
  39794. detach(): void;
  39795. private _radiusIsAnimating;
  39796. private _radiusBounceTransition;
  39797. private _animatables;
  39798. private _cachedWheelPrecision;
  39799. /**
  39800. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39801. * @param radiusLimit The limit to check against.
  39802. * @return Bool to indicate if at limit.
  39803. */
  39804. private _isRadiusAtLimit;
  39805. /**
  39806. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39807. * @param radiusDelta The delta by which to animate to. Can be negative.
  39808. */
  39809. private _applyBoundRadiusAnimation;
  39810. /**
  39811. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39812. */
  39813. protected _clearAnimationLocks(): void;
  39814. /**
  39815. * Stops and removes all animations that have been applied to the camera
  39816. */
  39817. stopAllAnimations(): void;
  39818. }
  39819. }
  39820. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39821. import { Behavior } from "babylonjs/Behaviors/behavior";
  39822. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39823. import { ExponentialEase } from "babylonjs/Animations/easing";
  39824. import { Nullable } from "babylonjs/types";
  39825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39826. import { Vector3 } from "babylonjs/Maths/math.vector";
  39827. /**
  39828. * 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.
  39829. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39830. */
  39831. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39832. /**
  39833. * Gets the name of the behavior.
  39834. */
  39835. get name(): string;
  39836. private _mode;
  39837. private _radiusScale;
  39838. private _positionScale;
  39839. private _defaultElevation;
  39840. private _elevationReturnTime;
  39841. private _elevationReturnWaitTime;
  39842. private _zoomStopsAnimation;
  39843. private _framingTime;
  39844. /**
  39845. * The easing function used by animations
  39846. */
  39847. static EasingFunction: ExponentialEase;
  39848. /**
  39849. * The easing mode used by animations
  39850. */
  39851. static EasingMode: number;
  39852. /**
  39853. * Sets the current mode used by the behavior
  39854. */
  39855. set mode(mode: number);
  39856. /**
  39857. * Gets current mode used by the behavior.
  39858. */
  39859. get mode(): number;
  39860. /**
  39861. * Sets the scale applied to the radius (1 by default)
  39862. */
  39863. set radiusScale(radius: number);
  39864. /**
  39865. * Gets the scale applied to the radius
  39866. */
  39867. get radiusScale(): number;
  39868. /**
  39869. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39870. */
  39871. set positionScale(scale: number);
  39872. /**
  39873. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39874. */
  39875. get positionScale(): number;
  39876. /**
  39877. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39878. * behaviour is triggered, in radians.
  39879. */
  39880. set defaultElevation(elevation: number);
  39881. /**
  39882. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39883. * behaviour is triggered, in radians.
  39884. */
  39885. get defaultElevation(): number;
  39886. /**
  39887. * Sets the time (in milliseconds) taken to return to the default beta position.
  39888. * Negative value indicates camera should not return to default.
  39889. */
  39890. set elevationReturnTime(speed: number);
  39891. /**
  39892. * Gets the time (in milliseconds) taken to return to the default beta position.
  39893. * Negative value indicates camera should not return to default.
  39894. */
  39895. get elevationReturnTime(): number;
  39896. /**
  39897. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39898. */
  39899. set elevationReturnWaitTime(time: number);
  39900. /**
  39901. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39902. */
  39903. get elevationReturnWaitTime(): number;
  39904. /**
  39905. * Sets the flag that indicates if user zooming should stop animation.
  39906. */
  39907. set zoomStopsAnimation(flag: boolean);
  39908. /**
  39909. * Gets the flag that indicates if user zooming should stop animation.
  39910. */
  39911. get zoomStopsAnimation(): boolean;
  39912. /**
  39913. * Sets the transition time when framing the mesh, in milliseconds
  39914. */
  39915. set framingTime(time: number);
  39916. /**
  39917. * Gets the transition time when framing the mesh, in milliseconds
  39918. */
  39919. get framingTime(): number;
  39920. /**
  39921. * Define if the behavior should automatically change the configured
  39922. * camera limits and sensibilities.
  39923. */
  39924. autoCorrectCameraLimitsAndSensibility: boolean;
  39925. private _onPrePointerObservableObserver;
  39926. private _onAfterCheckInputsObserver;
  39927. private _onMeshTargetChangedObserver;
  39928. private _attachedCamera;
  39929. private _isPointerDown;
  39930. private _lastInteractionTime;
  39931. /**
  39932. * Initializes the behavior.
  39933. */
  39934. init(): void;
  39935. /**
  39936. * Attaches the behavior to its arc rotate camera.
  39937. * @param camera Defines the camera to attach the behavior to
  39938. */
  39939. attach(camera: ArcRotateCamera): void;
  39940. /**
  39941. * Detaches the behavior from its current arc rotate camera.
  39942. */
  39943. detach(): void;
  39944. private _animatables;
  39945. private _betaIsAnimating;
  39946. private _betaTransition;
  39947. private _radiusTransition;
  39948. private _vectorTransition;
  39949. /**
  39950. * Targets the given mesh and updates zoom level accordingly.
  39951. * @param mesh The mesh to target.
  39952. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39953. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39954. */
  39955. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39956. /**
  39957. * Targets the given mesh with its children and updates zoom level accordingly.
  39958. * @param mesh The mesh to target.
  39959. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39960. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39961. */
  39962. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39963. /**
  39964. * Targets the given meshes with their children and updates zoom level accordingly.
  39965. * @param meshes The mesh to target.
  39966. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39967. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39968. */
  39969. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39970. /**
  39971. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39972. * @param minimumWorld Determines the smaller position of the bounding box extend
  39973. * @param maximumWorld Determines the bigger position of the bounding box extend
  39974. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39975. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39976. */
  39977. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39978. /**
  39979. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39980. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39981. * frustum width.
  39982. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39983. * to fully enclose the mesh in the viewing frustum.
  39984. */
  39985. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39986. /**
  39987. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39988. * is automatically returned to its default position (expected to be above ground plane).
  39989. */
  39990. private _maintainCameraAboveGround;
  39991. /**
  39992. * Returns the frustum slope based on the canvas ratio and camera FOV
  39993. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39994. */
  39995. private _getFrustumSlope;
  39996. /**
  39997. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39998. */
  39999. private _clearAnimationLocks;
  40000. /**
  40001. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40002. */
  40003. private _applyUserInteraction;
  40004. /**
  40005. * Stops and removes all animations that have been applied to the camera
  40006. */
  40007. stopAllAnimations(): void;
  40008. /**
  40009. * Gets a value indicating if the user is moving the camera
  40010. */
  40011. get isUserIsMoving(): boolean;
  40012. /**
  40013. * The camera can move all the way towards the mesh.
  40014. */
  40015. static IgnoreBoundsSizeMode: number;
  40016. /**
  40017. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40018. */
  40019. static FitFrustumSidesMode: number;
  40020. }
  40021. }
  40022. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  40023. import { Nullable } from "babylonjs/types";
  40024. import { Camera } from "babylonjs/Cameras/camera";
  40025. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40026. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40027. /**
  40028. * Base class for Camera Pointer Inputs.
  40029. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  40030. * for example usage.
  40031. */
  40032. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  40033. /**
  40034. * Defines the camera the input is attached to.
  40035. */
  40036. abstract camera: Camera;
  40037. /**
  40038. * Whether keyboard modifier keys are pressed at time of last mouse event.
  40039. */
  40040. protected _altKey: boolean;
  40041. protected _ctrlKey: boolean;
  40042. protected _metaKey: boolean;
  40043. protected _shiftKey: boolean;
  40044. /**
  40045. * Which mouse buttons were pressed at time of last mouse event.
  40046. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  40047. */
  40048. protected _buttonsPressed: number;
  40049. /**
  40050. * Defines the buttons associated with the input to handle camera move.
  40051. */
  40052. buttons: number[];
  40053. /**
  40054. * Attach the input controls to a specific dom element to get the input from.
  40055. * @param element Defines the element the controls should be listened from
  40056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40057. */
  40058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40059. /**
  40060. * Detach the current controls from the specified dom element.
  40061. * @param element Defines the element to stop listening the inputs from
  40062. */
  40063. detachControl(element: Nullable<HTMLElement>): void;
  40064. /**
  40065. * Gets the class name of the current input.
  40066. * @returns the class name
  40067. */
  40068. getClassName(): string;
  40069. /**
  40070. * Get the friendly name associated with the input class.
  40071. * @returns the input friendly name
  40072. */
  40073. getSimpleName(): string;
  40074. /**
  40075. * Called on pointer POINTERDOUBLETAP event.
  40076. * Override this method to provide functionality on POINTERDOUBLETAP event.
  40077. */
  40078. protected onDoubleTap(type: string): void;
  40079. /**
  40080. * Called on pointer POINTERMOVE event if only a single touch is active.
  40081. * Override this method to provide functionality.
  40082. */
  40083. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40084. /**
  40085. * Called on pointer POINTERMOVE event if multiple touches are active.
  40086. * Override this method to provide functionality.
  40087. */
  40088. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40089. /**
  40090. * Called on JS contextmenu event.
  40091. * Override this method to provide functionality.
  40092. */
  40093. protected onContextMenu(evt: PointerEvent): void;
  40094. /**
  40095. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40096. * press.
  40097. * Override this method to provide functionality.
  40098. */
  40099. protected onButtonDown(evt: PointerEvent): void;
  40100. /**
  40101. * Called each time a new POINTERUP event occurs. Ie, for each button
  40102. * release.
  40103. * Override this method to provide functionality.
  40104. */
  40105. protected onButtonUp(evt: PointerEvent): void;
  40106. /**
  40107. * Called when window becomes inactive.
  40108. * Override this method to provide functionality.
  40109. */
  40110. protected onLostFocus(): void;
  40111. private _pointerInput;
  40112. private _observer;
  40113. private _onLostFocus;
  40114. private pointA;
  40115. private pointB;
  40116. }
  40117. }
  40118. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  40119. import { Nullable } from "babylonjs/types";
  40120. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40121. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40122. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40123. /**
  40124. * Manage the pointers inputs to control an arc rotate camera.
  40125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40126. */
  40127. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  40128. /**
  40129. * Defines the camera the input is attached to.
  40130. */
  40131. camera: ArcRotateCamera;
  40132. /**
  40133. * Gets the class name of the current input.
  40134. * @returns the class name
  40135. */
  40136. getClassName(): string;
  40137. /**
  40138. * Defines the buttons associated with the input to handle camera move.
  40139. */
  40140. buttons: number[];
  40141. /**
  40142. * Defines the pointer angular sensibility along the X axis or how fast is
  40143. * the camera rotating.
  40144. */
  40145. angularSensibilityX: number;
  40146. /**
  40147. * Defines the pointer angular sensibility along the Y axis or how fast is
  40148. * the camera rotating.
  40149. */
  40150. angularSensibilityY: number;
  40151. /**
  40152. * Defines the pointer pinch precision or how fast is the camera zooming.
  40153. */
  40154. pinchPrecision: number;
  40155. /**
  40156. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40157. * from 0.
  40158. * It defines the percentage of current camera.radius to use as delta when
  40159. * pinch zoom is used.
  40160. */
  40161. pinchDeltaPercentage: number;
  40162. /**
  40163. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40164. * that any object in the plane at the camera's target point will scale
  40165. * perfectly with finger motion.
  40166. * Overrides pinchDeltaPercentage and pinchPrecision.
  40167. */
  40168. useNaturalPinchZoom: boolean;
  40169. /**
  40170. * Defines the pointer panning sensibility or how fast is the camera moving.
  40171. */
  40172. panningSensibility: number;
  40173. /**
  40174. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40175. */
  40176. multiTouchPanning: boolean;
  40177. /**
  40178. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  40179. * zoom (pinch) through multitouch.
  40180. */
  40181. multiTouchPanAndZoom: boolean;
  40182. /**
  40183. * Revers pinch action direction.
  40184. */
  40185. pinchInwards: boolean;
  40186. private _isPanClick;
  40187. private _twoFingerActivityCount;
  40188. private _isPinching;
  40189. /**
  40190. * Called on pointer POINTERMOVE event if only a single touch is active.
  40191. */
  40192. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40193. /**
  40194. * Called on pointer POINTERDOUBLETAP event.
  40195. */
  40196. protected onDoubleTap(type: string): void;
  40197. /**
  40198. * Called on pointer POINTERMOVE event if multiple touches are active.
  40199. */
  40200. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40201. /**
  40202. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40203. * press.
  40204. */
  40205. protected onButtonDown(evt: PointerEvent): void;
  40206. /**
  40207. * Called each time a new POINTERUP event occurs. Ie, for each button
  40208. * release.
  40209. */
  40210. protected onButtonUp(evt: PointerEvent): void;
  40211. /**
  40212. * Called when window becomes inactive.
  40213. */
  40214. protected onLostFocus(): void;
  40215. }
  40216. }
  40217. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  40218. import { Nullable } from "babylonjs/types";
  40219. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40220. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40221. /**
  40222. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40224. */
  40225. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40226. /**
  40227. * Defines the camera the input is attached to.
  40228. */
  40229. camera: ArcRotateCamera;
  40230. /**
  40231. * Defines the list of key codes associated with the up action (increase alpha)
  40232. */
  40233. keysUp: number[];
  40234. /**
  40235. * Defines the list of key codes associated with the down action (decrease alpha)
  40236. */
  40237. keysDown: number[];
  40238. /**
  40239. * Defines the list of key codes associated with the left action (increase beta)
  40240. */
  40241. keysLeft: number[];
  40242. /**
  40243. * Defines the list of key codes associated with the right action (decrease beta)
  40244. */
  40245. keysRight: number[];
  40246. /**
  40247. * Defines the list of key codes associated with the reset action.
  40248. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40249. */
  40250. keysReset: number[];
  40251. /**
  40252. * Defines the panning sensibility of the inputs.
  40253. * (How fast is the camera panning)
  40254. */
  40255. panningSensibility: number;
  40256. /**
  40257. * Defines the zooming sensibility of the inputs.
  40258. * (How fast is the camera zooming)
  40259. */
  40260. zoomingSensibility: number;
  40261. /**
  40262. * Defines whether maintaining the alt key down switch the movement mode from
  40263. * orientation to zoom.
  40264. */
  40265. useAltToZoom: boolean;
  40266. /**
  40267. * Rotation speed of the camera
  40268. */
  40269. angularSpeed: number;
  40270. private _keys;
  40271. private _ctrlPressed;
  40272. private _altPressed;
  40273. private _onCanvasBlurObserver;
  40274. private _onKeyboardObserver;
  40275. private _engine;
  40276. private _scene;
  40277. /**
  40278. * Attach the input controls to a specific dom element to get the input from.
  40279. * @param element Defines the element the controls should be listened from
  40280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40281. */
  40282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40283. /**
  40284. * Detach the current controls from the specified dom element.
  40285. * @param element Defines the element to stop listening the inputs from
  40286. */
  40287. detachControl(element: Nullable<HTMLElement>): void;
  40288. /**
  40289. * Update the current camera state depending on the inputs that have been used this frame.
  40290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40291. */
  40292. checkInputs(): void;
  40293. /**
  40294. * Gets the class name of the current intput.
  40295. * @returns the class name
  40296. */
  40297. getClassName(): string;
  40298. /**
  40299. * Get the friendly name associated with the input class.
  40300. * @returns the input friendly name
  40301. */
  40302. getSimpleName(): string;
  40303. }
  40304. }
  40305. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40306. import { Nullable } from "babylonjs/types";
  40307. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40308. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40309. /**
  40310. * Manage the mouse wheel inputs to control an arc rotate camera.
  40311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40312. */
  40313. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40314. /**
  40315. * Defines the camera the input is attached to.
  40316. */
  40317. camera: ArcRotateCamera;
  40318. /**
  40319. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40320. */
  40321. wheelPrecision: number;
  40322. /**
  40323. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40324. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40325. */
  40326. wheelDeltaPercentage: number;
  40327. private _wheel;
  40328. private _observer;
  40329. private computeDeltaFromMouseWheelLegacyEvent;
  40330. /**
  40331. * Attach the input controls to a specific dom element to get the input from.
  40332. * @param element Defines the element the controls should be listened from
  40333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40334. */
  40335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40336. /**
  40337. * Detach the current controls from the specified dom element.
  40338. * @param element Defines the element to stop listening the inputs from
  40339. */
  40340. detachControl(element: Nullable<HTMLElement>): void;
  40341. /**
  40342. * Gets the class name of the current intput.
  40343. * @returns the class name
  40344. */
  40345. getClassName(): string;
  40346. /**
  40347. * Get the friendly name associated with the input class.
  40348. * @returns the input friendly name
  40349. */
  40350. getSimpleName(): string;
  40351. }
  40352. }
  40353. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40354. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40355. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40356. /**
  40357. * Default Inputs manager for the ArcRotateCamera.
  40358. * It groups all the default supported inputs for ease of use.
  40359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40360. */
  40361. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40362. /**
  40363. * Instantiates a new ArcRotateCameraInputsManager.
  40364. * @param camera Defines the camera the inputs belong to
  40365. */
  40366. constructor(camera: ArcRotateCamera);
  40367. /**
  40368. * Add mouse wheel input support to the input manager.
  40369. * @returns the current input manager
  40370. */
  40371. addMouseWheel(): ArcRotateCameraInputsManager;
  40372. /**
  40373. * Add pointers input support to the input manager.
  40374. * @returns the current input manager
  40375. */
  40376. addPointers(): ArcRotateCameraInputsManager;
  40377. /**
  40378. * Add keyboard input support to the input manager.
  40379. * @returns the current input manager
  40380. */
  40381. addKeyboard(): ArcRotateCameraInputsManager;
  40382. }
  40383. }
  40384. declare module "babylonjs/Cameras/arcRotateCamera" {
  40385. import { Observable } from "babylonjs/Misc/observable";
  40386. import { Nullable } from "babylonjs/types";
  40387. import { Scene } from "babylonjs/scene";
  40388. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40390. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40391. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40392. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40393. import { Camera } from "babylonjs/Cameras/camera";
  40394. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40395. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40396. import { Collider } from "babylonjs/Collisions/collider";
  40397. /**
  40398. * This represents an orbital type of camera.
  40399. *
  40400. * 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.
  40401. * 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.
  40402. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40403. */
  40404. export class ArcRotateCamera extends TargetCamera {
  40405. /**
  40406. * Defines the rotation angle of the camera along the longitudinal axis.
  40407. */
  40408. alpha: number;
  40409. /**
  40410. * Defines the rotation angle of the camera along the latitudinal axis.
  40411. */
  40412. beta: number;
  40413. /**
  40414. * Defines the radius of the camera from it s target point.
  40415. */
  40416. radius: number;
  40417. protected _target: Vector3;
  40418. protected _targetHost: Nullable<AbstractMesh>;
  40419. /**
  40420. * Defines the target point of the camera.
  40421. * The camera looks towards it form the radius distance.
  40422. */
  40423. get target(): Vector3;
  40424. set target(value: Vector3);
  40425. /**
  40426. * Define the current local position of the camera in the scene
  40427. */
  40428. get position(): Vector3;
  40429. set position(newPosition: Vector3);
  40430. protected _upVector: Vector3;
  40431. protected _upToYMatrix: Matrix;
  40432. protected _YToUpMatrix: Matrix;
  40433. /**
  40434. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40435. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40436. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40437. */
  40438. set upVector(vec: Vector3);
  40439. get upVector(): Vector3;
  40440. /**
  40441. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40442. */
  40443. setMatUp(): void;
  40444. /**
  40445. * Current inertia value on the longitudinal axis.
  40446. * The bigger this number the longer it will take for the camera to stop.
  40447. */
  40448. inertialAlphaOffset: number;
  40449. /**
  40450. * Current inertia value on the latitudinal axis.
  40451. * The bigger this number the longer it will take for the camera to stop.
  40452. */
  40453. inertialBetaOffset: number;
  40454. /**
  40455. * Current inertia value on the radius axis.
  40456. * The bigger this number the longer it will take for the camera to stop.
  40457. */
  40458. inertialRadiusOffset: number;
  40459. /**
  40460. * Minimum allowed angle on the longitudinal axis.
  40461. * This can help limiting how the Camera is able to move in the scene.
  40462. */
  40463. lowerAlphaLimit: Nullable<number>;
  40464. /**
  40465. * Maximum allowed angle on the longitudinal axis.
  40466. * This can help limiting how the Camera is able to move in the scene.
  40467. */
  40468. upperAlphaLimit: Nullable<number>;
  40469. /**
  40470. * Minimum allowed angle on the latitudinal axis.
  40471. * This can help limiting how the Camera is able to move in the scene.
  40472. */
  40473. lowerBetaLimit: number;
  40474. /**
  40475. * Maximum allowed angle on the latitudinal axis.
  40476. * This can help limiting how the Camera is able to move in the scene.
  40477. */
  40478. upperBetaLimit: number;
  40479. /**
  40480. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40481. * This can help limiting how the Camera is able to move in the scene.
  40482. */
  40483. lowerRadiusLimit: Nullable<number>;
  40484. /**
  40485. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40486. * This can help limiting how the Camera is able to move in the scene.
  40487. */
  40488. upperRadiusLimit: Nullable<number>;
  40489. /**
  40490. * Defines the current inertia value used during panning of the camera along the X axis.
  40491. */
  40492. inertialPanningX: number;
  40493. /**
  40494. * Defines the current inertia value used during panning of the camera along the Y axis.
  40495. */
  40496. inertialPanningY: number;
  40497. /**
  40498. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40499. * Basically if your fingers moves away from more than this distance you will be considered
  40500. * in pinch mode.
  40501. */
  40502. pinchToPanMaxDistance: number;
  40503. /**
  40504. * Defines the maximum distance the camera can pan.
  40505. * This could help keeping the cammera always in your scene.
  40506. */
  40507. panningDistanceLimit: Nullable<number>;
  40508. /**
  40509. * Defines the target of the camera before paning.
  40510. */
  40511. panningOriginTarget: Vector3;
  40512. /**
  40513. * Defines the value of the inertia used during panning.
  40514. * 0 would mean stop inertia and one would mean no decelleration at all.
  40515. */
  40516. panningInertia: number;
  40517. /**
  40518. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40519. */
  40520. get angularSensibilityX(): number;
  40521. set angularSensibilityX(value: number);
  40522. /**
  40523. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40524. */
  40525. get angularSensibilityY(): number;
  40526. set angularSensibilityY(value: number);
  40527. /**
  40528. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40529. */
  40530. get pinchPrecision(): number;
  40531. set pinchPrecision(value: number);
  40532. /**
  40533. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40534. * It will be used instead of pinchDeltaPrecision if different from 0.
  40535. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40536. */
  40537. get pinchDeltaPercentage(): number;
  40538. set pinchDeltaPercentage(value: number);
  40539. /**
  40540. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40541. * and pinch delta percentage.
  40542. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40543. * that any object in the plane at the camera's target point will scale
  40544. * perfectly with finger motion.
  40545. */
  40546. get useNaturalPinchZoom(): boolean;
  40547. set useNaturalPinchZoom(value: boolean);
  40548. /**
  40549. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40550. */
  40551. get panningSensibility(): number;
  40552. set panningSensibility(value: number);
  40553. /**
  40554. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40555. */
  40556. get keysUp(): number[];
  40557. set keysUp(value: number[]);
  40558. /**
  40559. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40560. */
  40561. get keysDown(): number[];
  40562. set keysDown(value: number[]);
  40563. /**
  40564. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40565. */
  40566. get keysLeft(): number[];
  40567. set keysLeft(value: number[]);
  40568. /**
  40569. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40570. */
  40571. get keysRight(): number[];
  40572. set keysRight(value: number[]);
  40573. /**
  40574. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40575. */
  40576. get wheelPrecision(): number;
  40577. set wheelPrecision(value: number);
  40578. /**
  40579. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40580. * It will be used instead of pinchDeltaPrecision if different from 0.
  40581. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40582. */
  40583. get wheelDeltaPercentage(): number;
  40584. set wheelDeltaPercentage(value: number);
  40585. /**
  40586. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40587. */
  40588. zoomOnFactor: number;
  40589. /**
  40590. * Defines a screen offset for the camera position.
  40591. */
  40592. targetScreenOffset: Vector2;
  40593. /**
  40594. * Allows the camera to be completely reversed.
  40595. * If false the camera can not arrive upside down.
  40596. */
  40597. allowUpsideDown: boolean;
  40598. /**
  40599. * Define if double tap/click is used to restore the previously saved state of the camera.
  40600. */
  40601. useInputToRestoreState: boolean;
  40602. /** @hidden */
  40603. _viewMatrix: Matrix;
  40604. /** @hidden */
  40605. _useCtrlForPanning: boolean;
  40606. /** @hidden */
  40607. _panningMouseButton: number;
  40608. /**
  40609. * Defines the input associated to the camera.
  40610. */
  40611. inputs: ArcRotateCameraInputsManager;
  40612. /** @hidden */
  40613. _reset: () => void;
  40614. /**
  40615. * Defines the allowed panning axis.
  40616. */
  40617. panningAxis: Vector3;
  40618. protected _localDirection: Vector3;
  40619. protected _transformedDirection: Vector3;
  40620. private _bouncingBehavior;
  40621. /**
  40622. * Gets the bouncing behavior of the camera if it has been enabled.
  40623. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40624. */
  40625. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40626. /**
  40627. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40628. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40629. */
  40630. get useBouncingBehavior(): boolean;
  40631. set useBouncingBehavior(value: boolean);
  40632. private _framingBehavior;
  40633. /**
  40634. * Gets the framing behavior of the camera if it has been enabled.
  40635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40636. */
  40637. get framingBehavior(): Nullable<FramingBehavior>;
  40638. /**
  40639. * Defines if the framing behavior of the camera is enabled on the camera.
  40640. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40641. */
  40642. get useFramingBehavior(): boolean;
  40643. set useFramingBehavior(value: boolean);
  40644. private _autoRotationBehavior;
  40645. /**
  40646. * Gets the auto rotation behavior of the camera if it has been enabled.
  40647. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40648. */
  40649. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40650. /**
  40651. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40652. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40653. */
  40654. get useAutoRotationBehavior(): boolean;
  40655. set useAutoRotationBehavior(value: boolean);
  40656. /**
  40657. * Observable triggered when the mesh target has been changed on the camera.
  40658. */
  40659. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40660. /**
  40661. * Event raised when the camera is colliding with a mesh.
  40662. */
  40663. onCollide: (collidedMesh: AbstractMesh) => void;
  40664. /**
  40665. * Defines whether the camera should check collision with the objects oh the scene.
  40666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40667. */
  40668. checkCollisions: boolean;
  40669. /**
  40670. * Defines the collision radius of the camera.
  40671. * This simulates a sphere around the camera.
  40672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40673. */
  40674. collisionRadius: Vector3;
  40675. protected _collider: Collider;
  40676. protected _previousPosition: Vector3;
  40677. protected _collisionVelocity: Vector3;
  40678. protected _newPosition: Vector3;
  40679. protected _previousAlpha: number;
  40680. protected _previousBeta: number;
  40681. protected _previousRadius: number;
  40682. protected _collisionTriggered: boolean;
  40683. protected _targetBoundingCenter: Nullable<Vector3>;
  40684. private _computationVector;
  40685. /**
  40686. * Instantiates a new ArcRotateCamera in a given scene
  40687. * @param name Defines the name of the camera
  40688. * @param alpha Defines the camera rotation along the logitudinal axis
  40689. * @param beta Defines the camera rotation along the latitudinal axis
  40690. * @param radius Defines the camera distance from its target
  40691. * @param target Defines the camera target
  40692. * @param scene Defines the scene the camera belongs to
  40693. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40694. */
  40695. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40696. /** @hidden */
  40697. _initCache(): void;
  40698. /** @hidden */
  40699. _updateCache(ignoreParentClass?: boolean): void;
  40700. protected _getTargetPosition(): Vector3;
  40701. private _storedAlpha;
  40702. private _storedBeta;
  40703. private _storedRadius;
  40704. private _storedTarget;
  40705. private _storedTargetScreenOffset;
  40706. /**
  40707. * Stores the current state of the camera (alpha, beta, radius and target)
  40708. * @returns the camera itself
  40709. */
  40710. storeState(): Camera;
  40711. /**
  40712. * @hidden
  40713. * Restored camera state. You must call storeState() first
  40714. */
  40715. _restoreStateValues(): boolean;
  40716. /** @hidden */
  40717. _isSynchronizedViewMatrix(): boolean;
  40718. /**
  40719. * Attached controls to the current camera.
  40720. * @param element Defines the element the controls should be listened from
  40721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40722. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40723. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40724. */
  40725. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40726. /**
  40727. * Detach the current controls from the camera.
  40728. * The camera will stop reacting to inputs.
  40729. * @param element Defines the element to stop listening the inputs from
  40730. */
  40731. detachControl(element: HTMLElement): void;
  40732. /** @hidden */
  40733. _checkInputs(): void;
  40734. protected _checkLimits(): void;
  40735. /**
  40736. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40737. */
  40738. rebuildAnglesAndRadius(): void;
  40739. /**
  40740. * Use a position to define the current camera related information like alpha, beta and radius
  40741. * @param position Defines the position to set the camera at
  40742. */
  40743. setPosition(position: Vector3): void;
  40744. /**
  40745. * Defines the target the camera should look at.
  40746. * This will automatically adapt alpha beta and radius to fit within the new target.
  40747. * @param target Defines the new target as a Vector or a mesh
  40748. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40749. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40750. */
  40751. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40752. /** @hidden */
  40753. _getViewMatrix(): Matrix;
  40754. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40755. /**
  40756. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40757. * @param meshes Defines the mesh to zoom on
  40758. * @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)
  40759. */
  40760. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40761. /**
  40762. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40763. * The target will be changed but the radius
  40764. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40765. * @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)
  40766. */
  40767. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40768. min: Vector3;
  40769. max: Vector3;
  40770. distance: number;
  40771. }, doNotUpdateMaxZ?: boolean): void;
  40772. /**
  40773. * @override
  40774. * Override Camera.createRigCamera
  40775. */
  40776. createRigCamera(name: string, cameraIndex: number): Camera;
  40777. /**
  40778. * @hidden
  40779. * @override
  40780. * Override Camera._updateRigCameras
  40781. */
  40782. _updateRigCameras(): void;
  40783. /**
  40784. * Destroy the camera and release the current resources hold by it.
  40785. */
  40786. dispose(): void;
  40787. /**
  40788. * Gets the current object class name.
  40789. * @return the class name
  40790. */
  40791. getClassName(): string;
  40792. }
  40793. }
  40794. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40795. import { Behavior } from "babylonjs/Behaviors/behavior";
  40796. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40797. /**
  40798. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40800. */
  40801. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40802. /**
  40803. * Gets the name of the behavior.
  40804. */
  40805. get name(): string;
  40806. private _zoomStopsAnimation;
  40807. private _idleRotationSpeed;
  40808. private _idleRotationWaitTime;
  40809. private _idleRotationSpinupTime;
  40810. /**
  40811. * Sets the flag that indicates if user zooming should stop animation.
  40812. */
  40813. set zoomStopsAnimation(flag: boolean);
  40814. /**
  40815. * Gets the flag that indicates if user zooming should stop animation.
  40816. */
  40817. get zoomStopsAnimation(): boolean;
  40818. /**
  40819. * Sets the default speed at which the camera rotates around the model.
  40820. */
  40821. set idleRotationSpeed(speed: number);
  40822. /**
  40823. * Gets the default speed at which the camera rotates around the model.
  40824. */
  40825. get idleRotationSpeed(): number;
  40826. /**
  40827. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40828. */
  40829. set idleRotationWaitTime(time: number);
  40830. /**
  40831. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40832. */
  40833. get idleRotationWaitTime(): number;
  40834. /**
  40835. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40836. */
  40837. set idleRotationSpinupTime(time: number);
  40838. /**
  40839. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40840. */
  40841. get idleRotationSpinupTime(): number;
  40842. /**
  40843. * Gets a value indicating if the camera is currently rotating because of this behavior
  40844. */
  40845. get rotationInProgress(): boolean;
  40846. private _onPrePointerObservableObserver;
  40847. private _onAfterCheckInputsObserver;
  40848. private _attachedCamera;
  40849. private _isPointerDown;
  40850. private _lastFrameTime;
  40851. private _lastInteractionTime;
  40852. private _cameraRotationSpeed;
  40853. /**
  40854. * Initializes the behavior.
  40855. */
  40856. init(): void;
  40857. /**
  40858. * Attaches the behavior to its arc rotate camera.
  40859. * @param camera Defines the camera to attach the behavior to
  40860. */
  40861. attach(camera: ArcRotateCamera): void;
  40862. /**
  40863. * Detaches the behavior from its current arc rotate camera.
  40864. */
  40865. detach(): void;
  40866. /**
  40867. * Returns true if user is scrolling.
  40868. * @return true if user is scrolling.
  40869. */
  40870. private _userIsZooming;
  40871. private _lastFrameRadius;
  40872. private _shouldAnimationStopForInteraction;
  40873. /**
  40874. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40875. */
  40876. private _applyUserInteraction;
  40877. private _userIsMoving;
  40878. }
  40879. }
  40880. declare module "babylonjs/Behaviors/Cameras/index" {
  40881. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40882. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40883. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40884. }
  40885. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40886. import { Mesh } from "babylonjs/Meshes/mesh";
  40887. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40888. import { Behavior } from "babylonjs/Behaviors/behavior";
  40889. /**
  40890. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40891. */
  40892. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40893. private ui;
  40894. /**
  40895. * The name of the behavior
  40896. */
  40897. name: string;
  40898. /**
  40899. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40900. */
  40901. distanceAwayFromFace: number;
  40902. /**
  40903. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40904. */
  40905. distanceAwayFromBottomOfFace: number;
  40906. private _faceVectors;
  40907. private _target;
  40908. private _scene;
  40909. private _onRenderObserver;
  40910. private _tmpMatrix;
  40911. private _tmpVector;
  40912. /**
  40913. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40914. * @param ui The transform node that should be attched to the mesh
  40915. */
  40916. constructor(ui: TransformNode);
  40917. /**
  40918. * Initializes the behavior
  40919. */
  40920. init(): void;
  40921. private _closestFace;
  40922. private _zeroVector;
  40923. private _lookAtTmpMatrix;
  40924. private _lookAtToRef;
  40925. /**
  40926. * Attaches the AttachToBoxBehavior to the passed in mesh
  40927. * @param target The mesh that the specified node will be attached to
  40928. */
  40929. attach(target: Mesh): void;
  40930. /**
  40931. * Detaches the behavior from the mesh
  40932. */
  40933. detach(): void;
  40934. }
  40935. }
  40936. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40937. import { Behavior } from "babylonjs/Behaviors/behavior";
  40938. import { Mesh } from "babylonjs/Meshes/mesh";
  40939. /**
  40940. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40941. */
  40942. export class FadeInOutBehavior implements Behavior<Mesh> {
  40943. /**
  40944. * Time in milliseconds to delay before fading in (Default: 0)
  40945. */
  40946. delay: number;
  40947. /**
  40948. * Time in milliseconds for the mesh to fade in (Default: 300)
  40949. */
  40950. fadeInTime: number;
  40951. private _millisecondsPerFrame;
  40952. private _hovered;
  40953. private _hoverValue;
  40954. private _ownerNode;
  40955. /**
  40956. * Instatiates the FadeInOutBehavior
  40957. */
  40958. constructor();
  40959. /**
  40960. * The name of the behavior
  40961. */
  40962. get name(): string;
  40963. /**
  40964. * Initializes the behavior
  40965. */
  40966. init(): void;
  40967. /**
  40968. * Attaches the fade behavior on the passed in mesh
  40969. * @param ownerNode The mesh that will be faded in/out once attached
  40970. */
  40971. attach(ownerNode: Mesh): void;
  40972. /**
  40973. * Detaches the behavior from the mesh
  40974. */
  40975. detach(): void;
  40976. /**
  40977. * Triggers the mesh to begin fading in or out
  40978. * @param value if the object should fade in or out (true to fade in)
  40979. */
  40980. fadeIn(value: boolean): void;
  40981. private _update;
  40982. private _setAllVisibility;
  40983. }
  40984. }
  40985. declare module "babylonjs/Misc/pivotTools" {
  40986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40987. /**
  40988. * Class containing a set of static utilities functions for managing Pivots
  40989. * @hidden
  40990. */
  40991. export class PivotTools {
  40992. private static _PivotCached;
  40993. private static _OldPivotPoint;
  40994. private static _PivotTranslation;
  40995. private static _PivotTmpVector;
  40996. /** @hidden */
  40997. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40998. /** @hidden */
  40999. static _RestorePivotPoint(mesh: AbstractMesh): void;
  41000. }
  41001. }
  41002. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  41003. import { Scene } from "babylonjs/scene";
  41004. import { Vector4 } from "babylonjs/Maths/math.vector";
  41005. import { Mesh } from "babylonjs/Meshes/mesh";
  41006. import { Nullable } from "babylonjs/types";
  41007. import { Plane } from "babylonjs/Maths/math.plane";
  41008. /**
  41009. * Class containing static functions to help procedurally build meshes
  41010. */
  41011. export class PlaneBuilder {
  41012. /**
  41013. * Creates a plane mesh
  41014. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  41015. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  41016. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  41017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41018. * * 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
  41019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41020. * @param name defines the name of the mesh
  41021. * @param options defines the options used to create the mesh
  41022. * @param scene defines the hosting scene
  41023. * @returns the plane mesh
  41024. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  41025. */
  41026. static CreatePlane(name: string, options: {
  41027. size?: number;
  41028. width?: number;
  41029. height?: number;
  41030. sideOrientation?: number;
  41031. frontUVs?: Vector4;
  41032. backUVs?: Vector4;
  41033. updatable?: boolean;
  41034. sourcePlane?: Plane;
  41035. }, scene?: Nullable<Scene>): Mesh;
  41036. }
  41037. }
  41038. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  41039. import { Behavior } from "babylonjs/Behaviors/behavior";
  41040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41041. import { Observable } from "babylonjs/Misc/observable";
  41042. import { Vector3 } from "babylonjs/Maths/math.vector";
  41043. import { Ray } from "babylonjs/Culling/ray";
  41044. import "babylonjs/Meshes/Builders/planeBuilder";
  41045. /**
  41046. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41047. */
  41048. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  41049. private static _AnyMouseID;
  41050. /**
  41051. * Abstract mesh the behavior is set on
  41052. */
  41053. attachedNode: AbstractMesh;
  41054. private _dragPlane;
  41055. private _scene;
  41056. private _pointerObserver;
  41057. private _beforeRenderObserver;
  41058. private static _planeScene;
  41059. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  41060. /**
  41061. * 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)
  41062. */
  41063. maxDragAngle: number;
  41064. /**
  41065. * @hidden
  41066. */
  41067. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41068. /**
  41069. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41070. */
  41071. currentDraggingPointerID: number;
  41072. /**
  41073. * The last position where the pointer hit the drag plane in world space
  41074. */
  41075. lastDragPosition: Vector3;
  41076. /**
  41077. * If the behavior is currently in a dragging state
  41078. */
  41079. dragging: boolean;
  41080. /**
  41081. * 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)
  41082. */
  41083. dragDeltaRatio: number;
  41084. /**
  41085. * If the drag plane orientation should be updated during the dragging (Default: true)
  41086. */
  41087. updateDragPlane: boolean;
  41088. private _debugMode;
  41089. private _moving;
  41090. /**
  41091. * Fires each time the attached mesh is dragged with the pointer
  41092. * * delta between last drag position and current drag position in world space
  41093. * * dragDistance along the drag axis
  41094. * * dragPlaneNormal normal of the current drag plane used during the drag
  41095. * * dragPlanePoint in world space where the drag intersects the drag plane
  41096. */
  41097. onDragObservable: Observable<{
  41098. delta: Vector3;
  41099. dragPlanePoint: Vector3;
  41100. dragPlaneNormal: Vector3;
  41101. dragDistance: number;
  41102. pointerId: number;
  41103. }>;
  41104. /**
  41105. * Fires each time a drag begins (eg. mouse down on mesh)
  41106. */
  41107. onDragStartObservable: Observable<{
  41108. dragPlanePoint: Vector3;
  41109. pointerId: number;
  41110. }>;
  41111. /**
  41112. * Fires each time a drag ends (eg. mouse release after drag)
  41113. */
  41114. onDragEndObservable: Observable<{
  41115. dragPlanePoint: Vector3;
  41116. pointerId: number;
  41117. }>;
  41118. /**
  41119. * If the attached mesh should be moved when dragged
  41120. */
  41121. moveAttached: boolean;
  41122. /**
  41123. * If the drag behavior will react to drag events (Default: true)
  41124. */
  41125. enabled: boolean;
  41126. /**
  41127. * If pointer events should start and release the drag (Default: true)
  41128. */
  41129. startAndReleaseDragOnPointerEvents: boolean;
  41130. /**
  41131. * If camera controls should be detached during the drag
  41132. */
  41133. detachCameraControls: boolean;
  41134. /**
  41135. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41136. */
  41137. useObjectOrientationForDragging: boolean;
  41138. private _options;
  41139. /**
  41140. * Gets the options used by the behavior
  41141. */
  41142. get options(): {
  41143. dragAxis?: Vector3;
  41144. dragPlaneNormal?: Vector3;
  41145. };
  41146. /**
  41147. * Sets the options used by the behavior
  41148. */
  41149. set options(options: {
  41150. dragAxis?: Vector3;
  41151. dragPlaneNormal?: Vector3;
  41152. });
  41153. /**
  41154. * Creates a pointer drag behavior that can be attached to a mesh
  41155. * @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)
  41156. */
  41157. constructor(options?: {
  41158. dragAxis?: Vector3;
  41159. dragPlaneNormal?: Vector3;
  41160. });
  41161. /**
  41162. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41163. */
  41164. validateDrag: (targetPosition: Vector3) => boolean;
  41165. /**
  41166. * The name of the behavior
  41167. */
  41168. get name(): string;
  41169. /**
  41170. * Initializes the behavior
  41171. */
  41172. init(): void;
  41173. private _tmpVector;
  41174. private _alternatePickedPoint;
  41175. private _worldDragAxis;
  41176. private _targetPosition;
  41177. private _attachedElement;
  41178. /**
  41179. * Attaches the drag behavior the passed in mesh
  41180. * @param ownerNode The mesh that will be dragged around once attached
  41181. * @param predicate Predicate to use for pick filtering
  41182. */
  41183. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  41184. /**
  41185. * Force relase the drag action by code.
  41186. */
  41187. releaseDrag(): void;
  41188. private _startDragRay;
  41189. private _lastPointerRay;
  41190. /**
  41191. * Simulates the start of a pointer drag event on the behavior
  41192. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41193. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41194. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41195. */
  41196. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41197. private _startDrag;
  41198. private _dragDelta;
  41199. private _moveDrag;
  41200. private _pickWithRayOnDragPlane;
  41201. private _pointA;
  41202. private _pointB;
  41203. private _pointC;
  41204. private _lineA;
  41205. private _lineB;
  41206. private _localAxis;
  41207. private _lookAt;
  41208. private _updateDragPlanePosition;
  41209. /**
  41210. * Detaches the behavior from the mesh
  41211. */
  41212. detach(): void;
  41213. }
  41214. }
  41215. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  41216. import { Mesh } from "babylonjs/Meshes/mesh";
  41217. import { Behavior } from "babylonjs/Behaviors/behavior";
  41218. /**
  41219. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41220. */
  41221. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41222. private _dragBehaviorA;
  41223. private _dragBehaviorB;
  41224. private _startDistance;
  41225. private _initialScale;
  41226. private _targetScale;
  41227. private _ownerNode;
  41228. private _sceneRenderObserver;
  41229. /**
  41230. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41231. */
  41232. constructor();
  41233. /**
  41234. * The name of the behavior
  41235. */
  41236. get name(): string;
  41237. /**
  41238. * Initializes the behavior
  41239. */
  41240. init(): void;
  41241. private _getCurrentDistance;
  41242. /**
  41243. * Attaches the scale behavior the passed in mesh
  41244. * @param ownerNode The mesh that will be scaled around once attached
  41245. */
  41246. attach(ownerNode: Mesh): void;
  41247. /**
  41248. * Detaches the behavior from the mesh
  41249. */
  41250. detach(): void;
  41251. }
  41252. }
  41253. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  41254. import { Behavior } from "babylonjs/Behaviors/behavior";
  41255. import { Mesh } from "babylonjs/Meshes/mesh";
  41256. import { Observable } from "babylonjs/Misc/observable";
  41257. /**
  41258. * 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
  41259. */
  41260. export class SixDofDragBehavior implements Behavior<Mesh> {
  41261. private static _virtualScene;
  41262. private _ownerNode;
  41263. private _sceneRenderObserver;
  41264. private _scene;
  41265. private _targetPosition;
  41266. private _virtualOriginMesh;
  41267. private _virtualDragMesh;
  41268. private _pointerObserver;
  41269. private _moving;
  41270. private _startingOrientation;
  41271. private _attachedElement;
  41272. /**
  41273. * 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)
  41274. */
  41275. private zDragFactor;
  41276. /**
  41277. * If the object should rotate to face the drag origin
  41278. */
  41279. rotateDraggedObject: boolean;
  41280. /**
  41281. * If the behavior is currently in a dragging state
  41282. */
  41283. dragging: boolean;
  41284. /**
  41285. * 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)
  41286. */
  41287. dragDeltaRatio: number;
  41288. /**
  41289. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41290. */
  41291. currentDraggingPointerID: number;
  41292. /**
  41293. * If camera controls should be detached during the drag
  41294. */
  41295. detachCameraControls: boolean;
  41296. /**
  41297. * Fires each time a drag starts
  41298. */
  41299. onDragStartObservable: Observable<{}>;
  41300. /**
  41301. * Fires each time a drag ends (eg. mouse release after drag)
  41302. */
  41303. onDragEndObservable: Observable<{}>;
  41304. /**
  41305. * 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
  41306. */
  41307. constructor();
  41308. /**
  41309. * The name of the behavior
  41310. */
  41311. get name(): string;
  41312. /**
  41313. * Initializes the behavior
  41314. */
  41315. init(): void;
  41316. /**
  41317. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41318. */
  41319. private get _pointerCamera();
  41320. /**
  41321. * Attaches the scale behavior the passed in mesh
  41322. * @param ownerNode The mesh that will be scaled around once attached
  41323. */
  41324. attach(ownerNode: Mesh): void;
  41325. /**
  41326. * Detaches the behavior from the mesh
  41327. */
  41328. detach(): void;
  41329. }
  41330. }
  41331. declare module "babylonjs/Behaviors/Meshes/index" {
  41332. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41333. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41334. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41335. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41336. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41337. }
  41338. declare module "babylonjs/Behaviors/index" {
  41339. export * from "babylonjs/Behaviors/behavior";
  41340. export * from "babylonjs/Behaviors/Cameras/index";
  41341. export * from "babylonjs/Behaviors/Meshes/index";
  41342. }
  41343. declare module "babylonjs/Bones/boneIKController" {
  41344. import { Bone } from "babylonjs/Bones/bone";
  41345. import { Vector3 } from "babylonjs/Maths/math.vector";
  41346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41347. import { Nullable } from "babylonjs/types";
  41348. /**
  41349. * Class used to apply inverse kinematics to bones
  41350. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41351. */
  41352. export class BoneIKController {
  41353. private static _tmpVecs;
  41354. private static _tmpQuat;
  41355. private static _tmpMats;
  41356. /**
  41357. * Gets or sets the target mesh
  41358. */
  41359. targetMesh: AbstractMesh;
  41360. /** Gets or sets the mesh used as pole */
  41361. poleTargetMesh: AbstractMesh;
  41362. /**
  41363. * Gets or sets the bone used as pole
  41364. */
  41365. poleTargetBone: Nullable<Bone>;
  41366. /**
  41367. * Gets or sets the target position
  41368. */
  41369. targetPosition: Vector3;
  41370. /**
  41371. * Gets or sets the pole target position
  41372. */
  41373. poleTargetPosition: Vector3;
  41374. /**
  41375. * Gets or sets the pole target local offset
  41376. */
  41377. poleTargetLocalOffset: Vector3;
  41378. /**
  41379. * Gets or sets the pole angle
  41380. */
  41381. poleAngle: number;
  41382. /**
  41383. * Gets or sets the mesh associated with the controller
  41384. */
  41385. mesh: AbstractMesh;
  41386. /**
  41387. * 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)
  41388. */
  41389. slerpAmount: number;
  41390. private _bone1Quat;
  41391. private _bone1Mat;
  41392. private _bone2Ang;
  41393. private _bone1;
  41394. private _bone2;
  41395. private _bone1Length;
  41396. private _bone2Length;
  41397. private _maxAngle;
  41398. private _maxReach;
  41399. private _rightHandedSystem;
  41400. private _bendAxis;
  41401. private _slerping;
  41402. private _adjustRoll;
  41403. /**
  41404. * Gets or sets maximum allowed angle
  41405. */
  41406. get maxAngle(): number;
  41407. set maxAngle(value: number);
  41408. /**
  41409. * Creates a new BoneIKController
  41410. * @param mesh defines the mesh to control
  41411. * @param bone defines the bone to control
  41412. * @param options defines options to set up the controller
  41413. */
  41414. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41415. targetMesh?: AbstractMesh;
  41416. poleTargetMesh?: AbstractMesh;
  41417. poleTargetBone?: Bone;
  41418. poleTargetLocalOffset?: Vector3;
  41419. poleAngle?: number;
  41420. bendAxis?: Vector3;
  41421. maxAngle?: number;
  41422. slerpAmount?: number;
  41423. });
  41424. private _setMaxAngle;
  41425. /**
  41426. * Force the controller to update the bones
  41427. */
  41428. update(): void;
  41429. }
  41430. }
  41431. declare module "babylonjs/Bones/boneLookController" {
  41432. import { Vector3 } from "babylonjs/Maths/math.vector";
  41433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41434. import { Bone } from "babylonjs/Bones/bone";
  41435. import { Space } from "babylonjs/Maths/math.axis";
  41436. /**
  41437. * Class used to make a bone look toward a point in space
  41438. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41439. */
  41440. export class BoneLookController {
  41441. private static _tmpVecs;
  41442. private static _tmpQuat;
  41443. private static _tmpMats;
  41444. /**
  41445. * The target Vector3 that the bone will look at
  41446. */
  41447. target: Vector3;
  41448. /**
  41449. * The mesh that the bone is attached to
  41450. */
  41451. mesh: AbstractMesh;
  41452. /**
  41453. * The bone that will be looking to the target
  41454. */
  41455. bone: Bone;
  41456. /**
  41457. * The up axis of the coordinate system that is used when the bone is rotated
  41458. */
  41459. upAxis: Vector3;
  41460. /**
  41461. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41462. */
  41463. upAxisSpace: Space;
  41464. /**
  41465. * Used to make an adjustment to the yaw of the bone
  41466. */
  41467. adjustYaw: number;
  41468. /**
  41469. * Used to make an adjustment to the pitch of the bone
  41470. */
  41471. adjustPitch: number;
  41472. /**
  41473. * Used to make an adjustment to the roll of the bone
  41474. */
  41475. adjustRoll: number;
  41476. /**
  41477. * 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)
  41478. */
  41479. slerpAmount: number;
  41480. private _minYaw;
  41481. private _maxYaw;
  41482. private _minPitch;
  41483. private _maxPitch;
  41484. private _minYawSin;
  41485. private _minYawCos;
  41486. private _maxYawSin;
  41487. private _maxYawCos;
  41488. private _midYawConstraint;
  41489. private _minPitchTan;
  41490. private _maxPitchTan;
  41491. private _boneQuat;
  41492. private _slerping;
  41493. private _transformYawPitch;
  41494. private _transformYawPitchInv;
  41495. private _firstFrameSkipped;
  41496. private _yawRange;
  41497. private _fowardAxis;
  41498. /**
  41499. * Gets or sets the minimum yaw angle that the bone can look to
  41500. */
  41501. get minYaw(): number;
  41502. set minYaw(value: number);
  41503. /**
  41504. * Gets or sets the maximum yaw angle that the bone can look to
  41505. */
  41506. get maxYaw(): number;
  41507. set maxYaw(value: number);
  41508. /**
  41509. * Gets or sets the minimum pitch angle that the bone can look to
  41510. */
  41511. get minPitch(): number;
  41512. set minPitch(value: number);
  41513. /**
  41514. * Gets or sets the maximum pitch angle that the bone can look to
  41515. */
  41516. get maxPitch(): number;
  41517. set maxPitch(value: number);
  41518. /**
  41519. * Create a BoneLookController
  41520. * @param mesh the mesh that the bone belongs to
  41521. * @param bone the bone that will be looking to the target
  41522. * @param target the target Vector3 to look at
  41523. * @param options optional settings:
  41524. * * maxYaw: the maximum angle the bone will yaw to
  41525. * * minYaw: the minimum angle the bone will yaw to
  41526. * * maxPitch: the maximum angle the bone will pitch to
  41527. * * minPitch: the minimum angle the bone will yaw to
  41528. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41529. * * upAxis: the up axis of the coordinate system
  41530. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41531. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41532. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41533. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41534. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41535. * * adjustRoll: used to make an adjustment to the roll of the bone
  41536. **/
  41537. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41538. maxYaw?: number;
  41539. minYaw?: number;
  41540. maxPitch?: number;
  41541. minPitch?: number;
  41542. slerpAmount?: number;
  41543. upAxis?: Vector3;
  41544. upAxisSpace?: Space;
  41545. yawAxis?: Vector3;
  41546. pitchAxis?: Vector3;
  41547. adjustYaw?: number;
  41548. adjustPitch?: number;
  41549. adjustRoll?: number;
  41550. });
  41551. /**
  41552. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41553. */
  41554. update(): void;
  41555. private _getAngleDiff;
  41556. private _getAngleBetween;
  41557. private _isAngleBetween;
  41558. }
  41559. }
  41560. declare module "babylonjs/Bones/index" {
  41561. export * from "babylonjs/Bones/bone";
  41562. export * from "babylonjs/Bones/boneIKController";
  41563. export * from "babylonjs/Bones/boneLookController";
  41564. export * from "babylonjs/Bones/skeleton";
  41565. }
  41566. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41567. import { Nullable } from "babylonjs/types";
  41568. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41569. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41570. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41571. /**
  41572. * Manage the gamepad inputs to control an arc rotate camera.
  41573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41574. */
  41575. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41576. /**
  41577. * Defines the camera the input is attached to.
  41578. */
  41579. camera: ArcRotateCamera;
  41580. /**
  41581. * Defines the gamepad the input is gathering event from.
  41582. */
  41583. gamepad: Nullable<Gamepad>;
  41584. /**
  41585. * Defines the gamepad rotation sensiblity.
  41586. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41587. */
  41588. gamepadRotationSensibility: number;
  41589. /**
  41590. * Defines the gamepad move sensiblity.
  41591. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41592. */
  41593. gamepadMoveSensibility: number;
  41594. private _yAxisScale;
  41595. /**
  41596. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41597. */
  41598. get invertYAxis(): boolean;
  41599. set invertYAxis(value: boolean);
  41600. private _onGamepadConnectedObserver;
  41601. private _onGamepadDisconnectedObserver;
  41602. /**
  41603. * Attach the input controls to a specific dom element to get the input from.
  41604. * @param element Defines the element the controls should be listened from
  41605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41606. */
  41607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41608. /**
  41609. * Detach the current controls from the specified dom element.
  41610. * @param element Defines the element to stop listening the inputs from
  41611. */
  41612. detachControl(element: Nullable<HTMLElement>): void;
  41613. /**
  41614. * Update the current camera state depending on the inputs that have been used this frame.
  41615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41616. */
  41617. checkInputs(): void;
  41618. /**
  41619. * Gets the class name of the current intput.
  41620. * @returns the class name
  41621. */
  41622. getClassName(): string;
  41623. /**
  41624. * Get the friendly name associated with the input class.
  41625. * @returns the input friendly name
  41626. */
  41627. getSimpleName(): string;
  41628. }
  41629. }
  41630. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41631. import { Nullable } from "babylonjs/types";
  41632. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41633. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41634. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41635. interface ArcRotateCameraInputsManager {
  41636. /**
  41637. * Add orientation input support to the input manager.
  41638. * @returns the current input manager
  41639. */
  41640. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41641. }
  41642. }
  41643. /**
  41644. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41646. */
  41647. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41648. /**
  41649. * Defines the camera the input is attached to.
  41650. */
  41651. camera: ArcRotateCamera;
  41652. /**
  41653. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41654. */
  41655. alphaCorrection: number;
  41656. /**
  41657. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41658. */
  41659. gammaCorrection: number;
  41660. private _alpha;
  41661. private _gamma;
  41662. private _dirty;
  41663. private _deviceOrientationHandler;
  41664. /**
  41665. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41666. */
  41667. constructor();
  41668. /**
  41669. * Attach the input controls to a specific dom element to get the input from.
  41670. * @param element Defines the element the controls should be listened from
  41671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41672. */
  41673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41674. /** @hidden */
  41675. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41676. /**
  41677. * Update the current camera state depending on the inputs that have been used this frame.
  41678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41679. */
  41680. checkInputs(): void;
  41681. /**
  41682. * Detach the current controls from the specified dom element.
  41683. * @param element Defines the element to stop listening the inputs from
  41684. */
  41685. detachControl(element: Nullable<HTMLElement>): void;
  41686. /**
  41687. * Gets the class name of the current intput.
  41688. * @returns the class name
  41689. */
  41690. getClassName(): string;
  41691. /**
  41692. * Get the friendly name associated with the input class.
  41693. * @returns the input friendly name
  41694. */
  41695. getSimpleName(): string;
  41696. }
  41697. }
  41698. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41699. import { Nullable } from "babylonjs/types";
  41700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41701. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41702. /**
  41703. * Listen to mouse events to control the camera.
  41704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41705. */
  41706. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41707. /**
  41708. * Defines the camera the input is attached to.
  41709. */
  41710. camera: FlyCamera;
  41711. /**
  41712. * Defines if touch is enabled. (Default is true.)
  41713. */
  41714. touchEnabled: boolean;
  41715. /**
  41716. * Defines the buttons associated with the input to handle camera rotation.
  41717. */
  41718. buttons: number[];
  41719. /**
  41720. * Assign buttons for Yaw control.
  41721. */
  41722. buttonsYaw: number[];
  41723. /**
  41724. * Assign buttons for Pitch control.
  41725. */
  41726. buttonsPitch: number[];
  41727. /**
  41728. * Assign buttons for Roll control.
  41729. */
  41730. buttonsRoll: number[];
  41731. /**
  41732. * Detect if any button is being pressed while mouse is moved.
  41733. * -1 = Mouse locked.
  41734. * 0 = Left button.
  41735. * 1 = Middle Button.
  41736. * 2 = Right Button.
  41737. */
  41738. activeButton: number;
  41739. /**
  41740. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41741. * Higher values reduce its sensitivity.
  41742. */
  41743. angularSensibility: number;
  41744. private _mousemoveCallback;
  41745. private _observer;
  41746. private _rollObserver;
  41747. private previousPosition;
  41748. private noPreventDefault;
  41749. private element;
  41750. /**
  41751. * Listen to mouse events to control the camera.
  41752. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41754. */
  41755. constructor(touchEnabled?: boolean);
  41756. /**
  41757. * Attach the mouse control to the HTML DOM element.
  41758. * @param element Defines the element that listens to the input events.
  41759. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41760. */
  41761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41762. /**
  41763. * Detach the current controls from the specified dom element.
  41764. * @param element Defines the element to stop listening the inputs from
  41765. */
  41766. detachControl(element: Nullable<HTMLElement>): void;
  41767. /**
  41768. * Gets the class name of the current input.
  41769. * @returns the class name.
  41770. */
  41771. getClassName(): string;
  41772. /**
  41773. * Get the friendly name associated with the input class.
  41774. * @returns the input's friendly name.
  41775. */
  41776. getSimpleName(): string;
  41777. private _pointerInput;
  41778. private _onMouseMove;
  41779. /**
  41780. * Rotate camera by mouse offset.
  41781. */
  41782. private rotateCamera;
  41783. }
  41784. }
  41785. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41786. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41787. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41788. /**
  41789. * Default Inputs manager for the FlyCamera.
  41790. * It groups all the default supported inputs for ease of use.
  41791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41792. */
  41793. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41794. /**
  41795. * Instantiates a new FlyCameraInputsManager.
  41796. * @param camera Defines the camera the inputs belong to.
  41797. */
  41798. constructor(camera: FlyCamera);
  41799. /**
  41800. * Add keyboard input support to the input manager.
  41801. * @returns the new FlyCameraKeyboardMoveInput().
  41802. */
  41803. addKeyboard(): FlyCameraInputsManager;
  41804. /**
  41805. * Add mouse input support to the input manager.
  41806. * @param touchEnabled Enable touch screen support.
  41807. * @returns the new FlyCameraMouseInput().
  41808. */
  41809. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41810. }
  41811. }
  41812. declare module "babylonjs/Cameras/flyCamera" {
  41813. import { Scene } from "babylonjs/scene";
  41814. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41816. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41817. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41818. /**
  41819. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41820. * such as in a 3D Space Shooter or a Flight Simulator.
  41821. */
  41822. export class FlyCamera extends TargetCamera {
  41823. /**
  41824. * Define the collision ellipsoid of the camera.
  41825. * This is helpful for simulating a camera body, like a player's body.
  41826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41827. */
  41828. ellipsoid: Vector3;
  41829. /**
  41830. * Define an offset for the position of the ellipsoid around the camera.
  41831. * This can be helpful if the camera is attached away from the player's body center,
  41832. * such as at its head.
  41833. */
  41834. ellipsoidOffset: Vector3;
  41835. /**
  41836. * Enable or disable collisions of the camera with the rest of the scene objects.
  41837. */
  41838. checkCollisions: boolean;
  41839. /**
  41840. * Enable or disable gravity on the camera.
  41841. */
  41842. applyGravity: boolean;
  41843. /**
  41844. * Define the current direction the camera is moving to.
  41845. */
  41846. cameraDirection: Vector3;
  41847. /**
  41848. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41849. * This overrides and empties cameraRotation.
  41850. */
  41851. rotationQuaternion: Quaternion;
  41852. /**
  41853. * Track Roll to maintain the wanted Rolling when looking around.
  41854. */
  41855. _trackRoll: number;
  41856. /**
  41857. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41858. */
  41859. rollCorrect: number;
  41860. /**
  41861. * Mimic a banked turn, Rolling the camera when Yawing.
  41862. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41863. */
  41864. bankedTurn: boolean;
  41865. /**
  41866. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41867. */
  41868. bankedTurnLimit: number;
  41869. /**
  41870. * Value of 0 disables the banked Roll.
  41871. * Value of 1 is equal to the Yaw angle in radians.
  41872. */
  41873. bankedTurnMultiplier: number;
  41874. /**
  41875. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41876. */
  41877. inputs: FlyCameraInputsManager;
  41878. /**
  41879. * Gets the input sensibility for mouse input.
  41880. * Higher values reduce sensitivity.
  41881. */
  41882. get angularSensibility(): number;
  41883. /**
  41884. * Sets the input sensibility for a mouse input.
  41885. * Higher values reduce sensitivity.
  41886. */
  41887. set angularSensibility(value: number);
  41888. /**
  41889. * Get the keys for camera movement forward.
  41890. */
  41891. get keysForward(): number[];
  41892. /**
  41893. * Set the keys for camera movement forward.
  41894. */
  41895. set keysForward(value: number[]);
  41896. /**
  41897. * Get the keys for camera movement backward.
  41898. */
  41899. get keysBackward(): number[];
  41900. set keysBackward(value: number[]);
  41901. /**
  41902. * Get the keys for camera movement up.
  41903. */
  41904. get keysUp(): number[];
  41905. /**
  41906. * Set the keys for camera movement up.
  41907. */
  41908. set keysUp(value: number[]);
  41909. /**
  41910. * Get the keys for camera movement down.
  41911. */
  41912. get keysDown(): number[];
  41913. /**
  41914. * Set the keys for camera movement down.
  41915. */
  41916. set keysDown(value: number[]);
  41917. /**
  41918. * Get the keys for camera movement left.
  41919. */
  41920. get keysLeft(): number[];
  41921. /**
  41922. * Set the keys for camera movement left.
  41923. */
  41924. set keysLeft(value: number[]);
  41925. /**
  41926. * Set the keys for camera movement right.
  41927. */
  41928. get keysRight(): number[];
  41929. /**
  41930. * Set the keys for camera movement right.
  41931. */
  41932. set keysRight(value: number[]);
  41933. /**
  41934. * Event raised when the camera collides with a mesh in the scene.
  41935. */
  41936. onCollide: (collidedMesh: AbstractMesh) => void;
  41937. private _collider;
  41938. private _needMoveForGravity;
  41939. private _oldPosition;
  41940. private _diffPosition;
  41941. private _newPosition;
  41942. /** @hidden */
  41943. _localDirection: Vector3;
  41944. /** @hidden */
  41945. _transformedDirection: Vector3;
  41946. /**
  41947. * Instantiates a FlyCamera.
  41948. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41949. * such as in a 3D Space Shooter or a Flight Simulator.
  41950. * @param name Define the name of the camera in the scene.
  41951. * @param position Define the starting position of the camera in the scene.
  41952. * @param scene Define the scene the camera belongs to.
  41953. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41954. */
  41955. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41956. /**
  41957. * Attach a control to the HTML DOM element.
  41958. * @param element Defines the element that listens to the input events.
  41959. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41960. */
  41961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41962. /**
  41963. * Detach a control from the HTML DOM element.
  41964. * The camera will stop reacting to that input.
  41965. * @param element Defines the element that listens to the input events.
  41966. */
  41967. detachControl(element: HTMLElement): void;
  41968. private _collisionMask;
  41969. /**
  41970. * Get the mask that the camera ignores in collision events.
  41971. */
  41972. get collisionMask(): number;
  41973. /**
  41974. * Set the mask that the camera ignores in collision events.
  41975. */
  41976. set collisionMask(mask: number);
  41977. /** @hidden */
  41978. _collideWithWorld(displacement: Vector3): void;
  41979. /** @hidden */
  41980. private _onCollisionPositionChange;
  41981. /** @hidden */
  41982. _checkInputs(): void;
  41983. /** @hidden */
  41984. _decideIfNeedsToMove(): boolean;
  41985. /** @hidden */
  41986. _updatePosition(): void;
  41987. /**
  41988. * Restore the Roll to its target value at the rate specified.
  41989. * @param rate - Higher means slower restoring.
  41990. * @hidden
  41991. */
  41992. restoreRoll(rate: number): void;
  41993. /**
  41994. * Destroy the camera and release the current resources held by it.
  41995. */
  41996. dispose(): void;
  41997. /**
  41998. * Get the current object class name.
  41999. * @returns the class name.
  42000. */
  42001. getClassName(): string;
  42002. }
  42003. }
  42004. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  42005. import { Nullable } from "babylonjs/types";
  42006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42007. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  42008. /**
  42009. * Listen to keyboard events to control the camera.
  42010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42011. */
  42012. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  42013. /**
  42014. * Defines the camera the input is attached to.
  42015. */
  42016. camera: FlyCamera;
  42017. /**
  42018. * The list of keyboard keys used to control the forward move of the camera.
  42019. */
  42020. keysForward: number[];
  42021. /**
  42022. * The list of keyboard keys used to control the backward move of the camera.
  42023. */
  42024. keysBackward: number[];
  42025. /**
  42026. * The list of keyboard keys used to control the forward move of the camera.
  42027. */
  42028. keysUp: number[];
  42029. /**
  42030. * The list of keyboard keys used to control the backward move of the camera.
  42031. */
  42032. keysDown: number[];
  42033. /**
  42034. * The list of keyboard keys used to control the right strafe move of the camera.
  42035. */
  42036. keysRight: number[];
  42037. /**
  42038. * The list of keyboard keys used to control the left strafe move of the camera.
  42039. */
  42040. keysLeft: number[];
  42041. private _keys;
  42042. private _onCanvasBlurObserver;
  42043. private _onKeyboardObserver;
  42044. private _engine;
  42045. private _scene;
  42046. /**
  42047. * Attach the input controls to a specific dom element to get the input from.
  42048. * @param element Defines the element the controls should be listened from
  42049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42050. */
  42051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42052. /**
  42053. * Detach the current controls from the specified dom element.
  42054. * @param element Defines the element to stop listening the inputs from
  42055. */
  42056. detachControl(element: Nullable<HTMLElement>): void;
  42057. /**
  42058. * Gets the class name of the current intput.
  42059. * @returns the class name
  42060. */
  42061. getClassName(): string;
  42062. /** @hidden */
  42063. _onLostFocus(e: FocusEvent): void;
  42064. /**
  42065. * Get the friendly name associated with the input class.
  42066. * @returns the input friendly name
  42067. */
  42068. getSimpleName(): string;
  42069. /**
  42070. * Update the current camera state depending on the inputs that have been used this frame.
  42071. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42072. */
  42073. checkInputs(): void;
  42074. }
  42075. }
  42076. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  42077. import { Nullable } from "babylonjs/types";
  42078. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42079. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42080. /**
  42081. * Manage the mouse wheel inputs to control a follow camera.
  42082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42083. */
  42084. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  42085. /**
  42086. * Defines the camera the input is attached to.
  42087. */
  42088. camera: FollowCamera;
  42089. /**
  42090. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  42091. */
  42092. axisControlRadius: boolean;
  42093. /**
  42094. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  42095. */
  42096. axisControlHeight: boolean;
  42097. /**
  42098. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  42099. */
  42100. axisControlRotation: boolean;
  42101. /**
  42102. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  42103. * relation to mouseWheel events.
  42104. */
  42105. wheelPrecision: number;
  42106. /**
  42107. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42108. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42109. */
  42110. wheelDeltaPercentage: number;
  42111. private _wheel;
  42112. private _observer;
  42113. /**
  42114. * Attach the input controls to a specific dom element to get the input from.
  42115. * @param element Defines the element the controls should be listened from
  42116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42117. */
  42118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42119. /**
  42120. * Detach the current controls from the specified dom element.
  42121. * @param element Defines the element to stop listening the inputs from
  42122. */
  42123. detachControl(element: Nullable<HTMLElement>): void;
  42124. /**
  42125. * Gets the class name of the current intput.
  42126. * @returns the class name
  42127. */
  42128. getClassName(): string;
  42129. /**
  42130. * Get the friendly name associated with the input class.
  42131. * @returns the input friendly name
  42132. */
  42133. getSimpleName(): string;
  42134. }
  42135. }
  42136. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  42137. import { Nullable } from "babylonjs/types";
  42138. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42139. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42140. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42141. /**
  42142. * Manage the pointers inputs to control an follow camera.
  42143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42144. */
  42145. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  42146. /**
  42147. * Defines the camera the input is attached to.
  42148. */
  42149. camera: FollowCamera;
  42150. /**
  42151. * Gets the class name of the current input.
  42152. * @returns the class name
  42153. */
  42154. getClassName(): string;
  42155. /**
  42156. * Defines the pointer angular sensibility along the X axis or how fast is
  42157. * the camera rotating.
  42158. * A negative number will reverse the axis direction.
  42159. */
  42160. angularSensibilityX: number;
  42161. /**
  42162. * Defines the pointer angular sensibility along the Y axis or how fast is
  42163. * the camera rotating.
  42164. * A negative number will reverse the axis direction.
  42165. */
  42166. angularSensibilityY: number;
  42167. /**
  42168. * Defines the pointer pinch precision or how fast is the camera zooming.
  42169. * A negative number will reverse the axis direction.
  42170. */
  42171. pinchPrecision: number;
  42172. /**
  42173. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42174. * from 0.
  42175. * It defines the percentage of current camera.radius to use as delta when
  42176. * pinch zoom is used.
  42177. */
  42178. pinchDeltaPercentage: number;
  42179. /**
  42180. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  42181. */
  42182. axisXControlRadius: boolean;
  42183. /**
  42184. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  42185. */
  42186. axisXControlHeight: boolean;
  42187. /**
  42188. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  42189. */
  42190. axisXControlRotation: boolean;
  42191. /**
  42192. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  42193. */
  42194. axisYControlRadius: boolean;
  42195. /**
  42196. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  42197. */
  42198. axisYControlHeight: boolean;
  42199. /**
  42200. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  42201. */
  42202. axisYControlRotation: boolean;
  42203. /**
  42204. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  42205. */
  42206. axisPinchControlRadius: boolean;
  42207. /**
  42208. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  42209. */
  42210. axisPinchControlHeight: boolean;
  42211. /**
  42212. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  42213. */
  42214. axisPinchControlRotation: boolean;
  42215. /**
  42216. * Log error messages if basic misconfiguration has occurred.
  42217. */
  42218. warningEnable: boolean;
  42219. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42220. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42221. private _warningCounter;
  42222. private _warning;
  42223. }
  42224. }
  42225. declare module "babylonjs/Cameras/followCameraInputsManager" {
  42226. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42227. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42228. /**
  42229. * Default Inputs manager for the FollowCamera.
  42230. * It groups all the default supported inputs for ease of use.
  42231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42232. */
  42233. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  42234. /**
  42235. * Instantiates a new FollowCameraInputsManager.
  42236. * @param camera Defines the camera the inputs belong to
  42237. */
  42238. constructor(camera: FollowCamera);
  42239. /**
  42240. * Add keyboard input support to the input manager.
  42241. * @returns the current input manager
  42242. */
  42243. addKeyboard(): FollowCameraInputsManager;
  42244. /**
  42245. * Add mouse wheel input support to the input manager.
  42246. * @returns the current input manager
  42247. */
  42248. addMouseWheel(): FollowCameraInputsManager;
  42249. /**
  42250. * Add pointers input support to the input manager.
  42251. * @returns the current input manager
  42252. */
  42253. addPointers(): FollowCameraInputsManager;
  42254. /**
  42255. * Add orientation input support to the input manager.
  42256. * @returns the current input manager
  42257. */
  42258. addVRDeviceOrientation(): FollowCameraInputsManager;
  42259. }
  42260. }
  42261. declare module "babylonjs/Cameras/followCamera" {
  42262. import { Nullable } from "babylonjs/types";
  42263. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42264. import { Scene } from "babylonjs/scene";
  42265. import { Vector3 } from "babylonjs/Maths/math.vector";
  42266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42267. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  42268. /**
  42269. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  42270. * an arc rotate version arcFollowCamera are available.
  42271. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42272. */
  42273. export class FollowCamera extends TargetCamera {
  42274. /**
  42275. * Distance the follow camera should follow an object at
  42276. */
  42277. radius: number;
  42278. /**
  42279. * Minimum allowed distance of the camera to the axis of rotation
  42280. * (The camera can not get closer).
  42281. * This can help limiting how the Camera is able to move in the scene.
  42282. */
  42283. lowerRadiusLimit: Nullable<number>;
  42284. /**
  42285. * Maximum allowed distance of the camera to the axis of rotation
  42286. * (The camera can not get further).
  42287. * This can help limiting how the Camera is able to move in the scene.
  42288. */
  42289. upperRadiusLimit: Nullable<number>;
  42290. /**
  42291. * Define a rotation offset between the camera and the object it follows
  42292. */
  42293. rotationOffset: number;
  42294. /**
  42295. * Minimum allowed angle to camera position relative to target object.
  42296. * This can help limiting how the Camera is able to move in the scene.
  42297. */
  42298. lowerRotationOffsetLimit: Nullable<number>;
  42299. /**
  42300. * Maximum allowed angle to camera position relative to target object.
  42301. * This can help limiting how the Camera is able to move in the scene.
  42302. */
  42303. upperRotationOffsetLimit: Nullable<number>;
  42304. /**
  42305. * Define a height offset between the camera and the object it follows.
  42306. * It can help following an object from the top (like a car chaing a plane)
  42307. */
  42308. heightOffset: number;
  42309. /**
  42310. * Minimum allowed height of camera position relative to target object.
  42311. * This can help limiting how the Camera is able to move in the scene.
  42312. */
  42313. lowerHeightOffsetLimit: Nullable<number>;
  42314. /**
  42315. * Maximum allowed height of camera position relative to target object.
  42316. * This can help limiting how the Camera is able to move in the scene.
  42317. */
  42318. upperHeightOffsetLimit: Nullable<number>;
  42319. /**
  42320. * Define how fast the camera can accelerate to follow it s target.
  42321. */
  42322. cameraAcceleration: number;
  42323. /**
  42324. * Define the speed limit of the camera following an object.
  42325. */
  42326. maxCameraSpeed: number;
  42327. /**
  42328. * Define the target of the camera.
  42329. */
  42330. lockedTarget: Nullable<AbstractMesh>;
  42331. /**
  42332. * Defines the input associated with the camera.
  42333. */
  42334. inputs: FollowCameraInputsManager;
  42335. /**
  42336. * Instantiates the follow camera.
  42337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42338. * @param name Define the name of the camera in the scene
  42339. * @param position Define the position of the camera
  42340. * @param scene Define the scene the camera belong to
  42341. * @param lockedTarget Define the target of the camera
  42342. */
  42343. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42344. private _follow;
  42345. /**
  42346. * Attached controls to the current camera.
  42347. * @param element Defines the element the controls should be listened from
  42348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42349. */
  42350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42351. /**
  42352. * Detach the current controls from the camera.
  42353. * The camera will stop reacting to inputs.
  42354. * @param element Defines the element to stop listening the inputs from
  42355. */
  42356. detachControl(element: HTMLElement): void;
  42357. /** @hidden */
  42358. _checkInputs(): void;
  42359. private _checkLimits;
  42360. /**
  42361. * Gets the camera class name.
  42362. * @returns the class name
  42363. */
  42364. getClassName(): string;
  42365. }
  42366. /**
  42367. * Arc Rotate version of the follow camera.
  42368. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42369. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42370. */
  42371. export class ArcFollowCamera extends TargetCamera {
  42372. /** The longitudinal angle of the camera */
  42373. alpha: number;
  42374. /** The latitudinal angle of the camera */
  42375. beta: number;
  42376. /** The radius of the camera from its target */
  42377. radius: number;
  42378. /** Define the camera target (the messh it should follow) */
  42379. target: Nullable<AbstractMesh>;
  42380. private _cartesianCoordinates;
  42381. /**
  42382. * Instantiates a new ArcFollowCamera
  42383. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42384. * @param name Define the name of the camera
  42385. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42386. * @param beta Define the rotation angle of the camera around the elevation axis
  42387. * @param radius Define the radius of the camera from its target point
  42388. * @param target Define the target of the camera
  42389. * @param scene Define the scene the camera belongs to
  42390. */
  42391. constructor(name: string,
  42392. /** The longitudinal angle of the camera */
  42393. alpha: number,
  42394. /** The latitudinal angle of the camera */
  42395. beta: number,
  42396. /** The radius of the camera from its target */
  42397. radius: number,
  42398. /** Define the camera target (the messh it should follow) */
  42399. target: Nullable<AbstractMesh>, scene: Scene);
  42400. private _follow;
  42401. /** @hidden */
  42402. _checkInputs(): void;
  42403. /**
  42404. * Returns the class name of the object.
  42405. * It is mostly used internally for serialization purposes.
  42406. */
  42407. getClassName(): string;
  42408. }
  42409. }
  42410. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42411. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42412. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42413. import { Nullable } from "babylonjs/types";
  42414. /**
  42415. * Manage the keyboard inputs to control the movement of a follow camera.
  42416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42417. */
  42418. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42419. /**
  42420. * Defines the camera the input is attached to.
  42421. */
  42422. camera: FollowCamera;
  42423. /**
  42424. * Defines the list of key codes associated with the up action (increase heightOffset)
  42425. */
  42426. keysHeightOffsetIncr: number[];
  42427. /**
  42428. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42429. */
  42430. keysHeightOffsetDecr: number[];
  42431. /**
  42432. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42433. */
  42434. keysHeightOffsetModifierAlt: boolean;
  42435. /**
  42436. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42437. */
  42438. keysHeightOffsetModifierCtrl: boolean;
  42439. /**
  42440. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42441. */
  42442. keysHeightOffsetModifierShift: boolean;
  42443. /**
  42444. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42445. */
  42446. keysRotationOffsetIncr: number[];
  42447. /**
  42448. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42449. */
  42450. keysRotationOffsetDecr: number[];
  42451. /**
  42452. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42453. */
  42454. keysRotationOffsetModifierAlt: boolean;
  42455. /**
  42456. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42457. */
  42458. keysRotationOffsetModifierCtrl: boolean;
  42459. /**
  42460. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42461. */
  42462. keysRotationOffsetModifierShift: boolean;
  42463. /**
  42464. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42465. */
  42466. keysRadiusIncr: number[];
  42467. /**
  42468. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42469. */
  42470. keysRadiusDecr: number[];
  42471. /**
  42472. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42473. */
  42474. keysRadiusModifierAlt: boolean;
  42475. /**
  42476. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42477. */
  42478. keysRadiusModifierCtrl: boolean;
  42479. /**
  42480. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42481. */
  42482. keysRadiusModifierShift: boolean;
  42483. /**
  42484. * Defines the rate of change of heightOffset.
  42485. */
  42486. heightSensibility: number;
  42487. /**
  42488. * Defines the rate of change of rotationOffset.
  42489. */
  42490. rotationSensibility: number;
  42491. /**
  42492. * Defines the rate of change of radius.
  42493. */
  42494. radiusSensibility: number;
  42495. private _keys;
  42496. private _ctrlPressed;
  42497. private _altPressed;
  42498. private _shiftPressed;
  42499. private _onCanvasBlurObserver;
  42500. private _onKeyboardObserver;
  42501. private _engine;
  42502. private _scene;
  42503. /**
  42504. * Attach the input controls to a specific dom element to get the input from.
  42505. * @param element Defines the element the controls should be listened from
  42506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42507. */
  42508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42509. /**
  42510. * Detach the current controls from the specified dom element.
  42511. * @param element Defines the element to stop listening the inputs from
  42512. */
  42513. detachControl(element: Nullable<HTMLElement>): void;
  42514. /**
  42515. * Update the current camera state depending on the inputs that have been used this frame.
  42516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42517. */
  42518. checkInputs(): void;
  42519. /**
  42520. * Gets the class name of the current input.
  42521. * @returns the class name
  42522. */
  42523. getClassName(): string;
  42524. /**
  42525. * Get the friendly name associated with the input class.
  42526. * @returns the input friendly name
  42527. */
  42528. getSimpleName(): string;
  42529. /**
  42530. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42531. * allow modification of the heightOffset value.
  42532. */
  42533. private _modifierHeightOffset;
  42534. /**
  42535. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42536. * allow modification of the rotationOffset value.
  42537. */
  42538. private _modifierRotationOffset;
  42539. /**
  42540. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42541. * allow modification of the radius value.
  42542. */
  42543. private _modifierRadius;
  42544. }
  42545. }
  42546. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42547. import { Nullable } from "babylonjs/types";
  42548. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42549. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42550. import { Observable } from "babylonjs/Misc/observable";
  42551. module "babylonjs/Cameras/freeCameraInputsManager" {
  42552. interface FreeCameraInputsManager {
  42553. /**
  42554. * @hidden
  42555. */
  42556. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42557. /**
  42558. * Add orientation input support to the input manager.
  42559. * @returns the current input manager
  42560. */
  42561. addDeviceOrientation(): FreeCameraInputsManager;
  42562. }
  42563. }
  42564. /**
  42565. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42566. * Screen rotation is taken into account.
  42567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42568. */
  42569. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42570. private _camera;
  42571. private _screenOrientationAngle;
  42572. private _constantTranform;
  42573. private _screenQuaternion;
  42574. private _alpha;
  42575. private _beta;
  42576. private _gamma;
  42577. /**
  42578. * Can be used to detect if a device orientation sensor is available on a device
  42579. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42580. * @returns a promise that will resolve on orientation change
  42581. */
  42582. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42583. /**
  42584. * @hidden
  42585. */
  42586. _onDeviceOrientationChangedObservable: Observable<void>;
  42587. /**
  42588. * Instantiates a new input
  42589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42590. */
  42591. constructor();
  42592. /**
  42593. * Define the camera controlled by the input.
  42594. */
  42595. get camera(): FreeCamera;
  42596. set camera(camera: FreeCamera);
  42597. /**
  42598. * Attach the input controls to a specific dom element to get the input from.
  42599. * @param element Defines the element the controls should be listened from
  42600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42601. */
  42602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42603. private _orientationChanged;
  42604. private _deviceOrientation;
  42605. /**
  42606. * Detach the current controls from the specified dom element.
  42607. * @param element Defines the element to stop listening the inputs from
  42608. */
  42609. detachControl(element: Nullable<HTMLElement>): void;
  42610. /**
  42611. * Update the current camera state depending on the inputs that have been used this frame.
  42612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42613. */
  42614. checkInputs(): void;
  42615. /**
  42616. * Gets the class name of the current intput.
  42617. * @returns the class name
  42618. */
  42619. getClassName(): string;
  42620. /**
  42621. * Get the friendly name associated with the input class.
  42622. * @returns the input friendly name
  42623. */
  42624. getSimpleName(): string;
  42625. }
  42626. }
  42627. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42628. import { Nullable } from "babylonjs/types";
  42629. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42630. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42631. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42632. /**
  42633. * Manage the gamepad inputs to control a free camera.
  42634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42635. */
  42636. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42637. /**
  42638. * Define the camera the input is attached to.
  42639. */
  42640. camera: FreeCamera;
  42641. /**
  42642. * Define the Gamepad controlling the input
  42643. */
  42644. gamepad: Nullable<Gamepad>;
  42645. /**
  42646. * Defines the gamepad rotation sensiblity.
  42647. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42648. */
  42649. gamepadAngularSensibility: number;
  42650. /**
  42651. * Defines the gamepad move sensiblity.
  42652. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42653. */
  42654. gamepadMoveSensibility: number;
  42655. private _yAxisScale;
  42656. /**
  42657. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42658. */
  42659. get invertYAxis(): boolean;
  42660. set invertYAxis(value: boolean);
  42661. private _onGamepadConnectedObserver;
  42662. private _onGamepadDisconnectedObserver;
  42663. private _cameraTransform;
  42664. private _deltaTransform;
  42665. private _vector3;
  42666. private _vector2;
  42667. /**
  42668. * Attach the input controls to a specific dom element to get the input from.
  42669. * @param element Defines the element the controls should be listened from
  42670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42671. */
  42672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42673. /**
  42674. * Detach the current controls from the specified dom element.
  42675. * @param element Defines the element to stop listening the inputs from
  42676. */
  42677. detachControl(element: Nullable<HTMLElement>): void;
  42678. /**
  42679. * Update the current camera state depending on the inputs that have been used this frame.
  42680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42681. */
  42682. checkInputs(): void;
  42683. /**
  42684. * Gets the class name of the current intput.
  42685. * @returns the class name
  42686. */
  42687. getClassName(): string;
  42688. /**
  42689. * Get the friendly name associated with the input class.
  42690. * @returns the input friendly name
  42691. */
  42692. getSimpleName(): string;
  42693. }
  42694. }
  42695. declare module "babylonjs/Misc/virtualJoystick" {
  42696. import { Nullable } from "babylonjs/types";
  42697. import { Vector3 } from "babylonjs/Maths/math.vector";
  42698. /**
  42699. * Defines the potential axis of a Joystick
  42700. */
  42701. export enum JoystickAxis {
  42702. /** X axis */
  42703. X = 0,
  42704. /** Y axis */
  42705. Y = 1,
  42706. /** Z axis */
  42707. Z = 2
  42708. }
  42709. /**
  42710. * Class used to define virtual joystick (used in touch mode)
  42711. */
  42712. export class VirtualJoystick {
  42713. /**
  42714. * Gets or sets a boolean indicating that left and right values must be inverted
  42715. */
  42716. reverseLeftRight: boolean;
  42717. /**
  42718. * Gets or sets a boolean indicating that up and down values must be inverted
  42719. */
  42720. reverseUpDown: boolean;
  42721. /**
  42722. * Gets the offset value for the position (ie. the change of the position value)
  42723. */
  42724. deltaPosition: Vector3;
  42725. /**
  42726. * Gets a boolean indicating if the virtual joystick was pressed
  42727. */
  42728. pressed: boolean;
  42729. /**
  42730. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42731. */
  42732. static Canvas: Nullable<HTMLCanvasElement>;
  42733. private static _globalJoystickIndex;
  42734. private static vjCanvasContext;
  42735. private static vjCanvasWidth;
  42736. private static vjCanvasHeight;
  42737. private static halfWidth;
  42738. private _action;
  42739. private _axisTargetedByLeftAndRight;
  42740. private _axisTargetedByUpAndDown;
  42741. private _joystickSensibility;
  42742. private _inversedSensibility;
  42743. private _joystickPointerID;
  42744. private _joystickColor;
  42745. private _joystickPointerPos;
  42746. private _joystickPreviousPointerPos;
  42747. private _joystickPointerStartPos;
  42748. private _deltaJoystickVector;
  42749. private _leftJoystick;
  42750. private _touches;
  42751. private _onPointerDownHandlerRef;
  42752. private _onPointerMoveHandlerRef;
  42753. private _onPointerUpHandlerRef;
  42754. private _onResize;
  42755. /**
  42756. * Creates a new virtual joystick
  42757. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42758. */
  42759. constructor(leftJoystick?: boolean);
  42760. /**
  42761. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42762. * @param newJoystickSensibility defines the new sensibility
  42763. */
  42764. setJoystickSensibility(newJoystickSensibility: number): void;
  42765. private _onPointerDown;
  42766. private _onPointerMove;
  42767. private _onPointerUp;
  42768. /**
  42769. * Change the color of the virtual joystick
  42770. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42771. */
  42772. setJoystickColor(newColor: string): void;
  42773. /**
  42774. * Defines a callback to call when the joystick is touched
  42775. * @param action defines the callback
  42776. */
  42777. setActionOnTouch(action: () => any): void;
  42778. /**
  42779. * Defines which axis you'd like to control for left & right
  42780. * @param axis defines the axis to use
  42781. */
  42782. setAxisForLeftRight(axis: JoystickAxis): void;
  42783. /**
  42784. * Defines which axis you'd like to control for up & down
  42785. * @param axis defines the axis to use
  42786. */
  42787. setAxisForUpDown(axis: JoystickAxis): void;
  42788. private _drawVirtualJoystick;
  42789. /**
  42790. * Release internal HTML canvas
  42791. */
  42792. releaseCanvas(): void;
  42793. }
  42794. }
  42795. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42796. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42797. import { Nullable } from "babylonjs/types";
  42798. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42799. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42800. module "babylonjs/Cameras/freeCameraInputsManager" {
  42801. interface FreeCameraInputsManager {
  42802. /**
  42803. * Add virtual joystick input support to the input manager.
  42804. * @returns the current input manager
  42805. */
  42806. addVirtualJoystick(): FreeCameraInputsManager;
  42807. }
  42808. }
  42809. /**
  42810. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42812. */
  42813. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42814. /**
  42815. * Defines the camera the input is attached to.
  42816. */
  42817. camera: FreeCamera;
  42818. private _leftjoystick;
  42819. private _rightjoystick;
  42820. /**
  42821. * Gets the left stick of the virtual joystick.
  42822. * @returns The virtual Joystick
  42823. */
  42824. getLeftJoystick(): VirtualJoystick;
  42825. /**
  42826. * Gets the right stick of the virtual joystick.
  42827. * @returns The virtual Joystick
  42828. */
  42829. getRightJoystick(): VirtualJoystick;
  42830. /**
  42831. * Update the current camera state depending on the inputs that have been used this frame.
  42832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42833. */
  42834. checkInputs(): void;
  42835. /**
  42836. * Attach the input controls to a specific dom element to get the input from.
  42837. * @param element Defines the element the controls should be listened from
  42838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42839. */
  42840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42841. /**
  42842. * Detach the current controls from the specified dom element.
  42843. * @param element Defines the element to stop listening the inputs from
  42844. */
  42845. detachControl(element: Nullable<HTMLElement>): void;
  42846. /**
  42847. * Gets the class name of the current intput.
  42848. * @returns the class name
  42849. */
  42850. getClassName(): string;
  42851. /**
  42852. * Get the friendly name associated with the input class.
  42853. * @returns the input friendly name
  42854. */
  42855. getSimpleName(): string;
  42856. }
  42857. }
  42858. declare module "babylonjs/Cameras/Inputs/index" {
  42859. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42860. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42861. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42862. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42863. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42864. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42865. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42866. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42867. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42868. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42869. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42870. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42871. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42872. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42873. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42874. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42875. }
  42876. declare module "babylonjs/Cameras/touchCamera" {
  42877. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42878. import { Scene } from "babylonjs/scene";
  42879. import { Vector3 } from "babylonjs/Maths/math.vector";
  42880. /**
  42881. * This represents a FPS type of camera controlled by touch.
  42882. * This is like a universal camera minus the Gamepad controls.
  42883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42884. */
  42885. export class TouchCamera extends FreeCamera {
  42886. /**
  42887. * Defines the touch sensibility for rotation.
  42888. * The higher the faster.
  42889. */
  42890. get touchAngularSensibility(): number;
  42891. set touchAngularSensibility(value: number);
  42892. /**
  42893. * Defines the touch sensibility for move.
  42894. * The higher the faster.
  42895. */
  42896. get touchMoveSensibility(): number;
  42897. set touchMoveSensibility(value: number);
  42898. /**
  42899. * Instantiates a new touch camera.
  42900. * This represents a FPS type of camera controlled by touch.
  42901. * This is like a universal camera minus the Gamepad controls.
  42902. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42903. * @param name Define the name of the camera in the scene
  42904. * @param position Define the start position of the camera in the scene
  42905. * @param scene Define the scene the camera belongs to
  42906. */
  42907. constructor(name: string, position: Vector3, scene: Scene);
  42908. /**
  42909. * Gets the current object class name.
  42910. * @return the class name
  42911. */
  42912. getClassName(): string;
  42913. /** @hidden */
  42914. _setupInputs(): void;
  42915. }
  42916. }
  42917. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42918. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42919. import { Scene } from "babylonjs/scene";
  42920. import { Vector3 } from "babylonjs/Maths/math.vector";
  42921. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42922. import { Axis } from "babylonjs/Maths/math.axis";
  42923. /**
  42924. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42925. * being tilted forward or back and left or right.
  42926. */
  42927. export class DeviceOrientationCamera extends FreeCamera {
  42928. private _initialQuaternion;
  42929. private _quaternionCache;
  42930. private _tmpDragQuaternion;
  42931. private _disablePointerInputWhenUsingDeviceOrientation;
  42932. /**
  42933. * Creates a new device orientation camera
  42934. * @param name The name of the camera
  42935. * @param position The start position camera
  42936. * @param scene The scene the camera belongs to
  42937. */
  42938. constructor(name: string, position: Vector3, scene: Scene);
  42939. /**
  42940. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42941. */
  42942. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42943. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42944. private _dragFactor;
  42945. /**
  42946. * Enabled turning on the y axis when the orientation sensor is active
  42947. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42948. */
  42949. enableHorizontalDragging(dragFactor?: number): void;
  42950. /**
  42951. * Gets the current instance class name ("DeviceOrientationCamera").
  42952. * This helps avoiding instanceof at run time.
  42953. * @returns the class name
  42954. */
  42955. getClassName(): string;
  42956. /**
  42957. * @hidden
  42958. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42959. */
  42960. _checkInputs(): void;
  42961. /**
  42962. * Reset the camera to its default orientation on the specified axis only.
  42963. * @param axis The axis to reset
  42964. */
  42965. resetToCurrentRotation(axis?: Axis): void;
  42966. }
  42967. }
  42968. declare module "babylonjs/Gamepads/xboxGamepad" {
  42969. import { Observable } from "babylonjs/Misc/observable";
  42970. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42971. /**
  42972. * Defines supported buttons for XBox360 compatible gamepads
  42973. */
  42974. export enum Xbox360Button {
  42975. /** A */
  42976. A = 0,
  42977. /** B */
  42978. B = 1,
  42979. /** X */
  42980. X = 2,
  42981. /** Y */
  42982. Y = 3,
  42983. /** Left button */
  42984. LB = 4,
  42985. /** Right button */
  42986. RB = 5,
  42987. /** Back */
  42988. Back = 8,
  42989. /** Start */
  42990. Start = 9,
  42991. /** Left stick */
  42992. LeftStick = 10,
  42993. /** Right stick */
  42994. RightStick = 11
  42995. }
  42996. /** Defines values for XBox360 DPad */
  42997. export enum Xbox360Dpad {
  42998. /** Up */
  42999. Up = 12,
  43000. /** Down */
  43001. Down = 13,
  43002. /** Left */
  43003. Left = 14,
  43004. /** Right */
  43005. Right = 15
  43006. }
  43007. /**
  43008. * Defines a XBox360 gamepad
  43009. */
  43010. export class Xbox360Pad extends Gamepad {
  43011. private _leftTrigger;
  43012. private _rightTrigger;
  43013. private _onlefttriggerchanged;
  43014. private _onrighttriggerchanged;
  43015. private _onbuttondown;
  43016. private _onbuttonup;
  43017. private _ondpaddown;
  43018. private _ondpadup;
  43019. /** Observable raised when a button is pressed */
  43020. onButtonDownObservable: Observable<Xbox360Button>;
  43021. /** Observable raised when a button is released */
  43022. onButtonUpObservable: Observable<Xbox360Button>;
  43023. /** Observable raised when a pad is pressed */
  43024. onPadDownObservable: Observable<Xbox360Dpad>;
  43025. /** Observable raised when a pad is released */
  43026. onPadUpObservable: Observable<Xbox360Dpad>;
  43027. private _buttonA;
  43028. private _buttonB;
  43029. private _buttonX;
  43030. private _buttonY;
  43031. private _buttonBack;
  43032. private _buttonStart;
  43033. private _buttonLB;
  43034. private _buttonRB;
  43035. private _buttonLeftStick;
  43036. private _buttonRightStick;
  43037. private _dPadUp;
  43038. private _dPadDown;
  43039. private _dPadLeft;
  43040. private _dPadRight;
  43041. private _isXboxOnePad;
  43042. /**
  43043. * Creates a new XBox360 gamepad object
  43044. * @param id defines the id of this gamepad
  43045. * @param index defines its index
  43046. * @param gamepad defines the internal HTML gamepad object
  43047. * @param xboxOne defines if it is a XBox One gamepad
  43048. */
  43049. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  43050. /**
  43051. * Defines the callback to call when left trigger is pressed
  43052. * @param callback defines the callback to use
  43053. */
  43054. onlefttriggerchanged(callback: (value: number) => void): void;
  43055. /**
  43056. * Defines the callback to call when right trigger is pressed
  43057. * @param callback defines the callback to use
  43058. */
  43059. onrighttriggerchanged(callback: (value: number) => void): void;
  43060. /**
  43061. * Gets the left trigger value
  43062. */
  43063. get leftTrigger(): number;
  43064. /**
  43065. * Sets the left trigger value
  43066. */
  43067. set leftTrigger(newValue: number);
  43068. /**
  43069. * Gets the right trigger value
  43070. */
  43071. get rightTrigger(): number;
  43072. /**
  43073. * Sets the right trigger value
  43074. */
  43075. set rightTrigger(newValue: number);
  43076. /**
  43077. * Defines the callback to call when a button is pressed
  43078. * @param callback defines the callback to use
  43079. */
  43080. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  43081. /**
  43082. * Defines the callback to call when a button is released
  43083. * @param callback defines the callback to use
  43084. */
  43085. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  43086. /**
  43087. * Defines the callback to call when a pad is pressed
  43088. * @param callback defines the callback to use
  43089. */
  43090. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  43091. /**
  43092. * Defines the callback to call when a pad is released
  43093. * @param callback defines the callback to use
  43094. */
  43095. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  43096. private _setButtonValue;
  43097. private _setDPadValue;
  43098. /**
  43099. * Gets the value of the `A` button
  43100. */
  43101. get buttonA(): number;
  43102. /**
  43103. * Sets the value of the `A` button
  43104. */
  43105. set buttonA(value: number);
  43106. /**
  43107. * Gets the value of the `B` button
  43108. */
  43109. get buttonB(): number;
  43110. /**
  43111. * Sets the value of the `B` button
  43112. */
  43113. set buttonB(value: number);
  43114. /**
  43115. * Gets the value of the `X` button
  43116. */
  43117. get buttonX(): number;
  43118. /**
  43119. * Sets the value of the `X` button
  43120. */
  43121. set buttonX(value: number);
  43122. /**
  43123. * Gets the value of the `Y` button
  43124. */
  43125. get buttonY(): number;
  43126. /**
  43127. * Sets the value of the `Y` button
  43128. */
  43129. set buttonY(value: number);
  43130. /**
  43131. * Gets the value of the `Start` button
  43132. */
  43133. get buttonStart(): number;
  43134. /**
  43135. * Sets the value of the `Start` button
  43136. */
  43137. set buttonStart(value: number);
  43138. /**
  43139. * Gets the value of the `Back` button
  43140. */
  43141. get buttonBack(): number;
  43142. /**
  43143. * Sets the value of the `Back` button
  43144. */
  43145. set buttonBack(value: number);
  43146. /**
  43147. * Gets the value of the `Left` button
  43148. */
  43149. get buttonLB(): number;
  43150. /**
  43151. * Sets the value of the `Left` button
  43152. */
  43153. set buttonLB(value: number);
  43154. /**
  43155. * Gets the value of the `Right` button
  43156. */
  43157. get buttonRB(): number;
  43158. /**
  43159. * Sets the value of the `Right` button
  43160. */
  43161. set buttonRB(value: number);
  43162. /**
  43163. * Gets the value of the Left joystick
  43164. */
  43165. get buttonLeftStick(): number;
  43166. /**
  43167. * Sets the value of the Left joystick
  43168. */
  43169. set buttonLeftStick(value: number);
  43170. /**
  43171. * Gets the value of the Right joystick
  43172. */
  43173. get buttonRightStick(): number;
  43174. /**
  43175. * Sets the value of the Right joystick
  43176. */
  43177. set buttonRightStick(value: number);
  43178. /**
  43179. * Gets the value of D-pad up
  43180. */
  43181. get dPadUp(): number;
  43182. /**
  43183. * Sets the value of D-pad up
  43184. */
  43185. set dPadUp(value: number);
  43186. /**
  43187. * Gets the value of D-pad down
  43188. */
  43189. get dPadDown(): number;
  43190. /**
  43191. * Sets the value of D-pad down
  43192. */
  43193. set dPadDown(value: number);
  43194. /**
  43195. * Gets the value of D-pad left
  43196. */
  43197. get dPadLeft(): number;
  43198. /**
  43199. * Sets the value of D-pad left
  43200. */
  43201. set dPadLeft(value: number);
  43202. /**
  43203. * Gets the value of D-pad right
  43204. */
  43205. get dPadRight(): number;
  43206. /**
  43207. * Sets the value of D-pad right
  43208. */
  43209. set dPadRight(value: number);
  43210. /**
  43211. * Force the gamepad to synchronize with device values
  43212. */
  43213. update(): void;
  43214. /**
  43215. * Disposes the gamepad
  43216. */
  43217. dispose(): void;
  43218. }
  43219. }
  43220. declare module "babylonjs/Gamepads/dualShockGamepad" {
  43221. import { Observable } from "babylonjs/Misc/observable";
  43222. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43223. /**
  43224. * Defines supported buttons for DualShock compatible gamepads
  43225. */
  43226. export enum DualShockButton {
  43227. /** Cross */
  43228. Cross = 0,
  43229. /** Circle */
  43230. Circle = 1,
  43231. /** Square */
  43232. Square = 2,
  43233. /** Triangle */
  43234. Triangle = 3,
  43235. /** L1 */
  43236. L1 = 4,
  43237. /** R1 */
  43238. R1 = 5,
  43239. /** Share */
  43240. Share = 8,
  43241. /** Options */
  43242. Options = 9,
  43243. /** Left stick */
  43244. LeftStick = 10,
  43245. /** Right stick */
  43246. RightStick = 11
  43247. }
  43248. /** Defines values for DualShock DPad */
  43249. export enum DualShockDpad {
  43250. /** Up */
  43251. Up = 12,
  43252. /** Down */
  43253. Down = 13,
  43254. /** Left */
  43255. Left = 14,
  43256. /** Right */
  43257. Right = 15
  43258. }
  43259. /**
  43260. * Defines a DualShock gamepad
  43261. */
  43262. export class DualShockPad extends Gamepad {
  43263. private _leftTrigger;
  43264. private _rightTrigger;
  43265. private _onlefttriggerchanged;
  43266. private _onrighttriggerchanged;
  43267. private _onbuttondown;
  43268. private _onbuttonup;
  43269. private _ondpaddown;
  43270. private _ondpadup;
  43271. /** Observable raised when a button is pressed */
  43272. onButtonDownObservable: Observable<DualShockButton>;
  43273. /** Observable raised when a button is released */
  43274. onButtonUpObservable: Observable<DualShockButton>;
  43275. /** Observable raised when a pad is pressed */
  43276. onPadDownObservable: Observable<DualShockDpad>;
  43277. /** Observable raised when a pad is released */
  43278. onPadUpObservable: Observable<DualShockDpad>;
  43279. private _buttonCross;
  43280. private _buttonCircle;
  43281. private _buttonSquare;
  43282. private _buttonTriangle;
  43283. private _buttonShare;
  43284. private _buttonOptions;
  43285. private _buttonL1;
  43286. private _buttonR1;
  43287. private _buttonLeftStick;
  43288. private _buttonRightStick;
  43289. private _dPadUp;
  43290. private _dPadDown;
  43291. private _dPadLeft;
  43292. private _dPadRight;
  43293. /**
  43294. * Creates a new DualShock gamepad object
  43295. * @param id defines the id of this gamepad
  43296. * @param index defines its index
  43297. * @param gamepad defines the internal HTML gamepad object
  43298. */
  43299. constructor(id: string, index: number, gamepad: any);
  43300. /**
  43301. * Defines the callback to call when left trigger is pressed
  43302. * @param callback defines the callback to use
  43303. */
  43304. onlefttriggerchanged(callback: (value: number) => void): void;
  43305. /**
  43306. * Defines the callback to call when right trigger is pressed
  43307. * @param callback defines the callback to use
  43308. */
  43309. onrighttriggerchanged(callback: (value: number) => void): void;
  43310. /**
  43311. * Gets the left trigger value
  43312. */
  43313. get leftTrigger(): number;
  43314. /**
  43315. * Sets the left trigger value
  43316. */
  43317. set leftTrigger(newValue: number);
  43318. /**
  43319. * Gets the right trigger value
  43320. */
  43321. get rightTrigger(): number;
  43322. /**
  43323. * Sets the right trigger value
  43324. */
  43325. set rightTrigger(newValue: number);
  43326. /**
  43327. * Defines the callback to call when a button is pressed
  43328. * @param callback defines the callback to use
  43329. */
  43330. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43331. /**
  43332. * Defines the callback to call when a button is released
  43333. * @param callback defines the callback to use
  43334. */
  43335. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43336. /**
  43337. * Defines the callback to call when a pad is pressed
  43338. * @param callback defines the callback to use
  43339. */
  43340. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43341. /**
  43342. * Defines the callback to call when a pad is released
  43343. * @param callback defines the callback to use
  43344. */
  43345. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43346. private _setButtonValue;
  43347. private _setDPadValue;
  43348. /**
  43349. * Gets the value of the `Cross` button
  43350. */
  43351. get buttonCross(): number;
  43352. /**
  43353. * Sets the value of the `Cross` button
  43354. */
  43355. set buttonCross(value: number);
  43356. /**
  43357. * Gets the value of the `Circle` button
  43358. */
  43359. get buttonCircle(): number;
  43360. /**
  43361. * Sets the value of the `Circle` button
  43362. */
  43363. set buttonCircle(value: number);
  43364. /**
  43365. * Gets the value of the `Square` button
  43366. */
  43367. get buttonSquare(): number;
  43368. /**
  43369. * Sets the value of the `Square` button
  43370. */
  43371. set buttonSquare(value: number);
  43372. /**
  43373. * Gets the value of the `Triangle` button
  43374. */
  43375. get buttonTriangle(): number;
  43376. /**
  43377. * Sets the value of the `Triangle` button
  43378. */
  43379. set buttonTriangle(value: number);
  43380. /**
  43381. * Gets the value of the `Options` button
  43382. */
  43383. get buttonOptions(): number;
  43384. /**
  43385. * Sets the value of the `Options` button
  43386. */
  43387. set buttonOptions(value: number);
  43388. /**
  43389. * Gets the value of the `Share` button
  43390. */
  43391. get buttonShare(): number;
  43392. /**
  43393. * Sets the value of the `Share` button
  43394. */
  43395. set buttonShare(value: number);
  43396. /**
  43397. * Gets the value of the `L1` button
  43398. */
  43399. get buttonL1(): number;
  43400. /**
  43401. * Sets the value of the `L1` button
  43402. */
  43403. set buttonL1(value: number);
  43404. /**
  43405. * Gets the value of the `R1` button
  43406. */
  43407. get buttonR1(): number;
  43408. /**
  43409. * Sets the value of the `R1` button
  43410. */
  43411. set buttonR1(value: number);
  43412. /**
  43413. * Gets the value of the Left joystick
  43414. */
  43415. get buttonLeftStick(): number;
  43416. /**
  43417. * Sets the value of the Left joystick
  43418. */
  43419. set buttonLeftStick(value: number);
  43420. /**
  43421. * Gets the value of the Right joystick
  43422. */
  43423. get buttonRightStick(): number;
  43424. /**
  43425. * Sets the value of the Right joystick
  43426. */
  43427. set buttonRightStick(value: number);
  43428. /**
  43429. * Gets the value of D-pad up
  43430. */
  43431. get dPadUp(): number;
  43432. /**
  43433. * Sets the value of D-pad up
  43434. */
  43435. set dPadUp(value: number);
  43436. /**
  43437. * Gets the value of D-pad down
  43438. */
  43439. get dPadDown(): number;
  43440. /**
  43441. * Sets the value of D-pad down
  43442. */
  43443. set dPadDown(value: number);
  43444. /**
  43445. * Gets the value of D-pad left
  43446. */
  43447. get dPadLeft(): number;
  43448. /**
  43449. * Sets the value of D-pad left
  43450. */
  43451. set dPadLeft(value: number);
  43452. /**
  43453. * Gets the value of D-pad right
  43454. */
  43455. get dPadRight(): number;
  43456. /**
  43457. * Sets the value of D-pad right
  43458. */
  43459. set dPadRight(value: number);
  43460. /**
  43461. * Force the gamepad to synchronize with device values
  43462. */
  43463. update(): void;
  43464. /**
  43465. * Disposes the gamepad
  43466. */
  43467. dispose(): void;
  43468. }
  43469. }
  43470. declare module "babylonjs/Gamepads/gamepadManager" {
  43471. import { Observable } from "babylonjs/Misc/observable";
  43472. import { Nullable } from "babylonjs/types";
  43473. import { Scene } from "babylonjs/scene";
  43474. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43475. /**
  43476. * Manager for handling gamepads
  43477. */
  43478. export class GamepadManager {
  43479. private _scene?;
  43480. private _babylonGamepads;
  43481. private _oneGamepadConnected;
  43482. /** @hidden */
  43483. _isMonitoring: boolean;
  43484. private _gamepadEventSupported;
  43485. private _gamepadSupport?;
  43486. /**
  43487. * observable to be triggered when the gamepad controller has been connected
  43488. */
  43489. onGamepadConnectedObservable: Observable<Gamepad>;
  43490. /**
  43491. * observable to be triggered when the gamepad controller has been disconnected
  43492. */
  43493. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43494. private _onGamepadConnectedEvent;
  43495. private _onGamepadDisconnectedEvent;
  43496. /**
  43497. * Initializes the gamepad manager
  43498. * @param _scene BabylonJS scene
  43499. */
  43500. constructor(_scene?: Scene | undefined);
  43501. /**
  43502. * The gamepads in the game pad manager
  43503. */
  43504. get gamepads(): Gamepad[];
  43505. /**
  43506. * Get the gamepad controllers based on type
  43507. * @param type The type of gamepad controller
  43508. * @returns Nullable gamepad
  43509. */
  43510. getGamepadByType(type?: number): Nullable<Gamepad>;
  43511. /**
  43512. * Disposes the gamepad manager
  43513. */
  43514. dispose(): void;
  43515. private _addNewGamepad;
  43516. private _startMonitoringGamepads;
  43517. private _stopMonitoringGamepads;
  43518. /** @hidden */
  43519. _checkGamepadsStatus(): void;
  43520. private _updateGamepadObjects;
  43521. }
  43522. }
  43523. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43524. import { Nullable } from "babylonjs/types";
  43525. import { Scene } from "babylonjs/scene";
  43526. import { ISceneComponent } from "babylonjs/sceneComponent";
  43527. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43528. module "babylonjs/scene" {
  43529. interface Scene {
  43530. /** @hidden */
  43531. _gamepadManager: Nullable<GamepadManager>;
  43532. /**
  43533. * Gets the gamepad manager associated with the scene
  43534. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43535. */
  43536. gamepadManager: GamepadManager;
  43537. }
  43538. }
  43539. module "babylonjs/Cameras/freeCameraInputsManager" {
  43540. /**
  43541. * Interface representing a free camera inputs manager
  43542. */
  43543. interface FreeCameraInputsManager {
  43544. /**
  43545. * Adds gamepad input support to the FreeCameraInputsManager.
  43546. * @returns the FreeCameraInputsManager
  43547. */
  43548. addGamepad(): FreeCameraInputsManager;
  43549. }
  43550. }
  43551. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43552. /**
  43553. * Interface representing an arc rotate camera inputs manager
  43554. */
  43555. interface ArcRotateCameraInputsManager {
  43556. /**
  43557. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43558. * @returns the camera inputs manager
  43559. */
  43560. addGamepad(): ArcRotateCameraInputsManager;
  43561. }
  43562. }
  43563. /**
  43564. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43565. */
  43566. export class GamepadSystemSceneComponent implements ISceneComponent {
  43567. /**
  43568. * The component name helpfull to identify the component in the list of scene components.
  43569. */
  43570. readonly name: string;
  43571. /**
  43572. * The scene the component belongs to.
  43573. */
  43574. scene: Scene;
  43575. /**
  43576. * Creates a new instance of the component for the given scene
  43577. * @param scene Defines the scene to register the component in
  43578. */
  43579. constructor(scene: Scene);
  43580. /**
  43581. * Registers the component in a given scene
  43582. */
  43583. register(): void;
  43584. /**
  43585. * Rebuilds the elements related to this component in case of
  43586. * context lost for instance.
  43587. */
  43588. rebuild(): void;
  43589. /**
  43590. * Disposes the component and the associated ressources
  43591. */
  43592. dispose(): void;
  43593. private _beforeCameraUpdate;
  43594. }
  43595. }
  43596. declare module "babylonjs/Cameras/universalCamera" {
  43597. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43598. import { Scene } from "babylonjs/scene";
  43599. import { Vector3 } from "babylonjs/Maths/math.vector";
  43600. import "babylonjs/Gamepads/gamepadSceneComponent";
  43601. /**
  43602. * 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,
  43603. * which still works and will still be found in many Playgrounds.
  43604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43605. */
  43606. export class UniversalCamera extends TouchCamera {
  43607. /**
  43608. * Defines the gamepad rotation sensiblity.
  43609. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43610. */
  43611. get gamepadAngularSensibility(): number;
  43612. set gamepadAngularSensibility(value: number);
  43613. /**
  43614. * Defines the gamepad move sensiblity.
  43615. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43616. */
  43617. get gamepadMoveSensibility(): number;
  43618. set gamepadMoveSensibility(value: number);
  43619. /**
  43620. * 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,
  43621. * which still works and will still be found in many Playgrounds.
  43622. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43623. * @param name Define the name of the camera in the scene
  43624. * @param position Define the start position of the camera in the scene
  43625. * @param scene Define the scene the camera belongs to
  43626. */
  43627. constructor(name: string, position: Vector3, scene: Scene);
  43628. /**
  43629. * Gets the current object class name.
  43630. * @return the class name
  43631. */
  43632. getClassName(): string;
  43633. }
  43634. }
  43635. declare module "babylonjs/Cameras/gamepadCamera" {
  43636. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43637. import { Scene } from "babylonjs/scene";
  43638. import { Vector3 } from "babylonjs/Maths/math.vector";
  43639. /**
  43640. * This represents a FPS type of camera. This is only here for back compat purpose.
  43641. * Please use the UniversalCamera instead as both are identical.
  43642. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43643. */
  43644. export class GamepadCamera extends UniversalCamera {
  43645. /**
  43646. * Instantiates a new Gamepad Camera
  43647. * This represents a FPS type of camera. This is only here for back compat purpose.
  43648. * Please use the UniversalCamera instead as both are identical.
  43649. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43650. * @param name Define the name of the camera in the scene
  43651. * @param position Define the start position of the camera in the scene
  43652. * @param scene Define the scene the camera belongs to
  43653. */
  43654. constructor(name: string, position: Vector3, scene: Scene);
  43655. /**
  43656. * Gets the current object class name.
  43657. * @return the class name
  43658. */
  43659. getClassName(): string;
  43660. }
  43661. }
  43662. declare module "babylonjs/Shaders/pass.fragment" {
  43663. /** @hidden */
  43664. export var passPixelShader: {
  43665. name: string;
  43666. shader: string;
  43667. };
  43668. }
  43669. declare module "babylonjs/Shaders/passCube.fragment" {
  43670. /** @hidden */
  43671. export var passCubePixelShader: {
  43672. name: string;
  43673. shader: string;
  43674. };
  43675. }
  43676. declare module "babylonjs/PostProcesses/passPostProcess" {
  43677. import { Nullable } from "babylonjs/types";
  43678. import { Camera } from "babylonjs/Cameras/camera";
  43679. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43680. import { Engine } from "babylonjs/Engines/engine";
  43681. import "babylonjs/Shaders/pass.fragment";
  43682. import "babylonjs/Shaders/passCube.fragment";
  43683. /**
  43684. * PassPostProcess which produces an output the same as it's input
  43685. */
  43686. export class PassPostProcess extends PostProcess {
  43687. /**
  43688. * Creates the PassPostProcess
  43689. * @param name The name of the effect.
  43690. * @param options The required width/height ratio to downsize to before computing the render pass.
  43691. * @param camera The camera to apply the render pass to.
  43692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43693. * @param engine The engine which the post process will be applied. (default: current engine)
  43694. * @param reusable If the post process can be reused on the same frame. (default: false)
  43695. * @param textureType The type of texture to be used when performing the post processing.
  43696. * @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)
  43697. */
  43698. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43699. }
  43700. /**
  43701. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43702. */
  43703. export class PassCubePostProcess extends PostProcess {
  43704. private _face;
  43705. /**
  43706. * Gets or sets the cube face to display.
  43707. * * 0 is +X
  43708. * * 1 is -X
  43709. * * 2 is +Y
  43710. * * 3 is -Y
  43711. * * 4 is +Z
  43712. * * 5 is -Z
  43713. */
  43714. get face(): number;
  43715. set face(value: number);
  43716. /**
  43717. * Creates the PassCubePostProcess
  43718. * @param name The name of the effect.
  43719. * @param options The required width/height ratio to downsize to before computing the render pass.
  43720. * @param camera The camera to apply the render pass to.
  43721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43722. * @param engine The engine which the post process will be applied. (default: current engine)
  43723. * @param reusable If the post process can be reused on the same frame. (default: false)
  43724. * @param textureType The type of texture to be used when performing the post processing.
  43725. * @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)
  43726. */
  43727. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43728. }
  43729. }
  43730. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43731. /** @hidden */
  43732. export var anaglyphPixelShader: {
  43733. name: string;
  43734. shader: string;
  43735. };
  43736. }
  43737. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43738. import { Engine } from "babylonjs/Engines/engine";
  43739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43740. import { Camera } from "babylonjs/Cameras/camera";
  43741. import "babylonjs/Shaders/anaglyph.fragment";
  43742. /**
  43743. * Postprocess used to generate anaglyphic rendering
  43744. */
  43745. export class AnaglyphPostProcess extends PostProcess {
  43746. private _passedProcess;
  43747. /**
  43748. * Creates a new AnaglyphPostProcess
  43749. * @param name defines postprocess name
  43750. * @param options defines creation options or target ratio scale
  43751. * @param rigCameras defines cameras using this postprocess
  43752. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43753. * @param engine defines hosting engine
  43754. * @param reusable defines if the postprocess will be reused multiple times per frame
  43755. */
  43756. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43757. }
  43758. }
  43759. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43760. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43761. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43762. import { Scene } from "babylonjs/scene";
  43763. import { Vector3 } from "babylonjs/Maths/math.vector";
  43764. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43765. /**
  43766. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43767. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43768. */
  43769. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43770. /**
  43771. * Creates a new AnaglyphArcRotateCamera
  43772. * @param name defines camera name
  43773. * @param alpha defines alpha angle (in radians)
  43774. * @param beta defines beta angle (in radians)
  43775. * @param radius defines radius
  43776. * @param target defines camera target
  43777. * @param interaxialDistance defines distance between each color axis
  43778. * @param scene defines the hosting scene
  43779. */
  43780. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43781. /**
  43782. * Gets camera class name
  43783. * @returns AnaglyphArcRotateCamera
  43784. */
  43785. getClassName(): string;
  43786. }
  43787. }
  43788. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43789. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43790. import { Scene } from "babylonjs/scene";
  43791. import { Vector3 } from "babylonjs/Maths/math.vector";
  43792. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43793. /**
  43794. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43795. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43796. */
  43797. export class AnaglyphFreeCamera extends FreeCamera {
  43798. /**
  43799. * Creates a new AnaglyphFreeCamera
  43800. * @param name defines camera name
  43801. * @param position defines initial position
  43802. * @param interaxialDistance defines distance between each color axis
  43803. * @param scene defines the hosting scene
  43804. */
  43805. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43806. /**
  43807. * Gets camera class name
  43808. * @returns AnaglyphFreeCamera
  43809. */
  43810. getClassName(): string;
  43811. }
  43812. }
  43813. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43814. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43815. import { Scene } from "babylonjs/scene";
  43816. import { Vector3 } from "babylonjs/Maths/math.vector";
  43817. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43818. /**
  43819. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43820. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43821. */
  43822. export class AnaglyphGamepadCamera extends GamepadCamera {
  43823. /**
  43824. * Creates a new AnaglyphGamepadCamera
  43825. * @param name defines camera name
  43826. * @param position defines initial position
  43827. * @param interaxialDistance defines distance between each color axis
  43828. * @param scene defines the hosting scene
  43829. */
  43830. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43831. /**
  43832. * Gets camera class name
  43833. * @returns AnaglyphGamepadCamera
  43834. */
  43835. getClassName(): string;
  43836. }
  43837. }
  43838. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43839. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43840. import { Scene } from "babylonjs/scene";
  43841. import { Vector3 } from "babylonjs/Maths/math.vector";
  43842. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43843. /**
  43844. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43845. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43846. */
  43847. export class AnaglyphUniversalCamera extends UniversalCamera {
  43848. /**
  43849. * Creates a new AnaglyphUniversalCamera
  43850. * @param name defines camera name
  43851. * @param position defines initial position
  43852. * @param interaxialDistance defines distance between each color axis
  43853. * @param scene defines the hosting scene
  43854. */
  43855. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43856. /**
  43857. * Gets camera class name
  43858. * @returns AnaglyphUniversalCamera
  43859. */
  43860. getClassName(): string;
  43861. }
  43862. }
  43863. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43864. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43865. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43866. import { Scene } from "babylonjs/scene";
  43867. import { Vector3 } from "babylonjs/Maths/math.vector";
  43868. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43869. /**
  43870. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43871. * @see http://doc.babylonjs.com/features/cameras
  43872. */
  43873. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43874. /**
  43875. * Creates a new StereoscopicArcRotateCamera
  43876. * @param name defines camera name
  43877. * @param alpha defines alpha angle (in radians)
  43878. * @param beta defines beta angle (in radians)
  43879. * @param radius defines radius
  43880. * @param target defines camera target
  43881. * @param interaxialDistance defines distance between each color axis
  43882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43883. * @param scene defines the hosting scene
  43884. */
  43885. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43886. /**
  43887. * Gets camera class name
  43888. * @returns StereoscopicArcRotateCamera
  43889. */
  43890. getClassName(): string;
  43891. }
  43892. }
  43893. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43895. import { Scene } from "babylonjs/scene";
  43896. import { Vector3 } from "babylonjs/Maths/math.vector";
  43897. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43898. /**
  43899. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43900. * @see http://doc.babylonjs.com/features/cameras
  43901. */
  43902. export class StereoscopicFreeCamera extends FreeCamera {
  43903. /**
  43904. * Creates a new StereoscopicFreeCamera
  43905. * @param name defines camera name
  43906. * @param position defines initial position
  43907. * @param interaxialDistance defines distance between each color axis
  43908. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43909. * @param scene defines the hosting scene
  43910. */
  43911. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43912. /**
  43913. * Gets camera class name
  43914. * @returns StereoscopicFreeCamera
  43915. */
  43916. getClassName(): string;
  43917. }
  43918. }
  43919. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43920. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43921. import { Scene } from "babylonjs/scene";
  43922. import { Vector3 } from "babylonjs/Maths/math.vector";
  43923. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43924. /**
  43925. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43926. * @see http://doc.babylonjs.com/features/cameras
  43927. */
  43928. export class StereoscopicGamepadCamera extends GamepadCamera {
  43929. /**
  43930. * Creates a new StereoscopicGamepadCamera
  43931. * @param name defines camera name
  43932. * @param position defines initial position
  43933. * @param interaxialDistance defines distance between each color axis
  43934. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43935. * @param scene defines the hosting scene
  43936. */
  43937. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43938. /**
  43939. * Gets camera class name
  43940. * @returns StereoscopicGamepadCamera
  43941. */
  43942. getClassName(): string;
  43943. }
  43944. }
  43945. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43946. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43947. import { Scene } from "babylonjs/scene";
  43948. import { Vector3 } from "babylonjs/Maths/math.vector";
  43949. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43950. /**
  43951. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43952. * @see http://doc.babylonjs.com/features/cameras
  43953. */
  43954. export class StereoscopicUniversalCamera extends UniversalCamera {
  43955. /**
  43956. * Creates a new StereoscopicUniversalCamera
  43957. * @param name defines camera name
  43958. * @param position defines initial position
  43959. * @param interaxialDistance defines distance between each color axis
  43960. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43961. * @param scene defines the hosting scene
  43962. */
  43963. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43964. /**
  43965. * Gets camera class name
  43966. * @returns StereoscopicUniversalCamera
  43967. */
  43968. getClassName(): string;
  43969. }
  43970. }
  43971. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43972. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43973. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43974. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43975. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43976. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43977. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43978. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43979. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43980. }
  43981. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43982. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43983. import { Scene } from "babylonjs/scene";
  43984. import { Vector3 } from "babylonjs/Maths/math.vector";
  43985. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43986. /**
  43987. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43988. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43989. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43990. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43991. */
  43992. export class VirtualJoysticksCamera extends FreeCamera {
  43993. /**
  43994. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43995. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43996. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43997. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43998. * @param name Define the name of the camera in the scene
  43999. * @param position Define the start position of the camera in the scene
  44000. * @param scene Define the scene the camera belongs to
  44001. */
  44002. constructor(name: string, position: Vector3, scene: Scene);
  44003. /**
  44004. * Gets the current object class name.
  44005. * @return the class name
  44006. */
  44007. getClassName(): string;
  44008. }
  44009. }
  44010. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  44011. import { Matrix } from "babylonjs/Maths/math.vector";
  44012. /**
  44013. * This represents all the required metrics to create a VR camera.
  44014. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44015. */
  44016. export class VRCameraMetrics {
  44017. /**
  44018. * Define the horizontal resolution off the screen.
  44019. */
  44020. hResolution: number;
  44021. /**
  44022. * Define the vertical resolution off the screen.
  44023. */
  44024. vResolution: number;
  44025. /**
  44026. * Define the horizontal screen size.
  44027. */
  44028. hScreenSize: number;
  44029. /**
  44030. * Define the vertical screen size.
  44031. */
  44032. vScreenSize: number;
  44033. /**
  44034. * Define the vertical screen center position.
  44035. */
  44036. vScreenCenter: number;
  44037. /**
  44038. * Define the distance of the eyes to the screen.
  44039. */
  44040. eyeToScreenDistance: number;
  44041. /**
  44042. * Define the distance between both lenses
  44043. */
  44044. lensSeparationDistance: number;
  44045. /**
  44046. * Define the distance between both viewer's eyes.
  44047. */
  44048. interpupillaryDistance: number;
  44049. /**
  44050. * Define the distortion factor of the VR postprocess.
  44051. * Please, touch with care.
  44052. */
  44053. distortionK: number[];
  44054. /**
  44055. * Define the chromatic aberration correction factors for the VR post process.
  44056. */
  44057. chromaAbCorrection: number[];
  44058. /**
  44059. * Define the scale factor of the post process.
  44060. * The smaller the better but the slower.
  44061. */
  44062. postProcessScaleFactor: number;
  44063. /**
  44064. * Define an offset for the lens center.
  44065. */
  44066. lensCenterOffset: number;
  44067. /**
  44068. * Define if the current vr camera should compensate the distortion of the lense or not.
  44069. */
  44070. compensateDistortion: boolean;
  44071. /**
  44072. * Defines if multiview should be enabled when rendering (Default: false)
  44073. */
  44074. multiviewEnabled: boolean;
  44075. /**
  44076. * Gets the rendering aspect ratio based on the provided resolutions.
  44077. */
  44078. get aspectRatio(): number;
  44079. /**
  44080. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44081. */
  44082. get aspectRatioFov(): number;
  44083. /**
  44084. * @hidden
  44085. */
  44086. get leftHMatrix(): Matrix;
  44087. /**
  44088. * @hidden
  44089. */
  44090. get rightHMatrix(): Matrix;
  44091. /**
  44092. * @hidden
  44093. */
  44094. get leftPreViewMatrix(): Matrix;
  44095. /**
  44096. * @hidden
  44097. */
  44098. get rightPreViewMatrix(): Matrix;
  44099. /**
  44100. * Get the default VRMetrics based on the most generic setup.
  44101. * @returns the default vr metrics
  44102. */
  44103. static GetDefault(): VRCameraMetrics;
  44104. }
  44105. }
  44106. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  44107. /** @hidden */
  44108. export var vrDistortionCorrectionPixelShader: {
  44109. name: string;
  44110. shader: string;
  44111. };
  44112. }
  44113. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  44114. import { Camera } from "babylonjs/Cameras/camera";
  44115. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44117. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  44118. /**
  44119. * VRDistortionCorrectionPostProcess used for mobile VR
  44120. */
  44121. export class VRDistortionCorrectionPostProcess extends PostProcess {
  44122. private _isRightEye;
  44123. private _distortionFactors;
  44124. private _postProcessScaleFactor;
  44125. private _lensCenterOffset;
  44126. private _scaleIn;
  44127. private _scaleFactor;
  44128. private _lensCenter;
  44129. /**
  44130. * Initializes the VRDistortionCorrectionPostProcess
  44131. * @param name The name of the effect.
  44132. * @param camera The camera to apply the render pass to.
  44133. * @param isRightEye If this is for the right eye distortion
  44134. * @param vrMetrics All the required metrics for the VR camera
  44135. */
  44136. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  44137. }
  44138. }
  44139. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  44140. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  44141. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44142. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44143. import { Scene } from "babylonjs/scene";
  44144. import { Vector3 } from "babylonjs/Maths/math.vector";
  44145. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  44146. import "babylonjs/Cameras/RigModes/vrRigMode";
  44147. /**
  44148. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  44149. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44150. */
  44151. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  44152. /**
  44153. * Creates a new VRDeviceOrientationArcRotateCamera
  44154. * @param name defines camera name
  44155. * @param alpha defines the camera rotation along the logitudinal axis
  44156. * @param beta defines the camera rotation along the latitudinal axis
  44157. * @param radius defines the camera distance from its target
  44158. * @param target defines the camera target
  44159. * @param scene defines the scene the camera belongs to
  44160. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44161. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44162. */
  44163. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44164. /**
  44165. * Gets camera class name
  44166. * @returns VRDeviceOrientationArcRotateCamera
  44167. */
  44168. getClassName(): string;
  44169. }
  44170. }
  44171. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  44172. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44173. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44174. import { Scene } from "babylonjs/scene";
  44175. import { Vector3 } from "babylonjs/Maths/math.vector";
  44176. import "babylonjs/Cameras/RigModes/vrRigMode";
  44177. /**
  44178. * Camera used to simulate VR rendering (based on FreeCamera)
  44179. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44180. */
  44181. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  44182. /**
  44183. * Creates a new VRDeviceOrientationFreeCamera
  44184. * @param name defines camera name
  44185. * @param position defines the start position of the camera
  44186. * @param scene defines the scene the camera belongs to
  44187. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44188. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44189. */
  44190. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44191. /**
  44192. * Gets camera class name
  44193. * @returns VRDeviceOrientationFreeCamera
  44194. */
  44195. getClassName(): string;
  44196. }
  44197. }
  44198. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  44199. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44200. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44201. import { Scene } from "babylonjs/scene";
  44202. import { Vector3 } from "babylonjs/Maths/math.vector";
  44203. import "babylonjs/Gamepads/gamepadSceneComponent";
  44204. /**
  44205. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  44206. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44207. */
  44208. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  44209. /**
  44210. * Creates a new VRDeviceOrientationGamepadCamera
  44211. * @param name defines camera name
  44212. * @param position defines the start position of the camera
  44213. * @param scene defines the scene the camera belongs to
  44214. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44215. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44216. */
  44217. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44218. /**
  44219. * Gets camera class name
  44220. * @returns VRDeviceOrientationGamepadCamera
  44221. */
  44222. getClassName(): string;
  44223. }
  44224. }
  44225. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  44226. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44227. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44228. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44229. /** @hidden */
  44230. export var imageProcessingPixelShader: {
  44231. name: string;
  44232. shader: string;
  44233. };
  44234. }
  44235. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44236. import { Nullable } from "babylonjs/types";
  44237. import { Color4 } from "babylonjs/Maths/math.color";
  44238. import { Camera } from "babylonjs/Cameras/camera";
  44239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44240. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44241. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44242. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44243. import { Engine } from "babylonjs/Engines/engine";
  44244. import "babylonjs/Shaders/imageProcessing.fragment";
  44245. import "babylonjs/Shaders/postprocess.vertex";
  44246. /**
  44247. * ImageProcessingPostProcess
  44248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44249. */
  44250. export class ImageProcessingPostProcess extends PostProcess {
  44251. /**
  44252. * Default configuration related to image processing available in the PBR Material.
  44253. */
  44254. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44255. /**
  44256. * Gets the image processing configuration used either in this material.
  44257. */
  44258. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44259. /**
  44260. * Sets the Default image processing configuration used either in the this material.
  44261. *
  44262. * If sets to null, the scene one is in use.
  44263. */
  44264. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44265. /**
  44266. * Keep track of the image processing observer to allow dispose and replace.
  44267. */
  44268. private _imageProcessingObserver;
  44269. /**
  44270. * Attaches a new image processing configuration to the PBR Material.
  44271. * @param configuration
  44272. */
  44273. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44274. /**
  44275. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44276. */
  44277. get colorCurves(): Nullable<ColorCurves>;
  44278. /**
  44279. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44280. */
  44281. set colorCurves(value: Nullable<ColorCurves>);
  44282. /**
  44283. * Gets wether the color curves effect is enabled.
  44284. */
  44285. get colorCurvesEnabled(): boolean;
  44286. /**
  44287. * Sets wether the color curves effect is enabled.
  44288. */
  44289. set colorCurvesEnabled(value: boolean);
  44290. /**
  44291. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44292. */
  44293. get colorGradingTexture(): Nullable<BaseTexture>;
  44294. /**
  44295. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44296. */
  44297. set colorGradingTexture(value: Nullable<BaseTexture>);
  44298. /**
  44299. * Gets wether the color grading effect is enabled.
  44300. */
  44301. get colorGradingEnabled(): boolean;
  44302. /**
  44303. * Gets wether the color grading effect is enabled.
  44304. */
  44305. set colorGradingEnabled(value: boolean);
  44306. /**
  44307. * Gets exposure used in the effect.
  44308. */
  44309. get exposure(): number;
  44310. /**
  44311. * Sets exposure used in the effect.
  44312. */
  44313. set exposure(value: number);
  44314. /**
  44315. * Gets wether tonemapping is enabled or not.
  44316. */
  44317. get toneMappingEnabled(): boolean;
  44318. /**
  44319. * Sets wether tonemapping is enabled or not
  44320. */
  44321. set toneMappingEnabled(value: boolean);
  44322. /**
  44323. * Gets the type of tone mapping effect.
  44324. */
  44325. get toneMappingType(): number;
  44326. /**
  44327. * Sets the type of tone mapping effect.
  44328. */
  44329. set toneMappingType(value: number);
  44330. /**
  44331. * Gets contrast used in the effect.
  44332. */
  44333. get contrast(): number;
  44334. /**
  44335. * Sets contrast used in the effect.
  44336. */
  44337. set contrast(value: number);
  44338. /**
  44339. * Gets Vignette stretch size.
  44340. */
  44341. get vignetteStretch(): number;
  44342. /**
  44343. * Sets Vignette stretch size.
  44344. */
  44345. set vignetteStretch(value: number);
  44346. /**
  44347. * Gets Vignette centre X Offset.
  44348. */
  44349. get vignetteCentreX(): number;
  44350. /**
  44351. * Sets Vignette centre X Offset.
  44352. */
  44353. set vignetteCentreX(value: number);
  44354. /**
  44355. * Gets Vignette centre Y Offset.
  44356. */
  44357. get vignetteCentreY(): number;
  44358. /**
  44359. * Sets Vignette centre Y Offset.
  44360. */
  44361. set vignetteCentreY(value: number);
  44362. /**
  44363. * Gets Vignette weight or intensity of the vignette effect.
  44364. */
  44365. get vignetteWeight(): number;
  44366. /**
  44367. * Sets Vignette weight or intensity of the vignette effect.
  44368. */
  44369. set vignetteWeight(value: number);
  44370. /**
  44371. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44372. * if vignetteEnabled is set to true.
  44373. */
  44374. get vignetteColor(): Color4;
  44375. /**
  44376. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44377. * if vignetteEnabled is set to true.
  44378. */
  44379. set vignetteColor(value: Color4);
  44380. /**
  44381. * Gets Camera field of view used by the Vignette effect.
  44382. */
  44383. get vignetteCameraFov(): number;
  44384. /**
  44385. * Sets Camera field of view used by the Vignette effect.
  44386. */
  44387. set vignetteCameraFov(value: number);
  44388. /**
  44389. * Gets the vignette blend mode allowing different kind of effect.
  44390. */
  44391. get vignetteBlendMode(): number;
  44392. /**
  44393. * Sets the vignette blend mode allowing different kind of effect.
  44394. */
  44395. set vignetteBlendMode(value: number);
  44396. /**
  44397. * Gets wether the vignette effect is enabled.
  44398. */
  44399. get vignetteEnabled(): boolean;
  44400. /**
  44401. * Sets wether the vignette effect is enabled.
  44402. */
  44403. set vignetteEnabled(value: boolean);
  44404. private _fromLinearSpace;
  44405. /**
  44406. * Gets wether the input of the processing is in Gamma or Linear Space.
  44407. */
  44408. get fromLinearSpace(): boolean;
  44409. /**
  44410. * Sets wether the input of the processing is in Gamma or Linear Space.
  44411. */
  44412. set fromLinearSpace(value: boolean);
  44413. /**
  44414. * Defines cache preventing GC.
  44415. */
  44416. private _defines;
  44417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44418. /**
  44419. * "ImageProcessingPostProcess"
  44420. * @returns "ImageProcessingPostProcess"
  44421. */
  44422. getClassName(): string;
  44423. protected _updateParameters(): void;
  44424. dispose(camera?: Camera): void;
  44425. }
  44426. }
  44427. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44428. import { Scene } from "babylonjs/scene";
  44429. import { Color3 } from "babylonjs/Maths/math.color";
  44430. import { Mesh } from "babylonjs/Meshes/mesh";
  44431. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44432. import { Nullable } from "babylonjs/types";
  44433. /**
  44434. * Class containing static functions to help procedurally build meshes
  44435. */
  44436. export class GroundBuilder {
  44437. /**
  44438. * Creates a ground mesh
  44439. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44440. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44442. * @param name defines the name of the mesh
  44443. * @param options defines the options used to create the mesh
  44444. * @param scene defines the hosting scene
  44445. * @returns the ground mesh
  44446. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44447. */
  44448. static CreateGround(name: string, options: {
  44449. width?: number;
  44450. height?: number;
  44451. subdivisions?: number;
  44452. subdivisionsX?: number;
  44453. subdivisionsY?: number;
  44454. updatable?: boolean;
  44455. }, scene: any): Mesh;
  44456. /**
  44457. * Creates a tiled ground mesh
  44458. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44459. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44460. * * 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
  44461. * * 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
  44462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44463. * @param name defines the name of the mesh
  44464. * @param options defines the options used to create the mesh
  44465. * @param scene defines the hosting scene
  44466. * @returns the tiled ground mesh
  44467. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44468. */
  44469. static CreateTiledGround(name: string, options: {
  44470. xmin: number;
  44471. zmin: number;
  44472. xmax: number;
  44473. zmax: number;
  44474. subdivisions?: {
  44475. w: number;
  44476. h: number;
  44477. };
  44478. precision?: {
  44479. w: number;
  44480. h: number;
  44481. };
  44482. updatable?: boolean;
  44483. }, scene?: Nullable<Scene>): Mesh;
  44484. /**
  44485. * Creates a ground mesh from a height map
  44486. * * The parameter `url` sets the URL of the height map image resource.
  44487. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44488. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44489. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44490. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44491. * * 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.
  44492. * * 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).
  44493. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44495. * @param name defines the name of the mesh
  44496. * @param url defines the url to the height map
  44497. * @param options defines the options used to create the mesh
  44498. * @param scene defines the hosting scene
  44499. * @returns the ground mesh
  44500. * @see https://doc.babylonjs.com/babylon101/height_map
  44501. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44502. */
  44503. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44504. width?: number;
  44505. height?: number;
  44506. subdivisions?: number;
  44507. minHeight?: number;
  44508. maxHeight?: number;
  44509. colorFilter?: Color3;
  44510. alphaFilter?: number;
  44511. updatable?: boolean;
  44512. onReady?: (mesh: GroundMesh) => void;
  44513. }, scene?: Nullable<Scene>): GroundMesh;
  44514. }
  44515. }
  44516. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44517. import { Vector4 } from "babylonjs/Maths/math.vector";
  44518. import { Mesh } from "babylonjs/Meshes/mesh";
  44519. /**
  44520. * Class containing static functions to help procedurally build meshes
  44521. */
  44522. export class TorusBuilder {
  44523. /**
  44524. * Creates a torus mesh
  44525. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44526. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44527. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44529. * * 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
  44530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44531. * @param name defines the name of the mesh
  44532. * @param options defines the options used to create the mesh
  44533. * @param scene defines the hosting scene
  44534. * @returns the torus mesh
  44535. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44536. */
  44537. static CreateTorus(name: string, options: {
  44538. diameter?: number;
  44539. thickness?: number;
  44540. tessellation?: number;
  44541. updatable?: boolean;
  44542. sideOrientation?: number;
  44543. frontUVs?: Vector4;
  44544. backUVs?: Vector4;
  44545. }, scene: any): Mesh;
  44546. }
  44547. }
  44548. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44549. import { Vector4 } from "babylonjs/Maths/math.vector";
  44550. import { Color4 } from "babylonjs/Maths/math.color";
  44551. import { Mesh } from "babylonjs/Meshes/mesh";
  44552. /**
  44553. * Class containing static functions to help procedurally build meshes
  44554. */
  44555. export class CylinderBuilder {
  44556. /**
  44557. * Creates a cylinder or a cone mesh
  44558. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44559. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44560. * * 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.
  44561. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44562. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44563. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44564. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44565. * * 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).
  44566. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44567. * * 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).
  44568. * * 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
  44569. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44570. * * 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
  44571. * * 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.
  44572. * * If `enclose` is false, a ring surface is one element.
  44573. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44574. * * 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
  44575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44576. * * 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
  44577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44578. * @param name defines the name of the mesh
  44579. * @param options defines the options used to create the mesh
  44580. * @param scene defines the hosting scene
  44581. * @returns the cylinder mesh
  44582. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44583. */
  44584. static CreateCylinder(name: string, options: {
  44585. height?: number;
  44586. diameterTop?: number;
  44587. diameterBottom?: number;
  44588. diameter?: number;
  44589. tessellation?: number;
  44590. subdivisions?: number;
  44591. arc?: number;
  44592. faceColors?: Color4[];
  44593. faceUV?: Vector4[];
  44594. updatable?: boolean;
  44595. hasRings?: boolean;
  44596. enclose?: boolean;
  44597. cap?: number;
  44598. sideOrientation?: number;
  44599. frontUVs?: Vector4;
  44600. backUVs?: Vector4;
  44601. }, scene: any): Mesh;
  44602. }
  44603. }
  44604. declare module "babylonjs/XR/webXRTypes" {
  44605. import { Nullable } from "babylonjs/types";
  44606. import { IDisposable } from "babylonjs/scene";
  44607. /**
  44608. * States of the webXR experience
  44609. */
  44610. export enum WebXRState {
  44611. /**
  44612. * Transitioning to being in XR mode
  44613. */
  44614. ENTERING_XR = 0,
  44615. /**
  44616. * Transitioning to non XR mode
  44617. */
  44618. EXITING_XR = 1,
  44619. /**
  44620. * In XR mode and presenting
  44621. */
  44622. IN_XR = 2,
  44623. /**
  44624. * Not entered XR mode
  44625. */
  44626. NOT_IN_XR = 3
  44627. }
  44628. /**
  44629. * Abstraction of the XR render target
  44630. */
  44631. export interface WebXRRenderTarget extends IDisposable {
  44632. /**
  44633. * xrpresent context of the canvas which can be used to display/mirror xr content
  44634. */
  44635. canvasContext: WebGLRenderingContext;
  44636. /**
  44637. * xr layer for the canvas
  44638. */
  44639. xrLayer: Nullable<XRWebGLLayer>;
  44640. /**
  44641. * Initializes the xr layer for the session
  44642. * @param xrSession xr session
  44643. * @returns a promise that will resolve once the XR Layer has been created
  44644. */
  44645. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44646. }
  44647. }
  44648. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44649. import { Nullable } from "babylonjs/types";
  44650. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44651. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44652. /**
  44653. * COnfiguration object for WebXR output canvas
  44654. */
  44655. export class WebXRManagedOutputCanvasOptions {
  44656. /**
  44657. * An optional canvas in case you wish to create it yourself and provide it here.
  44658. * If not provided, a new canvas will be created
  44659. */
  44660. canvasElement?: HTMLCanvasElement;
  44661. /**
  44662. * Options for this XR Layer output
  44663. */
  44664. canvasOptions?: XRWebGLLayerOptions;
  44665. /**
  44666. * CSS styling for a newly created canvas (if not provided)
  44667. */
  44668. newCanvasCssStyle?: string;
  44669. /**
  44670. * Get the default values of the configuration object
  44671. * @returns default values of this configuration object
  44672. */
  44673. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44674. }
  44675. /**
  44676. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44677. */
  44678. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44679. private _options;
  44680. private _canvas;
  44681. private _engine;
  44682. /**
  44683. * Rendering context of the canvas which can be used to display/mirror xr content
  44684. */
  44685. canvasContext: WebGLRenderingContext;
  44686. /**
  44687. * xr layer for the canvas
  44688. */
  44689. xrLayer: Nullable<XRWebGLLayer>;
  44690. /**
  44691. * Initializes the canvas to be added/removed upon entering/exiting xr
  44692. * @param _xrSessionManager The XR Session manager
  44693. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44694. */
  44695. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44696. /**
  44697. * Disposes of the object
  44698. */
  44699. dispose(): void;
  44700. /**
  44701. * Initializes the xr layer for the session
  44702. * @param xrSession xr session
  44703. * @returns a promise that will resolve once the XR Layer has been created
  44704. */
  44705. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44706. private _addCanvas;
  44707. private _removeCanvas;
  44708. private _setManagedOutputCanvas;
  44709. }
  44710. }
  44711. declare module "babylonjs/XR/webXRSessionManager" {
  44712. import { Observable } from "babylonjs/Misc/observable";
  44713. import { Nullable } from "babylonjs/types";
  44714. import { IDisposable, Scene } from "babylonjs/scene";
  44715. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44716. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44717. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44718. /**
  44719. * Manages an XRSession to work with Babylon's engine
  44720. * @see https://doc.babylonjs.com/how_to/webxr
  44721. */
  44722. export class WebXRSessionManager implements IDisposable {
  44723. /** The scene which the session should be created for */
  44724. scene: Scene;
  44725. private _referenceSpace;
  44726. private _rttProvider;
  44727. private _sessionEnded;
  44728. private _xrNavigator;
  44729. private baseLayer;
  44730. /**
  44731. * The base reference space from which the session started. good if you want to reset your
  44732. * reference space
  44733. */
  44734. baseReferenceSpace: XRReferenceSpace;
  44735. /**
  44736. * Current XR frame
  44737. */
  44738. currentFrame: Nullable<XRFrame>;
  44739. /** WebXR timestamp updated every frame */
  44740. currentTimestamp: number;
  44741. /**
  44742. * Used just in case of a failure to initialize an immersive session.
  44743. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44744. */
  44745. defaultHeightCompensation: number;
  44746. /**
  44747. * Fires every time a new xrFrame arrives which can be used to update the camera
  44748. */
  44749. onXRFrameObservable: Observable<XRFrame>;
  44750. /**
  44751. * Fires when the reference space changed
  44752. */
  44753. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44754. /**
  44755. * Fires when the xr session is ended either by the device or manually done
  44756. */
  44757. onXRSessionEnded: Observable<any>;
  44758. /**
  44759. * Fires when the xr session is ended either by the device or manually done
  44760. */
  44761. onXRSessionInit: Observable<XRSession>;
  44762. /**
  44763. * Underlying xr session
  44764. */
  44765. session: XRSession;
  44766. /**
  44767. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44768. * or get the offset the player is currently at.
  44769. */
  44770. viewerReferenceSpace: XRReferenceSpace;
  44771. /**
  44772. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44773. * @param scene The scene which the session should be created for
  44774. */
  44775. constructor(
  44776. /** The scene which the session should be created for */
  44777. scene: Scene);
  44778. /**
  44779. * The current reference space used in this session. This reference space can constantly change!
  44780. * It is mainly used to offset the camera's position.
  44781. */
  44782. get referenceSpace(): XRReferenceSpace;
  44783. /**
  44784. * Set a new reference space and triggers the observable
  44785. */
  44786. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44787. /**
  44788. * Disposes of the session manager
  44789. */
  44790. dispose(): void;
  44791. /**
  44792. * Stops the xrSession and restores the render loop
  44793. * @returns Promise which resolves after it exits XR
  44794. */
  44795. exitXRAsync(): Promise<void>;
  44796. /**
  44797. * Gets the correct render target texture to be rendered this frame for this eye
  44798. * @param eye the eye for which to get the render target
  44799. * @returns the render target for the specified eye
  44800. */
  44801. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44802. /**
  44803. * Creates a WebXRRenderTarget object for the XR session
  44804. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44805. * @param options optional options to provide when creating a new render target
  44806. * @returns a WebXR render target to which the session can render
  44807. */
  44808. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44809. /**
  44810. * Initializes the manager
  44811. * After initialization enterXR can be called to start an XR session
  44812. * @returns Promise which resolves after it is initialized
  44813. */
  44814. initializeAsync(): Promise<void>;
  44815. /**
  44816. * Initializes an xr session
  44817. * @param xrSessionMode mode to initialize
  44818. * @param xrSessionInit defines optional and required values to pass to the session builder
  44819. * @returns a promise which will resolve once the session has been initialized
  44820. */
  44821. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44822. /**
  44823. * Checks if a session would be supported for the creation options specified
  44824. * @param sessionMode session mode to check if supported eg. immersive-vr
  44825. * @returns A Promise that resolves to true if supported and false if not
  44826. */
  44827. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44828. /**
  44829. * Resets the reference space to the one started the session
  44830. */
  44831. resetReferenceSpace(): void;
  44832. /**
  44833. * Starts rendering to the xr layer
  44834. */
  44835. runXRRenderLoop(): void;
  44836. /**
  44837. * Sets the reference space on the xr session
  44838. * @param referenceSpaceType space to set
  44839. * @returns a promise that will resolve once the reference space has been set
  44840. */
  44841. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44842. /**
  44843. * Updates the render state of the session
  44844. * @param state state to set
  44845. * @returns a promise that resolves once the render state has been updated
  44846. */
  44847. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44848. /**
  44849. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44850. * @param sessionMode defines the session to test
  44851. * @returns a promise with boolean as final value
  44852. */
  44853. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44854. private _createRenderTargetTexture;
  44855. }
  44856. }
  44857. declare module "babylonjs/XR/webXRCamera" {
  44858. import { Scene } from "babylonjs/scene";
  44859. import { Camera } from "babylonjs/Cameras/camera";
  44860. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44861. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44862. /**
  44863. * WebXR Camera which holds the views for the xrSession
  44864. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44865. */
  44866. export class WebXRCamera extends FreeCamera {
  44867. private _xrSessionManager;
  44868. private _firstFrame;
  44869. private _referenceQuaternion;
  44870. private _referencedPosition;
  44871. private _xrInvPositionCache;
  44872. private _xrInvQuaternionCache;
  44873. /**
  44874. * Should position compensation execute on first frame.
  44875. * This is used when copying the position from a native (non XR) camera
  44876. */
  44877. compensateOnFirstFrame: boolean;
  44878. /**
  44879. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44880. * @param name the name of the camera
  44881. * @param scene the scene to add the camera to
  44882. * @param _xrSessionManager a constructed xr session manager
  44883. */
  44884. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44885. /**
  44886. * Return the user's height, unrelated to the current ground.
  44887. * This will be the y position of this camera, when ground level is 0.
  44888. */
  44889. get realWorldHeight(): number;
  44890. /** @hidden */
  44891. _updateForDualEyeDebugging(): void;
  44892. /**
  44893. * Sets this camera's transformation based on a non-vr camera
  44894. * @param otherCamera the non-vr camera to copy the transformation from
  44895. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44896. */
  44897. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44898. /**
  44899. * Gets the current instance class name ("WebXRCamera").
  44900. * @returns the class name
  44901. */
  44902. getClassName(): string;
  44903. private _updateFromXRSession;
  44904. private _updateNumberOfRigCameras;
  44905. private _updateReferenceSpace;
  44906. private _updateReferenceSpaceOffset;
  44907. }
  44908. }
  44909. declare module "babylonjs/XR/webXRFeaturesManager" {
  44910. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44911. import { IDisposable } from "babylonjs/scene";
  44912. /**
  44913. * Defining the interface required for a (webxr) feature
  44914. */
  44915. export interface IWebXRFeature extends IDisposable {
  44916. /**
  44917. * Is this feature attached
  44918. */
  44919. attached: boolean;
  44920. /**
  44921. * Should auto-attach be disabled?
  44922. */
  44923. disableAutoAttach: boolean;
  44924. /**
  44925. * Attach the feature to the session
  44926. * Will usually be called by the features manager
  44927. *
  44928. * @param force should attachment be forced (even when already attached)
  44929. * @returns true if successful.
  44930. */
  44931. attach(force?: boolean): boolean;
  44932. /**
  44933. * Detach the feature from the session
  44934. * Will usually be called by the features manager
  44935. *
  44936. * @returns true if successful.
  44937. */
  44938. detach(): boolean;
  44939. }
  44940. /**
  44941. * A list of the currently available features without referencing them
  44942. */
  44943. export class WebXRFeatureName {
  44944. /**
  44945. * The name of the anchor system feature
  44946. */
  44947. static ANCHOR_SYSTEM: string;
  44948. /**
  44949. * The name of the background remover feature
  44950. */
  44951. static BACKGROUND_REMOVER: string;
  44952. /**
  44953. * The name of the hit test feature
  44954. */
  44955. static HIT_TEST: string;
  44956. /**
  44957. * physics impostors for xr controllers feature
  44958. */
  44959. static PHYSICS_CONTROLLERS: string;
  44960. /**
  44961. * The name of the plane detection feature
  44962. */
  44963. static PLANE_DETECTION: string;
  44964. /**
  44965. * The name of the pointer selection feature
  44966. */
  44967. static POINTER_SELECTION: string;
  44968. /**
  44969. * The name of the teleportation feature
  44970. */
  44971. static TELEPORTATION: string;
  44972. }
  44973. /**
  44974. * Defining the constructor of a feature. Used to register the modules.
  44975. */
  44976. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44977. /**
  44978. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44979. * It is mainly used in AR sessions.
  44980. *
  44981. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44982. */
  44983. export class WebXRFeaturesManager implements IDisposable {
  44984. private _xrSessionManager;
  44985. private static readonly _AvailableFeatures;
  44986. private _features;
  44987. /**
  44988. * constructs a new features manages.
  44989. *
  44990. * @param _xrSessionManager an instance of WebXRSessionManager
  44991. */
  44992. constructor(_xrSessionManager: WebXRSessionManager);
  44993. /**
  44994. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44995. * Mainly used internally.
  44996. *
  44997. * @param featureName the name of the feature to register
  44998. * @param constructorFunction the function used to construct the module
  44999. * @param version the (babylon) version of the module
  45000. * @param stable is that a stable version of this module
  45001. */
  45002. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45003. /**
  45004. * Returns a constructor of a specific feature.
  45005. *
  45006. * @param featureName the name of the feature to construct
  45007. * @param version the version of the feature to load
  45008. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45009. * @param options optional options provided to the module.
  45010. * @returns a function that, when called, will return a new instance of this feature
  45011. */
  45012. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45013. /**
  45014. * Can be used to return the list of features currently registered
  45015. *
  45016. * @returns an Array of available features
  45017. */
  45018. static GetAvailableFeatures(): string[];
  45019. /**
  45020. * Gets the versions available for a specific feature
  45021. * @param featureName the name of the feature
  45022. * @returns an array with the available versions
  45023. */
  45024. static GetAvailableVersions(featureName: string): string[];
  45025. /**
  45026. * Return the latest unstable version of this feature
  45027. * @param featureName the name of the feature to search
  45028. * @returns the version number. if not found will return -1
  45029. */
  45030. static GetLatestVersionOfFeature(featureName: string): number;
  45031. /**
  45032. * Return the latest stable version of this feature
  45033. * @param featureName the name of the feature to search
  45034. * @returns the version number. if not found will return -1
  45035. */
  45036. static GetStableVersionOfFeature(featureName: string): number;
  45037. /**
  45038. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45039. * Can be used during a session to start a feature
  45040. * @param featureName the name of feature to attach
  45041. */
  45042. attachFeature(featureName: string): void;
  45043. /**
  45044. * Can be used inside a session or when the session ends to detach a specific feature
  45045. * @param featureName the name of the feature to detach
  45046. */
  45047. detachFeature(featureName: string): void;
  45048. /**
  45049. * Used to disable an already-enabled feature
  45050. * The feature will be disposed and will be recreated once enabled.
  45051. * @param featureName the feature to disable
  45052. * @returns true if disable was successful
  45053. */
  45054. disableFeature(featureName: string | {
  45055. Name: string;
  45056. }): boolean;
  45057. /**
  45058. * dispose this features manager
  45059. */
  45060. dispose(): void;
  45061. /**
  45062. * 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.
  45063. * 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.
  45064. *
  45065. * @param featureName the name of the feature to load or the class of the feature
  45066. * @param version optional version to load. if not provided the latest version will be enabled
  45067. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45068. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45069. * @returns a new constructed feature or throws an error if feature not found.
  45070. */
  45071. enableFeature(featureName: string | {
  45072. Name: string;
  45073. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45074. /**
  45075. * get the implementation of an enabled feature.
  45076. * @param featureName the name of the feature to load
  45077. * @returns the feature class, if found
  45078. */
  45079. getEnabledFeature(featureName: string): IWebXRFeature;
  45080. /**
  45081. * Get the list of enabled features
  45082. * @returns an array of enabled features
  45083. */
  45084. getEnabledFeatures(): string[];
  45085. }
  45086. }
  45087. declare module "babylonjs/XR/webXRExperienceHelper" {
  45088. import { Observable } from "babylonjs/Misc/observable";
  45089. import { IDisposable, Scene } from "babylonjs/scene";
  45090. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45091. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45092. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  45093. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  45094. /**
  45095. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45096. * @see https://doc.babylonjs.com/how_to/webxr
  45097. */
  45098. export class WebXRExperienceHelper implements IDisposable {
  45099. private scene;
  45100. private _nonVRCamera;
  45101. private _originalSceneAutoClear;
  45102. private _supported;
  45103. /**
  45104. * Camera used to render xr content
  45105. */
  45106. camera: WebXRCamera;
  45107. /** A features manager for this xr session */
  45108. featuresManager: WebXRFeaturesManager;
  45109. /**
  45110. * Observers registered here will be triggered after the camera's initial transformation is set
  45111. * This can be used to set a different ground level or an extra rotation.
  45112. *
  45113. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45114. * to the position set after this observable is done executing.
  45115. */
  45116. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45117. /**
  45118. * Fires when the state of the experience helper has changed
  45119. */
  45120. onStateChangedObservable: Observable<WebXRState>;
  45121. /** Session manager used to keep track of xr session */
  45122. sessionManager: WebXRSessionManager;
  45123. /**
  45124. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45125. */
  45126. state: WebXRState;
  45127. /**
  45128. * Creates a WebXRExperienceHelper
  45129. * @param scene The scene the helper should be created in
  45130. */
  45131. private constructor();
  45132. /**
  45133. * Creates the experience helper
  45134. * @param scene the scene to attach the experience helper to
  45135. * @returns a promise for the experience helper
  45136. */
  45137. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45138. /**
  45139. * Disposes of the experience helper
  45140. */
  45141. dispose(): void;
  45142. /**
  45143. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45144. * @param sessionMode options for the XR session
  45145. * @param referenceSpaceType frame of reference of the XR session
  45146. * @param renderTarget the output canvas that will be used to enter XR mode
  45147. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  45148. * @returns promise that resolves after xr mode has entered
  45149. */
  45150. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  45151. /**
  45152. * Exits XR mode and returns the scene to its original state
  45153. * @returns promise that resolves after xr mode has exited
  45154. */
  45155. exitXRAsync(): Promise<void>;
  45156. private _nonXRToXRCamera;
  45157. private _setState;
  45158. }
  45159. }
  45160. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  45161. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45162. import { Observable } from "babylonjs/Misc/observable";
  45163. import { IDisposable } from "babylonjs/scene";
  45164. /**
  45165. * X-Y values for axes in WebXR
  45166. */
  45167. export interface IWebXRMotionControllerAxesValue {
  45168. /**
  45169. * The value of the x axis
  45170. */
  45171. x: number;
  45172. /**
  45173. * The value of the y-axis
  45174. */
  45175. y: number;
  45176. }
  45177. /**
  45178. * changed / previous values for the values of this component
  45179. */
  45180. export interface IWebXRMotionControllerComponentChangesValues<T> {
  45181. /**
  45182. * current (this frame) value
  45183. */
  45184. current: T;
  45185. /**
  45186. * previous (last change) value
  45187. */
  45188. previous: T;
  45189. }
  45190. /**
  45191. * Represents changes in the component between current frame and last values recorded
  45192. */
  45193. export interface IWebXRMotionControllerComponentChanges {
  45194. /**
  45195. * will be populated with previous and current values if axes changed
  45196. */
  45197. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  45198. /**
  45199. * will be populated with previous and current values if pressed changed
  45200. */
  45201. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45202. /**
  45203. * will be populated with previous and current values if touched changed
  45204. */
  45205. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45206. /**
  45207. * will be populated with previous and current values if value changed
  45208. */
  45209. value?: IWebXRMotionControllerComponentChangesValues<number>;
  45210. }
  45211. /**
  45212. * This class represents a single component (for example button or thumbstick) of a motion controller
  45213. */
  45214. export class WebXRControllerComponent implements IDisposable {
  45215. /**
  45216. * the id of this component
  45217. */
  45218. id: string;
  45219. /**
  45220. * the type of the component
  45221. */
  45222. type: MotionControllerComponentType;
  45223. private _buttonIndex;
  45224. private _axesIndices;
  45225. private _axes;
  45226. private _changes;
  45227. private _currentValue;
  45228. private _hasChanges;
  45229. private _pressed;
  45230. private _touched;
  45231. /**
  45232. * button component type
  45233. */
  45234. static BUTTON_TYPE: MotionControllerComponentType;
  45235. /**
  45236. * squeeze component type
  45237. */
  45238. static SQUEEZE_TYPE: MotionControllerComponentType;
  45239. /**
  45240. * Thumbstick component type
  45241. */
  45242. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45243. /**
  45244. * Touchpad component type
  45245. */
  45246. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45247. /**
  45248. * trigger component type
  45249. */
  45250. static TRIGGER_TYPE: MotionControllerComponentType;
  45251. /**
  45252. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45253. * the axes data changes
  45254. */
  45255. onAxisValueChangedObservable: Observable<{
  45256. x: number;
  45257. y: number;
  45258. }>;
  45259. /**
  45260. * Observers registered here will be triggered when the state of a button changes
  45261. * State change is either pressed / touched / value
  45262. */
  45263. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45264. /**
  45265. * Creates a new component for a motion controller.
  45266. * It is created by the motion controller itself
  45267. *
  45268. * @param id the id of this component
  45269. * @param type the type of the component
  45270. * @param _buttonIndex index in the buttons array of the gamepad
  45271. * @param _axesIndices indices of the values in the axes array of the gamepad
  45272. */
  45273. constructor(
  45274. /**
  45275. * the id of this component
  45276. */
  45277. id: string,
  45278. /**
  45279. * the type of the component
  45280. */
  45281. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45282. /**
  45283. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45284. */
  45285. get axes(): IWebXRMotionControllerAxesValue;
  45286. /**
  45287. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45288. */
  45289. get changes(): IWebXRMotionControllerComponentChanges;
  45290. /**
  45291. * Return whether or not the component changed the last frame
  45292. */
  45293. get hasChanges(): boolean;
  45294. /**
  45295. * is the button currently pressed
  45296. */
  45297. get pressed(): boolean;
  45298. /**
  45299. * is the button currently touched
  45300. */
  45301. get touched(): boolean;
  45302. /**
  45303. * Get the current value of this component
  45304. */
  45305. get value(): number;
  45306. /**
  45307. * Dispose this component
  45308. */
  45309. dispose(): void;
  45310. /**
  45311. * Are there axes correlating to this component
  45312. * @return true is axes data is available
  45313. */
  45314. isAxes(): boolean;
  45315. /**
  45316. * Is this component a button (hence - pressable)
  45317. * @returns true if can be pressed
  45318. */
  45319. isButton(): boolean;
  45320. /**
  45321. * update this component using the gamepad object it is in. Called on every frame
  45322. * @param nativeController the native gamepad controller object
  45323. */
  45324. update(nativeController: IMinimalMotionControllerObject): void;
  45325. }
  45326. }
  45327. declare module "babylonjs/Loading/sceneLoader" {
  45328. import { Observable } from "babylonjs/Misc/observable";
  45329. import { Nullable } from "babylonjs/types";
  45330. import { Scene } from "babylonjs/scene";
  45331. import { Engine } from "babylonjs/Engines/engine";
  45332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45333. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45334. import { AssetContainer } from "babylonjs/assetContainer";
  45335. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45336. import { Skeleton } from "babylonjs/Bones/skeleton";
  45337. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45338. import { WebRequest } from "babylonjs/Misc/webRequest";
  45339. /**
  45340. * Class used to represent data loading progression
  45341. */
  45342. export class SceneLoaderProgressEvent {
  45343. /** defines if data length to load can be evaluated */
  45344. readonly lengthComputable: boolean;
  45345. /** defines the loaded data length */
  45346. readonly loaded: number;
  45347. /** defines the data length to load */
  45348. readonly total: number;
  45349. /**
  45350. * Create a new progress event
  45351. * @param lengthComputable defines if data length to load can be evaluated
  45352. * @param loaded defines the loaded data length
  45353. * @param total defines the data length to load
  45354. */
  45355. constructor(
  45356. /** defines if data length to load can be evaluated */
  45357. lengthComputable: boolean,
  45358. /** defines the loaded data length */
  45359. loaded: number,
  45360. /** defines the data length to load */
  45361. total: number);
  45362. /**
  45363. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45364. * @param event defines the source event
  45365. * @returns a new SceneLoaderProgressEvent
  45366. */
  45367. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45368. }
  45369. /**
  45370. * Interface used by SceneLoader plugins to define supported file extensions
  45371. */
  45372. export interface ISceneLoaderPluginExtensions {
  45373. /**
  45374. * Defines the list of supported extensions
  45375. */
  45376. [extension: string]: {
  45377. isBinary: boolean;
  45378. };
  45379. }
  45380. /**
  45381. * Interface used by SceneLoader plugin factory
  45382. */
  45383. export interface ISceneLoaderPluginFactory {
  45384. /**
  45385. * Defines the name of the factory
  45386. */
  45387. name: string;
  45388. /**
  45389. * Function called to create a new plugin
  45390. * @return the new plugin
  45391. */
  45392. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45393. /**
  45394. * The callback that returns true if the data can be directly loaded.
  45395. * @param data string containing the file data
  45396. * @returns if the data can be loaded directly
  45397. */
  45398. canDirectLoad?(data: string): boolean;
  45399. }
  45400. /**
  45401. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45402. */
  45403. export interface ISceneLoaderPluginBase {
  45404. /**
  45405. * The friendly name of this plugin.
  45406. */
  45407. name: string;
  45408. /**
  45409. * The file extensions supported by this plugin.
  45410. */
  45411. extensions: string | ISceneLoaderPluginExtensions;
  45412. /**
  45413. * The callback called when loading from a url.
  45414. * @param scene scene loading this url
  45415. * @param url url to load
  45416. * @param onSuccess callback called when the file successfully loads
  45417. * @param onProgress callback called while file is loading (if the server supports this mode)
  45418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45419. * @param onError callback called when the file fails to load
  45420. * @returns a file request object
  45421. */
  45422. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45423. /**
  45424. * The callback called when loading from a file object.
  45425. * @param scene scene loading this file
  45426. * @param file defines the file to load
  45427. * @param onSuccess defines the callback to call when data is loaded
  45428. * @param onProgress defines the callback to call during loading process
  45429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45430. * @param onError defines the callback to call when an error occurs
  45431. * @returns a file request object
  45432. */
  45433. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45434. /**
  45435. * The callback that returns true if the data can be directly loaded.
  45436. * @param data string containing the file data
  45437. * @returns if the data can be loaded directly
  45438. */
  45439. canDirectLoad?(data: string): boolean;
  45440. /**
  45441. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45442. * @param scene scene loading this data
  45443. * @param data string containing the data
  45444. * @returns data to pass to the plugin
  45445. */
  45446. directLoad?(scene: Scene, data: string): any;
  45447. /**
  45448. * The callback that allows custom handling of the root url based on the response url.
  45449. * @param rootUrl the original root url
  45450. * @param responseURL the response url if available
  45451. * @returns the new root url
  45452. */
  45453. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45454. }
  45455. /**
  45456. * Interface used to define a SceneLoader plugin
  45457. */
  45458. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45459. /**
  45460. * Import meshes into a scene.
  45461. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45462. * @param scene The scene to import into
  45463. * @param data The data to import
  45464. * @param rootUrl The root url for scene and resources
  45465. * @param meshes The meshes array to import into
  45466. * @param particleSystems The particle systems array to import into
  45467. * @param skeletons The skeletons array to import into
  45468. * @param onError The callback when import fails
  45469. * @returns True if successful or false otherwise
  45470. */
  45471. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45472. /**
  45473. * Load into a scene.
  45474. * @param scene The scene to load into
  45475. * @param data The data to import
  45476. * @param rootUrl The root url for scene and resources
  45477. * @param onError The callback when import fails
  45478. * @returns True if successful or false otherwise
  45479. */
  45480. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45481. /**
  45482. * Load into an asset container.
  45483. * @param scene The scene to load into
  45484. * @param data The data to import
  45485. * @param rootUrl The root url for scene and resources
  45486. * @param onError The callback when import fails
  45487. * @returns The loaded asset container
  45488. */
  45489. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45490. }
  45491. /**
  45492. * Interface used to define an async SceneLoader plugin
  45493. */
  45494. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45495. /**
  45496. * Import meshes into a scene.
  45497. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45498. * @param scene The scene to import into
  45499. * @param data The data to import
  45500. * @param rootUrl The root url for scene and resources
  45501. * @param onProgress The callback when the load progresses
  45502. * @param fileName Defines the name of the file to load
  45503. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45504. */
  45505. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45506. meshes: AbstractMesh[];
  45507. particleSystems: IParticleSystem[];
  45508. skeletons: Skeleton[];
  45509. animationGroups: AnimationGroup[];
  45510. }>;
  45511. /**
  45512. * Load into a scene.
  45513. * @param scene The scene to load into
  45514. * @param data The data to import
  45515. * @param rootUrl The root url for scene and resources
  45516. * @param onProgress The callback when the load progresses
  45517. * @param fileName Defines the name of the file to load
  45518. * @returns Nothing
  45519. */
  45520. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45521. /**
  45522. * Load into an asset container.
  45523. * @param scene The scene to load into
  45524. * @param data The data to import
  45525. * @param rootUrl The root url for scene and resources
  45526. * @param onProgress The callback when the load progresses
  45527. * @param fileName Defines the name of the file to load
  45528. * @returns The loaded asset container
  45529. */
  45530. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45531. }
  45532. /**
  45533. * Mode that determines how to handle old animation groups before loading new ones.
  45534. */
  45535. export enum SceneLoaderAnimationGroupLoadingMode {
  45536. /**
  45537. * Reset all old animations to initial state then dispose them.
  45538. */
  45539. Clean = 0,
  45540. /**
  45541. * Stop all old animations.
  45542. */
  45543. Stop = 1,
  45544. /**
  45545. * Restart old animations from first frame.
  45546. */
  45547. Sync = 2,
  45548. /**
  45549. * Old animations remains untouched.
  45550. */
  45551. NoSync = 3
  45552. }
  45553. /**
  45554. * Class used to load scene from various file formats using registered plugins
  45555. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45556. */
  45557. export class SceneLoader {
  45558. /**
  45559. * No logging while loading
  45560. */
  45561. static readonly NO_LOGGING: number;
  45562. /**
  45563. * Minimal logging while loading
  45564. */
  45565. static readonly MINIMAL_LOGGING: number;
  45566. /**
  45567. * Summary logging while loading
  45568. */
  45569. static readonly SUMMARY_LOGGING: number;
  45570. /**
  45571. * Detailled logging while loading
  45572. */
  45573. static readonly DETAILED_LOGGING: number;
  45574. /**
  45575. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45576. */
  45577. static get ForceFullSceneLoadingForIncremental(): boolean;
  45578. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45579. /**
  45580. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45581. */
  45582. static get ShowLoadingScreen(): boolean;
  45583. static set ShowLoadingScreen(value: boolean);
  45584. /**
  45585. * Defines the current logging level (while loading the scene)
  45586. * @ignorenaming
  45587. */
  45588. static get loggingLevel(): number;
  45589. static set loggingLevel(value: number);
  45590. /**
  45591. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45592. */
  45593. static get CleanBoneMatrixWeights(): boolean;
  45594. static set CleanBoneMatrixWeights(value: boolean);
  45595. /**
  45596. * Event raised when a plugin is used to load a scene
  45597. */
  45598. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45599. private static _registeredPlugins;
  45600. private static _getDefaultPlugin;
  45601. private static _getPluginForExtension;
  45602. private static _getPluginForDirectLoad;
  45603. private static _getPluginForFilename;
  45604. private static _getDirectLoad;
  45605. private static _loadData;
  45606. private static _getFileInfo;
  45607. /**
  45608. * Gets a plugin that can load the given extension
  45609. * @param extension defines the extension to load
  45610. * @returns a plugin or null if none works
  45611. */
  45612. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45613. /**
  45614. * Gets a boolean indicating that the given extension can be loaded
  45615. * @param extension defines the extension to load
  45616. * @returns true if the extension is supported
  45617. */
  45618. static IsPluginForExtensionAvailable(extension: string): boolean;
  45619. /**
  45620. * Adds a new plugin to the list of registered plugins
  45621. * @param plugin defines the plugin to add
  45622. */
  45623. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45624. /**
  45625. * Import meshes into a scene
  45626. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45627. * @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)
  45628. * @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)
  45629. * @param scene the instance of BABYLON.Scene to append to
  45630. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45631. * @param onProgress a callback with a progress event for each file being loaded
  45632. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45633. * @param pluginExtension the extension used to determine the plugin
  45634. * @returns The loaded plugin
  45635. */
  45636. 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>;
  45637. /**
  45638. * Import meshes into a scene
  45639. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45640. * @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)
  45641. * @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)
  45642. * @param scene the instance of BABYLON.Scene to append to
  45643. * @param onProgress a callback with a progress event for each file being loaded
  45644. * @param pluginExtension the extension used to determine the plugin
  45645. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45646. */
  45647. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45648. meshes: AbstractMesh[];
  45649. particleSystems: IParticleSystem[];
  45650. skeletons: Skeleton[];
  45651. animationGroups: AnimationGroup[];
  45652. }>;
  45653. /**
  45654. * Load a scene
  45655. * @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)
  45656. * @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)
  45657. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45658. * @param onSuccess a callback with the scene when import succeeds
  45659. * @param onProgress a callback with a progress event for each file being loaded
  45660. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45661. * @param pluginExtension the extension used to determine the plugin
  45662. * @returns The loaded plugin
  45663. */
  45664. 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>;
  45665. /**
  45666. * Load a scene
  45667. * @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)
  45668. * @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)
  45669. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45670. * @param onProgress a callback with a progress event for each file being loaded
  45671. * @param pluginExtension the extension used to determine the plugin
  45672. * @returns The loaded scene
  45673. */
  45674. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45675. /**
  45676. * Append a scene
  45677. * @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)
  45678. * @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)
  45679. * @param scene is the instance of BABYLON.Scene to append to
  45680. * @param onSuccess a callback with the scene when import succeeds
  45681. * @param onProgress a callback with a progress event for each file being loaded
  45682. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45683. * @param pluginExtension the extension used to determine the plugin
  45684. * @returns The loaded plugin
  45685. */
  45686. 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>;
  45687. /**
  45688. * Append a scene
  45689. * @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)
  45690. * @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)
  45691. * @param scene is the instance of BABYLON.Scene to append to
  45692. * @param onProgress a callback with a progress event for each file being loaded
  45693. * @param pluginExtension the extension used to determine the plugin
  45694. * @returns The given scene
  45695. */
  45696. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45697. /**
  45698. * Load a scene into an asset container
  45699. * @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)
  45700. * @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)
  45701. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45702. * @param onSuccess a callback with the scene when import succeeds
  45703. * @param onProgress a callback with a progress event for each file being loaded
  45704. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45705. * @param pluginExtension the extension used to determine the plugin
  45706. * @returns The loaded plugin
  45707. */
  45708. 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>;
  45709. /**
  45710. * Load a scene into an asset container
  45711. * @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)
  45712. * @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)
  45713. * @param scene is the instance of Scene to append to
  45714. * @param onProgress a callback with a progress event for each file being loaded
  45715. * @param pluginExtension the extension used to determine the plugin
  45716. * @returns The loaded asset container
  45717. */
  45718. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45719. /**
  45720. * Import animations from a file into a scene
  45721. * @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)
  45722. * @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)
  45723. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45724. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45725. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45726. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45727. * @param onSuccess a callback with the scene when import succeeds
  45728. * @param onProgress a callback with a progress event for each file being loaded
  45729. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45730. */
  45731. 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;
  45732. /**
  45733. * Import animations from a file into a scene
  45734. * @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)
  45735. * @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)
  45736. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45737. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45738. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45739. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  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. * @returns the updated scene with imported animations
  45744. */
  45745. 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>;
  45746. }
  45747. }
  45748. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45749. import { IDisposable, Scene } from "babylonjs/scene";
  45750. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45751. import { Observable } from "babylonjs/Misc/observable";
  45752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45753. import { Nullable } from "babylonjs/types";
  45754. /**
  45755. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45756. */
  45757. export type MotionControllerHandedness = "none" | "left" | "right";
  45758. /**
  45759. * The type of components available in motion controllers.
  45760. * This is not the name of the component.
  45761. */
  45762. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45763. /**
  45764. * The state of a controller component
  45765. */
  45766. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45767. /**
  45768. * The schema of motion controller layout.
  45769. * No object will be initialized using this interface
  45770. * This is used just to define the profile.
  45771. */
  45772. export interface IMotionControllerLayout {
  45773. /**
  45774. * Path to load the assets. Usually relative to the base path
  45775. */
  45776. assetPath: string;
  45777. /**
  45778. * Available components (unsorted)
  45779. */
  45780. components: {
  45781. /**
  45782. * A map of component Ids
  45783. */
  45784. [componentId: string]: {
  45785. /**
  45786. * The type of input the component outputs
  45787. */
  45788. type: MotionControllerComponentType;
  45789. /**
  45790. * The indices of this component in the gamepad object
  45791. */
  45792. gamepadIndices: {
  45793. /**
  45794. * Index of button
  45795. */
  45796. button?: number;
  45797. /**
  45798. * If available, index of x-axis
  45799. */
  45800. xAxis?: number;
  45801. /**
  45802. * If available, index of y-axis
  45803. */
  45804. yAxis?: number;
  45805. };
  45806. /**
  45807. * The mesh's root node name
  45808. */
  45809. rootNodeName: string;
  45810. /**
  45811. * Animation definitions for this model
  45812. */
  45813. visualResponses: {
  45814. [stateKey: string]: {
  45815. /**
  45816. * What property will be animated
  45817. */
  45818. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45819. /**
  45820. * What states influence this visual response
  45821. */
  45822. states: MotionControllerComponentStateType[];
  45823. /**
  45824. * Type of animation - movement or visibility
  45825. */
  45826. valueNodeProperty: "transform" | "visibility";
  45827. /**
  45828. * Base node name to move. Its position will be calculated according to the min and max nodes
  45829. */
  45830. valueNodeName?: string;
  45831. /**
  45832. * Minimum movement node
  45833. */
  45834. minNodeName?: string;
  45835. /**
  45836. * Max movement node
  45837. */
  45838. maxNodeName?: string;
  45839. };
  45840. };
  45841. /**
  45842. * If touch enabled, what is the name of node to display user feedback
  45843. */
  45844. touchPointNodeName?: string;
  45845. };
  45846. };
  45847. /**
  45848. * Is it xr standard mapping or not
  45849. */
  45850. gamepadMapping: "" | "xr-standard";
  45851. /**
  45852. * Base root node of this entire model
  45853. */
  45854. rootNodeName: string;
  45855. /**
  45856. * Defines the main button component id
  45857. */
  45858. selectComponentId: string;
  45859. }
  45860. /**
  45861. * A definition for the layout map in the input profile
  45862. */
  45863. export interface IMotionControllerLayoutMap {
  45864. /**
  45865. * Layouts with handedness type as a key
  45866. */
  45867. [handedness: string]: IMotionControllerLayout;
  45868. }
  45869. /**
  45870. * The XR Input profile schema
  45871. * Profiles can be found here:
  45872. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45873. */
  45874. export interface IMotionControllerProfile {
  45875. /**
  45876. * fallback profiles for this profileId
  45877. */
  45878. fallbackProfileIds: string[];
  45879. /**
  45880. * The layout map, with handedness as key
  45881. */
  45882. layouts: IMotionControllerLayoutMap;
  45883. /**
  45884. * The id of this profile
  45885. * correlates to the profile(s) in the xrInput.profiles array
  45886. */
  45887. profileId: string;
  45888. }
  45889. /**
  45890. * A helper-interface for the 3 meshes needed for controller button animation
  45891. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45892. */
  45893. export interface IMotionControllerButtonMeshMap {
  45894. /**
  45895. * the mesh that defines the pressed value mesh position.
  45896. * This is used to find the max-position of this button
  45897. */
  45898. pressedMesh: AbstractMesh;
  45899. /**
  45900. * the mesh that defines the unpressed value mesh position.
  45901. * This is used to find the min (or initial) position of this button
  45902. */
  45903. unpressedMesh: AbstractMesh;
  45904. /**
  45905. * The mesh that will be changed when value changes
  45906. */
  45907. valueMesh: AbstractMesh;
  45908. }
  45909. /**
  45910. * A helper-interface for the 3 meshes needed for controller axis animation.
  45911. * This will be expanded when touchpad animations are fully supported
  45912. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45913. */
  45914. export interface IMotionControllerMeshMap {
  45915. /**
  45916. * the mesh that defines the maximum value mesh position.
  45917. */
  45918. maxMesh?: AbstractMesh;
  45919. /**
  45920. * the mesh that defines the minimum value mesh position.
  45921. */
  45922. minMesh?: AbstractMesh;
  45923. /**
  45924. * The mesh that will be changed when axis value changes
  45925. */
  45926. valueMesh: AbstractMesh;
  45927. }
  45928. /**
  45929. * The elements needed for change-detection of the gamepad objects in motion controllers
  45930. */
  45931. export interface IMinimalMotionControllerObject {
  45932. /**
  45933. * Available axes of this controller
  45934. */
  45935. axes: number[];
  45936. /**
  45937. * An array of available buttons
  45938. */
  45939. buttons: Array<{
  45940. /**
  45941. * Value of the button/trigger
  45942. */
  45943. value: number;
  45944. /**
  45945. * If the button/trigger is currently touched
  45946. */
  45947. touched: boolean;
  45948. /**
  45949. * If the button/trigger is currently pressed
  45950. */
  45951. pressed: boolean;
  45952. }>;
  45953. /**
  45954. * EXPERIMENTAL haptic support.
  45955. */
  45956. hapticActuators?: Array<{
  45957. pulse: (value: number, duration: number) => Promise<boolean>;
  45958. }>;
  45959. }
  45960. /**
  45961. * An Abstract Motion controller
  45962. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45963. * Each component has an observable to check for changes in value and state
  45964. */
  45965. export abstract class WebXRAbstractMotionController implements IDisposable {
  45966. protected scene: Scene;
  45967. protected layout: IMotionControllerLayout;
  45968. /**
  45969. * The gamepad object correlating to this controller
  45970. */
  45971. gamepadObject: IMinimalMotionControllerObject;
  45972. /**
  45973. * handedness (left/right/none) of this controller
  45974. */
  45975. handedness: MotionControllerHandedness;
  45976. private _initComponent;
  45977. private _modelReady;
  45978. /**
  45979. * A map of components (WebXRControllerComponent) in this motion controller
  45980. * Components have a ComponentType and can also have both button and axis definitions
  45981. */
  45982. readonly components: {
  45983. [id: string]: WebXRControllerComponent;
  45984. };
  45985. /**
  45986. * Disable the model's animation. Can be set at any time.
  45987. */
  45988. disableAnimation: boolean;
  45989. /**
  45990. * Observers registered here will be triggered when the model of this controller is done loading
  45991. */
  45992. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45993. /**
  45994. * The profile id of this motion controller
  45995. */
  45996. abstract profileId: string;
  45997. /**
  45998. * The root mesh of the model. It is null if the model was not yet initialized
  45999. */
  46000. rootMesh: Nullable<AbstractMesh>;
  46001. /**
  46002. * constructs a new abstract motion controller
  46003. * @param scene the scene to which the model of the controller will be added
  46004. * @param layout The profile layout to load
  46005. * @param gamepadObject The gamepad object correlating to this controller
  46006. * @param handedness handedness (left/right/none) of this controller
  46007. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46008. */
  46009. constructor(scene: Scene, layout: IMotionControllerLayout,
  46010. /**
  46011. * The gamepad object correlating to this controller
  46012. */
  46013. gamepadObject: IMinimalMotionControllerObject,
  46014. /**
  46015. * handedness (left/right/none) of this controller
  46016. */
  46017. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46018. /**
  46019. * Dispose this controller, the model mesh and all its components
  46020. */
  46021. dispose(): void;
  46022. /**
  46023. * Returns all components of specific type
  46024. * @param type the type to search for
  46025. * @return an array of components with this type
  46026. */
  46027. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46028. /**
  46029. * get a component based an its component id as defined in layout.components
  46030. * @param id the id of the component
  46031. * @returns the component correlates to the id or undefined if not found
  46032. */
  46033. getComponent(id: string): WebXRControllerComponent;
  46034. /**
  46035. * Get the list of components available in this motion controller
  46036. * @returns an array of strings correlating to available components
  46037. */
  46038. getComponentIds(): string[];
  46039. /**
  46040. * Get the first component of specific type
  46041. * @param type type of component to find
  46042. * @return a controller component or null if not found
  46043. */
  46044. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46045. /**
  46046. * Get the main (Select) component of this controller as defined in the layout
  46047. * @returns the main component of this controller
  46048. */
  46049. getMainComponent(): WebXRControllerComponent;
  46050. /**
  46051. * Loads the model correlating to this controller
  46052. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46053. * @returns A promise fulfilled with the result of the model loading
  46054. */
  46055. loadModel(): Promise<boolean>;
  46056. /**
  46057. * Update this model using the current XRFrame
  46058. * @param xrFrame the current xr frame to use and update the model
  46059. */
  46060. updateFromXRFrame(xrFrame: XRFrame): void;
  46061. /**
  46062. * Backwards compatibility due to a deeply-integrated typo
  46063. */
  46064. get handness(): XREye;
  46065. /**
  46066. * Pulse (vibrate) this controller
  46067. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46068. * Consecutive calls to this function will cancel the last pulse call
  46069. *
  46070. * @param value the strength of the pulse in 0.0...1.0 range
  46071. * @param duration Duration of the pulse in milliseconds
  46072. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46073. * @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
  46074. */
  46075. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46076. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46077. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46078. /**
  46079. * Moves the axis on the controller mesh based on its current state
  46080. * @param axis the index of the axis
  46081. * @param axisValue the value of the axis which determines the meshes new position
  46082. * @hidden
  46083. */
  46084. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46085. /**
  46086. * Update the model itself with the current frame data
  46087. * @param xrFrame the frame to use for updating the model mesh
  46088. */
  46089. protected updateModel(xrFrame: XRFrame): void;
  46090. /**
  46091. * Get the filename and path for this controller's model
  46092. * @returns a map of filename and path
  46093. */
  46094. protected abstract _getFilenameAndPath(): {
  46095. filename: string;
  46096. path: string;
  46097. };
  46098. /**
  46099. * This function is called before the mesh is loaded. It checks for loading constraints.
  46100. * For example, this function can check if the GLB loader is available
  46101. * If this function returns false, the generic controller will be loaded instead
  46102. * @returns Is the client ready to load the mesh
  46103. */
  46104. protected abstract _getModelLoadingConstraints(): boolean;
  46105. /**
  46106. * This function will be called after the model was successfully loaded and can be used
  46107. * for mesh transformations before it is available for the user
  46108. * @param meshes the loaded meshes
  46109. */
  46110. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46111. /**
  46112. * Set the root mesh for this controller. Important for the WebXR controller class
  46113. * @param meshes the loaded meshes
  46114. */
  46115. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46116. /**
  46117. * A function executed each frame that updates the mesh (if needed)
  46118. * @param xrFrame the current xrFrame
  46119. */
  46120. protected abstract _updateModel(xrFrame: XRFrame): void;
  46121. private _getGenericFilenameAndPath;
  46122. private _getGenericParentMesh;
  46123. }
  46124. }
  46125. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  46126. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46128. import { Scene } from "babylonjs/scene";
  46129. /**
  46130. * A generic trigger-only motion controller for WebXR
  46131. */
  46132. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46133. /**
  46134. * Static version of the profile id of this controller
  46135. */
  46136. static ProfileId: string;
  46137. profileId: string;
  46138. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46139. protected _getFilenameAndPath(): {
  46140. filename: string;
  46141. path: string;
  46142. };
  46143. protected _getModelLoadingConstraints(): boolean;
  46144. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46145. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46146. protected _updateModel(): void;
  46147. }
  46148. }
  46149. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46150. import { Vector4 } from "babylonjs/Maths/math.vector";
  46151. import { Mesh } from "babylonjs/Meshes/mesh";
  46152. import { Scene } from "babylonjs/scene";
  46153. import { Nullable } from "babylonjs/types";
  46154. /**
  46155. * Class containing static functions to help procedurally build meshes
  46156. */
  46157. export class SphereBuilder {
  46158. /**
  46159. * Creates a sphere mesh
  46160. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46161. * * 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`)
  46162. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46163. * * 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
  46164. * * 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)
  46165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46166. * * 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
  46167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46168. * @param name defines the name of the mesh
  46169. * @param options defines the options used to create the mesh
  46170. * @param scene defines the hosting scene
  46171. * @returns the sphere mesh
  46172. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46173. */
  46174. static CreateSphere(name: string, options: {
  46175. segments?: number;
  46176. diameter?: number;
  46177. diameterX?: number;
  46178. diameterY?: number;
  46179. diameterZ?: number;
  46180. arc?: number;
  46181. slice?: number;
  46182. sideOrientation?: number;
  46183. frontUVs?: Vector4;
  46184. backUVs?: Vector4;
  46185. updatable?: boolean;
  46186. }, scene?: Nullable<Scene>): Mesh;
  46187. }
  46188. }
  46189. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  46190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46191. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46192. import { Scene } from "babylonjs/scene";
  46193. /**
  46194. * A profiled motion controller has its profile loaded from an online repository.
  46195. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  46196. */
  46197. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  46198. private _repositoryUrl;
  46199. private _buttonMeshMapping;
  46200. private _touchDots;
  46201. /**
  46202. * The profile ID of this controller. Will be populated when the controller initializes.
  46203. */
  46204. profileId: string;
  46205. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  46206. dispose(): void;
  46207. protected _getFilenameAndPath(): {
  46208. filename: string;
  46209. path: string;
  46210. };
  46211. protected _getModelLoadingConstraints(): boolean;
  46212. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46213. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46214. protected _updateModel(_xrFrame: XRFrame): void;
  46215. }
  46216. }
  46217. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  46218. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46219. import { Scene } from "babylonjs/scene";
  46220. /**
  46221. * A construction function type to create a new controller based on an xrInput object
  46222. */
  46223. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  46224. /**
  46225. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  46226. *
  46227. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  46228. * it should be replaced with auto-loaded controllers.
  46229. *
  46230. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  46231. */
  46232. export class WebXRMotionControllerManager {
  46233. private static _AvailableControllers;
  46234. private static _Fallbacks;
  46235. private static _ProfileLoadingPromises;
  46236. private static _ProfilesList;
  46237. /**
  46238. * The base URL of the online controller repository. Can be changed at any time.
  46239. */
  46240. static BaseRepositoryUrl: string;
  46241. /**
  46242. * Which repository gets priority - local or online
  46243. */
  46244. static PrioritizeOnlineRepository: boolean;
  46245. /**
  46246. * Use the online repository, or use only locally-defined controllers
  46247. */
  46248. static UseOnlineRepository: boolean;
  46249. /**
  46250. * Clear the cache used for profile loading and reload when requested again
  46251. */
  46252. static ClearProfilesCache(): void;
  46253. /**
  46254. * Register the default fallbacks.
  46255. * This function is called automatically when this file is imported.
  46256. */
  46257. static DefaultFallbacks(): void;
  46258. /**
  46259. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46260. * @param profileId the profile to which a fallback needs to be found
  46261. * @return an array with corresponding fallback profiles
  46262. */
  46263. static FindFallbackWithProfileId(profileId: string): string[];
  46264. /**
  46265. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46266. * The order of search:
  46267. *
  46268. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46269. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46270. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46271. * 4) return the generic trigger controller if none were found
  46272. *
  46273. * @param xrInput the xrInput to which a new controller is initialized
  46274. * @param scene the scene to which the model will be added
  46275. * @param forceProfile force a certain profile for this controller
  46276. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46277. */
  46278. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46279. /**
  46280. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46281. *
  46282. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46283. *
  46284. * @param type the profile type to register
  46285. * @param constructFunction the function to be called when loading this profile
  46286. */
  46287. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46288. /**
  46289. * Register a fallback to a specific profile.
  46290. * @param profileId the profileId that will receive the fallbacks
  46291. * @param fallbacks A list of fallback profiles
  46292. */
  46293. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46294. /**
  46295. * Will update the list of profiles available in the repository
  46296. * @return a promise that resolves to a map of profiles available online
  46297. */
  46298. static UpdateProfilesList(): Promise<{
  46299. [profile: string]: string;
  46300. }>;
  46301. private static _LoadProfileFromRepository;
  46302. private static _LoadProfilesFromAvailableControllers;
  46303. }
  46304. }
  46305. declare module "babylonjs/XR/webXRInputSource" {
  46306. import { Observable } from "babylonjs/Misc/observable";
  46307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46308. import { Ray } from "babylonjs/Culling/ray";
  46309. import { Scene } from "babylonjs/scene";
  46310. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46311. /**
  46312. * Configuration options for the WebXR controller creation
  46313. */
  46314. export interface IWebXRControllerOptions {
  46315. /**
  46316. * Should the controller mesh be animated when a user interacts with it
  46317. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46318. */
  46319. disableMotionControllerAnimation?: boolean;
  46320. /**
  46321. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46322. */
  46323. doNotLoadControllerMesh?: boolean;
  46324. /**
  46325. * Force a specific controller type for this controller.
  46326. * This can be used when creating your own profile or when testing different controllers
  46327. */
  46328. forceControllerProfile?: string;
  46329. /**
  46330. * Defines a rendering group ID for meshes that will be loaded.
  46331. * This is for the default controllers only.
  46332. */
  46333. renderingGroupId?: number;
  46334. }
  46335. /**
  46336. * Represents an XR controller
  46337. */
  46338. export class WebXRInputSource {
  46339. private _scene;
  46340. /** The underlying input source for the controller */
  46341. inputSource: XRInputSource;
  46342. private _options;
  46343. private _tmpQuaternion;
  46344. private _tmpVector;
  46345. private _uniqueId;
  46346. /**
  46347. * 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
  46348. */
  46349. grip?: AbstractMesh;
  46350. /**
  46351. * If available, this is the gamepad object related to this controller.
  46352. * Using this object it is possible to get click events and trackpad changes of the
  46353. * webxr controller that is currently being used.
  46354. */
  46355. motionController?: WebXRAbstractMotionController;
  46356. /**
  46357. * Event that fires when the controller is removed/disposed.
  46358. * The object provided as event data is this controller, after associated assets were disposed.
  46359. * uniqueId is still available.
  46360. */
  46361. onDisposeObservable: Observable<WebXRInputSource>;
  46362. /**
  46363. * Will be triggered when the mesh associated with the motion controller is done loading.
  46364. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46365. * A shortened version of controller -> motion controller -> on mesh loaded.
  46366. */
  46367. onMeshLoadedObservable: Observable<AbstractMesh>;
  46368. /**
  46369. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46370. */
  46371. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46372. /**
  46373. * Pointer which can be used to select objects or attach a visible laser to
  46374. */
  46375. pointer: AbstractMesh;
  46376. /**
  46377. * Creates the controller
  46378. * @see https://doc.babylonjs.com/how_to/webxr
  46379. * @param _scene the scene which the controller should be associated to
  46380. * @param inputSource the underlying input source for the controller
  46381. * @param _options options for this controller creation
  46382. */
  46383. constructor(_scene: Scene,
  46384. /** The underlying input source for the controller */
  46385. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46386. /**
  46387. * Get this controllers unique id
  46388. */
  46389. get uniqueId(): string;
  46390. /**
  46391. * Disposes of the object
  46392. */
  46393. dispose(): void;
  46394. /**
  46395. * Gets a world space ray coming from the pointer or grip
  46396. * @param result the resulting ray
  46397. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46398. */
  46399. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46400. /**
  46401. * Updates the controller pose based on the given XRFrame
  46402. * @param xrFrame xr frame to update the pose with
  46403. * @param referenceSpace reference space to use
  46404. */
  46405. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46406. }
  46407. }
  46408. declare module "babylonjs/XR/webXRInput" {
  46409. import { Observable } from "babylonjs/Misc/observable";
  46410. import { IDisposable } from "babylonjs/scene";
  46411. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  46412. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46413. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46414. /**
  46415. * The schema for initialization options of the XR Input class
  46416. */
  46417. export interface IWebXRInputOptions {
  46418. /**
  46419. * If set to true no model will be automatically loaded
  46420. */
  46421. doNotLoadControllerMeshes?: boolean;
  46422. /**
  46423. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46424. * If not found, the xr input profile data will be used.
  46425. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46426. */
  46427. forceInputProfile?: string;
  46428. /**
  46429. * Do not send a request to the controller repository to load the profile.
  46430. *
  46431. * Instead, use the controllers available in babylon itself.
  46432. */
  46433. disableOnlineControllerRepository?: boolean;
  46434. /**
  46435. * A custom URL for the controllers repository
  46436. */
  46437. customControllersRepositoryURL?: string;
  46438. /**
  46439. * Should the controller model's components not move according to the user input
  46440. */
  46441. disableControllerAnimation?: boolean;
  46442. /**
  46443. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  46444. */
  46445. controllerOptions?: IWebXRControllerOptions;
  46446. }
  46447. /**
  46448. * XR input used to track XR inputs such as controllers/rays
  46449. */
  46450. export class WebXRInput implements IDisposable {
  46451. /**
  46452. * the xr session manager for this session
  46453. */
  46454. xrSessionManager: WebXRSessionManager;
  46455. /**
  46456. * the WebXR camera for this session. Mainly used for teleportation
  46457. */
  46458. xrCamera: WebXRCamera;
  46459. private readonly options;
  46460. /**
  46461. * XR controllers being tracked
  46462. */
  46463. controllers: Array<WebXRInputSource>;
  46464. private _frameObserver;
  46465. private _sessionEndedObserver;
  46466. private _sessionInitObserver;
  46467. /**
  46468. * Event when a controller has been connected/added
  46469. */
  46470. onControllerAddedObservable: Observable<WebXRInputSource>;
  46471. /**
  46472. * Event when a controller has been removed/disconnected
  46473. */
  46474. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46475. /**
  46476. * Initializes the WebXRInput
  46477. * @param xrSessionManager the xr session manager for this session
  46478. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46479. * @param options = initialization options for this xr input
  46480. */
  46481. constructor(
  46482. /**
  46483. * the xr session manager for this session
  46484. */
  46485. xrSessionManager: WebXRSessionManager,
  46486. /**
  46487. * the WebXR camera for this session. Mainly used for teleportation
  46488. */
  46489. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46490. private _onInputSourcesChange;
  46491. private _addAndRemoveControllers;
  46492. /**
  46493. * Disposes of the object
  46494. */
  46495. dispose(): void;
  46496. }
  46497. }
  46498. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46499. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46500. import { Observable, EventState } from "babylonjs/Misc/observable";
  46501. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46502. /**
  46503. * This is the base class for all WebXR features.
  46504. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46505. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46506. */
  46507. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46508. protected _xrSessionManager: WebXRSessionManager;
  46509. private _attached;
  46510. private _removeOnDetach;
  46511. /**
  46512. * Should auto-attach be disabled?
  46513. */
  46514. disableAutoAttach: boolean;
  46515. /**
  46516. * Construct a new (abstract) WebXR feature
  46517. * @param _xrSessionManager the xr session manager for this feature
  46518. */
  46519. constructor(_xrSessionManager: WebXRSessionManager);
  46520. /**
  46521. * Is this feature attached
  46522. */
  46523. get attached(): boolean;
  46524. /**
  46525. * attach this feature
  46526. *
  46527. * @param force should attachment be forced (even when already attached)
  46528. * @returns true if successful, false is failed or already attached
  46529. */
  46530. attach(force?: boolean): boolean;
  46531. /**
  46532. * detach this feature.
  46533. *
  46534. * @returns true if successful, false if failed or already detached
  46535. */
  46536. detach(): boolean;
  46537. /**
  46538. * Dispose this feature and all of the resources attached
  46539. */
  46540. dispose(): void;
  46541. /**
  46542. * This is used to register callbacks that will automatically be removed when detach is called.
  46543. * @param observable the observable to which the observer will be attached
  46544. * @param callback the callback to register
  46545. */
  46546. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46547. /**
  46548. * Code in this function will be executed on each xrFrame received from the browser.
  46549. * This function will not execute after the feature is detached.
  46550. * @param _xrFrame the current frame
  46551. */
  46552. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46553. }
  46554. }
  46555. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46556. import { IDisposable, Scene } from "babylonjs/scene";
  46557. import { Nullable } from "babylonjs/types";
  46558. import { Observable } from "babylonjs/Misc/observable";
  46559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46560. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46561. import { Camera } from "babylonjs/Cameras/camera";
  46562. /**
  46563. * Renders a layer on top of an existing scene
  46564. */
  46565. export class UtilityLayerRenderer implements IDisposable {
  46566. /** the original scene that will be rendered on top of */
  46567. originalScene: Scene;
  46568. private _pointerCaptures;
  46569. private _lastPointerEvents;
  46570. private static _DefaultUtilityLayer;
  46571. private static _DefaultKeepDepthUtilityLayer;
  46572. private _sharedGizmoLight;
  46573. private _renderCamera;
  46574. /**
  46575. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46576. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46577. * @returns the camera that is used when rendering the utility layer
  46578. */
  46579. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46580. /**
  46581. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46582. * @param cam the camera that should be used when rendering the utility layer
  46583. */
  46584. setRenderCamera(cam: Nullable<Camera>): void;
  46585. /**
  46586. * @hidden
  46587. * Light which used by gizmos to get light shading
  46588. */
  46589. _getSharedGizmoLight(): HemisphericLight;
  46590. /**
  46591. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46592. */
  46593. pickUtilitySceneFirst: boolean;
  46594. /**
  46595. * 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)
  46596. */
  46597. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46598. /**
  46599. * 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)
  46600. */
  46601. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46602. /**
  46603. * The scene that is rendered on top of the original scene
  46604. */
  46605. utilityLayerScene: Scene;
  46606. /**
  46607. * If the utility layer should automatically be rendered on top of existing scene
  46608. */
  46609. shouldRender: boolean;
  46610. /**
  46611. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46612. */
  46613. onlyCheckPointerDownEvents: boolean;
  46614. /**
  46615. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46616. */
  46617. processAllEvents: boolean;
  46618. /**
  46619. * Observable raised when the pointer move from the utility layer scene to the main scene
  46620. */
  46621. onPointerOutObservable: Observable<number>;
  46622. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46623. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46624. private _afterRenderObserver;
  46625. private _sceneDisposeObserver;
  46626. private _originalPointerObserver;
  46627. /**
  46628. * Instantiates a UtilityLayerRenderer
  46629. * @param originalScene the original scene that will be rendered on top of
  46630. * @param handleEvents boolean indicating if the utility layer should handle events
  46631. */
  46632. constructor(
  46633. /** the original scene that will be rendered on top of */
  46634. originalScene: Scene, handleEvents?: boolean);
  46635. private _notifyObservers;
  46636. /**
  46637. * Renders the utility layers scene on top of the original scene
  46638. */
  46639. render(): void;
  46640. /**
  46641. * Disposes of the renderer
  46642. */
  46643. dispose(): void;
  46644. private _updateCamera;
  46645. }
  46646. }
  46647. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46648. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46650. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46651. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46652. import { Scene } from "babylonjs/scene";
  46653. import { Nullable } from "babylonjs/types";
  46654. import { Color3 } from "babylonjs/Maths/math.color";
  46655. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46656. /**
  46657. * Options interface for the pointer selection module
  46658. */
  46659. export interface IWebXRControllerPointerSelectionOptions {
  46660. /**
  46661. * if provided, this scene will be used to render meshes.
  46662. */
  46663. customUtilityLayerScene?: Scene;
  46664. /**
  46665. * 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)
  46666. * If not disabled, the last picked point will be used to execute a pointer up event
  46667. * If disabled, pointer up event will be triggered right after the pointer down event.
  46668. * Used in screen and gaze target ray mode only
  46669. */
  46670. disablePointerUpOnTouchOut: boolean;
  46671. /**
  46672. * For gaze mode (time to select instead of press)
  46673. */
  46674. forceGazeMode: boolean;
  46675. /**
  46676. * 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
  46677. * to start a new countdown to the pointer down event.
  46678. * Defaults to 1.
  46679. */
  46680. gazeModePointerMovedFactor?: number;
  46681. /**
  46682. * Different button type to use instead of the main component
  46683. */
  46684. overrideButtonId?: string;
  46685. /**
  46686. * use this rendering group id for the meshes (optional)
  46687. */
  46688. renderingGroupId?: number;
  46689. /**
  46690. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46691. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46692. * 3000 means 3 seconds between pointing at something and selecting it
  46693. */
  46694. timeToSelect?: number;
  46695. /**
  46696. * Should meshes created here be added to a utility layer or the main scene
  46697. */
  46698. useUtilityLayer?: boolean;
  46699. /**
  46700. * the xr input to use with this pointer selection
  46701. */
  46702. xrInput: WebXRInput;
  46703. }
  46704. /**
  46705. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46706. */
  46707. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46708. private readonly _options;
  46709. private static _idCounter;
  46710. private _attachController;
  46711. private _controllers;
  46712. private _scene;
  46713. private _tmpVectorForPickCompare;
  46714. /**
  46715. * The module's name
  46716. */
  46717. static readonly Name: string;
  46718. /**
  46719. * The (Babylon) version of this module.
  46720. * This is an integer representing the implementation version.
  46721. * This number does not correspond to the WebXR specs version
  46722. */
  46723. static readonly Version: number;
  46724. /**
  46725. * Disable lighting on the laser pointer (so it will always be visible)
  46726. */
  46727. disablePointerLighting: boolean;
  46728. /**
  46729. * Disable lighting on the selection mesh (so it will always be visible)
  46730. */
  46731. disableSelectionMeshLighting: boolean;
  46732. /**
  46733. * Should the laser pointer be displayed
  46734. */
  46735. displayLaserPointer: boolean;
  46736. /**
  46737. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46738. */
  46739. displaySelectionMesh: boolean;
  46740. /**
  46741. * This color will be set to the laser pointer when selection is triggered
  46742. */
  46743. laserPointerPickedColor: Color3;
  46744. /**
  46745. * Default color of the laser pointer
  46746. */
  46747. lasterPointerDefaultColor: Color3;
  46748. /**
  46749. * default color of the selection ring
  46750. */
  46751. selectionMeshDefaultColor: Color3;
  46752. /**
  46753. * This color will be applied to the selection ring when selection is triggered
  46754. */
  46755. selectionMeshPickedColor: Color3;
  46756. /**
  46757. * Optional filter to be used for ray selection. This predicate shares behavior with
  46758. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46759. */
  46760. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46761. /**
  46762. * constructs a new background remover module
  46763. * @param _xrSessionManager the session manager for this module
  46764. * @param _options read-only options to be used in this module
  46765. */
  46766. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46767. /**
  46768. * attach this feature
  46769. * Will usually be called by the features manager
  46770. *
  46771. * @returns true if successful.
  46772. */
  46773. attach(): boolean;
  46774. /**
  46775. * detach this feature.
  46776. * Will usually be called by the features manager
  46777. *
  46778. * @returns true if successful.
  46779. */
  46780. detach(): boolean;
  46781. /**
  46782. * Will get the mesh under a specific pointer.
  46783. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46784. * @param controllerId the controllerId to check
  46785. * @returns The mesh under pointer or null if no mesh is under the pointer
  46786. */
  46787. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46788. /**
  46789. * Get the xr controller that correlates to the pointer id in the pointer event
  46790. *
  46791. * @param id the pointer id to search for
  46792. * @returns the controller that correlates to this id or null if not found
  46793. */
  46794. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46795. protected _onXRFrame(_xrFrame: XRFrame): void;
  46796. private _attachGazeMode;
  46797. private _attachScreenRayMode;
  46798. private _attachTrackedPointerRayMode;
  46799. private _convertNormalToDirectionOfRay;
  46800. private _detachController;
  46801. private _generateNewMeshPair;
  46802. private _pickingMoved;
  46803. private _updatePointerDistance;
  46804. }
  46805. }
  46806. declare module "babylonjs/XR/webXREnterExitUI" {
  46807. import { Nullable } from "babylonjs/types";
  46808. import { Observable } from "babylonjs/Misc/observable";
  46809. import { IDisposable, Scene } from "babylonjs/scene";
  46810. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46811. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46812. /**
  46813. * Button which can be used to enter a different mode of XR
  46814. */
  46815. export class WebXREnterExitUIButton {
  46816. /** button element */
  46817. element: HTMLElement;
  46818. /** XR initialization options for the button */
  46819. sessionMode: XRSessionMode;
  46820. /** Reference space type */
  46821. referenceSpaceType: XRReferenceSpaceType;
  46822. /**
  46823. * Creates a WebXREnterExitUIButton
  46824. * @param element button element
  46825. * @param sessionMode XR initialization session mode
  46826. * @param referenceSpaceType the type of reference space to be used
  46827. */
  46828. constructor(
  46829. /** button element */
  46830. element: HTMLElement,
  46831. /** XR initialization options for the button */
  46832. sessionMode: XRSessionMode,
  46833. /** Reference space type */
  46834. referenceSpaceType: XRReferenceSpaceType);
  46835. /**
  46836. * Extendable function which can be used to update the button's visuals when the state changes
  46837. * @param activeButton the current active button in the UI
  46838. */
  46839. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46840. }
  46841. /**
  46842. * Options to create the webXR UI
  46843. */
  46844. export class WebXREnterExitUIOptions {
  46845. /**
  46846. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46847. */
  46848. customButtons?: Array<WebXREnterExitUIButton>;
  46849. /**
  46850. * A reference space type to use when creating the default button.
  46851. * Default is local-floor
  46852. */
  46853. referenceSpaceType?: XRReferenceSpaceType;
  46854. /**
  46855. * Context to enter xr with
  46856. */
  46857. renderTarget?: Nullable<WebXRRenderTarget>;
  46858. /**
  46859. * A session mode to use when creating the default button.
  46860. * Default is immersive-vr
  46861. */
  46862. sessionMode?: XRSessionMode;
  46863. /**
  46864. * A list of optional features to init the session with
  46865. */
  46866. optionalFeatures?: string[];
  46867. }
  46868. /**
  46869. * UI to allow the user to enter/exit XR mode
  46870. */
  46871. export class WebXREnterExitUI implements IDisposable {
  46872. private scene;
  46873. /** version of the options passed to this UI */
  46874. options: WebXREnterExitUIOptions;
  46875. private _activeButton;
  46876. private _buttons;
  46877. private _overlay;
  46878. /**
  46879. * Fired every time the active button is changed.
  46880. *
  46881. * When xr is entered via a button that launches xr that button will be the callback parameter
  46882. *
  46883. * When exiting xr the callback parameter will be null)
  46884. */
  46885. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46886. /**
  46887. *
  46888. * @param scene babylon scene object to use
  46889. * @param options (read-only) version of the options passed to this UI
  46890. */
  46891. private constructor();
  46892. /**
  46893. * Creates UI to allow the user to enter/exit XR mode
  46894. * @param scene the scene to add the ui to
  46895. * @param helper the xr experience helper to enter/exit xr with
  46896. * @param options options to configure the UI
  46897. * @returns the created ui
  46898. */
  46899. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46900. /**
  46901. * Disposes of the XR UI component
  46902. */
  46903. dispose(): void;
  46904. private _updateButtons;
  46905. }
  46906. }
  46907. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46908. import { Vector3 } from "babylonjs/Maths/math.vector";
  46909. import { Color4 } from "babylonjs/Maths/math.color";
  46910. import { Nullable } from "babylonjs/types";
  46911. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46912. import { Scene } from "babylonjs/scene";
  46913. /**
  46914. * Class containing static functions to help procedurally build meshes
  46915. */
  46916. export class LinesBuilder {
  46917. /**
  46918. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46919. * * 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
  46920. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46921. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46922. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46923. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46924. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46925. * * 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
  46926. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46929. * @param name defines the name of the new line system
  46930. * @param options defines the options used to create the line system
  46931. * @param scene defines the hosting scene
  46932. * @returns a new line system mesh
  46933. */
  46934. static CreateLineSystem(name: string, options: {
  46935. lines: Vector3[][];
  46936. updatable?: boolean;
  46937. instance?: Nullable<LinesMesh>;
  46938. colors?: Nullable<Color4[][]>;
  46939. useVertexAlpha?: boolean;
  46940. }, scene: Nullable<Scene>): LinesMesh;
  46941. /**
  46942. * Creates a line mesh
  46943. * 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
  46944. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46945. * * The parameter `points` is an array successive Vector3
  46946. * * 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
  46947. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46948. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46949. * * When updating an instance, remember that only point positions can change, not the number of points
  46950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46952. * @param name defines the name of the new line system
  46953. * @param options defines the options used to create the line system
  46954. * @param scene defines the hosting scene
  46955. * @returns a new line mesh
  46956. */
  46957. static CreateLines(name: string, options: {
  46958. points: Vector3[];
  46959. updatable?: boolean;
  46960. instance?: Nullable<LinesMesh>;
  46961. colors?: Color4[];
  46962. useVertexAlpha?: boolean;
  46963. }, scene?: Nullable<Scene>): LinesMesh;
  46964. /**
  46965. * Creates a dashed line mesh
  46966. * * 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
  46967. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46968. * * The parameter `points` is an array successive Vector3
  46969. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46970. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46971. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46972. * * 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
  46973. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46974. * * When updating an instance, remember that only point positions can change, not the number of points
  46975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46976. * @param name defines the name of the mesh
  46977. * @param options defines the options used to create the mesh
  46978. * @param scene defines the hosting scene
  46979. * @returns the dashed line mesh
  46980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46981. */
  46982. static CreateDashedLines(name: string, options: {
  46983. points: Vector3[];
  46984. dashSize?: number;
  46985. gapSize?: number;
  46986. dashNb?: number;
  46987. updatable?: boolean;
  46988. instance?: LinesMesh;
  46989. useVertexAlpha?: boolean;
  46990. }, scene?: Nullable<Scene>): LinesMesh;
  46991. }
  46992. }
  46993. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46994. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46995. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46996. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46998. import { Vector3 } from "babylonjs/Maths/math.vector";
  46999. import { Material } from "babylonjs/Materials/material";
  47000. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  47001. import { Scene } from "babylonjs/scene";
  47002. /**
  47003. * The options container for the teleportation module
  47004. */
  47005. export interface IWebXRTeleportationOptions {
  47006. /**
  47007. * if provided, this scene will be used to render meshes.
  47008. */
  47009. customUtilityLayerScene?: Scene;
  47010. /**
  47011. * Values to configure the default target mesh
  47012. */
  47013. defaultTargetMeshOptions?: {
  47014. /**
  47015. * Fill color of the teleportation area
  47016. */
  47017. teleportationFillColor?: string;
  47018. /**
  47019. * Border color for the teleportation area
  47020. */
  47021. teleportationBorderColor?: string;
  47022. /**
  47023. * Disable the mesh's animation sequence
  47024. */
  47025. disableAnimation?: boolean;
  47026. /**
  47027. * Disable lighting on the material or the ring and arrow
  47028. */
  47029. disableLighting?: boolean;
  47030. /**
  47031. * Override the default material of the torus and arrow
  47032. */
  47033. torusArrowMaterial?: Material;
  47034. };
  47035. /**
  47036. * A list of meshes to use as floor meshes.
  47037. * Meshes can be added and removed after initializing the feature using the
  47038. * addFloorMesh and removeFloorMesh functions
  47039. * If empty, rotation will still work
  47040. */
  47041. floorMeshes?: AbstractMesh[];
  47042. /**
  47043. * use this rendering group id for the meshes (optional)
  47044. */
  47045. renderingGroupId?: number;
  47046. /**
  47047. * Should teleportation move only to snap points
  47048. */
  47049. snapPointsOnly?: boolean;
  47050. /**
  47051. * An array of points to which the teleportation will snap to.
  47052. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47053. */
  47054. snapPositions?: Vector3[];
  47055. /**
  47056. * How close should the teleportation ray be in order to snap to position.
  47057. * Default to 0.8 units (meters)
  47058. */
  47059. snapToPositionRadius?: number;
  47060. /**
  47061. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47062. * If you want to support rotation, make sure your mesh has a direction indicator.
  47063. *
  47064. * When left untouched, the default mesh will be initialized.
  47065. */
  47066. teleportationTargetMesh?: AbstractMesh;
  47067. /**
  47068. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47069. */
  47070. timeToTeleport?: number;
  47071. /**
  47072. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47073. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47074. */
  47075. useMainComponentOnly?: boolean;
  47076. /**
  47077. * Should meshes created here be added to a utility layer or the main scene
  47078. */
  47079. useUtilityLayer?: boolean;
  47080. /**
  47081. * Babylon XR Input class for controller
  47082. */
  47083. xrInput: WebXRInput;
  47084. }
  47085. /**
  47086. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47087. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47088. * the input of the attached controllers.
  47089. */
  47090. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47091. private _options;
  47092. private _controllers;
  47093. private _currentTeleportationControllerId;
  47094. private _floorMeshes;
  47095. private _quadraticBezierCurve;
  47096. private _selectionFeature;
  47097. private _snapToPositions;
  47098. private _snappedToPoint;
  47099. private _teleportationRingMaterial?;
  47100. private _tmpRay;
  47101. private _tmpVector;
  47102. /**
  47103. * The module's name
  47104. */
  47105. static readonly Name: string;
  47106. /**
  47107. * The (Babylon) version of this module.
  47108. * This is an integer representing the implementation version.
  47109. * This number does not correspond to the webxr specs version
  47110. */
  47111. static readonly Version: number;
  47112. /**
  47113. * Is movement backwards enabled
  47114. */
  47115. backwardsMovementEnabled: boolean;
  47116. /**
  47117. * Distance to travel when moving backwards
  47118. */
  47119. backwardsTeleportationDistance: number;
  47120. /**
  47121. * The distance from the user to the inspection point in the direction of the controller
  47122. * A higher number will allow the user to move further
  47123. * defaults to 5 (meters, in xr units)
  47124. */
  47125. parabolicCheckRadius: number;
  47126. /**
  47127. * Should the module support parabolic ray on top of direct ray
  47128. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47129. * Very helpful when moving between floors / different heights
  47130. */
  47131. parabolicRayEnabled: boolean;
  47132. /**
  47133. * How much rotation should be applied when rotating right and left
  47134. */
  47135. rotationAngle: number;
  47136. /**
  47137. * Is rotation enabled when moving forward?
  47138. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47139. */
  47140. rotationEnabled: boolean;
  47141. /**
  47142. * constructs a new anchor system
  47143. * @param _xrSessionManager an instance of WebXRSessionManager
  47144. * @param _options configuration object for this feature
  47145. */
  47146. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47147. /**
  47148. * Get the snapPointsOnly flag
  47149. */
  47150. get snapPointsOnly(): boolean;
  47151. /**
  47152. * Sets the snapPointsOnly flag
  47153. * @param snapToPoints should teleportation be exclusively to snap points
  47154. */
  47155. set snapPointsOnly(snapToPoints: boolean);
  47156. /**
  47157. * Add a new mesh to the floor meshes array
  47158. * @param mesh the mesh to use as floor mesh
  47159. */
  47160. addFloorMesh(mesh: AbstractMesh): void;
  47161. /**
  47162. * Add a new snap-to point to fix teleportation to this position
  47163. * @param newSnapPoint The new Snap-To point
  47164. */
  47165. addSnapPoint(newSnapPoint: Vector3): void;
  47166. attach(): boolean;
  47167. detach(): boolean;
  47168. dispose(): void;
  47169. /**
  47170. * Remove a mesh from the floor meshes array
  47171. * @param mesh the mesh to remove
  47172. */
  47173. removeFloorMesh(mesh: AbstractMesh): void;
  47174. /**
  47175. * Remove a mesh from the floor meshes array using its name
  47176. * @param name the mesh name to remove
  47177. */
  47178. removeFloorMeshByName(name: string): void;
  47179. /**
  47180. * 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
  47181. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47182. * @returns was the point found and removed or not
  47183. */
  47184. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47185. /**
  47186. * This function sets a selection feature that will be disabled when
  47187. * the forward ray is shown and will be reattached when hidden.
  47188. * This is used to remove the selection rays when moving.
  47189. * @param selectionFeature the feature to disable when forward movement is enabled
  47190. */
  47191. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47192. protected _onXRFrame(_xrFrame: XRFrame): void;
  47193. private _attachController;
  47194. private _createDefaultTargetMesh;
  47195. private _detachController;
  47196. private _findClosestSnapPointWithRadius;
  47197. private _setTargetMeshPosition;
  47198. private _setTargetMeshVisibility;
  47199. private _showParabolicPath;
  47200. private _teleportForward;
  47201. }
  47202. }
  47203. declare module "babylonjs/XR/webXRDefaultExperience" {
  47204. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  47205. import { Scene } from "babylonjs/scene";
  47206. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  47207. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  47208. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47209. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  47210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47211. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47212. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  47213. /**
  47214. * Options for the default xr helper
  47215. */
  47216. export class WebXRDefaultExperienceOptions {
  47217. /**
  47218. * Enable or disable default UI to enter XR
  47219. */
  47220. disableDefaultUI?: boolean;
  47221. /**
  47222. * Should teleportation not initialize. defaults to false.
  47223. */
  47224. disableTeleportation?: boolean;
  47225. /**
  47226. * Floor meshes that will be used for teleport
  47227. */
  47228. floorMeshes?: Array<AbstractMesh>;
  47229. /**
  47230. * If set to true, the first frame will not be used to reset position
  47231. * The first frame is mainly used when copying transformation from the old camera
  47232. * Mainly used in AR
  47233. */
  47234. ignoreNativeCameraTransformation?: boolean;
  47235. /**
  47236. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47237. */
  47238. inputOptions?: IWebXRInputOptions;
  47239. /**
  47240. * optional configuration for the output canvas
  47241. */
  47242. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  47243. /**
  47244. * optional UI options. This can be used among other to change session mode and reference space type
  47245. */
  47246. uiOptions?: WebXREnterExitUIOptions;
  47247. /**
  47248. * When loading teleportation and pointer select, use stable versions instead of latest.
  47249. */
  47250. useStablePlugins?: boolean;
  47251. /**
  47252. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  47253. */
  47254. renderingGroupId?: number;
  47255. /**
  47256. * A list of optional features to init the session with
  47257. * If set to true, all features we support will be added
  47258. */
  47259. optionalFeatures?: boolean | string[];
  47260. }
  47261. /**
  47262. * Default experience which provides a similar setup to the previous webVRExperience
  47263. */
  47264. export class WebXRDefaultExperience {
  47265. /**
  47266. * Base experience
  47267. */
  47268. baseExperience: WebXRExperienceHelper;
  47269. /**
  47270. * Enables ui for entering/exiting xr
  47271. */
  47272. enterExitUI: WebXREnterExitUI;
  47273. /**
  47274. * Input experience extension
  47275. */
  47276. input: WebXRInput;
  47277. /**
  47278. * Enables laser pointer and selection
  47279. */
  47280. pointerSelection: WebXRControllerPointerSelection;
  47281. /**
  47282. * Default target xr should render to
  47283. */
  47284. renderTarget: WebXRRenderTarget;
  47285. /**
  47286. * Enables teleportation
  47287. */
  47288. teleportation: WebXRMotionControllerTeleportation;
  47289. private constructor();
  47290. /**
  47291. * Creates the default xr experience
  47292. * @param scene scene
  47293. * @param options options for basic configuration
  47294. * @returns resulting WebXRDefaultExperience
  47295. */
  47296. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47297. /**
  47298. * DIsposes of the experience helper
  47299. */
  47300. dispose(): void;
  47301. }
  47302. }
  47303. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47304. import { Observable } from "babylonjs/Misc/observable";
  47305. import { Nullable } from "babylonjs/types";
  47306. import { Camera } from "babylonjs/Cameras/camera";
  47307. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47308. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47309. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47310. import { Scene } from "babylonjs/scene";
  47311. import { Vector3 } from "babylonjs/Maths/math.vector";
  47312. import { Color3 } from "babylonjs/Maths/math.color";
  47313. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47315. import { Mesh } from "babylonjs/Meshes/mesh";
  47316. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47317. import { EasingFunction } from "babylonjs/Animations/easing";
  47318. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47319. import "babylonjs/Meshes/Builders/groundBuilder";
  47320. import "babylonjs/Meshes/Builders/torusBuilder";
  47321. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47322. import "babylonjs/Gamepads/gamepadSceneComponent";
  47323. import "babylonjs/Animations/animatable";
  47324. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47325. /**
  47326. * Options to modify the vr teleportation behavior.
  47327. */
  47328. export interface VRTeleportationOptions {
  47329. /**
  47330. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47331. */
  47332. floorMeshName?: string;
  47333. /**
  47334. * A list of meshes to be used as the teleportation floor. (default: empty)
  47335. */
  47336. floorMeshes?: Mesh[];
  47337. /**
  47338. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47339. */
  47340. teleportationMode?: number;
  47341. /**
  47342. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47343. */
  47344. teleportationTime?: number;
  47345. /**
  47346. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47347. */
  47348. teleportationSpeed?: number;
  47349. /**
  47350. * The easing function used in the animation or null for Linear. (default CircleEase)
  47351. */
  47352. easingFunction?: EasingFunction;
  47353. }
  47354. /**
  47355. * Options to modify the vr experience helper's behavior.
  47356. */
  47357. export interface VRExperienceHelperOptions extends WebVROptions {
  47358. /**
  47359. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47360. */
  47361. createDeviceOrientationCamera?: boolean;
  47362. /**
  47363. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47364. */
  47365. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47366. /**
  47367. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47368. */
  47369. laserToggle?: boolean;
  47370. /**
  47371. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47372. */
  47373. floorMeshes?: Mesh[];
  47374. /**
  47375. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47376. */
  47377. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47378. /**
  47379. * Defines if WebXR should be used instead of WebVR (if available)
  47380. */
  47381. useXR?: boolean;
  47382. }
  47383. /**
  47384. * Event containing information after VR has been entered
  47385. */
  47386. export class OnAfterEnteringVRObservableEvent {
  47387. /**
  47388. * If entering vr was successful
  47389. */
  47390. success: boolean;
  47391. }
  47392. /**
  47393. * Helps to quickly add VR support to an existing scene.
  47394. * See http://doc.babylonjs.com/how_to/webvr_helper
  47395. */
  47396. export class VRExperienceHelper {
  47397. /** Options to modify the vr experience helper's behavior. */
  47398. webVROptions: VRExperienceHelperOptions;
  47399. private _scene;
  47400. private _position;
  47401. private _btnVR;
  47402. private _btnVRDisplayed;
  47403. private _webVRsupported;
  47404. private _webVRready;
  47405. private _webVRrequesting;
  47406. private _webVRpresenting;
  47407. private _hasEnteredVR;
  47408. private _fullscreenVRpresenting;
  47409. private _inputElement;
  47410. private _webVRCamera;
  47411. private _vrDeviceOrientationCamera;
  47412. private _deviceOrientationCamera;
  47413. private _existingCamera;
  47414. private _onKeyDown;
  47415. private _onVrDisplayPresentChange;
  47416. private _onVRDisplayChanged;
  47417. private _onVRRequestPresentStart;
  47418. private _onVRRequestPresentComplete;
  47419. /**
  47420. * 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)
  47421. */
  47422. enableGazeEvenWhenNoPointerLock: boolean;
  47423. /**
  47424. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47425. */
  47426. exitVROnDoubleTap: boolean;
  47427. /**
  47428. * Observable raised right before entering VR.
  47429. */
  47430. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47431. /**
  47432. * Observable raised when entering VR has completed.
  47433. */
  47434. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47435. /**
  47436. * Observable raised when exiting VR.
  47437. */
  47438. onExitingVRObservable: Observable<VRExperienceHelper>;
  47439. /**
  47440. * Observable raised when controller mesh is loaded.
  47441. */
  47442. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47443. /** Return this.onEnteringVRObservable
  47444. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47445. */
  47446. get onEnteringVR(): Observable<VRExperienceHelper>;
  47447. /** Return this.onExitingVRObservable
  47448. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47449. */
  47450. get onExitingVR(): Observable<VRExperienceHelper>;
  47451. /** Return this.onControllerMeshLoadedObservable
  47452. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47453. */
  47454. get onControllerMeshLoaded(): Observable<WebVRController>;
  47455. private _rayLength;
  47456. private _useCustomVRButton;
  47457. private _teleportationRequested;
  47458. private _teleportActive;
  47459. private _floorMeshName;
  47460. private _floorMeshesCollection;
  47461. private _teleportationMode;
  47462. private _teleportationTime;
  47463. private _teleportationSpeed;
  47464. private _teleportationEasing;
  47465. private _rotationAllowed;
  47466. private _teleportBackwardsVector;
  47467. private _teleportationTarget;
  47468. private _isDefaultTeleportationTarget;
  47469. private _postProcessMove;
  47470. private _teleportationFillColor;
  47471. private _teleportationBorderColor;
  47472. private _rotationAngle;
  47473. private _haloCenter;
  47474. private _cameraGazer;
  47475. private _padSensibilityUp;
  47476. private _padSensibilityDown;
  47477. private _leftController;
  47478. private _rightController;
  47479. private _gazeColor;
  47480. private _laserColor;
  47481. private _pickedLaserColor;
  47482. private _pickedGazeColor;
  47483. /**
  47484. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47485. */
  47486. onNewMeshSelected: Observable<AbstractMesh>;
  47487. /**
  47488. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47489. * This observable will provide the mesh and the controller used to select the mesh
  47490. */
  47491. onMeshSelectedWithController: Observable<{
  47492. mesh: AbstractMesh;
  47493. controller: WebVRController;
  47494. }>;
  47495. /**
  47496. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47497. */
  47498. onNewMeshPicked: Observable<PickingInfo>;
  47499. private _circleEase;
  47500. /**
  47501. * Observable raised before camera teleportation
  47502. */
  47503. onBeforeCameraTeleport: Observable<Vector3>;
  47504. /**
  47505. * Observable raised after camera teleportation
  47506. */
  47507. onAfterCameraTeleport: Observable<Vector3>;
  47508. /**
  47509. * Observable raised when current selected mesh gets unselected
  47510. */
  47511. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47512. private _raySelectionPredicate;
  47513. /**
  47514. * To be optionaly changed by user to define custom ray selection
  47515. */
  47516. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47517. /**
  47518. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47519. */
  47520. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47521. /**
  47522. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47523. */
  47524. teleportationEnabled: boolean;
  47525. private _defaultHeight;
  47526. private _teleportationInitialized;
  47527. private _interactionsEnabled;
  47528. private _interactionsRequested;
  47529. private _displayGaze;
  47530. private _displayLaserPointer;
  47531. /**
  47532. * The mesh used to display where the user is going to teleport.
  47533. */
  47534. get teleportationTarget(): Mesh;
  47535. /**
  47536. * Sets the mesh to be used to display where the user is going to teleport.
  47537. */
  47538. set teleportationTarget(value: Mesh);
  47539. /**
  47540. * 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
  47541. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47542. * See http://doc.babylonjs.com/resources/baking_transformations
  47543. */
  47544. get gazeTrackerMesh(): Mesh;
  47545. set gazeTrackerMesh(value: Mesh);
  47546. /**
  47547. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47548. */
  47549. updateGazeTrackerScale: boolean;
  47550. /**
  47551. * If the gaze trackers color should be updated when selecting meshes
  47552. */
  47553. updateGazeTrackerColor: boolean;
  47554. /**
  47555. * If the controller laser color should be updated when selecting meshes
  47556. */
  47557. updateControllerLaserColor: boolean;
  47558. /**
  47559. * The gaze tracking mesh corresponding to the left controller
  47560. */
  47561. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47562. /**
  47563. * The gaze tracking mesh corresponding to the right controller
  47564. */
  47565. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47566. /**
  47567. * If the ray of the gaze should be displayed.
  47568. */
  47569. get displayGaze(): boolean;
  47570. /**
  47571. * Sets if the ray of the gaze should be displayed.
  47572. */
  47573. set displayGaze(value: boolean);
  47574. /**
  47575. * If the ray of the LaserPointer should be displayed.
  47576. */
  47577. get displayLaserPointer(): boolean;
  47578. /**
  47579. * Sets if the ray of the LaserPointer should be displayed.
  47580. */
  47581. set displayLaserPointer(value: boolean);
  47582. /**
  47583. * The deviceOrientationCamera used as the camera when not in VR.
  47584. */
  47585. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47586. /**
  47587. * Based on the current WebVR support, returns the current VR camera used.
  47588. */
  47589. get currentVRCamera(): Nullable<Camera>;
  47590. /**
  47591. * The webVRCamera which is used when in VR.
  47592. */
  47593. get webVRCamera(): WebVRFreeCamera;
  47594. /**
  47595. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47596. */
  47597. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47598. /**
  47599. * The html button that is used to trigger entering into VR.
  47600. */
  47601. get vrButton(): Nullable<HTMLButtonElement>;
  47602. private get _teleportationRequestInitiated();
  47603. /**
  47604. * Defines whether or not Pointer lock should be requested when switching to
  47605. * full screen.
  47606. */
  47607. requestPointerLockOnFullScreen: boolean;
  47608. /**
  47609. * If asking to force XR, this will be populated with the default xr experience
  47610. */
  47611. xr: WebXRDefaultExperience;
  47612. /**
  47613. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47614. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47615. */
  47616. xrTestDone: boolean;
  47617. /**
  47618. * Instantiates a VRExperienceHelper.
  47619. * Helps to quickly add VR support to an existing scene.
  47620. * @param scene The scene the VRExperienceHelper belongs to.
  47621. * @param webVROptions Options to modify the vr experience helper's behavior.
  47622. */
  47623. constructor(scene: Scene,
  47624. /** Options to modify the vr experience helper's behavior. */
  47625. webVROptions?: VRExperienceHelperOptions);
  47626. private completeVRInit;
  47627. private _onDefaultMeshLoaded;
  47628. private _onResize;
  47629. private _onFullscreenChange;
  47630. /**
  47631. * Gets a value indicating if we are currently in VR mode.
  47632. */
  47633. get isInVRMode(): boolean;
  47634. private onVrDisplayPresentChange;
  47635. private onVRDisplayChanged;
  47636. private moveButtonToBottomRight;
  47637. private displayVRButton;
  47638. private updateButtonVisibility;
  47639. private _cachedAngularSensibility;
  47640. /**
  47641. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47642. * Otherwise, will use the fullscreen API.
  47643. */
  47644. enterVR(): void;
  47645. /**
  47646. * Attempt to exit VR, or fullscreen.
  47647. */
  47648. exitVR(): void;
  47649. /**
  47650. * The position of the vr experience helper.
  47651. */
  47652. get position(): Vector3;
  47653. /**
  47654. * Sets the position of the vr experience helper.
  47655. */
  47656. set position(value: Vector3);
  47657. /**
  47658. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47659. */
  47660. enableInteractions(): void;
  47661. private get _noControllerIsActive();
  47662. private beforeRender;
  47663. private _isTeleportationFloor;
  47664. /**
  47665. * Adds a floor mesh to be used for teleportation.
  47666. * @param floorMesh the mesh to be used for teleportation.
  47667. */
  47668. addFloorMesh(floorMesh: Mesh): void;
  47669. /**
  47670. * Removes a floor mesh from being used for teleportation.
  47671. * @param floorMesh the mesh to be removed.
  47672. */
  47673. removeFloorMesh(floorMesh: Mesh): void;
  47674. /**
  47675. * Enables interactions and teleportation using the VR controllers and gaze.
  47676. * @param vrTeleportationOptions options to modify teleportation behavior.
  47677. */
  47678. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47679. private _onNewGamepadConnected;
  47680. private _tryEnableInteractionOnController;
  47681. private _onNewGamepadDisconnected;
  47682. private _enableInteractionOnController;
  47683. private _checkTeleportWithRay;
  47684. private _checkRotate;
  47685. private _checkTeleportBackwards;
  47686. private _enableTeleportationOnController;
  47687. private _createTeleportationCircles;
  47688. private _displayTeleportationTarget;
  47689. private _hideTeleportationTarget;
  47690. private _rotateCamera;
  47691. private _moveTeleportationSelectorTo;
  47692. private _workingVector;
  47693. private _workingQuaternion;
  47694. private _workingMatrix;
  47695. /**
  47696. * Time Constant Teleportation Mode
  47697. */
  47698. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47699. /**
  47700. * Speed Constant Teleportation Mode
  47701. */
  47702. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47703. /**
  47704. * Teleports the users feet to the desired location
  47705. * @param location The location where the user's feet should be placed
  47706. */
  47707. teleportCamera(location: Vector3): void;
  47708. private _convertNormalToDirectionOfRay;
  47709. private _castRayAndSelectObject;
  47710. private _notifySelectedMeshUnselected;
  47711. /**
  47712. * Permanently set new colors for the laser pointer
  47713. * @param color the new laser color
  47714. * @param pickedColor the new laser color when picked mesh detected
  47715. */
  47716. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47717. /**
  47718. * Set lighting enabled / disabled on the laser pointer of both controllers
  47719. * @param enabled should the lighting be enabled on the laser pointer
  47720. */
  47721. setLaserLightingState(enabled?: boolean): void;
  47722. /**
  47723. * Permanently set new colors for the gaze pointer
  47724. * @param color the new gaze color
  47725. * @param pickedColor the new gaze color when picked mesh detected
  47726. */
  47727. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47728. /**
  47729. * Sets the color of the laser ray from the vr controllers.
  47730. * @param color new color for the ray.
  47731. */
  47732. changeLaserColor(color: Color3): void;
  47733. /**
  47734. * Sets the color of the ray from the vr headsets gaze.
  47735. * @param color new color for the ray.
  47736. */
  47737. changeGazeColor(color: Color3): void;
  47738. /**
  47739. * Exits VR and disposes of the vr experience helper
  47740. */
  47741. dispose(): void;
  47742. /**
  47743. * Gets the name of the VRExperienceHelper class
  47744. * @returns "VRExperienceHelper"
  47745. */
  47746. getClassName(): string;
  47747. }
  47748. }
  47749. declare module "babylonjs/Cameras/VR/index" {
  47750. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47751. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47752. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47753. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47754. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47755. export * from "babylonjs/Cameras/VR/webVRCamera";
  47756. }
  47757. declare module "babylonjs/Cameras/RigModes/index" {
  47758. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47759. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47760. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47761. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47762. }
  47763. declare module "babylonjs/Cameras/index" {
  47764. export * from "babylonjs/Cameras/Inputs/index";
  47765. export * from "babylonjs/Cameras/cameraInputsManager";
  47766. export * from "babylonjs/Cameras/camera";
  47767. export * from "babylonjs/Cameras/targetCamera";
  47768. export * from "babylonjs/Cameras/freeCamera";
  47769. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47770. export * from "babylonjs/Cameras/touchCamera";
  47771. export * from "babylonjs/Cameras/arcRotateCamera";
  47772. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47773. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47774. export * from "babylonjs/Cameras/flyCamera";
  47775. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47776. export * from "babylonjs/Cameras/followCamera";
  47777. export * from "babylonjs/Cameras/followCameraInputsManager";
  47778. export * from "babylonjs/Cameras/gamepadCamera";
  47779. export * from "babylonjs/Cameras/Stereoscopic/index";
  47780. export * from "babylonjs/Cameras/universalCamera";
  47781. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47782. export * from "babylonjs/Cameras/VR/index";
  47783. export * from "babylonjs/Cameras/RigModes/index";
  47784. }
  47785. declare module "babylonjs/Collisions/index" {
  47786. export * from "babylonjs/Collisions/collider";
  47787. export * from "babylonjs/Collisions/collisionCoordinator";
  47788. export * from "babylonjs/Collisions/pickingInfo";
  47789. export * from "babylonjs/Collisions/intersectionInfo";
  47790. export * from "babylonjs/Collisions/meshCollisionData";
  47791. }
  47792. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47793. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47794. import { Vector3 } from "babylonjs/Maths/math.vector";
  47795. import { Ray } from "babylonjs/Culling/ray";
  47796. import { Plane } from "babylonjs/Maths/math.plane";
  47797. /**
  47798. * Contains an array of blocks representing the octree
  47799. */
  47800. export interface IOctreeContainer<T> {
  47801. /**
  47802. * Blocks within the octree
  47803. */
  47804. blocks: Array<OctreeBlock<T>>;
  47805. }
  47806. /**
  47807. * Class used to store a cell in an octree
  47808. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47809. */
  47810. export class OctreeBlock<T> {
  47811. /**
  47812. * Gets the content of the current block
  47813. */
  47814. entries: T[];
  47815. /**
  47816. * Gets the list of block children
  47817. */
  47818. blocks: Array<OctreeBlock<T>>;
  47819. private _depth;
  47820. private _maxDepth;
  47821. private _capacity;
  47822. private _minPoint;
  47823. private _maxPoint;
  47824. private _boundingVectors;
  47825. private _creationFunc;
  47826. /**
  47827. * Creates a new block
  47828. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47829. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47830. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47831. * @param depth defines the current depth of this block in the octree
  47832. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47833. * @param creationFunc defines a callback to call when an element is added to the block
  47834. */
  47835. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47836. /**
  47837. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47838. */
  47839. get capacity(): number;
  47840. /**
  47841. * Gets the minimum vector (in world space) of the block's bounding box
  47842. */
  47843. get minPoint(): Vector3;
  47844. /**
  47845. * Gets the maximum vector (in world space) of the block's bounding box
  47846. */
  47847. get maxPoint(): Vector3;
  47848. /**
  47849. * Add a new element to this block
  47850. * @param entry defines the element to add
  47851. */
  47852. addEntry(entry: T): void;
  47853. /**
  47854. * Remove an element from this block
  47855. * @param entry defines the element to remove
  47856. */
  47857. removeEntry(entry: T): void;
  47858. /**
  47859. * Add an array of elements to this block
  47860. * @param entries defines the array of elements to add
  47861. */
  47862. addEntries(entries: T[]): void;
  47863. /**
  47864. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47865. * @param frustumPlanes defines the frustum planes to test
  47866. * @param selection defines the array to store current content if selection is positive
  47867. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47868. */
  47869. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47870. /**
  47871. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47872. * @param sphereCenter defines the bounding sphere center
  47873. * @param sphereRadius defines the bounding sphere radius
  47874. * @param selection defines the array to store current content if selection is positive
  47875. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47876. */
  47877. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47878. /**
  47879. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47880. * @param ray defines the ray to test with
  47881. * @param selection defines the array to store current content if selection is positive
  47882. */
  47883. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47884. /**
  47885. * Subdivide the content into child blocks (this block will then be empty)
  47886. */
  47887. createInnerBlocks(): void;
  47888. /**
  47889. * @hidden
  47890. */
  47891. 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;
  47892. }
  47893. }
  47894. declare module "babylonjs/Culling/Octrees/octree" {
  47895. import { SmartArray } from "babylonjs/Misc/smartArray";
  47896. import { Vector3 } from "babylonjs/Maths/math.vector";
  47897. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47899. import { Ray } from "babylonjs/Culling/ray";
  47900. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47901. import { Plane } from "babylonjs/Maths/math.plane";
  47902. /**
  47903. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47904. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47905. */
  47906. export class Octree<T> {
  47907. /** 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.) */
  47908. maxDepth: number;
  47909. /**
  47910. * Blocks within the octree containing objects
  47911. */
  47912. blocks: Array<OctreeBlock<T>>;
  47913. /**
  47914. * Content stored in the octree
  47915. */
  47916. dynamicContent: T[];
  47917. private _maxBlockCapacity;
  47918. private _selectionContent;
  47919. private _creationFunc;
  47920. /**
  47921. * Creates a octree
  47922. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47923. * @param creationFunc function to be used to instatiate the octree
  47924. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47925. * @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.)
  47926. */
  47927. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47928. /** 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.) */
  47929. maxDepth?: number);
  47930. /**
  47931. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47932. * @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);
  47933. * @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);
  47934. * @param entries meshes to be added to the octree blocks
  47935. */
  47936. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47937. /**
  47938. * Adds a mesh to the octree
  47939. * @param entry Mesh to add to the octree
  47940. */
  47941. addMesh(entry: T): void;
  47942. /**
  47943. * Remove an element from the octree
  47944. * @param entry defines the element to remove
  47945. */
  47946. removeMesh(entry: T): void;
  47947. /**
  47948. * Selects an array of meshes within the frustum
  47949. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47950. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47951. * @returns array of meshes within the frustum
  47952. */
  47953. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47954. /**
  47955. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47956. * @param sphereCenter defines the bounding sphere center
  47957. * @param sphereRadius defines the bounding sphere radius
  47958. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47959. * @returns an array of objects that intersect the sphere
  47960. */
  47961. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47962. /**
  47963. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47964. * @param ray defines the ray to test with
  47965. * @returns array of intersected objects
  47966. */
  47967. intersectsRay(ray: Ray): SmartArray<T>;
  47968. /**
  47969. * Adds a mesh into the octree block if it intersects the block
  47970. */
  47971. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47972. /**
  47973. * Adds a submesh into the octree block if it intersects the block
  47974. */
  47975. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47976. }
  47977. }
  47978. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47979. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47980. import { Scene } from "babylonjs/scene";
  47981. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47983. import { Ray } from "babylonjs/Culling/ray";
  47984. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47985. import { Collider } from "babylonjs/Collisions/collider";
  47986. module "babylonjs/scene" {
  47987. interface Scene {
  47988. /**
  47989. * @hidden
  47990. * Backing Filed
  47991. */
  47992. _selectionOctree: Octree<AbstractMesh>;
  47993. /**
  47994. * Gets the octree used to boost mesh selection (picking)
  47995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47996. */
  47997. selectionOctree: Octree<AbstractMesh>;
  47998. /**
  47999. * Creates or updates the octree used to boost selection (picking)
  48000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48001. * @param maxCapacity defines the maximum capacity per leaf
  48002. * @param maxDepth defines the maximum depth of the octree
  48003. * @returns an octree of AbstractMesh
  48004. */
  48005. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48006. }
  48007. }
  48008. module "babylonjs/Meshes/abstractMesh" {
  48009. interface AbstractMesh {
  48010. /**
  48011. * @hidden
  48012. * Backing Field
  48013. */
  48014. _submeshesOctree: Octree<SubMesh>;
  48015. /**
  48016. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48017. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48018. * @param maxCapacity defines the maximum size of each block (64 by default)
  48019. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48020. * @returns the new octree
  48021. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48023. */
  48024. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48025. }
  48026. }
  48027. /**
  48028. * Defines the octree scene component responsible to manage any octrees
  48029. * in a given scene.
  48030. */
  48031. export class OctreeSceneComponent {
  48032. /**
  48033. * The component name help to identify the component in the list of scene components.
  48034. */
  48035. readonly name: string;
  48036. /**
  48037. * The scene the component belongs to.
  48038. */
  48039. scene: Scene;
  48040. /**
  48041. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48042. */
  48043. readonly checksIsEnabled: boolean;
  48044. /**
  48045. * Creates a new instance of the component for the given scene
  48046. * @param scene Defines the scene to register the component in
  48047. */
  48048. constructor(scene: Scene);
  48049. /**
  48050. * Registers the component in a given scene
  48051. */
  48052. register(): void;
  48053. /**
  48054. * Return the list of active meshes
  48055. * @returns the list of active meshes
  48056. */
  48057. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48058. /**
  48059. * Return the list of active sub meshes
  48060. * @param mesh The mesh to get the candidates sub meshes from
  48061. * @returns the list of active sub meshes
  48062. */
  48063. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48064. private _tempRay;
  48065. /**
  48066. * Return the list of sub meshes intersecting with a given local ray
  48067. * @param mesh defines the mesh to find the submesh for
  48068. * @param localRay defines the ray in local space
  48069. * @returns the list of intersecting sub meshes
  48070. */
  48071. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48072. /**
  48073. * Return the list of sub meshes colliding with a collider
  48074. * @param mesh defines the mesh to find the submesh for
  48075. * @param collider defines the collider to evaluate the collision against
  48076. * @returns the list of colliding sub meshes
  48077. */
  48078. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48079. /**
  48080. * Rebuilds the elements related to this component in case of
  48081. * context lost for instance.
  48082. */
  48083. rebuild(): void;
  48084. /**
  48085. * Disposes the component and the associated ressources.
  48086. */
  48087. dispose(): void;
  48088. }
  48089. }
  48090. declare module "babylonjs/Culling/Octrees/index" {
  48091. export * from "babylonjs/Culling/Octrees/octree";
  48092. export * from "babylonjs/Culling/Octrees/octreeBlock";
  48093. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  48094. }
  48095. declare module "babylonjs/Culling/index" {
  48096. export * from "babylonjs/Culling/boundingBox";
  48097. export * from "babylonjs/Culling/boundingInfo";
  48098. export * from "babylonjs/Culling/boundingSphere";
  48099. export * from "babylonjs/Culling/Octrees/index";
  48100. export * from "babylonjs/Culling/ray";
  48101. }
  48102. declare module "babylonjs/Gizmos/gizmo" {
  48103. import { Nullable } from "babylonjs/types";
  48104. import { IDisposable } from "babylonjs/scene";
  48105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48106. import { Mesh } from "babylonjs/Meshes/mesh";
  48107. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48108. /**
  48109. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48110. */
  48111. export class Gizmo implements IDisposable {
  48112. /** The utility layer the gizmo will be added to */
  48113. gizmoLayer: UtilityLayerRenderer;
  48114. /**
  48115. * The root mesh of the gizmo
  48116. */
  48117. _rootMesh: Mesh;
  48118. private _attachedMesh;
  48119. /**
  48120. * Ratio for the scale of the gizmo (Default: 1)
  48121. */
  48122. scaleRatio: number;
  48123. /**
  48124. * If a custom mesh has been set (Default: false)
  48125. */
  48126. protected _customMeshSet: boolean;
  48127. /**
  48128. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48129. * * When set, interactions will be enabled
  48130. */
  48131. get attachedMesh(): Nullable<AbstractMesh>;
  48132. set attachedMesh(value: Nullable<AbstractMesh>);
  48133. /**
  48134. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48135. * @param mesh The mesh to replace the default mesh of the gizmo
  48136. */
  48137. setCustomMesh(mesh: Mesh): void;
  48138. /**
  48139. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48140. */
  48141. updateGizmoRotationToMatchAttachedMesh: boolean;
  48142. /**
  48143. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48144. */
  48145. updateGizmoPositionToMatchAttachedMesh: boolean;
  48146. /**
  48147. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48148. */
  48149. updateScale: boolean;
  48150. protected _interactionsEnabled: boolean;
  48151. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48152. private _beforeRenderObserver;
  48153. private _tempVector;
  48154. /**
  48155. * Creates a gizmo
  48156. * @param gizmoLayer The utility layer the gizmo will be added to
  48157. */
  48158. constructor(
  48159. /** The utility layer the gizmo will be added to */
  48160. gizmoLayer?: UtilityLayerRenderer);
  48161. /**
  48162. * Updates the gizmo to match the attached mesh's position/rotation
  48163. */
  48164. protected _update(): void;
  48165. /**
  48166. * Disposes of the gizmo
  48167. */
  48168. dispose(): void;
  48169. }
  48170. }
  48171. declare module "babylonjs/Gizmos/planeDragGizmo" {
  48172. import { Observable } from "babylonjs/Misc/observable";
  48173. import { Nullable } from "babylonjs/types";
  48174. import { Vector3 } from "babylonjs/Maths/math.vector";
  48175. import { Color3 } from "babylonjs/Maths/math.color";
  48176. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48178. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48179. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48180. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48181. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48182. import { Scene } from "babylonjs/scene";
  48183. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48184. /**
  48185. * Single plane drag gizmo
  48186. */
  48187. export class PlaneDragGizmo extends Gizmo {
  48188. /**
  48189. * Drag behavior responsible for the gizmos dragging interactions
  48190. */
  48191. dragBehavior: PointerDragBehavior;
  48192. private _pointerObserver;
  48193. /**
  48194. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48195. */
  48196. snapDistance: number;
  48197. /**
  48198. * Event that fires each time the gizmo snaps to a new location.
  48199. * * snapDistance is the the change in distance
  48200. */
  48201. onSnapObservable: Observable<{
  48202. snapDistance: number;
  48203. }>;
  48204. private _plane;
  48205. private _coloredMaterial;
  48206. private _hoverMaterial;
  48207. private _isEnabled;
  48208. private _parent;
  48209. /** @hidden */
  48210. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48211. /** @hidden */
  48212. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48213. /**
  48214. * Creates a PlaneDragGizmo
  48215. * @param gizmoLayer The utility layer the gizmo will be added to
  48216. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48217. * @param color The color of the gizmo
  48218. */
  48219. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48220. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48221. /**
  48222. * If the gizmo is enabled
  48223. */
  48224. set isEnabled(value: boolean);
  48225. get isEnabled(): boolean;
  48226. /**
  48227. * Disposes of the gizmo
  48228. */
  48229. dispose(): void;
  48230. }
  48231. }
  48232. declare module "babylonjs/Gizmos/positionGizmo" {
  48233. import { Observable } from "babylonjs/Misc/observable";
  48234. import { Nullable } from "babylonjs/types";
  48235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48236. import { Mesh } from "babylonjs/Meshes/mesh";
  48237. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48238. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  48239. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  48240. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48241. /**
  48242. * Gizmo that enables dragging a mesh along 3 axis
  48243. */
  48244. export class PositionGizmo extends Gizmo {
  48245. /**
  48246. * Internal gizmo used for interactions on the x axis
  48247. */
  48248. xGizmo: AxisDragGizmo;
  48249. /**
  48250. * Internal gizmo used for interactions on the y axis
  48251. */
  48252. yGizmo: AxisDragGizmo;
  48253. /**
  48254. * Internal gizmo used for interactions on the z axis
  48255. */
  48256. zGizmo: AxisDragGizmo;
  48257. /**
  48258. * Internal gizmo used for interactions on the yz plane
  48259. */
  48260. xPlaneGizmo: PlaneDragGizmo;
  48261. /**
  48262. * Internal gizmo used for interactions on the xz plane
  48263. */
  48264. yPlaneGizmo: PlaneDragGizmo;
  48265. /**
  48266. * Internal gizmo used for interactions on the xy plane
  48267. */
  48268. zPlaneGizmo: PlaneDragGizmo;
  48269. /**
  48270. * private variables
  48271. */
  48272. private _meshAttached;
  48273. private _updateGizmoRotationToMatchAttachedMesh;
  48274. private _snapDistance;
  48275. private _scaleRatio;
  48276. /** Fires an event when any of it's sub gizmos are dragged */
  48277. onDragStartObservable: Observable<unknown>;
  48278. /** Fires an event when any of it's sub gizmos are released from dragging */
  48279. onDragEndObservable: Observable<unknown>;
  48280. /**
  48281. * If set to true, planar drag is enabled
  48282. */
  48283. private _planarGizmoEnabled;
  48284. get attachedMesh(): Nullable<AbstractMesh>;
  48285. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48286. /**
  48287. * Creates a PositionGizmo
  48288. * @param gizmoLayer The utility layer the gizmo will be added to
  48289. */
  48290. constructor(gizmoLayer?: UtilityLayerRenderer);
  48291. /**
  48292. * If the planar drag gizmo is enabled
  48293. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48294. */
  48295. set planarGizmoEnabled(value: boolean);
  48296. get planarGizmoEnabled(): boolean;
  48297. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48298. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48299. /**
  48300. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48301. */
  48302. set snapDistance(value: number);
  48303. get snapDistance(): number;
  48304. /**
  48305. * Ratio for the scale of the gizmo (Default: 1)
  48306. */
  48307. set scaleRatio(value: number);
  48308. get scaleRatio(): number;
  48309. /**
  48310. * Disposes of the gizmo
  48311. */
  48312. dispose(): void;
  48313. /**
  48314. * CustomMeshes are not supported by this gizmo
  48315. * @param mesh The mesh to replace the default mesh of the gizmo
  48316. */
  48317. setCustomMesh(mesh: Mesh): void;
  48318. }
  48319. }
  48320. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48321. import { Observable } from "babylonjs/Misc/observable";
  48322. import { Nullable } from "babylonjs/types";
  48323. import { Vector3 } from "babylonjs/Maths/math.vector";
  48324. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48326. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48327. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48328. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48329. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48330. import { Scene } from "babylonjs/scene";
  48331. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48332. import { Color3 } from "babylonjs/Maths/math.color";
  48333. /**
  48334. * Single axis drag gizmo
  48335. */
  48336. export class AxisDragGizmo extends Gizmo {
  48337. /**
  48338. * Drag behavior responsible for the gizmos dragging interactions
  48339. */
  48340. dragBehavior: PointerDragBehavior;
  48341. private _pointerObserver;
  48342. /**
  48343. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48344. */
  48345. snapDistance: number;
  48346. /**
  48347. * Event that fires each time the gizmo snaps to a new location.
  48348. * * snapDistance is the the change in distance
  48349. */
  48350. onSnapObservable: Observable<{
  48351. snapDistance: number;
  48352. }>;
  48353. private _isEnabled;
  48354. private _parent;
  48355. private _arrow;
  48356. private _coloredMaterial;
  48357. private _hoverMaterial;
  48358. /** @hidden */
  48359. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48360. /** @hidden */
  48361. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48362. /**
  48363. * Creates an AxisDragGizmo
  48364. * @param gizmoLayer The utility layer the gizmo will be added to
  48365. * @param dragAxis The axis which the gizmo will be able to drag on
  48366. * @param color The color of the gizmo
  48367. */
  48368. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48369. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48370. /**
  48371. * If the gizmo is enabled
  48372. */
  48373. set isEnabled(value: boolean);
  48374. get isEnabled(): boolean;
  48375. /**
  48376. * Disposes of the gizmo
  48377. */
  48378. dispose(): void;
  48379. }
  48380. }
  48381. declare module "babylonjs/Debug/axesViewer" {
  48382. import { Vector3 } from "babylonjs/Maths/math.vector";
  48383. import { Nullable } from "babylonjs/types";
  48384. import { Scene } from "babylonjs/scene";
  48385. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48386. /**
  48387. * The Axes viewer will show 3 axes in a specific point in space
  48388. */
  48389. export class AxesViewer {
  48390. private _xAxis;
  48391. private _yAxis;
  48392. private _zAxis;
  48393. private _scaleLinesFactor;
  48394. private _instanced;
  48395. /**
  48396. * Gets the hosting scene
  48397. */
  48398. scene: Scene;
  48399. /**
  48400. * Gets or sets a number used to scale line length
  48401. */
  48402. scaleLines: number;
  48403. /** Gets the node hierarchy used to render x-axis */
  48404. get xAxis(): TransformNode;
  48405. /** Gets the node hierarchy used to render y-axis */
  48406. get yAxis(): TransformNode;
  48407. /** Gets the node hierarchy used to render z-axis */
  48408. get zAxis(): TransformNode;
  48409. /**
  48410. * Creates a new AxesViewer
  48411. * @param scene defines the hosting scene
  48412. * @param scaleLines defines a number used to scale line length (1 by default)
  48413. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48414. * @param xAxis defines the node hierarchy used to render the x-axis
  48415. * @param yAxis defines the node hierarchy used to render the y-axis
  48416. * @param zAxis defines the node hierarchy used to render the z-axis
  48417. */
  48418. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48419. /**
  48420. * Force the viewer to update
  48421. * @param position defines the position of the viewer
  48422. * @param xaxis defines the x axis of the viewer
  48423. * @param yaxis defines the y axis of the viewer
  48424. * @param zaxis defines the z axis of the viewer
  48425. */
  48426. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48427. /**
  48428. * Creates an instance of this axes viewer.
  48429. * @returns a new axes viewer with instanced meshes
  48430. */
  48431. createInstance(): AxesViewer;
  48432. /** Releases resources */
  48433. dispose(): void;
  48434. private static _SetRenderingGroupId;
  48435. }
  48436. }
  48437. declare module "babylonjs/Debug/boneAxesViewer" {
  48438. import { Nullable } from "babylonjs/types";
  48439. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48440. import { Vector3 } from "babylonjs/Maths/math.vector";
  48441. import { Mesh } from "babylonjs/Meshes/mesh";
  48442. import { Bone } from "babylonjs/Bones/bone";
  48443. import { Scene } from "babylonjs/scene";
  48444. /**
  48445. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48446. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48447. */
  48448. export class BoneAxesViewer extends AxesViewer {
  48449. /**
  48450. * Gets or sets the target mesh where to display the axes viewer
  48451. */
  48452. mesh: Nullable<Mesh>;
  48453. /**
  48454. * Gets or sets the target bone where to display the axes viewer
  48455. */
  48456. bone: Nullable<Bone>;
  48457. /** Gets current position */
  48458. pos: Vector3;
  48459. /** Gets direction of X axis */
  48460. xaxis: Vector3;
  48461. /** Gets direction of Y axis */
  48462. yaxis: Vector3;
  48463. /** Gets direction of Z axis */
  48464. zaxis: Vector3;
  48465. /**
  48466. * Creates a new BoneAxesViewer
  48467. * @param scene defines the hosting scene
  48468. * @param bone defines the target bone
  48469. * @param mesh defines the target mesh
  48470. * @param scaleLines defines a scaling factor for line length (1 by default)
  48471. */
  48472. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48473. /**
  48474. * Force the viewer to update
  48475. */
  48476. update(): void;
  48477. /** Releases resources */
  48478. dispose(): void;
  48479. }
  48480. }
  48481. declare module "babylonjs/Debug/debugLayer" {
  48482. import { Scene } from "babylonjs/scene";
  48483. /**
  48484. * Interface used to define scene explorer extensibility option
  48485. */
  48486. export interface IExplorerExtensibilityOption {
  48487. /**
  48488. * Define the option label
  48489. */
  48490. label: string;
  48491. /**
  48492. * Defines the action to execute on click
  48493. */
  48494. action: (entity: any) => void;
  48495. }
  48496. /**
  48497. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48498. */
  48499. export interface IExplorerExtensibilityGroup {
  48500. /**
  48501. * Defines a predicate to test if a given type mut be extended
  48502. */
  48503. predicate: (entity: any) => boolean;
  48504. /**
  48505. * Gets the list of options added to a type
  48506. */
  48507. entries: IExplorerExtensibilityOption[];
  48508. }
  48509. /**
  48510. * Interface used to define the options to use to create the Inspector
  48511. */
  48512. export interface IInspectorOptions {
  48513. /**
  48514. * Display in overlay mode (default: false)
  48515. */
  48516. overlay?: boolean;
  48517. /**
  48518. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48519. */
  48520. globalRoot?: HTMLElement;
  48521. /**
  48522. * Display the Scene explorer
  48523. */
  48524. showExplorer?: boolean;
  48525. /**
  48526. * Display the property inspector
  48527. */
  48528. showInspector?: boolean;
  48529. /**
  48530. * Display in embed mode (both panes on the right)
  48531. */
  48532. embedMode?: boolean;
  48533. /**
  48534. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48535. */
  48536. handleResize?: boolean;
  48537. /**
  48538. * Allow the panes to popup (default: true)
  48539. */
  48540. enablePopup?: boolean;
  48541. /**
  48542. * Allow the panes to be closed by users (default: true)
  48543. */
  48544. enableClose?: boolean;
  48545. /**
  48546. * Optional list of extensibility entries
  48547. */
  48548. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48549. /**
  48550. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48551. */
  48552. inspectorURL?: string;
  48553. /**
  48554. * Optional initial tab (default to DebugLayerTab.Properties)
  48555. */
  48556. initialTab?: DebugLayerTab;
  48557. }
  48558. module "babylonjs/scene" {
  48559. interface Scene {
  48560. /**
  48561. * @hidden
  48562. * Backing field
  48563. */
  48564. _debugLayer: DebugLayer;
  48565. /**
  48566. * Gets the debug layer (aka Inspector) associated with the scene
  48567. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48568. */
  48569. debugLayer: DebugLayer;
  48570. }
  48571. }
  48572. /**
  48573. * Enum of inspector action tab
  48574. */
  48575. export enum DebugLayerTab {
  48576. /**
  48577. * Properties tag (default)
  48578. */
  48579. Properties = 0,
  48580. /**
  48581. * Debug tab
  48582. */
  48583. Debug = 1,
  48584. /**
  48585. * Statistics tab
  48586. */
  48587. Statistics = 2,
  48588. /**
  48589. * Tools tab
  48590. */
  48591. Tools = 3,
  48592. /**
  48593. * Settings tab
  48594. */
  48595. Settings = 4
  48596. }
  48597. /**
  48598. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48599. * what is happening in your scene
  48600. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48601. */
  48602. export class DebugLayer {
  48603. /**
  48604. * Define the url to get the inspector script from.
  48605. * By default it uses the babylonjs CDN.
  48606. * @ignoreNaming
  48607. */
  48608. static InspectorURL: string;
  48609. private _scene;
  48610. private BJSINSPECTOR;
  48611. private _onPropertyChangedObservable?;
  48612. /**
  48613. * Observable triggered when a property is changed through the inspector.
  48614. */
  48615. get onPropertyChangedObservable(): any;
  48616. /**
  48617. * Instantiates a new debug layer.
  48618. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48619. * what is happening in your scene
  48620. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48621. * @param scene Defines the scene to inspect
  48622. */
  48623. constructor(scene: Scene);
  48624. /** Creates the inspector window. */
  48625. private _createInspector;
  48626. /**
  48627. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48628. * @param entity defines the entity to select
  48629. * @param lineContainerTitle defines the specific block to highlight
  48630. */
  48631. select(entity: any, lineContainerTitle?: string): void;
  48632. /** Get the inspector from bundle or global */
  48633. private _getGlobalInspector;
  48634. /**
  48635. * Get if the inspector is visible or not.
  48636. * @returns true if visible otherwise, false
  48637. */
  48638. isVisible(): boolean;
  48639. /**
  48640. * Hide the inspector and close its window.
  48641. */
  48642. hide(): void;
  48643. /**
  48644. * Update the scene in the inspector
  48645. */
  48646. setAsActiveScene(): void;
  48647. /**
  48648. * Launch the debugLayer.
  48649. * @param config Define the configuration of the inspector
  48650. * @return a promise fulfilled when the debug layer is visible
  48651. */
  48652. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48653. }
  48654. }
  48655. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48656. import { Nullable } from "babylonjs/types";
  48657. import { Scene } from "babylonjs/scene";
  48658. import { Vector4 } from "babylonjs/Maths/math.vector";
  48659. import { Color4 } from "babylonjs/Maths/math.color";
  48660. import { Mesh } from "babylonjs/Meshes/mesh";
  48661. /**
  48662. * Class containing static functions to help procedurally build meshes
  48663. */
  48664. export class BoxBuilder {
  48665. /**
  48666. * Creates a box mesh
  48667. * * The parameter `size` sets the size (float) of each box side (default 1)
  48668. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48669. * * 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)
  48670. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48672. * * 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
  48673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48674. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48675. * @param name defines the name of the mesh
  48676. * @param options defines the options used to create the mesh
  48677. * @param scene defines the hosting scene
  48678. * @returns the box mesh
  48679. */
  48680. static CreateBox(name: string, options: {
  48681. size?: number;
  48682. width?: number;
  48683. height?: number;
  48684. depth?: number;
  48685. faceUV?: Vector4[];
  48686. faceColors?: Color4[];
  48687. sideOrientation?: number;
  48688. frontUVs?: Vector4;
  48689. backUVs?: Vector4;
  48690. wrap?: boolean;
  48691. topBaseAt?: number;
  48692. bottomBaseAt?: number;
  48693. updatable?: boolean;
  48694. }, scene?: Nullable<Scene>): Mesh;
  48695. }
  48696. }
  48697. declare module "babylonjs/Debug/physicsViewer" {
  48698. import { Nullable } from "babylonjs/types";
  48699. import { Scene } from "babylonjs/scene";
  48700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48701. import { Mesh } from "babylonjs/Meshes/mesh";
  48702. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48703. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48704. /**
  48705. * Used to show the physics impostor around the specific mesh
  48706. */
  48707. export class PhysicsViewer {
  48708. /** @hidden */
  48709. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48710. /** @hidden */
  48711. protected _meshes: Array<Nullable<AbstractMesh>>;
  48712. /** @hidden */
  48713. protected _scene: Nullable<Scene>;
  48714. /** @hidden */
  48715. protected _numMeshes: number;
  48716. /** @hidden */
  48717. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48718. private _renderFunction;
  48719. private _utilityLayer;
  48720. private _debugBoxMesh;
  48721. private _debugSphereMesh;
  48722. private _debugCylinderMesh;
  48723. private _debugMaterial;
  48724. private _debugMeshMeshes;
  48725. /**
  48726. * Creates a new PhysicsViewer
  48727. * @param scene defines the hosting scene
  48728. */
  48729. constructor(scene: Scene);
  48730. /** @hidden */
  48731. protected _updateDebugMeshes(): void;
  48732. /**
  48733. * Renders a specified physic impostor
  48734. * @param impostor defines the impostor to render
  48735. * @param targetMesh defines the mesh represented by the impostor
  48736. * @returns the new debug mesh used to render the impostor
  48737. */
  48738. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48739. /**
  48740. * Hides a specified physic impostor
  48741. * @param impostor defines the impostor to hide
  48742. */
  48743. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48744. private _getDebugMaterial;
  48745. private _getDebugBoxMesh;
  48746. private _getDebugSphereMesh;
  48747. private _getDebugCylinderMesh;
  48748. private _getDebugMeshMesh;
  48749. private _getDebugMesh;
  48750. /** Releases all resources */
  48751. dispose(): void;
  48752. }
  48753. }
  48754. declare module "babylonjs/Debug/rayHelper" {
  48755. import { Nullable } from "babylonjs/types";
  48756. import { Ray } from "babylonjs/Culling/ray";
  48757. import { Vector3 } from "babylonjs/Maths/math.vector";
  48758. import { Color3 } from "babylonjs/Maths/math.color";
  48759. import { Scene } from "babylonjs/scene";
  48760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48761. import "babylonjs/Meshes/Builders/linesBuilder";
  48762. /**
  48763. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48764. * in order to better appreciate the issue one might have.
  48765. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48766. */
  48767. export class RayHelper {
  48768. /**
  48769. * Defines the ray we are currently tryin to visualize.
  48770. */
  48771. ray: Nullable<Ray>;
  48772. private _renderPoints;
  48773. private _renderLine;
  48774. private _renderFunction;
  48775. private _scene;
  48776. private _updateToMeshFunction;
  48777. private _attachedToMesh;
  48778. private _meshSpaceDirection;
  48779. private _meshSpaceOrigin;
  48780. /**
  48781. * Helper function to create a colored helper in a scene in one line.
  48782. * @param ray Defines the ray we are currently tryin to visualize
  48783. * @param scene Defines the scene the ray is used in
  48784. * @param color Defines the color we want to see the ray in
  48785. * @returns The newly created ray helper.
  48786. */
  48787. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48788. /**
  48789. * Instantiate a new ray helper.
  48790. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48791. * in order to better appreciate the issue one might have.
  48792. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48793. * @param ray Defines the ray we are currently tryin to visualize
  48794. */
  48795. constructor(ray: Ray);
  48796. /**
  48797. * Shows the ray we are willing to debug.
  48798. * @param scene Defines the scene the ray needs to be rendered in
  48799. * @param color Defines the color the ray needs to be rendered in
  48800. */
  48801. show(scene: Scene, color?: Color3): void;
  48802. /**
  48803. * Hides the ray we are debugging.
  48804. */
  48805. hide(): void;
  48806. private _render;
  48807. /**
  48808. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48809. * @param mesh Defines the mesh we want the helper attached to
  48810. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48811. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48812. * @param length Defines the length of the ray
  48813. */
  48814. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48815. /**
  48816. * Detach the ray helper from the mesh it has previously been attached to.
  48817. */
  48818. detachFromMesh(): void;
  48819. private _updateToMesh;
  48820. /**
  48821. * Dispose the helper and release its associated resources.
  48822. */
  48823. dispose(): void;
  48824. }
  48825. }
  48826. declare module "babylonjs/Debug/skeletonViewer" {
  48827. import { Color3 } from "babylonjs/Maths/math.color";
  48828. import { Scene } from "babylonjs/scene";
  48829. import { Nullable } from "babylonjs/types";
  48830. import { Skeleton } from "babylonjs/Bones/skeleton";
  48831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48832. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48833. /**
  48834. * Class used to render a debug view of a given skeleton
  48835. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48836. */
  48837. export class SkeletonViewer {
  48838. /** defines the skeleton to render */
  48839. skeleton: Skeleton;
  48840. /** defines the mesh attached to the skeleton */
  48841. mesh: AbstractMesh;
  48842. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48843. autoUpdateBonesMatrices: boolean;
  48844. /** defines the rendering group id to use with the viewer */
  48845. renderingGroupId: number;
  48846. /** Gets or sets the color used to render the skeleton */
  48847. color: Color3;
  48848. private _scene;
  48849. private _debugLines;
  48850. private _debugMesh;
  48851. private _isEnabled;
  48852. private _renderFunction;
  48853. private _utilityLayer;
  48854. /**
  48855. * Returns the mesh used to render the bones
  48856. */
  48857. get debugMesh(): Nullable<LinesMesh>;
  48858. /**
  48859. * Creates a new SkeletonViewer
  48860. * @param skeleton defines the skeleton to render
  48861. * @param mesh defines the mesh attached to the skeleton
  48862. * @param scene defines the hosting scene
  48863. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48864. * @param renderingGroupId defines the rendering group id to use with the viewer
  48865. */
  48866. constructor(
  48867. /** defines the skeleton to render */
  48868. skeleton: Skeleton,
  48869. /** defines the mesh attached to the skeleton */
  48870. mesh: AbstractMesh, scene: Scene,
  48871. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48872. autoUpdateBonesMatrices?: boolean,
  48873. /** defines the rendering group id to use with the viewer */
  48874. renderingGroupId?: number);
  48875. /** Gets or sets a boolean indicating if the viewer is enabled */
  48876. set isEnabled(value: boolean);
  48877. get isEnabled(): boolean;
  48878. private _getBonePosition;
  48879. private _getLinesForBonesWithLength;
  48880. private _getLinesForBonesNoLength;
  48881. /** Update the viewer to sync with current skeleton state */
  48882. update(): void;
  48883. /** Release associated resources */
  48884. dispose(): void;
  48885. }
  48886. }
  48887. declare module "babylonjs/Debug/index" {
  48888. export * from "babylonjs/Debug/axesViewer";
  48889. export * from "babylonjs/Debug/boneAxesViewer";
  48890. export * from "babylonjs/Debug/debugLayer";
  48891. export * from "babylonjs/Debug/physicsViewer";
  48892. export * from "babylonjs/Debug/rayHelper";
  48893. export * from "babylonjs/Debug/skeletonViewer";
  48894. }
  48895. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  48896. import { Observable } from "babylonjs/Misc/observable";
  48897. import { Engine } from "babylonjs/Engines/engine";
  48898. import { IDisposable } from "babylonjs/scene";
  48899. import { Nullable } from "babylonjs/types";
  48900. /**
  48901. * This class will take all inputs from Keyboard, Pointer, and
  48902. * any Gamepads and provide a polling system that all devices
  48903. * will use. This class assumes that there will only be one
  48904. * pointer device and one keyboard.
  48905. */
  48906. export class DeviceInputSystem implements IDisposable {
  48907. /** POINTER_DEVICE */
  48908. static readonly POINTER_DEVICE: string;
  48909. /** KEYBOARD_DEVICE */
  48910. static readonly KEYBOARD_DEVICE: string;
  48911. /**
  48912. * Observable to be triggered when a device is connected
  48913. */
  48914. onDeviceConnectedObservable: Observable<string>;
  48915. /**
  48916. * Observable to be triggered when a device is disconnected
  48917. */
  48918. onDeviceDisconnectedObservable: Observable<string>;
  48919. private _inputs;
  48920. private _gamepads;
  48921. private _keyboardActive;
  48922. private _pointerActive;
  48923. private _elementToAttachTo;
  48924. private _keyboardDownEvent;
  48925. private _keyboardUpEvent;
  48926. private _pointerMoveEvent;
  48927. private _pointerDownEvent;
  48928. private _pointerUpEvent;
  48929. private _gamepadConnectedEvent;
  48930. private _gamepadDisconnectedEvent;
  48931. private static _MAX_KEYCODES;
  48932. private static _MAX_POINTER_INPUTS;
  48933. /**
  48934. * Default Constructor
  48935. * @param engine - engine to pull input element from
  48936. */
  48937. constructor(engine: Engine);
  48938. /**
  48939. * Checks for current device input value, given an id and input index
  48940. * @param deviceName Id of connected device
  48941. * @param inputIndex Index of device input
  48942. * @returns Current value of input
  48943. */
  48944. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  48945. /**
  48946. * Dispose of all the eventlisteners and clears the observables
  48947. */
  48948. dispose(): void;
  48949. /**
  48950. * Add device and inputs to device map
  48951. * @param deviceName Assigned name of device (may be SN)
  48952. * @param numberOfInputs Number of input entries to create for given device
  48953. */
  48954. private _registerDevice;
  48955. /**
  48956. * Given a specific device name, remove that device from the device map
  48957. * @param deviceName Name of device to be removed
  48958. */
  48959. private _unregisterDevice;
  48960. /**
  48961. * Handle all actions that come from keyboard interaction
  48962. */
  48963. private _handleKeyActions;
  48964. /**
  48965. * Handle all actions that come from pointer interaction
  48966. */
  48967. private _handlePointerActions;
  48968. /**
  48969. * Handle all actions that come from gamepad interaction
  48970. */
  48971. private _handleGamepadActions;
  48972. /**
  48973. * Update all non-event based devices with each frame
  48974. */
  48975. private _updateDevice;
  48976. }
  48977. }
  48978. declare module "babylonjs/DeviceInput/index" {
  48979. export * from "babylonjs/DeviceInput/deviceInputSystem";
  48980. }
  48981. declare module "babylonjs/Engines/nullEngine" {
  48982. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48983. import { Engine } from "babylonjs/Engines/engine";
  48984. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48985. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48986. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48987. import { Effect } from "babylonjs/Materials/effect";
  48988. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48989. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48990. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48991. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48992. /**
  48993. * Options to create the null engine
  48994. */
  48995. export class NullEngineOptions {
  48996. /**
  48997. * Render width (Default: 512)
  48998. */
  48999. renderWidth: number;
  49000. /**
  49001. * Render height (Default: 256)
  49002. */
  49003. renderHeight: number;
  49004. /**
  49005. * Texture size (Default: 512)
  49006. */
  49007. textureSize: number;
  49008. /**
  49009. * If delta time between frames should be constant
  49010. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49011. */
  49012. deterministicLockstep: boolean;
  49013. /**
  49014. * Maximum about of steps between frames (Default: 4)
  49015. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49016. */
  49017. lockstepMaxSteps: number;
  49018. }
  49019. /**
  49020. * The null engine class provides support for headless version of babylon.js.
  49021. * This can be used in server side scenario or for testing purposes
  49022. */
  49023. export class NullEngine extends Engine {
  49024. private _options;
  49025. /**
  49026. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49027. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49028. * @returns true if engine is in deterministic lock step mode
  49029. */
  49030. isDeterministicLockStep(): boolean;
  49031. /**
  49032. * Gets the max steps when engine is running in deterministic lock step
  49033. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49034. * @returns the max steps
  49035. */
  49036. getLockstepMaxSteps(): number;
  49037. /**
  49038. * Gets the current hardware scaling level.
  49039. * By default the hardware scaling level is computed from the window device ratio.
  49040. * 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.
  49041. * @returns a number indicating the current hardware scaling level
  49042. */
  49043. getHardwareScalingLevel(): number;
  49044. constructor(options?: NullEngineOptions);
  49045. /**
  49046. * Creates a vertex buffer
  49047. * @param vertices the data for the vertex buffer
  49048. * @returns the new WebGL static buffer
  49049. */
  49050. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49051. /**
  49052. * Creates a new index buffer
  49053. * @param indices defines the content of the index buffer
  49054. * @param updatable defines if the index buffer must be updatable
  49055. * @returns a new webGL buffer
  49056. */
  49057. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49058. /**
  49059. * Clear the current render buffer or the current render target (if any is set up)
  49060. * @param color defines the color to use
  49061. * @param backBuffer defines if the back buffer must be cleared
  49062. * @param depth defines if the depth buffer must be cleared
  49063. * @param stencil defines if the stencil buffer must be cleared
  49064. */
  49065. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49066. /**
  49067. * Gets the current render width
  49068. * @param useScreen defines if screen size must be used (or the current render target if any)
  49069. * @returns a number defining the current render width
  49070. */
  49071. getRenderWidth(useScreen?: boolean): number;
  49072. /**
  49073. * Gets the current render height
  49074. * @param useScreen defines if screen size must be used (or the current render target if any)
  49075. * @returns a number defining the current render height
  49076. */
  49077. getRenderHeight(useScreen?: boolean): number;
  49078. /**
  49079. * Set the WebGL's viewport
  49080. * @param viewport defines the viewport element to be used
  49081. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  49082. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  49083. */
  49084. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  49085. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  49086. /**
  49087. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  49088. * @param pipelineContext defines the pipeline context to use
  49089. * @param uniformsNames defines the list of uniform names
  49090. * @returns an array of webGL uniform locations
  49091. */
  49092. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49093. /**
  49094. * Gets the lsit of active attributes for a given webGL program
  49095. * @param pipelineContext defines the pipeline context to use
  49096. * @param attributesNames defines the list of attribute names to get
  49097. * @returns an array of indices indicating the offset of each attribute
  49098. */
  49099. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49100. /**
  49101. * Binds an effect to the webGL context
  49102. * @param effect defines the effect to bind
  49103. */
  49104. bindSamplers(effect: Effect): void;
  49105. /**
  49106. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49107. * @param effect defines the effect to activate
  49108. */
  49109. enableEffect(effect: Effect): void;
  49110. /**
  49111. * Set various states to the webGL context
  49112. * @param culling defines backface culling state
  49113. * @param zOffset defines the value to apply to zOffset (0 by default)
  49114. * @param force defines if states must be applied even if cache is up to date
  49115. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  49116. */
  49117. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49118. /**
  49119. * Set the value of an uniform to an array of int32
  49120. * @param uniform defines the webGL uniform location where to store the value
  49121. * @param array defines the array of int32 to store
  49122. */
  49123. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49124. /**
  49125. * Set the value of an uniform to an array of int32 (stored as vec2)
  49126. * @param uniform defines the webGL uniform location where to store the value
  49127. * @param array defines the array of int32 to store
  49128. */
  49129. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49130. /**
  49131. * Set the value of an uniform to an array of int32 (stored as vec3)
  49132. * @param uniform defines the webGL uniform location where to store the value
  49133. * @param array defines the array of int32 to store
  49134. */
  49135. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49136. /**
  49137. * Set the value of an uniform to an array of int32 (stored as vec4)
  49138. * @param uniform defines the webGL uniform location where to store the value
  49139. * @param array defines the array of int32 to store
  49140. */
  49141. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49142. /**
  49143. * Set the value of an uniform to an array of float32
  49144. * @param uniform defines the webGL uniform location where to store the value
  49145. * @param array defines the array of float32 to store
  49146. */
  49147. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49148. /**
  49149. * Set the value of an uniform to an array of float32 (stored as vec2)
  49150. * @param uniform defines the webGL uniform location where to store the value
  49151. * @param array defines the array of float32 to store
  49152. */
  49153. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49154. /**
  49155. * Set the value of an uniform to an array of float32 (stored as vec3)
  49156. * @param uniform defines the webGL uniform location where to store the value
  49157. * @param array defines the array of float32 to store
  49158. */
  49159. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49160. /**
  49161. * Set the value of an uniform to an array of float32 (stored as vec4)
  49162. * @param uniform defines the webGL uniform location where to store the value
  49163. * @param array defines the array of float32 to store
  49164. */
  49165. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49166. /**
  49167. * Set the value of an uniform to an array of number
  49168. * @param uniform defines the webGL uniform location where to store the value
  49169. * @param array defines the array of number to store
  49170. */
  49171. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49172. /**
  49173. * Set the value of an uniform to an array of number (stored as vec2)
  49174. * @param uniform defines the webGL uniform location where to store the value
  49175. * @param array defines the array of number to store
  49176. */
  49177. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49178. /**
  49179. * Set the value of an uniform to an array of number (stored as vec3)
  49180. * @param uniform defines the webGL uniform location where to store the value
  49181. * @param array defines the array of number to store
  49182. */
  49183. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49184. /**
  49185. * Set the value of an uniform to an array of number (stored as vec4)
  49186. * @param uniform defines the webGL uniform location where to store the value
  49187. * @param array defines the array of number to store
  49188. */
  49189. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49190. /**
  49191. * Set the value of an uniform to an array of float32 (stored as matrices)
  49192. * @param uniform defines the webGL uniform location where to store the value
  49193. * @param matrices defines the array of float32 to store
  49194. */
  49195. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49196. /**
  49197. * Set the value of an uniform to a matrix (3x3)
  49198. * @param uniform defines the webGL uniform location where to store the value
  49199. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49200. */
  49201. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49202. /**
  49203. * Set the value of an uniform to a matrix (2x2)
  49204. * @param uniform defines the webGL uniform location where to store the value
  49205. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49206. */
  49207. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49208. /**
  49209. * Set the value of an uniform to a number (float)
  49210. * @param uniform defines the webGL uniform location where to store the value
  49211. * @param value defines the float number to store
  49212. */
  49213. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49214. /**
  49215. * Set the value of an uniform to a vec2
  49216. * @param uniform defines the webGL uniform location where to store the value
  49217. * @param x defines the 1st component of the value
  49218. * @param y defines the 2nd component of the value
  49219. */
  49220. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49221. /**
  49222. * Set the value of an uniform to a vec3
  49223. * @param uniform defines the webGL uniform location where to store the value
  49224. * @param x defines the 1st component of the value
  49225. * @param y defines the 2nd component of the value
  49226. * @param z defines the 3rd component of the value
  49227. */
  49228. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49229. /**
  49230. * Set the value of an uniform to a boolean
  49231. * @param uniform defines the webGL uniform location where to store the value
  49232. * @param bool defines the boolean to store
  49233. */
  49234. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49235. /**
  49236. * Set the value of an uniform to a vec4
  49237. * @param uniform defines the webGL uniform location where to store the value
  49238. * @param x defines the 1st component of the value
  49239. * @param y defines the 2nd component of the value
  49240. * @param z defines the 3rd component of the value
  49241. * @param w defines the 4th component of the value
  49242. */
  49243. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49244. /**
  49245. * Sets the current alpha mode
  49246. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49247. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49248. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49249. */
  49250. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49251. /**
  49252. * Bind webGl buffers directly to the webGL context
  49253. * @param vertexBuffers defines the vertex buffer to bind
  49254. * @param indexBuffer defines the index buffer to bind
  49255. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49256. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49257. * @param effect defines the effect associated with the vertex buffer
  49258. */
  49259. bindBuffers(vertexBuffers: {
  49260. [key: string]: VertexBuffer;
  49261. }, indexBuffer: DataBuffer, effect: Effect): void;
  49262. /**
  49263. * Force the entire cache to be cleared
  49264. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49265. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49266. */
  49267. wipeCaches(bruteForce?: boolean): void;
  49268. /**
  49269. * Send a draw order
  49270. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49271. * @param indexStart defines the starting index
  49272. * @param indexCount defines the number of index to draw
  49273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49274. */
  49275. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49276. /**
  49277. * Draw a list of indexed primitives
  49278. * @param fillMode defines the primitive to use
  49279. * @param indexStart defines the starting index
  49280. * @param indexCount defines the number of index to draw
  49281. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49282. */
  49283. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49284. /**
  49285. * Draw a list of unindexed primitives
  49286. * @param fillMode defines the primitive to use
  49287. * @param verticesStart defines the index of first vertex to draw
  49288. * @param verticesCount defines the count of vertices to draw
  49289. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49290. */
  49291. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49292. /** @hidden */
  49293. _createTexture(): WebGLTexture;
  49294. /** @hidden */
  49295. _releaseTexture(texture: InternalTexture): void;
  49296. /**
  49297. * Usually called from Texture.ts.
  49298. * Passed information to create a WebGLTexture
  49299. * @param urlArg defines a value which contains one of the following:
  49300. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49301. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49302. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49303. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49304. * @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)
  49305. * @param scene needed for loading to the correct scene
  49306. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49307. * @param onLoad optional callback to be called upon successful completion
  49308. * @param onError optional callback to be called upon failure
  49309. * @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
  49310. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49311. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49312. * @param forcedExtension defines the extension to use to pick the right loader
  49313. * @param mimeType defines an optional mime type
  49314. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49315. */
  49316. 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;
  49317. /**
  49318. * Creates a new render target texture
  49319. * @param size defines the size of the texture
  49320. * @param options defines the options used to create the texture
  49321. * @returns a new render target texture stored in an InternalTexture
  49322. */
  49323. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49324. /**
  49325. * Update the sampling mode of a given texture
  49326. * @param samplingMode defines the required sampling mode
  49327. * @param texture defines the texture to update
  49328. */
  49329. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49330. /**
  49331. * Binds the frame buffer to the specified texture.
  49332. * @param texture The texture to render to or null for the default canvas
  49333. * @param faceIndex The face of the texture to render to in case of cube texture
  49334. * @param requiredWidth The width of the target to render to
  49335. * @param requiredHeight The height of the target to render to
  49336. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49337. * @param lodLevel defines le lod level to bind to the frame buffer
  49338. */
  49339. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49340. /**
  49341. * Unbind the current render target texture from the webGL context
  49342. * @param texture defines the render target texture to unbind
  49343. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49344. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49345. */
  49346. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49347. /**
  49348. * Creates a dynamic vertex buffer
  49349. * @param vertices the data for the dynamic vertex buffer
  49350. * @returns the new WebGL dynamic buffer
  49351. */
  49352. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49353. /**
  49354. * Update the content of a dynamic texture
  49355. * @param texture defines the texture to update
  49356. * @param canvas defines the canvas containing the source
  49357. * @param invertY defines if data must be stored with Y axis inverted
  49358. * @param premulAlpha defines if alpha is stored as premultiplied
  49359. * @param format defines the format of the data
  49360. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49361. */
  49362. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49363. /**
  49364. * Gets a boolean indicating if all created effects are ready
  49365. * @returns true if all effects are ready
  49366. */
  49367. areAllEffectsReady(): boolean;
  49368. /**
  49369. * @hidden
  49370. * Get the current error code of the webGL context
  49371. * @returns the error code
  49372. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49373. */
  49374. getError(): number;
  49375. /** @hidden */
  49376. _getUnpackAlignement(): number;
  49377. /** @hidden */
  49378. _unpackFlipY(value: boolean): void;
  49379. /**
  49380. * Update a dynamic index buffer
  49381. * @param indexBuffer defines the target index buffer
  49382. * @param indices defines the data to update
  49383. * @param offset defines the offset in the target index buffer where update should start
  49384. */
  49385. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49386. /**
  49387. * Updates a dynamic vertex buffer.
  49388. * @param vertexBuffer the vertex buffer to update
  49389. * @param vertices the data used to update the vertex buffer
  49390. * @param byteOffset the byte offset of the data (optional)
  49391. * @param byteLength the byte length of the data (optional)
  49392. */
  49393. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49394. /** @hidden */
  49395. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49396. /** @hidden */
  49397. _bindTexture(channel: number, texture: InternalTexture): void;
  49398. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49399. /**
  49400. * 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
  49401. */
  49402. releaseEffects(): void;
  49403. displayLoadingUI(): void;
  49404. hideLoadingUI(): void;
  49405. /** @hidden */
  49406. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49407. /** @hidden */
  49408. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49409. /** @hidden */
  49410. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49411. /** @hidden */
  49412. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49413. }
  49414. }
  49415. declare module "babylonjs/Instrumentation/timeToken" {
  49416. import { Nullable } from "babylonjs/types";
  49417. /**
  49418. * @hidden
  49419. **/
  49420. export class _TimeToken {
  49421. _startTimeQuery: Nullable<WebGLQuery>;
  49422. _endTimeQuery: Nullable<WebGLQuery>;
  49423. _timeElapsedQuery: Nullable<WebGLQuery>;
  49424. _timeElapsedQueryEnded: boolean;
  49425. }
  49426. }
  49427. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49428. import { Nullable, int } from "babylonjs/types";
  49429. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49430. /** @hidden */
  49431. export class _OcclusionDataStorage {
  49432. /** @hidden */
  49433. occlusionInternalRetryCounter: number;
  49434. /** @hidden */
  49435. isOcclusionQueryInProgress: boolean;
  49436. /** @hidden */
  49437. isOccluded: boolean;
  49438. /** @hidden */
  49439. occlusionRetryCount: number;
  49440. /** @hidden */
  49441. occlusionType: number;
  49442. /** @hidden */
  49443. occlusionQueryAlgorithmType: number;
  49444. }
  49445. module "babylonjs/Engines/engine" {
  49446. interface Engine {
  49447. /**
  49448. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49449. * @return the new query
  49450. */
  49451. createQuery(): WebGLQuery;
  49452. /**
  49453. * Delete and release a webGL query
  49454. * @param query defines the query to delete
  49455. * @return the current engine
  49456. */
  49457. deleteQuery(query: WebGLQuery): Engine;
  49458. /**
  49459. * Check if a given query has resolved and got its value
  49460. * @param query defines the query to check
  49461. * @returns true if the query got its value
  49462. */
  49463. isQueryResultAvailable(query: WebGLQuery): boolean;
  49464. /**
  49465. * Gets the value of a given query
  49466. * @param query defines the query to check
  49467. * @returns the value of the query
  49468. */
  49469. getQueryResult(query: WebGLQuery): number;
  49470. /**
  49471. * Initiates an occlusion query
  49472. * @param algorithmType defines the algorithm to use
  49473. * @param query defines the query to use
  49474. * @returns the current engine
  49475. * @see http://doc.babylonjs.com/features/occlusionquery
  49476. */
  49477. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49478. /**
  49479. * Ends an occlusion query
  49480. * @see http://doc.babylonjs.com/features/occlusionquery
  49481. * @param algorithmType defines the algorithm to use
  49482. * @returns the current engine
  49483. */
  49484. endOcclusionQuery(algorithmType: number): Engine;
  49485. /**
  49486. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49487. * Please note that only one query can be issued at a time
  49488. * @returns a time token used to track the time span
  49489. */
  49490. startTimeQuery(): Nullable<_TimeToken>;
  49491. /**
  49492. * Ends a time query
  49493. * @param token defines the token used to measure the time span
  49494. * @returns the time spent (in ns)
  49495. */
  49496. endTimeQuery(token: _TimeToken): int;
  49497. /** @hidden */
  49498. _currentNonTimestampToken: Nullable<_TimeToken>;
  49499. /** @hidden */
  49500. _createTimeQuery(): WebGLQuery;
  49501. /** @hidden */
  49502. _deleteTimeQuery(query: WebGLQuery): void;
  49503. /** @hidden */
  49504. _getGlAlgorithmType(algorithmType: number): number;
  49505. /** @hidden */
  49506. _getTimeQueryResult(query: WebGLQuery): any;
  49507. /** @hidden */
  49508. _getTimeQueryAvailability(query: WebGLQuery): any;
  49509. }
  49510. }
  49511. module "babylonjs/Meshes/abstractMesh" {
  49512. interface AbstractMesh {
  49513. /**
  49514. * Backing filed
  49515. * @hidden
  49516. */
  49517. __occlusionDataStorage: _OcclusionDataStorage;
  49518. /**
  49519. * Access property
  49520. * @hidden
  49521. */
  49522. _occlusionDataStorage: _OcclusionDataStorage;
  49523. /**
  49524. * 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.
  49525. * The default value is -1 which means don't break the query and wait till the result
  49526. * @see http://doc.babylonjs.com/features/occlusionquery
  49527. */
  49528. occlusionRetryCount: number;
  49529. /**
  49530. * 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:
  49531. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49532. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49533. * * 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.
  49534. * @see http://doc.babylonjs.com/features/occlusionquery
  49535. */
  49536. occlusionType: number;
  49537. /**
  49538. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49539. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49540. * * 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.
  49541. * @see http://doc.babylonjs.com/features/occlusionquery
  49542. */
  49543. occlusionQueryAlgorithmType: number;
  49544. /**
  49545. * 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
  49546. * @see http://doc.babylonjs.com/features/occlusionquery
  49547. */
  49548. isOccluded: boolean;
  49549. /**
  49550. * Flag to check the progress status of the query
  49551. * @see http://doc.babylonjs.com/features/occlusionquery
  49552. */
  49553. isOcclusionQueryInProgress: boolean;
  49554. }
  49555. }
  49556. }
  49557. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49558. import { Nullable } from "babylonjs/types";
  49559. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49560. /** @hidden */
  49561. export var _forceTransformFeedbackToBundle: boolean;
  49562. module "babylonjs/Engines/engine" {
  49563. interface Engine {
  49564. /**
  49565. * Creates a webGL transform feedback object
  49566. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49567. * @returns the webGL transform feedback object
  49568. */
  49569. createTransformFeedback(): WebGLTransformFeedback;
  49570. /**
  49571. * Delete a webGL transform feedback object
  49572. * @param value defines the webGL transform feedback object to delete
  49573. */
  49574. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49575. /**
  49576. * Bind a webGL transform feedback object to the webgl context
  49577. * @param value defines the webGL transform feedback object to bind
  49578. */
  49579. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49580. /**
  49581. * Begins a transform feedback operation
  49582. * @param usePoints defines if points or triangles must be used
  49583. */
  49584. beginTransformFeedback(usePoints: boolean): void;
  49585. /**
  49586. * Ends a transform feedback operation
  49587. */
  49588. endTransformFeedback(): void;
  49589. /**
  49590. * Specify the varyings to use with transform feedback
  49591. * @param program defines the associated webGL program
  49592. * @param value defines the list of strings representing the varying names
  49593. */
  49594. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49595. /**
  49596. * Bind a webGL buffer for a transform feedback operation
  49597. * @param value defines the webGL buffer to bind
  49598. */
  49599. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49600. }
  49601. }
  49602. }
  49603. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49604. import { Scene } from "babylonjs/scene";
  49605. import { Engine } from "babylonjs/Engines/engine";
  49606. import { Texture } from "babylonjs/Materials/Textures/texture";
  49607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49608. import "babylonjs/Engines/Extensions/engine.multiRender";
  49609. /**
  49610. * Creation options of the multi render target texture.
  49611. */
  49612. export interface IMultiRenderTargetOptions {
  49613. /**
  49614. * Define if the texture needs to create mip maps after render.
  49615. */
  49616. generateMipMaps?: boolean;
  49617. /**
  49618. * Define the types of all the draw buffers we want to create
  49619. */
  49620. types?: number[];
  49621. /**
  49622. * Define the sampling modes of all the draw buffers we want to create
  49623. */
  49624. samplingModes?: number[];
  49625. /**
  49626. * Define if a depth buffer is required
  49627. */
  49628. generateDepthBuffer?: boolean;
  49629. /**
  49630. * Define if a stencil buffer is required
  49631. */
  49632. generateStencilBuffer?: boolean;
  49633. /**
  49634. * Define if a depth texture is required instead of a depth buffer
  49635. */
  49636. generateDepthTexture?: boolean;
  49637. /**
  49638. * Define the number of desired draw buffers
  49639. */
  49640. textureCount?: number;
  49641. /**
  49642. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49643. */
  49644. doNotChangeAspectRatio?: boolean;
  49645. /**
  49646. * Define the default type of the buffers we are creating
  49647. */
  49648. defaultType?: number;
  49649. }
  49650. /**
  49651. * A multi render target, like a render target provides the ability to render to a texture.
  49652. * Unlike the render target, it can render to several draw buffers in one draw.
  49653. * This is specially interesting in deferred rendering or for any effects requiring more than
  49654. * just one color from a single pass.
  49655. */
  49656. export class MultiRenderTarget extends RenderTargetTexture {
  49657. private _internalTextures;
  49658. private _textures;
  49659. private _multiRenderTargetOptions;
  49660. /**
  49661. * Get if draw buffers are currently supported by the used hardware and browser.
  49662. */
  49663. get isSupported(): boolean;
  49664. /**
  49665. * Get the list of textures generated by the multi render target.
  49666. */
  49667. get textures(): Texture[];
  49668. /**
  49669. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49670. */
  49671. get depthTexture(): Texture;
  49672. /**
  49673. * Set the wrapping mode on U of all the textures we are rendering to.
  49674. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49675. */
  49676. set wrapU(wrap: number);
  49677. /**
  49678. * Set the wrapping mode on V of all the textures we are rendering to.
  49679. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49680. */
  49681. set wrapV(wrap: number);
  49682. /**
  49683. * Instantiate a new multi render target texture.
  49684. * A multi render target, like a render target provides the ability to render to a texture.
  49685. * Unlike the render target, it can render to several draw buffers in one draw.
  49686. * This is specially interesting in deferred rendering or for any effects requiring more than
  49687. * just one color from a single pass.
  49688. * @param name Define the name of the texture
  49689. * @param size Define the size of the buffers to render to
  49690. * @param count Define the number of target we are rendering into
  49691. * @param scene Define the scene the texture belongs to
  49692. * @param options Define the options used to create the multi render target
  49693. */
  49694. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49695. /** @hidden */
  49696. _rebuild(): void;
  49697. private _createInternalTextures;
  49698. private _createTextures;
  49699. /**
  49700. * Define the number of samples used if MSAA is enabled.
  49701. */
  49702. get samples(): number;
  49703. set samples(value: number);
  49704. /**
  49705. * Resize all the textures in the multi render target.
  49706. * Be carrefull as it will recreate all the data in the new texture.
  49707. * @param size Define the new size
  49708. */
  49709. resize(size: any): void;
  49710. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49711. /**
  49712. * Dispose the render targets and their associated resources
  49713. */
  49714. dispose(): void;
  49715. /**
  49716. * Release all the underlying texture used as draw buffers.
  49717. */
  49718. releaseInternalTextures(): void;
  49719. }
  49720. }
  49721. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49722. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49723. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49724. import { Nullable } from "babylonjs/types";
  49725. module "babylonjs/Engines/thinEngine" {
  49726. interface ThinEngine {
  49727. /**
  49728. * Unbind a list of render target textures from the webGL context
  49729. * This is used only when drawBuffer extension or webGL2 are active
  49730. * @param textures defines the render target textures to unbind
  49731. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49732. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49733. */
  49734. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49735. /**
  49736. * Create a multi render target texture
  49737. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49738. * @param size defines the size of the texture
  49739. * @param options defines the creation options
  49740. * @returns the cube texture as an InternalTexture
  49741. */
  49742. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49743. /**
  49744. * Update the sample count for a given multiple render target texture
  49745. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49746. * @param textures defines the textures to update
  49747. * @param samples defines the sample count to set
  49748. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49749. */
  49750. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49751. }
  49752. }
  49753. }
  49754. declare module "babylonjs/Engines/Extensions/engine.views" {
  49755. import { Camera } from "babylonjs/Cameras/camera";
  49756. import { Nullable } from "babylonjs/types";
  49757. /**
  49758. * Class used to define an additional view for the engine
  49759. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49760. */
  49761. export class EngineView {
  49762. /** Defines the canvas where to render the view */
  49763. target: HTMLCanvasElement;
  49764. /** Defines an optional camera used to render the view (will use active camera else) */
  49765. camera?: Camera;
  49766. }
  49767. module "babylonjs/Engines/engine" {
  49768. interface Engine {
  49769. /**
  49770. * Gets or sets the HTML element to use for attaching events
  49771. */
  49772. inputElement: Nullable<HTMLElement>;
  49773. /**
  49774. * Gets the current engine view
  49775. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49776. */
  49777. activeView: Nullable<EngineView>;
  49778. /** Gets or sets the list of views */
  49779. views: EngineView[];
  49780. /**
  49781. * Register a new child canvas
  49782. * @param canvas defines the canvas to register
  49783. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49784. * @returns the associated view
  49785. */
  49786. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49787. /**
  49788. * Remove a registered child canvas
  49789. * @param canvas defines the canvas to remove
  49790. * @returns the current engine
  49791. */
  49792. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49793. }
  49794. }
  49795. }
  49796. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49797. import { Nullable } from "babylonjs/types";
  49798. module "babylonjs/Engines/engine" {
  49799. interface Engine {
  49800. /** @hidden */
  49801. _excludedCompressedTextures: string[];
  49802. /** @hidden */
  49803. _textureFormatInUse: string;
  49804. /**
  49805. * Gets the list of texture formats supported
  49806. */
  49807. readonly texturesSupported: Array<string>;
  49808. /**
  49809. * Gets the texture format in use
  49810. */
  49811. readonly textureFormatInUse: Nullable<string>;
  49812. /**
  49813. * Set the compressed texture extensions or file names to skip.
  49814. *
  49815. * @param skippedFiles defines the list of those texture files you want to skip
  49816. * Example: [".dds", ".env", "myfile.png"]
  49817. */
  49818. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49819. /**
  49820. * Set the compressed texture format to use, based on the formats you have, and the formats
  49821. * supported by the hardware / browser.
  49822. *
  49823. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49824. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49825. * to API arguments needed to compressed textures. This puts the burden on the container
  49826. * generator to house the arcane code for determining these for current & future formats.
  49827. *
  49828. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49829. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49830. *
  49831. * Note: The result of this call is not taken into account when a texture is base64.
  49832. *
  49833. * @param formatsAvailable defines the list of those format families you have created
  49834. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49835. *
  49836. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49837. * @returns The extension selected.
  49838. */
  49839. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49840. }
  49841. }
  49842. }
  49843. declare module "babylonjs/Engines/Extensions/index" {
  49844. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49845. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49846. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49847. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49848. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49849. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49850. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49851. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49852. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49853. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49854. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49855. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49856. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49857. export * from "babylonjs/Engines/Extensions/engine.views";
  49858. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  49859. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49860. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49861. }
  49862. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49863. import { Nullable } from "babylonjs/types";
  49864. /**
  49865. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49866. */
  49867. export interface CubeMapInfo {
  49868. /**
  49869. * The pixel array for the front face.
  49870. * This is stored in format, left to right, up to down format.
  49871. */
  49872. front: Nullable<ArrayBufferView>;
  49873. /**
  49874. * The pixel array for the back face.
  49875. * This is stored in format, left to right, up to down format.
  49876. */
  49877. back: Nullable<ArrayBufferView>;
  49878. /**
  49879. * The pixel array for the left face.
  49880. * This is stored in format, left to right, up to down format.
  49881. */
  49882. left: Nullable<ArrayBufferView>;
  49883. /**
  49884. * The pixel array for the right face.
  49885. * This is stored in format, left to right, up to down format.
  49886. */
  49887. right: Nullable<ArrayBufferView>;
  49888. /**
  49889. * The pixel array for the up face.
  49890. * This is stored in format, left to right, up to down format.
  49891. */
  49892. up: Nullable<ArrayBufferView>;
  49893. /**
  49894. * The pixel array for the down face.
  49895. * This is stored in format, left to right, up to down format.
  49896. */
  49897. down: Nullable<ArrayBufferView>;
  49898. /**
  49899. * The size of the cubemap stored.
  49900. *
  49901. * Each faces will be size * size pixels.
  49902. */
  49903. size: number;
  49904. /**
  49905. * The format of the texture.
  49906. *
  49907. * RGBA, RGB.
  49908. */
  49909. format: number;
  49910. /**
  49911. * The type of the texture data.
  49912. *
  49913. * UNSIGNED_INT, FLOAT.
  49914. */
  49915. type: number;
  49916. /**
  49917. * Specifies whether the texture is in gamma space.
  49918. */
  49919. gammaSpace: boolean;
  49920. }
  49921. /**
  49922. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49923. */
  49924. export class PanoramaToCubeMapTools {
  49925. private static FACE_LEFT;
  49926. private static FACE_RIGHT;
  49927. private static FACE_FRONT;
  49928. private static FACE_BACK;
  49929. private static FACE_DOWN;
  49930. private static FACE_UP;
  49931. /**
  49932. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49933. *
  49934. * @param float32Array The source data.
  49935. * @param inputWidth The width of the input panorama.
  49936. * @param inputHeight The height of the input panorama.
  49937. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49938. * @return The cubemap data
  49939. */
  49940. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49941. private static CreateCubemapTexture;
  49942. private static CalcProjectionSpherical;
  49943. }
  49944. }
  49945. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49946. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49948. import { Nullable } from "babylonjs/types";
  49949. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49950. /**
  49951. * Helper class dealing with the extraction of spherical polynomial dataArray
  49952. * from a cube map.
  49953. */
  49954. export class CubeMapToSphericalPolynomialTools {
  49955. private static FileFaces;
  49956. /**
  49957. * Converts a texture to the according Spherical Polynomial data.
  49958. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49959. *
  49960. * @param texture The texture to extract the information from.
  49961. * @return The Spherical Polynomial data.
  49962. */
  49963. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49964. /**
  49965. * Converts a cubemap to the according Spherical Polynomial data.
  49966. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49967. *
  49968. * @param cubeInfo The Cube map to extract the information from.
  49969. * @return The Spherical Polynomial data.
  49970. */
  49971. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49972. }
  49973. }
  49974. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49975. import { Nullable } from "babylonjs/types";
  49976. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49977. module "babylonjs/Materials/Textures/baseTexture" {
  49978. interface BaseTexture {
  49979. /**
  49980. * Get the polynomial representation of the texture data.
  49981. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49982. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49983. */
  49984. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49985. }
  49986. }
  49987. }
  49988. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49990. /** @hidden */
  49991. export var rgbdEncodePixelShader: {
  49992. name: string;
  49993. shader: string;
  49994. };
  49995. }
  49996. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49997. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49998. /** @hidden */
  49999. export var rgbdDecodePixelShader: {
  50000. name: string;
  50001. shader: string;
  50002. };
  50003. }
  50004. declare module "babylonjs/Misc/environmentTextureTools" {
  50005. import { Nullable } from "babylonjs/types";
  50006. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50007. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50009. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  50010. import "babylonjs/Engines/Extensions/engine.readTexture";
  50011. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50012. import "babylonjs/Shaders/rgbdEncode.fragment";
  50013. import "babylonjs/Shaders/rgbdDecode.fragment";
  50014. /**
  50015. * Raw texture data and descriptor sufficient for WebGL texture upload
  50016. */
  50017. export interface EnvironmentTextureInfo {
  50018. /**
  50019. * Version of the environment map
  50020. */
  50021. version: number;
  50022. /**
  50023. * Width of image
  50024. */
  50025. width: number;
  50026. /**
  50027. * Irradiance information stored in the file.
  50028. */
  50029. irradiance: any;
  50030. /**
  50031. * Specular information stored in the file.
  50032. */
  50033. specular: any;
  50034. }
  50035. /**
  50036. * Defines One Image in the file. It requires only the position in the file
  50037. * as well as the length.
  50038. */
  50039. interface BufferImageData {
  50040. /**
  50041. * Length of the image data.
  50042. */
  50043. length: number;
  50044. /**
  50045. * Position of the data from the null terminator delimiting the end of the JSON.
  50046. */
  50047. position: number;
  50048. }
  50049. /**
  50050. * Defines the specular data enclosed in the file.
  50051. * This corresponds to the version 1 of the data.
  50052. */
  50053. export interface EnvironmentTextureSpecularInfoV1 {
  50054. /**
  50055. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50056. */
  50057. specularDataPosition?: number;
  50058. /**
  50059. * This contains all the images data needed to reconstruct the cubemap.
  50060. */
  50061. mipmaps: Array<BufferImageData>;
  50062. /**
  50063. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50064. */
  50065. lodGenerationScale: number;
  50066. }
  50067. /**
  50068. * Sets of helpers addressing the serialization and deserialization of environment texture
  50069. * stored in a BabylonJS env file.
  50070. * Those files are usually stored as .env files.
  50071. */
  50072. export class EnvironmentTextureTools {
  50073. /**
  50074. * Magic number identifying the env file.
  50075. */
  50076. private static _MagicBytes;
  50077. /**
  50078. * Gets the environment info from an env file.
  50079. * @param data The array buffer containing the .env bytes.
  50080. * @returns the environment file info (the json header) if successfully parsed.
  50081. */
  50082. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50083. /**
  50084. * Creates an environment texture from a loaded cube texture.
  50085. * @param texture defines the cube texture to convert in env file
  50086. * @return a promise containing the environment data if succesfull.
  50087. */
  50088. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50089. /**
  50090. * Creates a JSON representation of the spherical data.
  50091. * @param texture defines the texture containing the polynomials
  50092. * @return the JSON representation of the spherical info
  50093. */
  50094. private static _CreateEnvTextureIrradiance;
  50095. /**
  50096. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50097. * @param data the image data
  50098. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50099. * @return the views described by info providing access to the underlying buffer
  50100. */
  50101. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50102. /**
  50103. * Uploads the texture info contained in the env file to the GPU.
  50104. * @param texture defines the internal texture to upload to
  50105. * @param data defines the data to load
  50106. * @param info defines the texture info retrieved through the GetEnvInfo method
  50107. * @returns a promise
  50108. */
  50109. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50110. private static _OnImageReadyAsync;
  50111. /**
  50112. * Uploads the levels of image data to the GPU.
  50113. * @param texture defines the internal texture to upload to
  50114. * @param imageData defines the array buffer views of image data [mipmap][face]
  50115. * @returns a promise
  50116. */
  50117. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50118. /**
  50119. * Uploads spherical polynomials information to the texture.
  50120. * @param texture defines the texture we are trying to upload the information to
  50121. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50122. */
  50123. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50124. /** @hidden */
  50125. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50126. }
  50127. }
  50128. declare module "babylonjs/Maths/math.vertexFormat" {
  50129. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50130. /**
  50131. * Contains position and normal vectors for a vertex
  50132. */
  50133. export class PositionNormalVertex {
  50134. /** the position of the vertex (defaut: 0,0,0) */
  50135. position: Vector3;
  50136. /** the normal of the vertex (defaut: 0,1,0) */
  50137. normal: Vector3;
  50138. /**
  50139. * Creates a PositionNormalVertex
  50140. * @param position the position of the vertex (defaut: 0,0,0)
  50141. * @param normal the normal of the vertex (defaut: 0,1,0)
  50142. */
  50143. constructor(
  50144. /** the position of the vertex (defaut: 0,0,0) */
  50145. position?: Vector3,
  50146. /** the normal of the vertex (defaut: 0,1,0) */
  50147. normal?: Vector3);
  50148. /**
  50149. * Clones the PositionNormalVertex
  50150. * @returns the cloned PositionNormalVertex
  50151. */
  50152. clone(): PositionNormalVertex;
  50153. }
  50154. /**
  50155. * Contains position, normal and uv vectors for a vertex
  50156. */
  50157. export class PositionNormalTextureVertex {
  50158. /** the position of the vertex (defaut: 0,0,0) */
  50159. position: Vector3;
  50160. /** the normal of the vertex (defaut: 0,1,0) */
  50161. normal: Vector3;
  50162. /** the uv of the vertex (default: 0,0) */
  50163. uv: Vector2;
  50164. /**
  50165. * Creates a PositionNormalTextureVertex
  50166. * @param position the position of the vertex (defaut: 0,0,0)
  50167. * @param normal the normal of the vertex (defaut: 0,1,0)
  50168. * @param uv the uv of the vertex (default: 0,0)
  50169. */
  50170. constructor(
  50171. /** the position of the vertex (defaut: 0,0,0) */
  50172. position?: Vector3,
  50173. /** the normal of the vertex (defaut: 0,1,0) */
  50174. normal?: Vector3,
  50175. /** the uv of the vertex (default: 0,0) */
  50176. uv?: Vector2);
  50177. /**
  50178. * Clones the PositionNormalTextureVertex
  50179. * @returns the cloned PositionNormalTextureVertex
  50180. */
  50181. clone(): PositionNormalTextureVertex;
  50182. }
  50183. }
  50184. declare module "babylonjs/Maths/math" {
  50185. export * from "babylonjs/Maths/math.axis";
  50186. export * from "babylonjs/Maths/math.color";
  50187. export * from "babylonjs/Maths/math.constants";
  50188. export * from "babylonjs/Maths/math.frustum";
  50189. export * from "babylonjs/Maths/math.path";
  50190. export * from "babylonjs/Maths/math.plane";
  50191. export * from "babylonjs/Maths/math.size";
  50192. export * from "babylonjs/Maths/math.vector";
  50193. export * from "babylonjs/Maths/math.vertexFormat";
  50194. export * from "babylonjs/Maths/math.viewport";
  50195. }
  50196. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  50197. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50198. /** @hidden */
  50199. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50200. private _genericAttributeLocation;
  50201. private _varyingLocationCount;
  50202. private _varyingLocationMap;
  50203. private _replacements;
  50204. private _textureCount;
  50205. private _uniforms;
  50206. lineProcessor(line: string): string;
  50207. attributeProcessor(attribute: string): string;
  50208. varyingProcessor(varying: string, isFragment: boolean): string;
  50209. uniformProcessor(uniform: string): string;
  50210. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50211. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50212. }
  50213. }
  50214. declare module "babylonjs/Engines/nativeEngine" {
  50215. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  50216. import { Engine } from "babylonjs/Engines/engine";
  50217. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  50218. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50220. import { Effect } from "babylonjs/Materials/effect";
  50221. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  50222. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  50223. import { IColor4Like } from "babylonjs/Maths/math.like";
  50224. import { Scene } from "babylonjs/scene";
  50225. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  50226. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  50227. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  50228. /**
  50229. * Container for accessors for natively-stored mesh data buffers.
  50230. */
  50231. class NativeDataBuffer extends DataBuffer {
  50232. /**
  50233. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50234. */
  50235. nativeIndexBuffer?: any;
  50236. /**
  50237. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50238. */
  50239. nativeVertexBuffer?: any;
  50240. }
  50241. /** @hidden */
  50242. class NativeTexture extends InternalTexture {
  50243. getInternalTexture(): InternalTexture;
  50244. getViewCount(): number;
  50245. }
  50246. /** @hidden */
  50247. export class NativeEngine extends Engine {
  50248. private readonly _native;
  50249. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50250. private readonly INVALID_HANDLE;
  50251. getHardwareScalingLevel(): number;
  50252. constructor();
  50253. dispose(): void;
  50254. /**
  50255. * Can be used to override the current requestAnimationFrame requester.
  50256. * @hidden
  50257. */
  50258. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50259. /**
  50260. * Override default engine behavior.
  50261. * @param color
  50262. * @param backBuffer
  50263. * @param depth
  50264. * @param stencil
  50265. */
  50266. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50267. /**
  50268. * Gets host document
  50269. * @returns the host document object
  50270. */
  50271. getHostDocument(): Nullable<Document>;
  50272. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50273. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50274. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50275. recordVertexArrayObject(vertexBuffers: {
  50276. [key: string]: VertexBuffer;
  50277. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50278. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50279. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50280. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50281. /**
  50282. * Draw a list of indexed primitives
  50283. * @param fillMode defines the primitive to use
  50284. * @param indexStart defines the starting index
  50285. * @param indexCount defines the number of index to draw
  50286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50287. */
  50288. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50289. /**
  50290. * Draw a list of unindexed primitives
  50291. * @param fillMode defines the primitive to use
  50292. * @param verticesStart defines the index of first vertex to draw
  50293. * @param verticesCount defines the count of vertices to draw
  50294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50295. */
  50296. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50297. createPipelineContext(): IPipelineContext;
  50298. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50299. /** @hidden */
  50300. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50301. /** @hidden */
  50302. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50303. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50304. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50305. protected _setProgram(program: WebGLProgram): void;
  50306. _releaseEffect(effect: Effect): void;
  50307. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50308. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50309. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50310. bindSamplers(effect: Effect): void;
  50311. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50312. getRenderWidth(useScreen?: boolean): number;
  50313. getRenderHeight(useScreen?: boolean): number;
  50314. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50315. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50316. /**
  50317. * Set the z offset to apply to current rendering
  50318. * @param value defines the offset to apply
  50319. */
  50320. setZOffset(value: number): void;
  50321. /**
  50322. * Gets the current value of the zOffset
  50323. * @returns the current zOffset state
  50324. */
  50325. getZOffset(): number;
  50326. /**
  50327. * Enable or disable depth buffering
  50328. * @param enable defines the state to set
  50329. */
  50330. setDepthBuffer(enable: boolean): void;
  50331. /**
  50332. * Gets a boolean indicating if depth writing is enabled
  50333. * @returns the current depth writing state
  50334. */
  50335. getDepthWrite(): boolean;
  50336. /**
  50337. * Enable or disable depth writing
  50338. * @param enable defines the state to set
  50339. */
  50340. setDepthWrite(enable: boolean): void;
  50341. /**
  50342. * Enable or disable color writing
  50343. * @param enable defines the state to set
  50344. */
  50345. setColorWrite(enable: boolean): void;
  50346. /**
  50347. * Gets a boolean indicating if color writing is enabled
  50348. * @returns the current color writing state
  50349. */
  50350. getColorWrite(): boolean;
  50351. /**
  50352. * Sets alpha constants used by some alpha blending modes
  50353. * @param r defines the red component
  50354. * @param g defines the green component
  50355. * @param b defines the blue component
  50356. * @param a defines the alpha component
  50357. */
  50358. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50359. /**
  50360. * Sets the current alpha mode
  50361. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50362. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50363. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50364. */
  50365. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50366. /**
  50367. * Gets the current alpha mode
  50368. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50369. * @returns the current alpha mode
  50370. */
  50371. getAlphaMode(): number;
  50372. setInt(uniform: WebGLUniformLocation, int: number): void;
  50373. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50374. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50375. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50376. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50377. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50378. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50379. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50380. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50381. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50382. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50383. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50384. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50385. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50386. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50387. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50388. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50389. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50390. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50391. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50392. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50393. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50394. wipeCaches(bruteForce?: boolean): void;
  50395. _createTexture(): WebGLTexture;
  50396. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50397. /**
  50398. * Usually called from Texture.ts.
  50399. * Passed information to create a WebGLTexture
  50400. * @param url defines a value which contains one of the following:
  50401. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50402. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50403. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50405. * @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)
  50406. * @param scene needed for loading to the correct scene
  50407. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50408. * @param onLoad optional callback to be called upon successful completion
  50409. * @param onError optional callback to be called upon failure
  50410. * @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
  50411. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50412. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50413. * @param forcedExtension defines the extension to use to pick the right loader
  50414. * @param mimeType defines an optional mime type
  50415. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50416. */
  50417. 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;
  50418. /**
  50419. * Creates a cube texture
  50420. * @param rootUrl defines the url where the files to load is located
  50421. * @param scene defines the current scene
  50422. * @param files defines the list of files to load (1 per face)
  50423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50424. * @param onLoad defines an optional callback raised when the texture is loaded
  50425. * @param onError defines an optional callback raised if there is an issue to load the texture
  50426. * @param format defines the format of the data
  50427. * @param forcedExtension defines the extension to use to pick the right loader
  50428. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50429. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50430. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50431. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50432. * @returns the cube texture as an InternalTexture
  50433. */
  50434. 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;
  50435. private _getSamplingFilter;
  50436. private static _GetNativeTextureFormat;
  50437. createRenderTargetTexture(size: number | {
  50438. width: number;
  50439. height: number;
  50440. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50441. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50442. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50443. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50444. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50445. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50446. /**
  50447. * Updates a dynamic vertex buffer.
  50448. * @param vertexBuffer the vertex buffer to update
  50449. * @param data the data used to update the vertex buffer
  50450. * @param byteOffset the byte offset of the data (optional)
  50451. * @param byteLength the byte length of the data (optional)
  50452. */
  50453. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50454. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50455. private _updateAnisotropicLevel;
  50456. private _getAddressMode;
  50457. /** @hidden */
  50458. _bindTexture(channel: number, texture: InternalTexture): void;
  50459. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50460. releaseEffects(): void;
  50461. /** @hidden */
  50462. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50463. /** @hidden */
  50464. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50465. /** @hidden */
  50466. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50467. /** @hidden */
  50468. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50469. }
  50470. }
  50471. declare module "babylonjs/Engines/index" {
  50472. export * from "babylonjs/Engines/constants";
  50473. export * from "babylonjs/Engines/engineCapabilities";
  50474. export * from "babylonjs/Engines/instancingAttributeInfo";
  50475. export * from "babylonjs/Engines/thinEngine";
  50476. export * from "babylonjs/Engines/engine";
  50477. export * from "babylonjs/Engines/engineStore";
  50478. export * from "babylonjs/Engines/nullEngine";
  50479. export * from "babylonjs/Engines/Extensions/index";
  50480. export * from "babylonjs/Engines/IPipelineContext";
  50481. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50482. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50483. export * from "babylonjs/Engines/nativeEngine";
  50484. }
  50485. declare module "babylonjs/Events/clipboardEvents" {
  50486. /**
  50487. * Gather the list of clipboard event types as constants.
  50488. */
  50489. export class ClipboardEventTypes {
  50490. /**
  50491. * The clipboard event is fired when a copy command is active (pressed).
  50492. */
  50493. static readonly COPY: number;
  50494. /**
  50495. * The clipboard event is fired when a cut command is active (pressed).
  50496. */
  50497. static readonly CUT: number;
  50498. /**
  50499. * The clipboard event is fired when a paste command is active (pressed).
  50500. */
  50501. static readonly PASTE: number;
  50502. }
  50503. /**
  50504. * This class is used to store clipboard related info for the onClipboardObservable event.
  50505. */
  50506. export class ClipboardInfo {
  50507. /**
  50508. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50509. */
  50510. type: number;
  50511. /**
  50512. * Defines the related dom event
  50513. */
  50514. event: ClipboardEvent;
  50515. /**
  50516. *Creates an instance of ClipboardInfo.
  50517. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50518. * @param event Defines the related dom event
  50519. */
  50520. constructor(
  50521. /**
  50522. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50523. */
  50524. type: number,
  50525. /**
  50526. * Defines the related dom event
  50527. */
  50528. event: ClipboardEvent);
  50529. /**
  50530. * Get the clipboard event's type from the keycode.
  50531. * @param keyCode Defines the keyCode for the current keyboard event.
  50532. * @return {number}
  50533. */
  50534. static GetTypeFromCharacter(keyCode: number): number;
  50535. }
  50536. }
  50537. declare module "babylonjs/Events/index" {
  50538. export * from "babylonjs/Events/keyboardEvents";
  50539. export * from "babylonjs/Events/pointerEvents";
  50540. export * from "babylonjs/Events/clipboardEvents";
  50541. }
  50542. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50543. import { Scene } from "babylonjs/scene";
  50544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50545. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50546. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50547. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50548. /**
  50549. * Google Daydream controller
  50550. */
  50551. export class DaydreamController extends WebVRController {
  50552. /**
  50553. * Base Url for the controller model.
  50554. */
  50555. static MODEL_BASE_URL: string;
  50556. /**
  50557. * File name for the controller model.
  50558. */
  50559. static MODEL_FILENAME: string;
  50560. /**
  50561. * Gamepad Id prefix used to identify Daydream Controller.
  50562. */
  50563. static readonly GAMEPAD_ID_PREFIX: string;
  50564. /**
  50565. * Creates a new DaydreamController from a gamepad
  50566. * @param vrGamepad the gamepad that the controller should be created from
  50567. */
  50568. constructor(vrGamepad: any);
  50569. /**
  50570. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50571. * @param scene scene in which to add meshes
  50572. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50573. */
  50574. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50575. /**
  50576. * Called once for each button that changed state since the last frame
  50577. * @param buttonIdx Which button index changed
  50578. * @param state New state of the button
  50579. * @param changes Which properties on the state changed since last frame
  50580. */
  50581. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50582. }
  50583. }
  50584. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50585. import { Scene } from "babylonjs/scene";
  50586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50587. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50588. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50589. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50590. /**
  50591. * Gear VR Controller
  50592. */
  50593. export class GearVRController extends WebVRController {
  50594. /**
  50595. * Base Url for the controller model.
  50596. */
  50597. static MODEL_BASE_URL: string;
  50598. /**
  50599. * File name for the controller model.
  50600. */
  50601. static MODEL_FILENAME: string;
  50602. /**
  50603. * Gamepad Id prefix used to identify this controller.
  50604. */
  50605. static readonly GAMEPAD_ID_PREFIX: string;
  50606. private readonly _buttonIndexToObservableNameMap;
  50607. /**
  50608. * Creates a new GearVRController from a gamepad
  50609. * @param vrGamepad the gamepad that the controller should be created from
  50610. */
  50611. constructor(vrGamepad: any);
  50612. /**
  50613. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50614. * @param scene scene in which to add meshes
  50615. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50616. */
  50617. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50618. /**
  50619. * Called once for each button that changed state since the last frame
  50620. * @param buttonIdx Which button index changed
  50621. * @param state New state of the button
  50622. * @param changes Which properties on the state changed since last frame
  50623. */
  50624. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50625. }
  50626. }
  50627. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50628. import { Scene } from "babylonjs/scene";
  50629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50630. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50631. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50632. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50633. /**
  50634. * Generic Controller
  50635. */
  50636. export class GenericController extends WebVRController {
  50637. /**
  50638. * Base Url for the controller model.
  50639. */
  50640. static readonly MODEL_BASE_URL: string;
  50641. /**
  50642. * File name for the controller model.
  50643. */
  50644. static readonly MODEL_FILENAME: string;
  50645. /**
  50646. * Creates a new GenericController 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/oculusTouchController" {
  50666. import { Observable } from "babylonjs/Misc/observable";
  50667. import { Scene } from "babylonjs/scene";
  50668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50669. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50670. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50671. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50672. /**
  50673. * Oculus Touch Controller
  50674. */
  50675. export class OculusTouchController extends WebVRController {
  50676. /**
  50677. * Base Url for the controller model.
  50678. */
  50679. static MODEL_BASE_URL: string;
  50680. /**
  50681. * File name for the left controller model.
  50682. */
  50683. static MODEL_LEFT_FILENAME: string;
  50684. /**
  50685. * File name for the right controller model.
  50686. */
  50687. static MODEL_RIGHT_FILENAME: string;
  50688. /**
  50689. * Base Url for the Quest controller model.
  50690. */
  50691. static QUEST_MODEL_BASE_URL: string;
  50692. /**
  50693. * @hidden
  50694. * If the controllers are running on a device that needs the updated Quest controller models
  50695. */
  50696. static _IsQuest: boolean;
  50697. /**
  50698. * Fired when the secondary trigger on this controller is modified
  50699. */
  50700. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50701. /**
  50702. * Fired when the thumb rest on this controller is modified
  50703. */
  50704. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50705. /**
  50706. * Creates a new OculusTouchController from a gamepad
  50707. * @param vrGamepad the gamepad that the controller should be created from
  50708. */
  50709. constructor(vrGamepad: any);
  50710. /**
  50711. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50712. * @param scene scene in which to add meshes
  50713. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50714. */
  50715. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50716. /**
  50717. * Fired when the A button on this controller is modified
  50718. */
  50719. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50720. /**
  50721. * Fired when the B button on this controller is modified
  50722. */
  50723. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50724. /**
  50725. * Fired when the X button on this controller is modified
  50726. */
  50727. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50728. /**
  50729. * Fired when the Y button on this controller is modified
  50730. */
  50731. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50732. /**
  50733. * Called once for each button that changed state since the last frame
  50734. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50735. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50736. * 2) secondary trigger (same)
  50737. * 3) A (right) X (left), touch, pressed = value
  50738. * 4) B / Y
  50739. * 5) thumb rest
  50740. * @param buttonIdx Which button index changed
  50741. * @param state New state of the button
  50742. * @param changes Which properties on the state changed since last frame
  50743. */
  50744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50745. }
  50746. }
  50747. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50748. import { Scene } from "babylonjs/scene";
  50749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50750. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50751. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50752. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50753. import { Observable } from "babylonjs/Misc/observable";
  50754. /**
  50755. * Vive Controller
  50756. */
  50757. export class ViveController extends WebVRController {
  50758. /**
  50759. * Base Url for the controller model.
  50760. */
  50761. static MODEL_BASE_URL: string;
  50762. /**
  50763. * File name for the controller model.
  50764. */
  50765. static MODEL_FILENAME: string;
  50766. /**
  50767. * Creates a new ViveController from a gamepad
  50768. * @param vrGamepad the gamepad that the controller should be created from
  50769. */
  50770. constructor(vrGamepad: any);
  50771. /**
  50772. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50773. * @param scene scene in which to add meshes
  50774. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50775. */
  50776. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50777. /**
  50778. * Fired when the left button on this controller is modified
  50779. */
  50780. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50781. /**
  50782. * Fired when the right button on this controller is modified
  50783. */
  50784. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50785. /**
  50786. * Fired when the menu button on this controller is modified
  50787. */
  50788. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50789. /**
  50790. * Called once for each button that changed state since the last frame
  50791. * Vive mapping:
  50792. * 0: touchpad
  50793. * 1: trigger
  50794. * 2: left AND right buttons
  50795. * 3: menu button
  50796. * @param buttonIdx Which button index changed
  50797. * @param state New state of the button
  50798. * @param changes Which properties on the state changed since last frame
  50799. */
  50800. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50801. }
  50802. }
  50803. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50804. import { Observable } from "babylonjs/Misc/observable";
  50805. import { Scene } from "babylonjs/scene";
  50806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50807. import { Ray } from "babylonjs/Culling/ray";
  50808. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50809. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50810. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50811. /**
  50812. * Defines the WindowsMotionController object that the state of the windows motion controller
  50813. */
  50814. export class WindowsMotionController extends WebVRController {
  50815. /**
  50816. * The base url used to load the left and right controller models
  50817. */
  50818. static MODEL_BASE_URL: string;
  50819. /**
  50820. * The name of the left controller model file
  50821. */
  50822. static MODEL_LEFT_FILENAME: string;
  50823. /**
  50824. * The name of the right controller model file
  50825. */
  50826. static MODEL_RIGHT_FILENAME: string;
  50827. /**
  50828. * The controller name prefix for this controller type
  50829. */
  50830. static readonly GAMEPAD_ID_PREFIX: string;
  50831. /**
  50832. * The controller id pattern for this controller type
  50833. */
  50834. private static readonly GAMEPAD_ID_PATTERN;
  50835. private _loadedMeshInfo;
  50836. protected readonly _mapping: {
  50837. buttons: string[];
  50838. buttonMeshNames: {
  50839. trigger: string;
  50840. menu: string;
  50841. grip: string;
  50842. thumbstick: string;
  50843. trackpad: string;
  50844. };
  50845. buttonObservableNames: {
  50846. trigger: string;
  50847. menu: string;
  50848. grip: string;
  50849. thumbstick: string;
  50850. trackpad: string;
  50851. };
  50852. axisMeshNames: string[];
  50853. pointingPoseMeshName: string;
  50854. };
  50855. /**
  50856. * Fired when the trackpad on this controller is clicked
  50857. */
  50858. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50859. /**
  50860. * Fired when the trackpad on this controller is modified
  50861. */
  50862. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50863. /**
  50864. * The current x and y values of this controller's trackpad
  50865. */
  50866. trackpad: StickValues;
  50867. /**
  50868. * Creates a new WindowsMotionController from a gamepad
  50869. * @param vrGamepad the gamepad that the controller should be created from
  50870. */
  50871. constructor(vrGamepad: any);
  50872. /**
  50873. * Fired when the trigger on this controller is modified
  50874. */
  50875. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50876. /**
  50877. * Fired when the menu button on this controller is modified
  50878. */
  50879. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50880. /**
  50881. * Fired when the grip button on this controller is modified
  50882. */
  50883. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50884. /**
  50885. * Fired when the thumbstick button on this controller is modified
  50886. */
  50887. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50888. /**
  50889. * Fired when the touchpad button on this controller is modified
  50890. */
  50891. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50892. /**
  50893. * Fired when the touchpad values on this controller are modified
  50894. */
  50895. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50896. protected _updateTrackpad(): void;
  50897. /**
  50898. * Called once per frame by the engine.
  50899. */
  50900. update(): void;
  50901. /**
  50902. * Called once for each button that changed state since the last frame
  50903. * @param buttonIdx Which button index changed
  50904. * @param state New state of the button
  50905. * @param changes Which properties on the state changed since last frame
  50906. */
  50907. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50908. /**
  50909. * Moves the buttons on the controller mesh based on their current state
  50910. * @param buttonName the name of the button to move
  50911. * @param buttonValue the value of the button which determines the buttons new position
  50912. */
  50913. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50914. /**
  50915. * Moves the axis on the controller mesh based on its current state
  50916. * @param axis the index of the axis
  50917. * @param axisValue the value of the axis which determines the meshes new position
  50918. * @hidden
  50919. */
  50920. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50921. /**
  50922. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50923. * @param scene scene in which to add meshes
  50924. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50925. */
  50926. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50927. /**
  50928. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50929. * can be transformed by button presses and axes values, based on this._mapping.
  50930. *
  50931. * @param scene scene in which the meshes exist
  50932. * @param meshes list of meshes that make up the controller model to process
  50933. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50934. */
  50935. private processModel;
  50936. private createMeshInfo;
  50937. /**
  50938. * Gets the ray of the controller in the direction the controller is pointing
  50939. * @param length the length the resulting ray should be
  50940. * @returns a ray in the direction the controller is pointing
  50941. */
  50942. getForwardRay(length?: number): Ray;
  50943. /**
  50944. * Disposes of the controller
  50945. */
  50946. dispose(): void;
  50947. }
  50948. /**
  50949. * This class represents a new windows motion controller in XR.
  50950. */
  50951. export class XRWindowsMotionController extends WindowsMotionController {
  50952. /**
  50953. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50954. */
  50955. protected readonly _mapping: {
  50956. buttons: string[];
  50957. buttonMeshNames: {
  50958. trigger: string;
  50959. menu: string;
  50960. grip: string;
  50961. thumbstick: string;
  50962. trackpad: string;
  50963. };
  50964. buttonObservableNames: {
  50965. trigger: string;
  50966. menu: string;
  50967. grip: string;
  50968. thumbstick: string;
  50969. trackpad: string;
  50970. };
  50971. axisMeshNames: string[];
  50972. pointingPoseMeshName: string;
  50973. };
  50974. /**
  50975. * Construct a new XR-Based windows motion controller
  50976. *
  50977. * @param gamepadInfo the gamepad object from the browser
  50978. */
  50979. constructor(gamepadInfo: any);
  50980. /**
  50981. * holds the thumbstick values (X,Y)
  50982. */
  50983. thumbstickValues: StickValues;
  50984. /**
  50985. * Fired when the thumbstick on this controller is clicked
  50986. */
  50987. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50988. /**
  50989. * Fired when the thumbstick on this controller is modified
  50990. */
  50991. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50992. /**
  50993. * Fired when the touchpad button on this controller is modified
  50994. */
  50995. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50996. /**
  50997. * Fired when the touchpad values on this controller are modified
  50998. */
  50999. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51000. /**
  51001. * Fired when the thumbstick button on this controller is modified
  51002. * here to prevent breaking changes
  51003. */
  51004. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51005. /**
  51006. * updating the thumbstick(!) and not the trackpad.
  51007. * This is named this way due to the difference between WebVR and XR and to avoid
  51008. * changing the parent class.
  51009. */
  51010. protected _updateTrackpad(): void;
  51011. /**
  51012. * Disposes the class with joy
  51013. */
  51014. dispose(): void;
  51015. }
  51016. }
  51017. declare module "babylonjs/Gamepads/Controllers/index" {
  51018. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  51019. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  51020. export * from "babylonjs/Gamepads/Controllers/genericController";
  51021. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  51022. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  51023. export * from "babylonjs/Gamepads/Controllers/viveController";
  51024. export * from "babylonjs/Gamepads/Controllers/webVRController";
  51025. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  51026. }
  51027. declare module "babylonjs/Gamepads/index" {
  51028. export * from "babylonjs/Gamepads/Controllers/index";
  51029. export * from "babylonjs/Gamepads/gamepad";
  51030. export * from "babylonjs/Gamepads/gamepadManager";
  51031. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  51032. export * from "babylonjs/Gamepads/xboxGamepad";
  51033. export * from "babylonjs/Gamepads/dualShockGamepad";
  51034. }
  51035. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  51036. import { Scene } from "babylonjs/scene";
  51037. import { Vector4 } from "babylonjs/Maths/math.vector";
  51038. import { Color4 } from "babylonjs/Maths/math.color";
  51039. import { Mesh } from "babylonjs/Meshes/mesh";
  51040. import { Nullable } from "babylonjs/types";
  51041. /**
  51042. * Class containing static functions to help procedurally build meshes
  51043. */
  51044. export class PolyhedronBuilder {
  51045. /**
  51046. * Creates a polyhedron mesh
  51047. * * 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
  51048. * * The parameter `size` (positive float, default 1) sets the polygon size
  51049. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51050. * * 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`
  51051. * * 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
  51052. * * 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)`)
  51053. * * 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
  51054. * * 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
  51055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51056. * * 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
  51057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51058. * @param name defines the name of the mesh
  51059. * @param options defines the options used to create the mesh
  51060. * @param scene defines the hosting scene
  51061. * @returns the polyhedron mesh
  51062. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51063. */
  51064. static CreatePolyhedron(name: string, options: {
  51065. type?: number;
  51066. size?: number;
  51067. sizeX?: number;
  51068. sizeY?: number;
  51069. sizeZ?: number;
  51070. custom?: any;
  51071. faceUV?: Vector4[];
  51072. faceColors?: Color4[];
  51073. flat?: boolean;
  51074. updatable?: boolean;
  51075. sideOrientation?: number;
  51076. frontUVs?: Vector4;
  51077. backUVs?: Vector4;
  51078. }, scene?: Nullable<Scene>): Mesh;
  51079. }
  51080. }
  51081. declare module "babylonjs/Gizmos/scaleGizmo" {
  51082. import { Observable } from "babylonjs/Misc/observable";
  51083. import { Nullable } from "babylonjs/types";
  51084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51085. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51086. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  51087. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51088. /**
  51089. * Gizmo that enables scaling a mesh along 3 axis
  51090. */
  51091. export class ScaleGizmo extends Gizmo {
  51092. /**
  51093. * Internal gizmo used for interactions on the x axis
  51094. */
  51095. xGizmo: AxisScaleGizmo;
  51096. /**
  51097. * Internal gizmo used for interactions on the y axis
  51098. */
  51099. yGizmo: AxisScaleGizmo;
  51100. /**
  51101. * Internal gizmo used for interactions on the z axis
  51102. */
  51103. zGizmo: AxisScaleGizmo;
  51104. /**
  51105. * Internal gizmo used to scale all axis equally
  51106. */
  51107. uniformScaleGizmo: AxisScaleGizmo;
  51108. private _meshAttached;
  51109. private _updateGizmoRotationToMatchAttachedMesh;
  51110. private _snapDistance;
  51111. private _scaleRatio;
  51112. private _uniformScalingMesh;
  51113. private _octahedron;
  51114. private _sensitivity;
  51115. /** Fires an event when any of it's sub gizmos are dragged */
  51116. onDragStartObservable: Observable<unknown>;
  51117. /** Fires an event when any of it's sub gizmos are released from dragging */
  51118. onDragEndObservable: Observable<unknown>;
  51119. get attachedMesh(): Nullable<AbstractMesh>;
  51120. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51121. /**
  51122. * Creates a ScaleGizmo
  51123. * @param gizmoLayer The utility layer the gizmo will be added to
  51124. */
  51125. constructor(gizmoLayer?: UtilityLayerRenderer);
  51126. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51127. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51128. /**
  51129. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51130. */
  51131. set snapDistance(value: number);
  51132. get snapDistance(): number;
  51133. /**
  51134. * Ratio for the scale of the gizmo (Default: 1)
  51135. */
  51136. set scaleRatio(value: number);
  51137. get scaleRatio(): number;
  51138. /**
  51139. * Sensitivity factor for dragging (Default: 1)
  51140. */
  51141. set sensitivity(value: number);
  51142. get sensitivity(): number;
  51143. /**
  51144. * Disposes of the gizmo
  51145. */
  51146. dispose(): void;
  51147. }
  51148. }
  51149. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  51150. import { Observable } from "babylonjs/Misc/observable";
  51151. import { Nullable } from "babylonjs/types";
  51152. import { Vector3 } from "babylonjs/Maths/math.vector";
  51153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51154. import { Mesh } from "babylonjs/Meshes/mesh";
  51155. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51156. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51157. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51158. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51159. import { Color3 } from "babylonjs/Maths/math.color";
  51160. /**
  51161. * Single axis scale gizmo
  51162. */
  51163. export class AxisScaleGizmo extends Gizmo {
  51164. /**
  51165. * Drag behavior responsible for the gizmos dragging interactions
  51166. */
  51167. dragBehavior: PointerDragBehavior;
  51168. private _pointerObserver;
  51169. /**
  51170. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51171. */
  51172. snapDistance: number;
  51173. /**
  51174. * Event that fires each time the gizmo snaps to a new location.
  51175. * * snapDistance is the the change in distance
  51176. */
  51177. onSnapObservable: Observable<{
  51178. snapDistance: number;
  51179. }>;
  51180. /**
  51181. * If the scaling operation should be done on all axis (default: false)
  51182. */
  51183. uniformScaling: boolean;
  51184. /**
  51185. * Custom sensitivity value for the drag strength
  51186. */
  51187. sensitivity: number;
  51188. private _isEnabled;
  51189. private _parent;
  51190. private _arrow;
  51191. private _coloredMaterial;
  51192. private _hoverMaterial;
  51193. /**
  51194. * Creates an AxisScaleGizmo
  51195. * @param gizmoLayer The utility layer the gizmo will be added to
  51196. * @param dragAxis The axis which the gizmo will be able to scale on
  51197. * @param color The color of the gizmo
  51198. */
  51199. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51200. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51201. /**
  51202. * If the gizmo is enabled
  51203. */
  51204. set isEnabled(value: boolean);
  51205. get isEnabled(): boolean;
  51206. /**
  51207. * Disposes of the gizmo
  51208. */
  51209. dispose(): void;
  51210. /**
  51211. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51212. * @param mesh The mesh to replace the default mesh of the gizmo
  51213. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51214. */
  51215. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51216. }
  51217. }
  51218. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  51219. import { Observable } from "babylonjs/Misc/observable";
  51220. import { Nullable } from "babylonjs/types";
  51221. import { Vector3 } from "babylonjs/Maths/math.vector";
  51222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51223. import { Mesh } from "babylonjs/Meshes/mesh";
  51224. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51225. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51226. import { Color3 } from "babylonjs/Maths/math.color";
  51227. import "babylonjs/Meshes/Builders/boxBuilder";
  51228. /**
  51229. * Bounding box gizmo
  51230. */
  51231. export class BoundingBoxGizmo extends Gizmo {
  51232. private _lineBoundingBox;
  51233. private _rotateSpheresParent;
  51234. private _scaleBoxesParent;
  51235. private _boundingDimensions;
  51236. private _renderObserver;
  51237. private _pointerObserver;
  51238. private _scaleDragSpeed;
  51239. private _tmpQuaternion;
  51240. private _tmpVector;
  51241. private _tmpRotationMatrix;
  51242. /**
  51243. * 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)
  51244. */
  51245. ignoreChildren: boolean;
  51246. /**
  51247. * 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)
  51248. */
  51249. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51250. /**
  51251. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51252. */
  51253. rotationSphereSize: number;
  51254. /**
  51255. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51256. */
  51257. scaleBoxSize: number;
  51258. /**
  51259. * 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)
  51260. */
  51261. fixedDragMeshScreenSize: boolean;
  51262. /**
  51263. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51264. */
  51265. fixedDragMeshScreenSizeDistanceFactor: number;
  51266. /**
  51267. * Fired when a rotation sphere or scale box is dragged
  51268. */
  51269. onDragStartObservable: Observable<{}>;
  51270. /**
  51271. * Fired when a scale box is dragged
  51272. */
  51273. onScaleBoxDragObservable: Observable<{}>;
  51274. /**
  51275. * Fired when a scale box drag is ended
  51276. */
  51277. onScaleBoxDragEndObservable: Observable<{}>;
  51278. /**
  51279. * Fired when a rotation sphere is dragged
  51280. */
  51281. onRotationSphereDragObservable: Observable<{}>;
  51282. /**
  51283. * Fired when a rotation sphere drag is ended
  51284. */
  51285. onRotationSphereDragEndObservable: Observable<{}>;
  51286. /**
  51287. * 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)
  51288. */
  51289. scalePivot: Nullable<Vector3>;
  51290. /**
  51291. * Mesh used as a pivot to rotate the attached mesh
  51292. */
  51293. private _anchorMesh;
  51294. private _existingMeshScale;
  51295. private _dragMesh;
  51296. private pointerDragBehavior;
  51297. private coloredMaterial;
  51298. private hoverColoredMaterial;
  51299. /**
  51300. * Sets the color of the bounding box gizmo
  51301. * @param color the color to set
  51302. */
  51303. setColor(color: Color3): void;
  51304. /**
  51305. * Creates an BoundingBoxGizmo
  51306. * @param gizmoLayer The utility layer the gizmo will be added to
  51307. * @param color The color of the gizmo
  51308. */
  51309. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51310. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51311. private _selectNode;
  51312. /**
  51313. * Updates the bounding box information for the Gizmo
  51314. */
  51315. updateBoundingBox(): void;
  51316. private _updateRotationSpheres;
  51317. private _updateScaleBoxes;
  51318. /**
  51319. * Enables rotation on the specified axis and disables rotation on the others
  51320. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51321. */
  51322. setEnabledRotationAxis(axis: string): void;
  51323. /**
  51324. * Enables/disables scaling
  51325. * @param enable if scaling should be enabled
  51326. * @param homogeneousScaling defines if scaling should only be homogeneous
  51327. */
  51328. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51329. private _updateDummy;
  51330. /**
  51331. * Enables a pointer drag behavior on the bounding box of the gizmo
  51332. */
  51333. enableDragBehavior(): void;
  51334. /**
  51335. * Disposes of the gizmo
  51336. */
  51337. dispose(): void;
  51338. /**
  51339. * 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)
  51340. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51341. * @returns the bounding box mesh with the passed in mesh as a child
  51342. */
  51343. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51344. /**
  51345. * CustomMeshes are not supported by this gizmo
  51346. * @param mesh The mesh to replace the default mesh of the gizmo
  51347. */
  51348. setCustomMesh(mesh: Mesh): void;
  51349. }
  51350. }
  51351. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  51352. import { Observable } from "babylonjs/Misc/observable";
  51353. import { Nullable } from "babylonjs/types";
  51354. import { Vector3 } from "babylonjs/Maths/math.vector";
  51355. import { Color3 } from "babylonjs/Maths/math.color";
  51356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51357. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51358. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51359. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51360. import "babylonjs/Meshes/Builders/linesBuilder";
  51361. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51362. /**
  51363. * Single plane rotation gizmo
  51364. */
  51365. export class PlaneRotationGizmo extends Gizmo {
  51366. /**
  51367. * Drag behavior responsible for the gizmos dragging interactions
  51368. */
  51369. dragBehavior: PointerDragBehavior;
  51370. private _pointerObserver;
  51371. /**
  51372. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51373. */
  51374. snapDistance: number;
  51375. /**
  51376. * Event that fires each time the gizmo snaps to a new location.
  51377. * * snapDistance is the the change in distance
  51378. */
  51379. onSnapObservable: Observable<{
  51380. snapDistance: number;
  51381. }>;
  51382. private _isEnabled;
  51383. private _parent;
  51384. /**
  51385. * Creates a PlaneRotationGizmo
  51386. * @param gizmoLayer The utility layer the gizmo will be added to
  51387. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51388. * @param color The color of the gizmo
  51389. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51390. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51391. */
  51392. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51393. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51394. /**
  51395. * If the gizmo is enabled
  51396. */
  51397. set isEnabled(value: boolean);
  51398. get isEnabled(): boolean;
  51399. /**
  51400. * Disposes of the gizmo
  51401. */
  51402. dispose(): void;
  51403. }
  51404. }
  51405. declare module "babylonjs/Gizmos/rotationGizmo" {
  51406. import { Observable } from "babylonjs/Misc/observable";
  51407. import { Nullable } from "babylonjs/types";
  51408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51409. import { Mesh } from "babylonjs/Meshes/mesh";
  51410. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51411. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51412. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51413. /**
  51414. * Gizmo that enables rotating a mesh along 3 axis
  51415. */
  51416. export class RotationGizmo extends Gizmo {
  51417. /**
  51418. * Internal gizmo used for interactions on the x axis
  51419. */
  51420. xGizmo: PlaneRotationGizmo;
  51421. /**
  51422. * Internal gizmo used for interactions on the y axis
  51423. */
  51424. yGizmo: PlaneRotationGizmo;
  51425. /**
  51426. * Internal gizmo used for interactions on the z axis
  51427. */
  51428. zGizmo: PlaneRotationGizmo;
  51429. /** Fires an event when any of it's sub gizmos are dragged */
  51430. onDragStartObservable: Observable<unknown>;
  51431. /** Fires an event when any of it's sub gizmos are released from dragging */
  51432. onDragEndObservable: Observable<unknown>;
  51433. private _meshAttached;
  51434. get attachedMesh(): Nullable<AbstractMesh>;
  51435. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51436. /**
  51437. * Creates a RotationGizmo
  51438. * @param gizmoLayer The utility layer the gizmo will be added to
  51439. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51440. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51441. */
  51442. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51443. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51444. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51445. /**
  51446. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51447. */
  51448. set snapDistance(value: number);
  51449. get snapDistance(): number;
  51450. /**
  51451. * Ratio for the scale of the gizmo (Default: 1)
  51452. */
  51453. set scaleRatio(value: number);
  51454. get scaleRatio(): number;
  51455. /**
  51456. * Disposes of the gizmo
  51457. */
  51458. dispose(): void;
  51459. /**
  51460. * CustomMeshes are not supported by this gizmo
  51461. * @param mesh The mesh to replace the default mesh of the gizmo
  51462. */
  51463. setCustomMesh(mesh: Mesh): void;
  51464. }
  51465. }
  51466. declare module "babylonjs/Gizmos/gizmoManager" {
  51467. import { Observable } from "babylonjs/Misc/observable";
  51468. import { Nullable } from "babylonjs/types";
  51469. import { Scene, IDisposable } from "babylonjs/scene";
  51470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51471. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51472. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51473. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51474. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51475. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51476. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51477. /**
  51478. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51479. */
  51480. export class GizmoManager implements IDisposable {
  51481. private scene;
  51482. /**
  51483. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51484. */
  51485. gizmos: {
  51486. positionGizmo: Nullable<PositionGizmo>;
  51487. rotationGizmo: Nullable<RotationGizmo>;
  51488. scaleGizmo: Nullable<ScaleGizmo>;
  51489. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51490. };
  51491. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51492. clearGizmoOnEmptyPointerEvent: boolean;
  51493. /** Fires an event when the manager is attached to a mesh */
  51494. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51495. private _gizmosEnabled;
  51496. private _pointerObserver;
  51497. private _attachedMesh;
  51498. private _boundingBoxColor;
  51499. private _defaultUtilityLayer;
  51500. private _defaultKeepDepthUtilityLayer;
  51501. /**
  51502. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51503. */
  51504. boundingBoxDragBehavior: SixDofDragBehavior;
  51505. /**
  51506. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51507. */
  51508. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51509. /**
  51510. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51511. */
  51512. usePointerToAttachGizmos: boolean;
  51513. /**
  51514. * Utility layer that the bounding box gizmo belongs to
  51515. */
  51516. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51517. /**
  51518. * Utility layer that all gizmos besides bounding box belong to
  51519. */
  51520. get utilityLayer(): UtilityLayerRenderer;
  51521. /**
  51522. * Instatiates a gizmo manager
  51523. * @param scene the scene to overlay the gizmos on top of
  51524. */
  51525. constructor(scene: Scene);
  51526. /**
  51527. * Attaches a set of gizmos to the specified mesh
  51528. * @param mesh The mesh the gizmo's should be attached to
  51529. */
  51530. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51531. /**
  51532. * If the position gizmo is enabled
  51533. */
  51534. set positionGizmoEnabled(value: boolean);
  51535. get positionGizmoEnabled(): boolean;
  51536. /**
  51537. * If the rotation gizmo is enabled
  51538. */
  51539. set rotationGizmoEnabled(value: boolean);
  51540. get rotationGizmoEnabled(): boolean;
  51541. /**
  51542. * If the scale gizmo is enabled
  51543. */
  51544. set scaleGizmoEnabled(value: boolean);
  51545. get scaleGizmoEnabled(): boolean;
  51546. /**
  51547. * If the boundingBox gizmo is enabled
  51548. */
  51549. set boundingBoxGizmoEnabled(value: boolean);
  51550. get boundingBoxGizmoEnabled(): boolean;
  51551. /**
  51552. * Disposes of the gizmo manager
  51553. */
  51554. dispose(): void;
  51555. }
  51556. }
  51557. declare module "babylonjs/Lights/directionalLight" {
  51558. import { Camera } from "babylonjs/Cameras/camera";
  51559. import { Scene } from "babylonjs/scene";
  51560. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51562. import { Light } from "babylonjs/Lights/light";
  51563. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51564. import { Effect } from "babylonjs/Materials/effect";
  51565. /**
  51566. * A directional light is defined by a direction (what a surprise!).
  51567. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51568. * 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.
  51569. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51570. */
  51571. export class DirectionalLight extends ShadowLight {
  51572. private _shadowFrustumSize;
  51573. /**
  51574. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51575. */
  51576. get shadowFrustumSize(): number;
  51577. /**
  51578. * Specifies a fix frustum size for the shadow generation.
  51579. */
  51580. set shadowFrustumSize(value: number);
  51581. private _shadowOrthoScale;
  51582. /**
  51583. * Gets the shadow projection scale against the optimal computed one.
  51584. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51585. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51586. */
  51587. get shadowOrthoScale(): number;
  51588. /**
  51589. * Sets the shadow projection scale against the optimal computed one.
  51590. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51591. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51592. */
  51593. set shadowOrthoScale(value: number);
  51594. /**
  51595. * Automatically compute the projection matrix to best fit (including all the casters)
  51596. * on each frame.
  51597. */
  51598. autoUpdateExtends: boolean;
  51599. /**
  51600. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51601. * on each frame. autoUpdateExtends must be set to true for this to work
  51602. */
  51603. autoCalcShadowZBounds: boolean;
  51604. private _orthoLeft;
  51605. private _orthoRight;
  51606. private _orthoTop;
  51607. private _orthoBottom;
  51608. /**
  51609. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51610. * The directional light is emitted from everywhere in the given direction.
  51611. * It can cast shadows.
  51612. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51613. * @param name The friendly name of the light
  51614. * @param direction The direction of the light
  51615. * @param scene The scene the light belongs to
  51616. */
  51617. constructor(name: string, direction: Vector3, scene: Scene);
  51618. /**
  51619. * Returns the string "DirectionalLight".
  51620. * @return The class name
  51621. */
  51622. getClassName(): string;
  51623. /**
  51624. * Returns the integer 1.
  51625. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51626. */
  51627. getTypeID(): number;
  51628. /**
  51629. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51630. * Returns the DirectionalLight Shadow projection matrix.
  51631. */
  51632. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51633. /**
  51634. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51635. * Returns the DirectionalLight Shadow projection matrix.
  51636. */
  51637. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51638. /**
  51639. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51640. * Returns the DirectionalLight Shadow projection matrix.
  51641. */
  51642. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51643. protected _buildUniformLayout(): void;
  51644. /**
  51645. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51646. * @param effect The effect to update
  51647. * @param lightIndex The index of the light in the effect to update
  51648. * @returns The directional light
  51649. */
  51650. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51651. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51652. /**
  51653. * Gets the minZ used for shadow according to both the scene and the light.
  51654. *
  51655. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51656. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51657. * @param activeCamera The camera we are returning the min for
  51658. * @returns the depth min z
  51659. */
  51660. getDepthMinZ(activeCamera: Camera): number;
  51661. /**
  51662. * Gets the maxZ used for shadow according to both the scene and the light.
  51663. *
  51664. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51665. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51666. * @param activeCamera The camera we are returning the max for
  51667. * @returns the depth max z
  51668. */
  51669. getDepthMaxZ(activeCamera: Camera): number;
  51670. /**
  51671. * Prepares the list of defines specific to the light type.
  51672. * @param defines the list of defines
  51673. * @param lightIndex defines the index of the light for the effect
  51674. */
  51675. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51676. }
  51677. }
  51678. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51679. import { Mesh } from "babylonjs/Meshes/mesh";
  51680. /**
  51681. * Class containing static functions to help procedurally build meshes
  51682. */
  51683. export class HemisphereBuilder {
  51684. /**
  51685. * Creates a hemisphere mesh
  51686. * @param name defines the name of the mesh
  51687. * @param options defines the options used to create the mesh
  51688. * @param scene defines the hosting scene
  51689. * @returns the hemisphere mesh
  51690. */
  51691. static CreateHemisphere(name: string, options: {
  51692. segments?: number;
  51693. diameter?: number;
  51694. sideOrientation?: number;
  51695. }, scene: any): Mesh;
  51696. }
  51697. }
  51698. declare module "babylonjs/Lights/spotLight" {
  51699. import { Nullable } from "babylonjs/types";
  51700. import { Scene } from "babylonjs/scene";
  51701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51703. import { Effect } from "babylonjs/Materials/effect";
  51704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51705. import { Light } from "babylonjs/Lights/light";
  51706. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51707. /**
  51708. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51709. * These values define a cone of light starting from the position, emitting toward the direction.
  51710. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51711. * and the exponent defines the speed of the decay of the light with distance (reach).
  51712. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51713. */
  51714. export class SpotLight extends ShadowLight {
  51715. private _angle;
  51716. private _innerAngle;
  51717. private _cosHalfAngle;
  51718. private _lightAngleScale;
  51719. private _lightAngleOffset;
  51720. /**
  51721. * Gets the cone angle of the spot light in Radians.
  51722. */
  51723. get angle(): number;
  51724. /**
  51725. * Sets the cone angle of the spot light in Radians.
  51726. */
  51727. set angle(value: number);
  51728. /**
  51729. * Only used in gltf falloff mode, this defines the angle where
  51730. * the directional falloff will start before cutting at angle which could be seen
  51731. * as outer angle.
  51732. */
  51733. get innerAngle(): number;
  51734. /**
  51735. * Only used in gltf falloff mode, this defines the angle where
  51736. * the directional falloff will start before cutting at angle which could be seen
  51737. * as outer angle.
  51738. */
  51739. set innerAngle(value: number);
  51740. private _shadowAngleScale;
  51741. /**
  51742. * Allows scaling the angle of the light for shadow generation only.
  51743. */
  51744. get shadowAngleScale(): number;
  51745. /**
  51746. * Allows scaling the angle of the light for shadow generation only.
  51747. */
  51748. set shadowAngleScale(value: number);
  51749. /**
  51750. * The light decay speed with the distance from the emission spot.
  51751. */
  51752. exponent: number;
  51753. private _projectionTextureMatrix;
  51754. /**
  51755. * Allows reading the projecton texture
  51756. */
  51757. get projectionTextureMatrix(): Matrix;
  51758. protected _projectionTextureLightNear: number;
  51759. /**
  51760. * Gets the near clip of the Spotlight for texture projection.
  51761. */
  51762. get projectionTextureLightNear(): number;
  51763. /**
  51764. * Sets the near clip of the Spotlight for texture projection.
  51765. */
  51766. set projectionTextureLightNear(value: number);
  51767. protected _projectionTextureLightFar: number;
  51768. /**
  51769. * Gets the far clip of the Spotlight for texture projection.
  51770. */
  51771. get projectionTextureLightFar(): number;
  51772. /**
  51773. * Sets the far clip of the Spotlight for texture projection.
  51774. */
  51775. set projectionTextureLightFar(value: number);
  51776. protected _projectionTextureUpDirection: Vector3;
  51777. /**
  51778. * Gets the Up vector of the Spotlight for texture projection.
  51779. */
  51780. get projectionTextureUpDirection(): Vector3;
  51781. /**
  51782. * Sets the Up vector of the Spotlight for texture projection.
  51783. */
  51784. set projectionTextureUpDirection(value: Vector3);
  51785. private _projectionTexture;
  51786. /**
  51787. * Gets the projection texture of the light.
  51788. */
  51789. get projectionTexture(): Nullable<BaseTexture>;
  51790. /**
  51791. * Sets the projection texture of the light.
  51792. */
  51793. set projectionTexture(value: Nullable<BaseTexture>);
  51794. private _projectionTextureViewLightDirty;
  51795. private _projectionTextureProjectionLightDirty;
  51796. private _projectionTextureDirty;
  51797. private _projectionTextureViewTargetVector;
  51798. private _projectionTextureViewLightMatrix;
  51799. private _projectionTextureProjectionLightMatrix;
  51800. private _projectionTextureScalingMatrix;
  51801. /**
  51802. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51803. * It can cast shadows.
  51804. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51805. * @param name The light friendly name
  51806. * @param position The position of the spot light in the scene
  51807. * @param direction The direction of the light in the scene
  51808. * @param angle The cone angle of the light in Radians
  51809. * @param exponent The light decay speed with the distance from the emission spot
  51810. * @param scene The scene the lights belongs to
  51811. */
  51812. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51813. /**
  51814. * Returns the string "SpotLight".
  51815. * @returns the class name
  51816. */
  51817. getClassName(): string;
  51818. /**
  51819. * Returns the integer 2.
  51820. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51821. */
  51822. getTypeID(): number;
  51823. /**
  51824. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51825. */
  51826. protected _setDirection(value: Vector3): void;
  51827. /**
  51828. * Overrides the position setter to recompute the projection texture view light Matrix.
  51829. */
  51830. protected _setPosition(value: Vector3): void;
  51831. /**
  51832. * 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.
  51833. * Returns the SpotLight.
  51834. */
  51835. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51836. protected _computeProjectionTextureViewLightMatrix(): void;
  51837. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51838. /**
  51839. * Main function for light texture projection matrix computing.
  51840. */
  51841. protected _computeProjectionTextureMatrix(): void;
  51842. protected _buildUniformLayout(): void;
  51843. private _computeAngleValues;
  51844. /**
  51845. * Sets the passed Effect "effect" with the Light textures.
  51846. * @param effect The effect to update
  51847. * @param lightIndex The index of the light in the effect to update
  51848. * @returns The light
  51849. */
  51850. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51851. /**
  51852. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51853. * @param effect The effect to update
  51854. * @param lightIndex The index of the light in the effect to update
  51855. * @returns The spot light
  51856. */
  51857. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51858. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51859. /**
  51860. * Disposes the light and the associated resources.
  51861. */
  51862. dispose(): void;
  51863. /**
  51864. * Prepares the list of defines specific to the light type.
  51865. * @param defines the list of defines
  51866. * @param lightIndex defines the index of the light for the effect
  51867. */
  51868. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51869. }
  51870. }
  51871. declare module "babylonjs/Gizmos/lightGizmo" {
  51872. import { Nullable } from "babylonjs/types";
  51873. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51874. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51875. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51876. import { Light } from "babylonjs/Lights/light";
  51877. /**
  51878. * Gizmo that enables viewing a light
  51879. */
  51880. export class LightGizmo extends Gizmo {
  51881. private _lightMesh;
  51882. private _material;
  51883. private _cachedPosition;
  51884. private _cachedForward;
  51885. private _attachedMeshParent;
  51886. /**
  51887. * Creates a LightGizmo
  51888. * @param gizmoLayer The utility layer the gizmo will be added to
  51889. */
  51890. constructor(gizmoLayer?: UtilityLayerRenderer);
  51891. private _light;
  51892. /**
  51893. * The light that the gizmo is attached to
  51894. */
  51895. set light(light: Nullable<Light>);
  51896. get light(): Nullable<Light>;
  51897. /**
  51898. * Gets the material used to render the light gizmo
  51899. */
  51900. get material(): StandardMaterial;
  51901. /**
  51902. * @hidden
  51903. * Updates the gizmo to match the attached mesh's position/rotation
  51904. */
  51905. protected _update(): void;
  51906. private static _Scale;
  51907. /**
  51908. * Creates the lines for a light mesh
  51909. */
  51910. private static _CreateLightLines;
  51911. /**
  51912. * Disposes of the light gizmo
  51913. */
  51914. dispose(): void;
  51915. private static _CreateHemisphericLightMesh;
  51916. private static _CreatePointLightMesh;
  51917. private static _CreateSpotLightMesh;
  51918. private static _CreateDirectionalLightMesh;
  51919. }
  51920. }
  51921. declare module "babylonjs/Gizmos/index" {
  51922. export * from "babylonjs/Gizmos/axisDragGizmo";
  51923. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51924. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51925. export * from "babylonjs/Gizmos/gizmo";
  51926. export * from "babylonjs/Gizmos/gizmoManager";
  51927. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51928. export * from "babylonjs/Gizmos/positionGizmo";
  51929. export * from "babylonjs/Gizmos/rotationGizmo";
  51930. export * from "babylonjs/Gizmos/scaleGizmo";
  51931. export * from "babylonjs/Gizmos/lightGizmo";
  51932. export * from "babylonjs/Gizmos/planeDragGizmo";
  51933. }
  51934. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51935. /** @hidden */
  51936. export var backgroundFragmentDeclaration: {
  51937. name: string;
  51938. shader: string;
  51939. };
  51940. }
  51941. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51942. /** @hidden */
  51943. export var backgroundUboDeclaration: {
  51944. name: string;
  51945. shader: string;
  51946. };
  51947. }
  51948. declare module "babylonjs/Shaders/background.fragment" {
  51949. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51950. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51951. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51952. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51953. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51954. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51955. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51956. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51957. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51958. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51959. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51960. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51961. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51962. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51963. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51964. /** @hidden */
  51965. export var backgroundPixelShader: {
  51966. name: string;
  51967. shader: string;
  51968. };
  51969. }
  51970. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51971. /** @hidden */
  51972. export var backgroundVertexDeclaration: {
  51973. name: string;
  51974. shader: string;
  51975. };
  51976. }
  51977. declare module "babylonjs/Shaders/background.vertex" {
  51978. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51979. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51980. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51981. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51982. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51983. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51984. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51985. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51986. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51987. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51988. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51989. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51990. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51991. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51992. /** @hidden */
  51993. export var backgroundVertexShader: {
  51994. name: string;
  51995. shader: string;
  51996. };
  51997. }
  51998. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51999. import { Nullable, int, float } from "babylonjs/types";
  52000. import { Scene } from "babylonjs/scene";
  52001. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52002. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52004. import { Mesh } from "babylonjs/Meshes/mesh";
  52005. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52006. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52007. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52009. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  52010. import { Color3 } from "babylonjs/Maths/math.color";
  52011. import "babylonjs/Shaders/background.fragment";
  52012. import "babylonjs/Shaders/background.vertex";
  52013. /**
  52014. * Background material used to create an efficient environement around your scene.
  52015. */
  52016. export class BackgroundMaterial extends PushMaterial {
  52017. /**
  52018. * Standard reflectance value at parallel view angle.
  52019. */
  52020. static StandardReflectance0: number;
  52021. /**
  52022. * Standard reflectance value at grazing angle.
  52023. */
  52024. static StandardReflectance90: number;
  52025. protected _primaryColor: Color3;
  52026. /**
  52027. * Key light Color (multiply against the environement texture)
  52028. */
  52029. primaryColor: Color3;
  52030. protected __perceptualColor: Nullable<Color3>;
  52031. /**
  52032. * Experimental Internal Use Only.
  52033. *
  52034. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52035. * This acts as a helper to set the primary color to a more "human friendly" value.
  52036. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52037. * output color as close as possible from the chosen value.
  52038. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52039. * part of lighting setup.)
  52040. */
  52041. get _perceptualColor(): Nullable<Color3>;
  52042. set _perceptualColor(value: Nullable<Color3>);
  52043. protected _primaryColorShadowLevel: float;
  52044. /**
  52045. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52046. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52047. */
  52048. get primaryColorShadowLevel(): float;
  52049. set primaryColorShadowLevel(value: float);
  52050. protected _primaryColorHighlightLevel: float;
  52051. /**
  52052. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52053. * The primary color is used at the level chosen to define what the white area would look.
  52054. */
  52055. get primaryColorHighlightLevel(): float;
  52056. set primaryColorHighlightLevel(value: float);
  52057. protected _reflectionTexture: Nullable<BaseTexture>;
  52058. /**
  52059. * Reflection Texture used in the material.
  52060. * Should be author in a specific way for the best result (refer to the documentation).
  52061. */
  52062. reflectionTexture: Nullable<BaseTexture>;
  52063. protected _reflectionBlur: float;
  52064. /**
  52065. * Reflection Texture level of blur.
  52066. *
  52067. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52068. * texture twice.
  52069. */
  52070. reflectionBlur: float;
  52071. protected _diffuseTexture: Nullable<BaseTexture>;
  52072. /**
  52073. * Diffuse Texture used in the material.
  52074. * Should be author in a specific way for the best result (refer to the documentation).
  52075. */
  52076. diffuseTexture: Nullable<BaseTexture>;
  52077. protected _shadowLights: Nullable<IShadowLight[]>;
  52078. /**
  52079. * Specify the list of lights casting shadow on the material.
  52080. * All scene shadow lights will be included if null.
  52081. */
  52082. shadowLights: Nullable<IShadowLight[]>;
  52083. protected _shadowLevel: float;
  52084. /**
  52085. * Helps adjusting the shadow to a softer level if required.
  52086. * 0 means black shadows and 1 means no shadows.
  52087. */
  52088. shadowLevel: float;
  52089. protected _sceneCenter: Vector3;
  52090. /**
  52091. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52092. * It is usually zero but might be interesting to modify according to your setup.
  52093. */
  52094. sceneCenter: Vector3;
  52095. protected _opacityFresnel: boolean;
  52096. /**
  52097. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52098. * This helps ensuring a nice transition when the camera goes under the ground.
  52099. */
  52100. opacityFresnel: boolean;
  52101. protected _reflectionFresnel: boolean;
  52102. /**
  52103. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52104. * This helps adding a mirror texture on the ground.
  52105. */
  52106. reflectionFresnel: boolean;
  52107. protected _reflectionFalloffDistance: number;
  52108. /**
  52109. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52110. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52111. */
  52112. reflectionFalloffDistance: number;
  52113. protected _reflectionAmount: number;
  52114. /**
  52115. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52116. */
  52117. reflectionAmount: number;
  52118. protected _reflectionReflectance0: number;
  52119. /**
  52120. * This specifies the weight of the reflection at grazing angle.
  52121. */
  52122. reflectionReflectance0: number;
  52123. protected _reflectionReflectance90: number;
  52124. /**
  52125. * This specifies the weight of the reflection at a perpendicular point of view.
  52126. */
  52127. reflectionReflectance90: number;
  52128. /**
  52129. * Sets the reflection reflectance fresnel values according to the default standard
  52130. * empirically know to work well :-)
  52131. */
  52132. set reflectionStandardFresnelWeight(value: number);
  52133. protected _useRGBColor: boolean;
  52134. /**
  52135. * Helps to directly use the maps channels instead of their level.
  52136. */
  52137. useRGBColor: boolean;
  52138. protected _enableNoise: boolean;
  52139. /**
  52140. * This helps reducing the banding effect that could occur on the background.
  52141. */
  52142. enableNoise: boolean;
  52143. /**
  52144. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52145. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52146. * Recommended to be keep at 1.0 except for special cases.
  52147. */
  52148. get fovMultiplier(): number;
  52149. set fovMultiplier(value: number);
  52150. private _fovMultiplier;
  52151. /**
  52152. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52153. */
  52154. useEquirectangularFOV: boolean;
  52155. private _maxSimultaneousLights;
  52156. /**
  52157. * Number of Simultaneous lights allowed on the material.
  52158. */
  52159. maxSimultaneousLights: int;
  52160. /**
  52161. * Default configuration related to image processing available in the Background Material.
  52162. */
  52163. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52164. /**
  52165. * Keep track of the image processing observer to allow dispose and replace.
  52166. */
  52167. private _imageProcessingObserver;
  52168. /**
  52169. * Attaches a new image processing configuration to the PBR Material.
  52170. * @param configuration (if null the scene configuration will be use)
  52171. */
  52172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52173. /**
  52174. * Gets the image processing configuration used either in this material.
  52175. */
  52176. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52177. /**
  52178. * Sets the Default image processing configuration used either in the this material.
  52179. *
  52180. * If sets to null, the scene one is in use.
  52181. */
  52182. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52183. /**
  52184. * Gets wether the color curves effect is enabled.
  52185. */
  52186. get cameraColorCurvesEnabled(): boolean;
  52187. /**
  52188. * Sets wether the color curves effect is enabled.
  52189. */
  52190. set cameraColorCurvesEnabled(value: boolean);
  52191. /**
  52192. * Gets wether the color grading effect is enabled.
  52193. */
  52194. get cameraColorGradingEnabled(): boolean;
  52195. /**
  52196. * Gets wether the color grading effect is enabled.
  52197. */
  52198. set cameraColorGradingEnabled(value: boolean);
  52199. /**
  52200. * Gets wether tonemapping is enabled or not.
  52201. */
  52202. get cameraToneMappingEnabled(): boolean;
  52203. /**
  52204. * Sets wether tonemapping is enabled or not
  52205. */
  52206. set cameraToneMappingEnabled(value: boolean);
  52207. /**
  52208. * The camera exposure used on this material.
  52209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52210. * This corresponds to a photographic exposure.
  52211. */
  52212. get cameraExposure(): float;
  52213. /**
  52214. * The camera exposure used on this material.
  52215. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52216. * This corresponds to a photographic exposure.
  52217. */
  52218. set cameraExposure(value: float);
  52219. /**
  52220. * Gets The camera contrast used on this material.
  52221. */
  52222. get cameraContrast(): float;
  52223. /**
  52224. * Sets The camera contrast used on this material.
  52225. */
  52226. set cameraContrast(value: float);
  52227. /**
  52228. * Gets the Color Grading 2D Lookup Texture.
  52229. */
  52230. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52231. /**
  52232. * Sets the Color Grading 2D Lookup Texture.
  52233. */
  52234. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52235. /**
  52236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52238. * 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;
  52239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52240. */
  52241. get cameraColorCurves(): Nullable<ColorCurves>;
  52242. /**
  52243. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52244. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52245. * 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;
  52246. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52247. */
  52248. set cameraColorCurves(value: Nullable<ColorCurves>);
  52249. /**
  52250. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52251. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52252. */
  52253. switchToBGR: boolean;
  52254. private _renderTargets;
  52255. private _reflectionControls;
  52256. private _white;
  52257. private _primaryShadowColor;
  52258. private _primaryHighlightColor;
  52259. /**
  52260. * Instantiates a Background Material in the given scene
  52261. * @param name The friendly name of the material
  52262. * @param scene The scene to add the material to
  52263. */
  52264. constructor(name: string, scene: Scene);
  52265. /**
  52266. * Gets a boolean indicating that current material needs to register RTT
  52267. */
  52268. get hasRenderTargetTextures(): boolean;
  52269. /**
  52270. * The entire material has been created in order to prevent overdraw.
  52271. * @returns false
  52272. */
  52273. needAlphaTesting(): boolean;
  52274. /**
  52275. * The entire material has been created in order to prevent overdraw.
  52276. * @returns true if blending is enable
  52277. */
  52278. needAlphaBlending(): boolean;
  52279. /**
  52280. * Checks wether the material is ready to be rendered for a given mesh.
  52281. * @param mesh The mesh to render
  52282. * @param subMesh The submesh to check against
  52283. * @param useInstances Specify wether or not the material is used with instances
  52284. * @returns true if all the dependencies are ready (Textures, Effects...)
  52285. */
  52286. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52287. /**
  52288. * Compute the primary color according to the chosen perceptual color.
  52289. */
  52290. private _computePrimaryColorFromPerceptualColor;
  52291. /**
  52292. * Compute the highlights and shadow colors according to their chosen levels.
  52293. */
  52294. private _computePrimaryColors;
  52295. /**
  52296. * Build the uniform buffer used in the material.
  52297. */
  52298. buildUniformLayout(): void;
  52299. /**
  52300. * Unbind the material.
  52301. */
  52302. unbind(): void;
  52303. /**
  52304. * Bind only the world matrix to the material.
  52305. * @param world The world matrix to bind.
  52306. */
  52307. bindOnlyWorldMatrix(world: Matrix): void;
  52308. /**
  52309. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52310. * @param world The world matrix to bind.
  52311. * @param subMesh The submesh to bind for.
  52312. */
  52313. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52314. /**
  52315. * Checks to see if a texture is used in the material.
  52316. * @param texture - Base texture to use.
  52317. * @returns - Boolean specifying if a texture is used in the material.
  52318. */
  52319. hasTexture(texture: BaseTexture): boolean;
  52320. /**
  52321. * Dispose the material.
  52322. * @param forceDisposeEffect Force disposal of the associated effect.
  52323. * @param forceDisposeTextures Force disposal of the associated textures.
  52324. */
  52325. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52326. /**
  52327. * Clones the material.
  52328. * @param name The cloned name.
  52329. * @returns The cloned material.
  52330. */
  52331. clone(name: string): BackgroundMaterial;
  52332. /**
  52333. * Serializes the current material to its JSON representation.
  52334. * @returns The JSON representation.
  52335. */
  52336. serialize(): any;
  52337. /**
  52338. * Gets the class name of the material
  52339. * @returns "BackgroundMaterial"
  52340. */
  52341. getClassName(): string;
  52342. /**
  52343. * Parse a JSON input to create back a background material.
  52344. * @param source The JSON data to parse
  52345. * @param scene The scene to create the parsed material in
  52346. * @param rootUrl The root url of the assets the material depends upon
  52347. * @returns the instantiated BackgroundMaterial.
  52348. */
  52349. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52350. }
  52351. }
  52352. declare module "babylonjs/Helpers/environmentHelper" {
  52353. import { Observable } from "babylonjs/Misc/observable";
  52354. import { Nullable } from "babylonjs/types";
  52355. import { Scene } from "babylonjs/scene";
  52356. import { Vector3 } from "babylonjs/Maths/math.vector";
  52357. import { Color3 } from "babylonjs/Maths/math.color";
  52358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52359. import { Mesh } from "babylonjs/Meshes/mesh";
  52360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52361. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  52362. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52363. import "babylonjs/Meshes/Builders/planeBuilder";
  52364. import "babylonjs/Meshes/Builders/boxBuilder";
  52365. /**
  52366. * Represents the different options available during the creation of
  52367. * a Environment helper.
  52368. *
  52369. * This can control the default ground, skybox and image processing setup of your scene.
  52370. */
  52371. export interface IEnvironmentHelperOptions {
  52372. /**
  52373. * Specifies whether or not to create a ground.
  52374. * True by default.
  52375. */
  52376. createGround: boolean;
  52377. /**
  52378. * Specifies the ground size.
  52379. * 15 by default.
  52380. */
  52381. groundSize: number;
  52382. /**
  52383. * The texture used on the ground for the main color.
  52384. * Comes from the BabylonJS CDN by default.
  52385. *
  52386. * Remarks: Can be either a texture or a url.
  52387. */
  52388. groundTexture: string | BaseTexture;
  52389. /**
  52390. * The color mixed in the ground texture by default.
  52391. * BabylonJS clearColor by default.
  52392. */
  52393. groundColor: Color3;
  52394. /**
  52395. * Specifies the ground opacity.
  52396. * 1 by default.
  52397. */
  52398. groundOpacity: number;
  52399. /**
  52400. * Enables the ground to receive shadows.
  52401. * True by default.
  52402. */
  52403. enableGroundShadow: boolean;
  52404. /**
  52405. * Helps preventing the shadow to be fully black on the ground.
  52406. * 0.5 by default.
  52407. */
  52408. groundShadowLevel: number;
  52409. /**
  52410. * Creates a mirror texture attach to the ground.
  52411. * false by default.
  52412. */
  52413. enableGroundMirror: boolean;
  52414. /**
  52415. * Specifies the ground mirror size ratio.
  52416. * 0.3 by default as the default kernel is 64.
  52417. */
  52418. groundMirrorSizeRatio: number;
  52419. /**
  52420. * Specifies the ground mirror blur kernel size.
  52421. * 64 by default.
  52422. */
  52423. groundMirrorBlurKernel: number;
  52424. /**
  52425. * Specifies the ground mirror visibility amount.
  52426. * 1 by default
  52427. */
  52428. groundMirrorAmount: number;
  52429. /**
  52430. * Specifies the ground mirror reflectance weight.
  52431. * This uses the standard weight of the background material to setup the fresnel effect
  52432. * of the mirror.
  52433. * 1 by default.
  52434. */
  52435. groundMirrorFresnelWeight: number;
  52436. /**
  52437. * Specifies the ground mirror Falloff distance.
  52438. * This can helps reducing the size of the reflection.
  52439. * 0 by Default.
  52440. */
  52441. groundMirrorFallOffDistance: number;
  52442. /**
  52443. * Specifies the ground mirror texture type.
  52444. * Unsigned Int by Default.
  52445. */
  52446. groundMirrorTextureType: number;
  52447. /**
  52448. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52449. * the shown objects.
  52450. */
  52451. groundYBias: number;
  52452. /**
  52453. * Specifies whether or not to create a skybox.
  52454. * True by default.
  52455. */
  52456. createSkybox: boolean;
  52457. /**
  52458. * Specifies the skybox size.
  52459. * 20 by default.
  52460. */
  52461. skyboxSize: number;
  52462. /**
  52463. * The texture used on the skybox for the main color.
  52464. * Comes from the BabylonJS CDN by default.
  52465. *
  52466. * Remarks: Can be either a texture or a url.
  52467. */
  52468. skyboxTexture: string | BaseTexture;
  52469. /**
  52470. * The color mixed in the skybox texture by default.
  52471. * BabylonJS clearColor by default.
  52472. */
  52473. skyboxColor: Color3;
  52474. /**
  52475. * The background rotation around the Y axis of the scene.
  52476. * This helps aligning the key lights of your scene with the background.
  52477. * 0 by default.
  52478. */
  52479. backgroundYRotation: number;
  52480. /**
  52481. * Compute automatically the size of the elements to best fit with the scene.
  52482. */
  52483. sizeAuto: boolean;
  52484. /**
  52485. * Default position of the rootMesh if autoSize is not true.
  52486. */
  52487. rootPosition: Vector3;
  52488. /**
  52489. * Sets up the image processing in the scene.
  52490. * true by default.
  52491. */
  52492. setupImageProcessing: boolean;
  52493. /**
  52494. * The texture used as your environment texture in the scene.
  52495. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52496. *
  52497. * Remarks: Can be either a texture or a url.
  52498. */
  52499. environmentTexture: string | BaseTexture;
  52500. /**
  52501. * The value of the exposure to apply to the scene.
  52502. * 0.6 by default if setupImageProcessing is true.
  52503. */
  52504. cameraExposure: number;
  52505. /**
  52506. * The value of the contrast to apply to the scene.
  52507. * 1.6 by default if setupImageProcessing is true.
  52508. */
  52509. cameraContrast: number;
  52510. /**
  52511. * Specifies whether or not tonemapping should be enabled in the scene.
  52512. * true by default if setupImageProcessing is true.
  52513. */
  52514. toneMappingEnabled: boolean;
  52515. }
  52516. /**
  52517. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52518. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52519. * It also helps with the default setup of your imageProcessing configuration.
  52520. */
  52521. export class EnvironmentHelper {
  52522. /**
  52523. * Default ground texture URL.
  52524. */
  52525. private static _groundTextureCDNUrl;
  52526. /**
  52527. * Default skybox texture URL.
  52528. */
  52529. private static _skyboxTextureCDNUrl;
  52530. /**
  52531. * Default environment texture URL.
  52532. */
  52533. private static _environmentTextureCDNUrl;
  52534. /**
  52535. * Creates the default options for the helper.
  52536. */
  52537. private static _getDefaultOptions;
  52538. private _rootMesh;
  52539. /**
  52540. * Gets the root mesh created by the helper.
  52541. */
  52542. get rootMesh(): Mesh;
  52543. private _skybox;
  52544. /**
  52545. * Gets the skybox created by the helper.
  52546. */
  52547. get skybox(): Nullable<Mesh>;
  52548. private _skyboxTexture;
  52549. /**
  52550. * Gets the skybox texture created by the helper.
  52551. */
  52552. get skyboxTexture(): Nullable<BaseTexture>;
  52553. private _skyboxMaterial;
  52554. /**
  52555. * Gets the skybox material created by the helper.
  52556. */
  52557. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52558. private _ground;
  52559. /**
  52560. * Gets the ground mesh created by the helper.
  52561. */
  52562. get ground(): Nullable<Mesh>;
  52563. private _groundTexture;
  52564. /**
  52565. * Gets the ground texture created by the helper.
  52566. */
  52567. get groundTexture(): Nullable<BaseTexture>;
  52568. private _groundMirror;
  52569. /**
  52570. * Gets the ground mirror created by the helper.
  52571. */
  52572. get groundMirror(): Nullable<MirrorTexture>;
  52573. /**
  52574. * Gets the ground mirror render list to helps pushing the meshes
  52575. * you wish in the ground reflection.
  52576. */
  52577. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52578. private _groundMaterial;
  52579. /**
  52580. * Gets the ground material created by the helper.
  52581. */
  52582. get groundMaterial(): Nullable<BackgroundMaterial>;
  52583. /**
  52584. * Stores the creation options.
  52585. */
  52586. private readonly _scene;
  52587. private _options;
  52588. /**
  52589. * This observable will be notified with any error during the creation of the environment,
  52590. * mainly texture creation errors.
  52591. */
  52592. onErrorObservable: Observable<{
  52593. message?: string;
  52594. exception?: any;
  52595. }>;
  52596. /**
  52597. * constructor
  52598. * @param options Defines the options we want to customize the helper
  52599. * @param scene The scene to add the material to
  52600. */
  52601. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52602. /**
  52603. * Updates the background according to the new options
  52604. * @param options
  52605. */
  52606. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52607. /**
  52608. * Sets the primary color of all the available elements.
  52609. * @param color the main color to affect to the ground and the background
  52610. */
  52611. setMainColor(color: Color3): void;
  52612. /**
  52613. * Setup the image processing according to the specified options.
  52614. */
  52615. private _setupImageProcessing;
  52616. /**
  52617. * Setup the environment texture according to the specified options.
  52618. */
  52619. private _setupEnvironmentTexture;
  52620. /**
  52621. * Setup the background according to the specified options.
  52622. */
  52623. private _setupBackground;
  52624. /**
  52625. * Get the scene sizes according to the setup.
  52626. */
  52627. private _getSceneSize;
  52628. /**
  52629. * Setup the ground according to the specified options.
  52630. */
  52631. private _setupGround;
  52632. /**
  52633. * Setup the ground material according to the specified options.
  52634. */
  52635. private _setupGroundMaterial;
  52636. /**
  52637. * Setup the ground diffuse texture according to the specified options.
  52638. */
  52639. private _setupGroundDiffuseTexture;
  52640. /**
  52641. * Setup the ground mirror texture according to the specified options.
  52642. */
  52643. private _setupGroundMirrorTexture;
  52644. /**
  52645. * Setup the ground to receive the mirror texture.
  52646. */
  52647. private _setupMirrorInGroundMaterial;
  52648. /**
  52649. * Setup the skybox according to the specified options.
  52650. */
  52651. private _setupSkybox;
  52652. /**
  52653. * Setup the skybox material according to the specified options.
  52654. */
  52655. private _setupSkyboxMaterial;
  52656. /**
  52657. * Setup the skybox reflection texture according to the specified options.
  52658. */
  52659. private _setupSkyboxReflectionTexture;
  52660. private _errorHandler;
  52661. /**
  52662. * Dispose all the elements created by the Helper.
  52663. */
  52664. dispose(): void;
  52665. }
  52666. }
  52667. declare module "babylonjs/Helpers/photoDome" {
  52668. import { Observable } from "babylonjs/Misc/observable";
  52669. import { Nullable } from "babylonjs/types";
  52670. import { Scene } from "babylonjs/scene";
  52671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52672. import { Mesh } from "babylonjs/Meshes/mesh";
  52673. import { Texture } from "babylonjs/Materials/Textures/texture";
  52674. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52675. import "babylonjs/Meshes/Builders/sphereBuilder";
  52676. /**
  52677. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52678. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52679. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52680. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52681. */
  52682. export class PhotoDome extends TransformNode {
  52683. /**
  52684. * Define the image as a Monoscopic panoramic 360 image.
  52685. */
  52686. static readonly MODE_MONOSCOPIC: number;
  52687. /**
  52688. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52689. */
  52690. static readonly MODE_TOPBOTTOM: number;
  52691. /**
  52692. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52693. */
  52694. static readonly MODE_SIDEBYSIDE: number;
  52695. private _useDirectMapping;
  52696. /**
  52697. * The texture being displayed on the sphere
  52698. */
  52699. protected _photoTexture: Texture;
  52700. /**
  52701. * Gets or sets the texture being displayed on the sphere
  52702. */
  52703. get photoTexture(): Texture;
  52704. set photoTexture(value: Texture);
  52705. /**
  52706. * Observable raised when an error occured while loading the 360 image
  52707. */
  52708. onLoadErrorObservable: Observable<string>;
  52709. /**
  52710. * The skybox material
  52711. */
  52712. protected _material: BackgroundMaterial;
  52713. /**
  52714. * The surface used for the skybox
  52715. */
  52716. protected _mesh: Mesh;
  52717. /**
  52718. * Gets the mesh used for the skybox.
  52719. */
  52720. get mesh(): Mesh;
  52721. /**
  52722. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52723. * Also see the options.resolution property.
  52724. */
  52725. get fovMultiplier(): number;
  52726. set fovMultiplier(value: number);
  52727. private _imageMode;
  52728. /**
  52729. * Gets or set the current video mode for the video. It can be:
  52730. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52731. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52732. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52733. */
  52734. get imageMode(): number;
  52735. set imageMode(value: number);
  52736. /**
  52737. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52738. * @param name Element's name, child elements will append suffixes for their own names.
  52739. * @param urlsOfPhoto defines the url of the photo to display
  52740. * @param options defines an object containing optional or exposed sub element properties
  52741. * @param onError defines a callback called when an error occured while loading the texture
  52742. */
  52743. constructor(name: string, urlOfPhoto: string, options: {
  52744. resolution?: number;
  52745. size?: number;
  52746. useDirectMapping?: boolean;
  52747. faceForward?: boolean;
  52748. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52749. private _onBeforeCameraRenderObserver;
  52750. private _changeImageMode;
  52751. /**
  52752. * Releases resources associated with this node.
  52753. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52754. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52755. */
  52756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52757. }
  52758. }
  52759. declare module "babylonjs/Misc/rgbdTextureTools" {
  52760. import "babylonjs/Shaders/rgbdDecode.fragment";
  52761. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52762. import { Texture } from "babylonjs/Materials/Textures/texture";
  52763. /**
  52764. * Class used to host RGBD texture specific utilities
  52765. */
  52766. export class RGBDTextureTools {
  52767. /**
  52768. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52769. * @param texture the texture to expand.
  52770. */
  52771. static ExpandRGBDTexture(texture: Texture): void;
  52772. }
  52773. }
  52774. declare module "babylonjs/Misc/brdfTextureTools" {
  52775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52776. import { Scene } from "babylonjs/scene";
  52777. /**
  52778. * Class used to host texture specific utilities
  52779. */
  52780. export class BRDFTextureTools {
  52781. /**
  52782. * Prevents texture cache collision
  52783. */
  52784. private static _instanceNumber;
  52785. /**
  52786. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52787. * @param scene defines the hosting scene
  52788. * @returns the environment BRDF texture
  52789. */
  52790. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52791. private static _environmentBRDFBase64Texture;
  52792. }
  52793. }
  52794. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52795. import { Nullable } from "babylonjs/types";
  52796. import { Color3 } from "babylonjs/Maths/math.color";
  52797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52798. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52799. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52800. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52801. import { Engine } from "babylonjs/Engines/engine";
  52802. import { Scene } from "babylonjs/scene";
  52803. /**
  52804. * @hidden
  52805. */
  52806. export interface IMaterialClearCoatDefines {
  52807. CLEARCOAT: boolean;
  52808. CLEARCOAT_DEFAULTIOR: boolean;
  52809. CLEARCOAT_TEXTURE: boolean;
  52810. CLEARCOAT_TEXTUREDIRECTUV: number;
  52811. CLEARCOAT_BUMP: boolean;
  52812. CLEARCOAT_BUMPDIRECTUV: number;
  52813. CLEARCOAT_TINT: boolean;
  52814. CLEARCOAT_TINT_TEXTURE: boolean;
  52815. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52816. /** @hidden */
  52817. _areTexturesDirty: boolean;
  52818. }
  52819. /**
  52820. * Define the code related to the clear coat parameters of the pbr material.
  52821. */
  52822. export class PBRClearCoatConfiguration {
  52823. /**
  52824. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52825. * The default fits with a polyurethane material.
  52826. */
  52827. private static readonly _DefaultIndexOfRefraction;
  52828. private _isEnabled;
  52829. /**
  52830. * Defines if the clear coat is enabled in the material.
  52831. */
  52832. isEnabled: boolean;
  52833. /**
  52834. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52835. */
  52836. intensity: number;
  52837. /**
  52838. * Defines the clear coat layer roughness.
  52839. */
  52840. roughness: number;
  52841. private _indexOfRefraction;
  52842. /**
  52843. * Defines the index of refraction of the clear coat.
  52844. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52845. * The default fits with a polyurethane material.
  52846. * Changing the default value is more performance intensive.
  52847. */
  52848. indexOfRefraction: number;
  52849. private _texture;
  52850. /**
  52851. * Stores the clear coat values in a texture.
  52852. */
  52853. texture: Nullable<BaseTexture>;
  52854. private _bumpTexture;
  52855. /**
  52856. * Define the clear coat specific bump texture.
  52857. */
  52858. bumpTexture: Nullable<BaseTexture>;
  52859. private _isTintEnabled;
  52860. /**
  52861. * Defines if the clear coat tint is enabled in the material.
  52862. */
  52863. isTintEnabled: boolean;
  52864. /**
  52865. * Defines the clear coat tint of the material.
  52866. * This is only use if tint is enabled
  52867. */
  52868. tintColor: Color3;
  52869. /**
  52870. * Defines the distance at which the tint color should be found in the
  52871. * clear coat media.
  52872. * This is only use if tint is enabled
  52873. */
  52874. tintColorAtDistance: number;
  52875. /**
  52876. * Defines the clear coat layer thickness.
  52877. * This is only use if tint is enabled
  52878. */
  52879. tintThickness: number;
  52880. private _tintTexture;
  52881. /**
  52882. * Stores the clear tint values in a texture.
  52883. * rgb is tint
  52884. * a is a thickness factor
  52885. */
  52886. tintTexture: Nullable<BaseTexture>;
  52887. /** @hidden */
  52888. private _internalMarkAllSubMeshesAsTexturesDirty;
  52889. /** @hidden */
  52890. _markAllSubMeshesAsTexturesDirty(): void;
  52891. /**
  52892. * Instantiate a new istance of clear coat configuration.
  52893. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52894. */
  52895. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52896. /**
  52897. * Gets wehter the submesh is ready to be used or not.
  52898. * @param defines the list of "defines" to update.
  52899. * @param scene defines the scene the material belongs to.
  52900. * @param engine defines the engine the material belongs to.
  52901. * @param disableBumpMap defines wether the material disables bump or not.
  52902. * @returns - boolean indicating that the submesh is ready or not.
  52903. */
  52904. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52905. /**
  52906. * Checks to see if a texture is used in the material.
  52907. * @param defines the list of "defines" to update.
  52908. * @param scene defines the scene to the material belongs to.
  52909. */
  52910. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52911. /**
  52912. * Binds the material data.
  52913. * @param uniformBuffer defines the Uniform buffer to fill in.
  52914. * @param scene defines the scene the material belongs to.
  52915. * @param engine defines the engine the material belongs to.
  52916. * @param disableBumpMap defines wether the material disables bump or not.
  52917. * @param isFrozen defines wether the material is frozen or not.
  52918. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52919. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52920. */
  52921. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52922. /**
  52923. * Checks to see if a texture is used in the material.
  52924. * @param texture - Base texture to use.
  52925. * @returns - Boolean specifying if a texture is used in the material.
  52926. */
  52927. hasTexture(texture: BaseTexture): boolean;
  52928. /**
  52929. * Returns an array of the actively used textures.
  52930. * @param activeTextures Array of BaseTextures
  52931. */
  52932. getActiveTextures(activeTextures: BaseTexture[]): void;
  52933. /**
  52934. * Returns the animatable textures.
  52935. * @param animatables Array of animatable textures.
  52936. */
  52937. getAnimatables(animatables: IAnimatable[]): void;
  52938. /**
  52939. * Disposes the resources of the material.
  52940. * @param forceDisposeTextures - Forces the disposal of all textures.
  52941. */
  52942. dispose(forceDisposeTextures?: boolean): void;
  52943. /**
  52944. * Get the current class name of the texture useful for serialization or dynamic coding.
  52945. * @returns "PBRClearCoatConfiguration"
  52946. */
  52947. getClassName(): string;
  52948. /**
  52949. * Add fallbacks to the effect fallbacks list.
  52950. * @param defines defines the Base texture to use.
  52951. * @param fallbacks defines the current fallback list.
  52952. * @param currentRank defines the current fallback rank.
  52953. * @returns the new fallback rank.
  52954. */
  52955. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52956. /**
  52957. * Add the required uniforms to the current list.
  52958. * @param uniforms defines the current uniform list.
  52959. */
  52960. static AddUniforms(uniforms: string[]): void;
  52961. /**
  52962. * Add the required samplers to the current list.
  52963. * @param samplers defines the current sampler list.
  52964. */
  52965. static AddSamplers(samplers: string[]): void;
  52966. /**
  52967. * Add the required uniforms to the current buffer.
  52968. * @param uniformBuffer defines the current uniform buffer.
  52969. */
  52970. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52971. /**
  52972. * Makes a duplicate of the current configuration into another one.
  52973. * @param clearCoatConfiguration define the config where to copy the info
  52974. */
  52975. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52976. /**
  52977. * Serializes this clear coat configuration.
  52978. * @returns - An object with the serialized config.
  52979. */
  52980. serialize(): any;
  52981. /**
  52982. * Parses a anisotropy Configuration from a serialized object.
  52983. * @param source - Serialized object.
  52984. * @param scene Defines the scene we are parsing for
  52985. * @param rootUrl Defines the rootUrl to load from
  52986. */
  52987. parse(source: any, scene: Scene, rootUrl: string): void;
  52988. }
  52989. }
  52990. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52991. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52993. import { Vector2 } from "babylonjs/Maths/math.vector";
  52994. import { Scene } from "babylonjs/scene";
  52995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52996. import { Nullable } from "babylonjs/types";
  52997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52998. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52999. /**
  53000. * @hidden
  53001. */
  53002. export interface IMaterialAnisotropicDefines {
  53003. ANISOTROPIC: boolean;
  53004. ANISOTROPIC_TEXTURE: boolean;
  53005. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53006. MAINUV1: boolean;
  53007. _areTexturesDirty: boolean;
  53008. _needUVs: boolean;
  53009. }
  53010. /**
  53011. * Define the code related to the anisotropic parameters of the pbr material.
  53012. */
  53013. export class PBRAnisotropicConfiguration {
  53014. private _isEnabled;
  53015. /**
  53016. * Defines if the anisotropy is enabled in the material.
  53017. */
  53018. isEnabled: boolean;
  53019. /**
  53020. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53021. */
  53022. intensity: number;
  53023. /**
  53024. * Defines if the effect is along the tangents, bitangents or in between.
  53025. * By default, the effect is "strectching" the highlights along the tangents.
  53026. */
  53027. direction: Vector2;
  53028. private _texture;
  53029. /**
  53030. * Stores the anisotropy values in a texture.
  53031. * rg is direction (like normal from -1 to 1)
  53032. * b is a intensity
  53033. */
  53034. texture: Nullable<BaseTexture>;
  53035. /** @hidden */
  53036. private _internalMarkAllSubMeshesAsTexturesDirty;
  53037. /** @hidden */
  53038. _markAllSubMeshesAsTexturesDirty(): void;
  53039. /**
  53040. * Instantiate a new istance of anisotropy configuration.
  53041. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53042. */
  53043. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53044. /**
  53045. * Specifies that the submesh is ready to be used.
  53046. * @param defines the list of "defines" to update.
  53047. * @param scene defines the scene the material belongs to.
  53048. * @returns - boolean indicating that the submesh is ready or not.
  53049. */
  53050. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53051. /**
  53052. * Checks to see if a texture is used in the material.
  53053. * @param defines the list of "defines" to update.
  53054. * @param mesh the mesh we are preparing the defines for.
  53055. * @param scene defines the scene the material belongs to.
  53056. */
  53057. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53058. /**
  53059. * Binds the material data.
  53060. * @param uniformBuffer defines the Uniform buffer to fill in.
  53061. * @param scene defines the scene the material belongs to.
  53062. * @param isFrozen defines wether the material is frozen or not.
  53063. */
  53064. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53065. /**
  53066. * Checks to see if a texture is used in the material.
  53067. * @param texture - Base texture to use.
  53068. * @returns - Boolean specifying if a texture is used in the material.
  53069. */
  53070. hasTexture(texture: BaseTexture): boolean;
  53071. /**
  53072. * Returns an array of the actively used textures.
  53073. * @param activeTextures Array of BaseTextures
  53074. */
  53075. getActiveTextures(activeTextures: BaseTexture[]): void;
  53076. /**
  53077. * Returns the animatable textures.
  53078. * @param animatables Array of animatable textures.
  53079. */
  53080. getAnimatables(animatables: IAnimatable[]): void;
  53081. /**
  53082. * Disposes the resources of the material.
  53083. * @param forceDisposeTextures - Forces the disposal of all textures.
  53084. */
  53085. dispose(forceDisposeTextures?: boolean): void;
  53086. /**
  53087. * Get the current class name of the texture useful for serialization or dynamic coding.
  53088. * @returns "PBRAnisotropicConfiguration"
  53089. */
  53090. getClassName(): string;
  53091. /**
  53092. * Add fallbacks to the effect fallbacks list.
  53093. * @param defines defines the Base texture to use.
  53094. * @param fallbacks defines the current fallback list.
  53095. * @param currentRank defines the current fallback rank.
  53096. * @returns the new fallback rank.
  53097. */
  53098. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53099. /**
  53100. * Add the required uniforms to the current list.
  53101. * @param uniforms defines the current uniform list.
  53102. */
  53103. static AddUniforms(uniforms: string[]): void;
  53104. /**
  53105. * Add the required uniforms to the current buffer.
  53106. * @param uniformBuffer defines the current uniform buffer.
  53107. */
  53108. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53109. /**
  53110. * Add the required samplers to the current list.
  53111. * @param samplers defines the current sampler list.
  53112. */
  53113. static AddSamplers(samplers: string[]): void;
  53114. /**
  53115. * Makes a duplicate of the current configuration into another one.
  53116. * @param anisotropicConfiguration define the config where to copy the info
  53117. */
  53118. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53119. /**
  53120. * Serializes this anisotropy configuration.
  53121. * @returns - An object with the serialized config.
  53122. */
  53123. serialize(): any;
  53124. /**
  53125. * Parses a anisotropy Configuration from a serialized object.
  53126. * @param source - Serialized object.
  53127. * @param scene Defines the scene we are parsing for
  53128. * @param rootUrl Defines the rootUrl to load from
  53129. */
  53130. parse(source: any, scene: Scene, rootUrl: string): void;
  53131. }
  53132. }
  53133. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  53134. import { Scene } from "babylonjs/scene";
  53135. /**
  53136. * @hidden
  53137. */
  53138. export interface IMaterialBRDFDefines {
  53139. BRDF_V_HEIGHT_CORRELATED: boolean;
  53140. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53141. SPHERICAL_HARMONICS: boolean;
  53142. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53143. /** @hidden */
  53144. _areMiscDirty: boolean;
  53145. }
  53146. /**
  53147. * Define the code related to the BRDF parameters of the pbr material.
  53148. */
  53149. export class PBRBRDFConfiguration {
  53150. /**
  53151. * Default value used for the energy conservation.
  53152. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53153. */
  53154. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53155. /**
  53156. * Default value used for the Smith Visibility Height Correlated mode.
  53157. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53158. */
  53159. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53160. /**
  53161. * Default value used for the IBL diffuse part.
  53162. * This can help switching back to the polynomials mode globally which is a tiny bit
  53163. * less GPU intensive at the drawback of a lower quality.
  53164. */
  53165. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53166. /**
  53167. * Default value used for activating energy conservation for the specular workflow.
  53168. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53169. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53170. */
  53171. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53172. private _useEnergyConservation;
  53173. /**
  53174. * Defines if the material uses energy conservation.
  53175. */
  53176. useEnergyConservation: boolean;
  53177. private _useSmithVisibilityHeightCorrelated;
  53178. /**
  53179. * LEGACY Mode set to false
  53180. * Defines if the material uses height smith correlated visibility term.
  53181. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53182. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53183. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53184. * Not relying on height correlated will also disable energy conservation.
  53185. */
  53186. useSmithVisibilityHeightCorrelated: boolean;
  53187. private _useSphericalHarmonics;
  53188. /**
  53189. * LEGACY Mode set to false
  53190. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53191. * diffuse part of the IBL.
  53192. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53193. * to the ground truth.
  53194. */
  53195. useSphericalHarmonics: boolean;
  53196. private _useSpecularGlossinessInputEnergyConservation;
  53197. /**
  53198. * Defines if the material uses energy conservation, when the specular workflow is active.
  53199. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53200. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53201. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53202. */
  53203. useSpecularGlossinessInputEnergyConservation: boolean;
  53204. /** @hidden */
  53205. private _internalMarkAllSubMeshesAsMiscDirty;
  53206. /** @hidden */
  53207. _markAllSubMeshesAsMiscDirty(): void;
  53208. /**
  53209. * Instantiate a new istance of clear coat configuration.
  53210. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53211. */
  53212. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53213. /**
  53214. * Checks to see if a texture is used in the material.
  53215. * @param defines the list of "defines" to update.
  53216. */
  53217. prepareDefines(defines: IMaterialBRDFDefines): void;
  53218. /**
  53219. * Get the current class name of the texture useful for serialization or dynamic coding.
  53220. * @returns "PBRClearCoatConfiguration"
  53221. */
  53222. getClassName(): string;
  53223. /**
  53224. * Makes a duplicate of the current configuration into another one.
  53225. * @param brdfConfiguration define the config where to copy the info
  53226. */
  53227. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53228. /**
  53229. * Serializes this BRDF configuration.
  53230. * @returns - An object with the serialized config.
  53231. */
  53232. serialize(): any;
  53233. /**
  53234. * Parses a anisotropy Configuration from a serialized object.
  53235. * @param source - Serialized object.
  53236. * @param scene Defines the scene we are parsing for
  53237. * @param rootUrl Defines the rootUrl to load from
  53238. */
  53239. parse(source: any, scene: Scene, rootUrl: string): void;
  53240. }
  53241. }
  53242. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  53243. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53244. import { Color3 } from "babylonjs/Maths/math.color";
  53245. import { Scene } from "babylonjs/scene";
  53246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53247. import { Nullable } from "babylonjs/types";
  53248. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53249. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53250. /**
  53251. * @hidden
  53252. */
  53253. export interface IMaterialSheenDefines {
  53254. SHEEN: boolean;
  53255. SHEEN_TEXTURE: boolean;
  53256. SHEEN_TEXTUREDIRECTUV: number;
  53257. SHEEN_LINKWITHALBEDO: boolean;
  53258. SHEEN_ROUGHNESS: boolean;
  53259. SHEEN_ALBEDOSCALING: boolean;
  53260. /** @hidden */
  53261. _areTexturesDirty: boolean;
  53262. }
  53263. /**
  53264. * Define the code related to the Sheen parameters of the pbr material.
  53265. */
  53266. export class PBRSheenConfiguration {
  53267. private _isEnabled;
  53268. /**
  53269. * Defines if the material uses sheen.
  53270. */
  53271. isEnabled: boolean;
  53272. private _linkSheenWithAlbedo;
  53273. /**
  53274. * Defines if the sheen is linked to the sheen color.
  53275. */
  53276. linkSheenWithAlbedo: boolean;
  53277. /**
  53278. * Defines the sheen intensity.
  53279. */
  53280. intensity: number;
  53281. /**
  53282. * Defines the sheen color.
  53283. */
  53284. color: Color3;
  53285. private _texture;
  53286. /**
  53287. * Stores the sheen tint values in a texture.
  53288. * rgb is tint
  53289. * a is a intensity
  53290. */
  53291. texture: Nullable<BaseTexture>;
  53292. private _roughness;
  53293. /**
  53294. * Defines the sheen roughness.
  53295. * It is not taken into account if linkSheenWithAlbedo is true.
  53296. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53297. */
  53298. roughness: Nullable<number>;
  53299. private _albedoScaling;
  53300. /**
  53301. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53302. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53303. * making it easier to setup and tweak the effect
  53304. */
  53305. albedoScaling: boolean;
  53306. /** @hidden */
  53307. private _internalMarkAllSubMeshesAsTexturesDirty;
  53308. /** @hidden */
  53309. _markAllSubMeshesAsTexturesDirty(): void;
  53310. /**
  53311. * Instantiate a new istance of clear coat configuration.
  53312. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53313. */
  53314. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53315. /**
  53316. * Specifies that the submesh is ready to be used.
  53317. * @param defines the list of "defines" to update.
  53318. * @param scene defines the scene the material belongs to.
  53319. * @returns - boolean indicating that the submesh is ready or not.
  53320. */
  53321. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53322. /**
  53323. * Checks to see if a texture is used in the material.
  53324. * @param defines the list of "defines" to update.
  53325. * @param scene defines the scene the material belongs to.
  53326. */
  53327. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53328. /**
  53329. * Binds the material data.
  53330. * @param uniformBuffer defines the Uniform buffer to fill in.
  53331. * @param scene defines the scene the material belongs to.
  53332. * @param isFrozen defines wether the material is frozen or not.
  53333. */
  53334. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53335. /**
  53336. * Checks to see if a texture is used in the material.
  53337. * @param texture - Base texture to use.
  53338. * @returns - Boolean specifying if a texture is used in the material.
  53339. */
  53340. hasTexture(texture: BaseTexture): boolean;
  53341. /**
  53342. * Returns an array of the actively used textures.
  53343. * @param activeTextures Array of BaseTextures
  53344. */
  53345. getActiveTextures(activeTextures: BaseTexture[]): void;
  53346. /**
  53347. * Returns the animatable textures.
  53348. * @param animatables Array of animatable textures.
  53349. */
  53350. getAnimatables(animatables: IAnimatable[]): void;
  53351. /**
  53352. * Disposes the resources of the material.
  53353. * @param forceDisposeTextures - Forces the disposal of all textures.
  53354. */
  53355. dispose(forceDisposeTextures?: boolean): void;
  53356. /**
  53357. * Get the current class name of the texture useful for serialization or dynamic coding.
  53358. * @returns "PBRSheenConfiguration"
  53359. */
  53360. getClassName(): string;
  53361. /**
  53362. * Add fallbacks to the effect fallbacks list.
  53363. * @param defines defines the Base texture to use.
  53364. * @param fallbacks defines the current fallback list.
  53365. * @param currentRank defines the current fallback rank.
  53366. * @returns the new fallback rank.
  53367. */
  53368. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53369. /**
  53370. * Add the required uniforms to the current list.
  53371. * @param uniforms defines the current uniform list.
  53372. */
  53373. static AddUniforms(uniforms: string[]): void;
  53374. /**
  53375. * Add the required uniforms to the current buffer.
  53376. * @param uniformBuffer defines the current uniform buffer.
  53377. */
  53378. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53379. /**
  53380. * Add the required samplers to the current list.
  53381. * @param samplers defines the current sampler list.
  53382. */
  53383. static AddSamplers(samplers: string[]): void;
  53384. /**
  53385. * Makes a duplicate of the current configuration into another one.
  53386. * @param sheenConfiguration define the config where to copy the info
  53387. */
  53388. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53389. /**
  53390. * Serializes this BRDF configuration.
  53391. * @returns - An object with the serialized config.
  53392. */
  53393. serialize(): any;
  53394. /**
  53395. * Parses a anisotropy Configuration from a serialized object.
  53396. * @param source - Serialized object.
  53397. * @param scene Defines the scene we are parsing for
  53398. * @param rootUrl Defines the rootUrl to load from
  53399. */
  53400. parse(source: any, scene: Scene, rootUrl: string): void;
  53401. }
  53402. }
  53403. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53404. import { Nullable } from "babylonjs/types";
  53405. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53406. import { Color3 } from "babylonjs/Maths/math.color";
  53407. import { SmartArray } from "babylonjs/Misc/smartArray";
  53408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53410. import { Effect } from "babylonjs/Materials/effect";
  53411. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53412. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53413. import { Engine } from "babylonjs/Engines/engine";
  53414. import { Scene } from "babylonjs/scene";
  53415. /**
  53416. * @hidden
  53417. */
  53418. export interface IMaterialSubSurfaceDefines {
  53419. SUBSURFACE: boolean;
  53420. SS_REFRACTION: boolean;
  53421. SS_TRANSLUCENCY: boolean;
  53422. SS_SCATERRING: boolean;
  53423. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53424. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53425. SS_REFRACTIONMAP_3D: boolean;
  53426. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53427. SS_LODINREFRACTIONALPHA: boolean;
  53428. SS_GAMMAREFRACTION: boolean;
  53429. SS_RGBDREFRACTION: boolean;
  53430. SS_LINEARSPECULARREFRACTION: boolean;
  53431. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53432. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53433. /** @hidden */
  53434. _areTexturesDirty: boolean;
  53435. }
  53436. /**
  53437. * Define the code related to the sub surface parameters of the pbr material.
  53438. */
  53439. export class PBRSubSurfaceConfiguration {
  53440. private _isRefractionEnabled;
  53441. /**
  53442. * Defines if the refraction is enabled in the material.
  53443. */
  53444. isRefractionEnabled: boolean;
  53445. private _isTranslucencyEnabled;
  53446. /**
  53447. * Defines if the translucency is enabled in the material.
  53448. */
  53449. isTranslucencyEnabled: boolean;
  53450. private _isScatteringEnabled;
  53451. /**
  53452. * Defines the refraction intensity of the material.
  53453. * The refraction when enabled replaces the Diffuse part of the material.
  53454. * The intensity helps transitionning between diffuse and refraction.
  53455. */
  53456. refractionIntensity: number;
  53457. /**
  53458. * Defines the translucency intensity of the material.
  53459. * When translucency has been enabled, this defines how much of the "translucency"
  53460. * is addded to the diffuse part of the material.
  53461. */
  53462. translucencyIntensity: number;
  53463. /**
  53464. * Defines the scattering intensity of the material.
  53465. * When scattering has been enabled, this defines how much of the "scattered light"
  53466. * is addded to the diffuse part of the material.
  53467. */
  53468. scatteringIntensity: number;
  53469. private _thicknessTexture;
  53470. /**
  53471. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53472. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53473. * 0 would mean minimumThickness
  53474. * 1 would mean maximumThickness
  53475. * The other channels might be use as a mask to vary the different effects intensity.
  53476. */
  53477. thicknessTexture: Nullable<BaseTexture>;
  53478. private _refractionTexture;
  53479. /**
  53480. * Defines the texture to use for refraction.
  53481. */
  53482. refractionTexture: Nullable<BaseTexture>;
  53483. private _indexOfRefraction;
  53484. /**
  53485. * Defines the index of refraction used in the material.
  53486. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53487. */
  53488. indexOfRefraction: number;
  53489. private _invertRefractionY;
  53490. /**
  53491. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53492. */
  53493. invertRefractionY: boolean;
  53494. private _linkRefractionWithTransparency;
  53495. /**
  53496. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53497. * Materials half opaque for instance using refraction could benefit from this control.
  53498. */
  53499. linkRefractionWithTransparency: boolean;
  53500. /**
  53501. * Defines the minimum thickness stored in the thickness map.
  53502. * If no thickness map is defined, this value will be used to simulate thickness.
  53503. */
  53504. minimumThickness: number;
  53505. /**
  53506. * Defines the maximum thickness stored in the thickness map.
  53507. */
  53508. maximumThickness: number;
  53509. /**
  53510. * Defines the volume tint of the material.
  53511. * This is used for both translucency and scattering.
  53512. */
  53513. tintColor: Color3;
  53514. /**
  53515. * Defines the distance at which the tint color should be found in the media.
  53516. * This is used for refraction only.
  53517. */
  53518. tintColorAtDistance: number;
  53519. /**
  53520. * Defines how far each channel transmit through the media.
  53521. * It is defined as a color to simplify it selection.
  53522. */
  53523. diffusionDistance: Color3;
  53524. private _useMaskFromThicknessTexture;
  53525. /**
  53526. * Stores the intensity of the different subsurface effects in the thickness texture.
  53527. * * the green channel is the translucency intensity.
  53528. * * the blue channel is the scattering intensity.
  53529. * * the alpha channel is the refraction intensity.
  53530. */
  53531. useMaskFromThicknessTexture: boolean;
  53532. /** @hidden */
  53533. private _internalMarkAllSubMeshesAsTexturesDirty;
  53534. /** @hidden */
  53535. _markAllSubMeshesAsTexturesDirty(): void;
  53536. /**
  53537. * Instantiate a new istance of sub surface configuration.
  53538. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53539. */
  53540. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53541. /**
  53542. * Gets wehter the submesh is ready to be used or not.
  53543. * @param defines the list of "defines" to update.
  53544. * @param scene defines the scene the material belongs to.
  53545. * @returns - boolean indicating that the submesh is ready or not.
  53546. */
  53547. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53548. /**
  53549. * Checks to see if a texture is used in the material.
  53550. * @param defines the list of "defines" to update.
  53551. * @param scene defines the scene to the material belongs to.
  53552. */
  53553. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53554. /**
  53555. * Binds the material data.
  53556. * @param uniformBuffer defines the Uniform buffer to fill in.
  53557. * @param scene defines the scene the material belongs to.
  53558. * @param engine defines the engine the material belongs to.
  53559. * @param isFrozen defines wether the material is frozen or not.
  53560. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53561. */
  53562. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53563. /**
  53564. * Unbinds the material from the mesh.
  53565. * @param activeEffect defines the effect that should be unbound from.
  53566. * @returns true if unbound, otherwise false
  53567. */
  53568. unbind(activeEffect: Effect): boolean;
  53569. /**
  53570. * Returns the texture used for refraction or null if none is used.
  53571. * @param scene defines the scene the material belongs to.
  53572. * @returns - Refraction texture if present. If no refraction texture and refraction
  53573. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53574. */
  53575. private _getRefractionTexture;
  53576. /**
  53577. * Returns true if alpha blending should be disabled.
  53578. */
  53579. get disableAlphaBlending(): boolean;
  53580. /**
  53581. * Fills the list of render target textures.
  53582. * @param renderTargets the list of render targets to update
  53583. */
  53584. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53585. /**
  53586. * Checks to see if a texture is used in the material.
  53587. * @param texture - Base texture to use.
  53588. * @returns - Boolean specifying if a texture is used in the material.
  53589. */
  53590. hasTexture(texture: BaseTexture): boolean;
  53591. /**
  53592. * Gets a boolean indicating that current material needs to register RTT
  53593. * @returns true if this uses a render target otherwise false.
  53594. */
  53595. hasRenderTargetTextures(): boolean;
  53596. /**
  53597. * Returns an array of the actively used textures.
  53598. * @param activeTextures Array of BaseTextures
  53599. */
  53600. getActiveTextures(activeTextures: BaseTexture[]): void;
  53601. /**
  53602. * Returns the animatable textures.
  53603. * @param animatables Array of animatable textures.
  53604. */
  53605. getAnimatables(animatables: IAnimatable[]): void;
  53606. /**
  53607. * Disposes the resources of the material.
  53608. * @param forceDisposeTextures - Forces the disposal of all textures.
  53609. */
  53610. dispose(forceDisposeTextures?: boolean): void;
  53611. /**
  53612. * Get the current class name of the texture useful for serialization or dynamic coding.
  53613. * @returns "PBRSubSurfaceConfiguration"
  53614. */
  53615. getClassName(): string;
  53616. /**
  53617. * Add fallbacks to the effect fallbacks list.
  53618. * @param defines defines the Base texture to use.
  53619. * @param fallbacks defines the current fallback list.
  53620. * @param currentRank defines the current fallback rank.
  53621. * @returns the new fallback rank.
  53622. */
  53623. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53624. /**
  53625. * Add the required uniforms to the current list.
  53626. * @param uniforms defines the current uniform list.
  53627. */
  53628. static AddUniforms(uniforms: string[]): void;
  53629. /**
  53630. * Add the required samplers to the current list.
  53631. * @param samplers defines the current sampler list.
  53632. */
  53633. static AddSamplers(samplers: string[]): void;
  53634. /**
  53635. * Add the required uniforms to the current buffer.
  53636. * @param uniformBuffer defines the current uniform buffer.
  53637. */
  53638. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53639. /**
  53640. * Makes a duplicate of the current configuration into another one.
  53641. * @param configuration define the config where to copy the info
  53642. */
  53643. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53644. /**
  53645. * Serializes this Sub Surface configuration.
  53646. * @returns - An object with the serialized config.
  53647. */
  53648. serialize(): any;
  53649. /**
  53650. * Parses a anisotropy Configuration from a serialized object.
  53651. * @param source - Serialized object.
  53652. * @param scene Defines the scene we are parsing for
  53653. * @param rootUrl Defines the rootUrl to load from
  53654. */
  53655. parse(source: any, scene: Scene, rootUrl: string): void;
  53656. }
  53657. }
  53658. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53659. /** @hidden */
  53660. export var pbrFragmentDeclaration: {
  53661. name: string;
  53662. shader: string;
  53663. };
  53664. }
  53665. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53666. /** @hidden */
  53667. export var pbrUboDeclaration: {
  53668. name: string;
  53669. shader: string;
  53670. };
  53671. }
  53672. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53673. /** @hidden */
  53674. export var pbrFragmentExtraDeclaration: {
  53675. name: string;
  53676. shader: string;
  53677. };
  53678. }
  53679. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53680. /** @hidden */
  53681. export var pbrFragmentSamplersDeclaration: {
  53682. name: string;
  53683. shader: string;
  53684. };
  53685. }
  53686. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53687. /** @hidden */
  53688. export var pbrHelperFunctions: {
  53689. name: string;
  53690. shader: string;
  53691. };
  53692. }
  53693. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53694. /** @hidden */
  53695. export var harmonicsFunctions: {
  53696. name: string;
  53697. shader: string;
  53698. };
  53699. }
  53700. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53701. /** @hidden */
  53702. export var pbrDirectLightingSetupFunctions: {
  53703. name: string;
  53704. shader: string;
  53705. };
  53706. }
  53707. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53708. /** @hidden */
  53709. export var pbrDirectLightingFalloffFunctions: {
  53710. name: string;
  53711. shader: string;
  53712. };
  53713. }
  53714. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53715. /** @hidden */
  53716. export var pbrBRDFFunctions: {
  53717. name: string;
  53718. shader: string;
  53719. };
  53720. }
  53721. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53722. /** @hidden */
  53723. export var pbrDirectLightingFunctions: {
  53724. name: string;
  53725. shader: string;
  53726. };
  53727. }
  53728. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53729. /** @hidden */
  53730. export var pbrIBLFunctions: {
  53731. name: string;
  53732. shader: string;
  53733. };
  53734. }
  53735. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53736. /** @hidden */
  53737. export var pbrBlockAlbedoOpacity: {
  53738. name: string;
  53739. shader: string;
  53740. };
  53741. }
  53742. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53743. /** @hidden */
  53744. export var pbrBlockReflectivity: {
  53745. name: string;
  53746. shader: string;
  53747. };
  53748. }
  53749. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53750. /** @hidden */
  53751. export var pbrBlockAmbientOcclusion: {
  53752. name: string;
  53753. shader: string;
  53754. };
  53755. }
  53756. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53757. /** @hidden */
  53758. export var pbrBlockAlphaFresnel: {
  53759. name: string;
  53760. shader: string;
  53761. };
  53762. }
  53763. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53764. /** @hidden */
  53765. export var pbrBlockAnisotropic: {
  53766. name: string;
  53767. shader: string;
  53768. };
  53769. }
  53770. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53771. /** @hidden */
  53772. export var pbrBlockReflection: {
  53773. name: string;
  53774. shader: string;
  53775. };
  53776. }
  53777. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53778. /** @hidden */
  53779. export var pbrBlockSheen: {
  53780. name: string;
  53781. shader: string;
  53782. };
  53783. }
  53784. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53785. /** @hidden */
  53786. export var pbrBlockClearcoat: {
  53787. name: string;
  53788. shader: string;
  53789. };
  53790. }
  53791. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53792. /** @hidden */
  53793. export var pbrBlockSubSurface: {
  53794. name: string;
  53795. shader: string;
  53796. };
  53797. }
  53798. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53799. /** @hidden */
  53800. export var pbrBlockNormalGeometric: {
  53801. name: string;
  53802. shader: string;
  53803. };
  53804. }
  53805. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53806. /** @hidden */
  53807. export var pbrBlockNormalFinal: {
  53808. name: string;
  53809. shader: string;
  53810. };
  53811. }
  53812. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53813. /** @hidden */
  53814. export var pbrBlockGeometryInfo: {
  53815. name: string;
  53816. shader: string;
  53817. };
  53818. }
  53819. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53820. /** @hidden */
  53821. export var pbrBlockReflectance0: {
  53822. name: string;
  53823. shader: string;
  53824. };
  53825. }
  53826. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53827. /** @hidden */
  53828. export var pbrBlockReflectance: {
  53829. name: string;
  53830. shader: string;
  53831. };
  53832. }
  53833. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53834. /** @hidden */
  53835. export var pbrBlockDirectLighting: {
  53836. name: string;
  53837. shader: string;
  53838. };
  53839. }
  53840. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53841. /** @hidden */
  53842. export var pbrBlockFinalLitComponents: {
  53843. name: string;
  53844. shader: string;
  53845. };
  53846. }
  53847. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53848. /** @hidden */
  53849. export var pbrBlockFinalUnlitComponents: {
  53850. name: string;
  53851. shader: string;
  53852. };
  53853. }
  53854. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53855. /** @hidden */
  53856. export var pbrBlockFinalColorComposition: {
  53857. name: string;
  53858. shader: string;
  53859. };
  53860. }
  53861. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53862. /** @hidden */
  53863. export var pbrBlockImageProcessing: {
  53864. name: string;
  53865. shader: string;
  53866. };
  53867. }
  53868. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53869. /** @hidden */
  53870. export var pbrDebug: {
  53871. name: string;
  53872. shader: string;
  53873. };
  53874. }
  53875. declare module "babylonjs/Shaders/pbr.fragment" {
  53876. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53877. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53878. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53879. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53880. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53881. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53882. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53883. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53884. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53885. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53886. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53887. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53888. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53889. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53890. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53891. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53892. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53893. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53894. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53895. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53896. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  53897. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53898. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53899. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53900. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53901. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53902. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53903. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53904. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53905. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53906. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53907. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53908. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53909. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53910. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53911. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53912. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53913. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53914. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53915. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53916. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53917. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53918. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53919. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53920. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53921. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53922. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53923. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53924. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53925. /** @hidden */
  53926. export var pbrPixelShader: {
  53927. name: string;
  53928. shader: string;
  53929. };
  53930. }
  53931. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53932. /** @hidden */
  53933. export var pbrVertexDeclaration: {
  53934. name: string;
  53935. shader: string;
  53936. };
  53937. }
  53938. declare module "babylonjs/Shaders/pbr.vertex" {
  53939. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53940. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53941. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53942. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53943. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53944. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53945. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53946. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53947. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53948. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53949. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53951. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53952. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53953. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53954. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53955. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53956. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53957. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53958. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53959. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53960. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53961. /** @hidden */
  53962. export var pbrVertexShader: {
  53963. name: string;
  53964. shader: string;
  53965. };
  53966. }
  53967. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53968. import { Nullable } from "babylonjs/types";
  53969. import { Scene } from "babylonjs/scene";
  53970. import { Matrix } from "babylonjs/Maths/math.vector";
  53971. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53973. import { Mesh } from "babylonjs/Meshes/mesh";
  53974. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53975. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53976. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53977. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53978. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53979. import { Color3 } from "babylonjs/Maths/math.color";
  53980. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53981. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53982. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53983. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53985. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53986. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53987. import "babylonjs/Shaders/pbr.fragment";
  53988. import "babylonjs/Shaders/pbr.vertex";
  53989. /**
  53990. * Manages the defines for the PBR Material.
  53991. * @hidden
  53992. */
  53993. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53994. PBR: boolean;
  53995. MAINUV1: boolean;
  53996. MAINUV2: boolean;
  53997. UV1: boolean;
  53998. UV2: boolean;
  53999. ALBEDO: boolean;
  54000. GAMMAALBEDO: boolean;
  54001. ALBEDODIRECTUV: number;
  54002. VERTEXCOLOR: boolean;
  54003. AMBIENT: boolean;
  54004. AMBIENTDIRECTUV: number;
  54005. AMBIENTINGRAYSCALE: boolean;
  54006. OPACITY: boolean;
  54007. VERTEXALPHA: boolean;
  54008. OPACITYDIRECTUV: number;
  54009. OPACITYRGB: boolean;
  54010. ALPHATEST: boolean;
  54011. DEPTHPREPASS: boolean;
  54012. ALPHABLEND: boolean;
  54013. ALPHAFROMALBEDO: boolean;
  54014. ALPHATESTVALUE: string;
  54015. SPECULAROVERALPHA: boolean;
  54016. RADIANCEOVERALPHA: boolean;
  54017. ALPHAFRESNEL: boolean;
  54018. LINEARALPHAFRESNEL: boolean;
  54019. PREMULTIPLYALPHA: boolean;
  54020. EMISSIVE: boolean;
  54021. EMISSIVEDIRECTUV: number;
  54022. REFLECTIVITY: boolean;
  54023. REFLECTIVITYDIRECTUV: number;
  54024. SPECULARTERM: boolean;
  54025. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54026. MICROSURFACEAUTOMATIC: boolean;
  54027. LODBASEDMICROSFURACE: boolean;
  54028. MICROSURFACEMAP: boolean;
  54029. MICROSURFACEMAPDIRECTUV: number;
  54030. METALLICWORKFLOW: boolean;
  54031. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54032. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54033. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54034. AOSTOREINMETALMAPRED: boolean;
  54035. METALLICF0FACTORFROMMETALLICMAP: boolean;
  54036. ENVIRONMENTBRDF: boolean;
  54037. ENVIRONMENTBRDF_RGBD: boolean;
  54038. NORMAL: boolean;
  54039. TANGENT: boolean;
  54040. BUMP: boolean;
  54041. BUMPDIRECTUV: number;
  54042. OBJECTSPACE_NORMALMAP: boolean;
  54043. PARALLAX: boolean;
  54044. PARALLAXOCCLUSION: boolean;
  54045. NORMALXYSCALE: boolean;
  54046. LIGHTMAP: boolean;
  54047. LIGHTMAPDIRECTUV: number;
  54048. USELIGHTMAPASSHADOWMAP: boolean;
  54049. GAMMALIGHTMAP: boolean;
  54050. RGBDLIGHTMAP: boolean;
  54051. REFLECTION: boolean;
  54052. REFLECTIONMAP_3D: boolean;
  54053. REFLECTIONMAP_SPHERICAL: boolean;
  54054. REFLECTIONMAP_PLANAR: boolean;
  54055. REFLECTIONMAP_CUBIC: boolean;
  54056. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54057. REFLECTIONMAP_PROJECTION: boolean;
  54058. REFLECTIONMAP_SKYBOX: boolean;
  54059. REFLECTIONMAP_EXPLICIT: boolean;
  54060. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54061. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54062. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54063. INVERTCUBICMAP: boolean;
  54064. USESPHERICALFROMREFLECTIONMAP: boolean;
  54065. USEIRRADIANCEMAP: boolean;
  54066. SPHERICAL_HARMONICS: boolean;
  54067. USESPHERICALINVERTEX: boolean;
  54068. REFLECTIONMAP_OPPOSITEZ: boolean;
  54069. LODINREFLECTIONALPHA: boolean;
  54070. GAMMAREFLECTION: boolean;
  54071. RGBDREFLECTION: boolean;
  54072. LINEARSPECULARREFLECTION: boolean;
  54073. RADIANCEOCCLUSION: boolean;
  54074. HORIZONOCCLUSION: boolean;
  54075. INSTANCES: boolean;
  54076. NUM_BONE_INFLUENCERS: number;
  54077. BonesPerMesh: number;
  54078. BONETEXTURE: boolean;
  54079. NONUNIFORMSCALING: boolean;
  54080. MORPHTARGETS: boolean;
  54081. MORPHTARGETS_NORMAL: boolean;
  54082. MORPHTARGETS_TANGENT: boolean;
  54083. MORPHTARGETS_UV: boolean;
  54084. NUM_MORPH_INFLUENCERS: number;
  54085. IMAGEPROCESSING: boolean;
  54086. VIGNETTE: boolean;
  54087. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54088. VIGNETTEBLENDMODEOPAQUE: boolean;
  54089. TONEMAPPING: boolean;
  54090. TONEMAPPING_ACES: boolean;
  54091. CONTRAST: boolean;
  54092. COLORCURVES: boolean;
  54093. COLORGRADING: boolean;
  54094. COLORGRADING3D: boolean;
  54095. SAMPLER3DGREENDEPTH: boolean;
  54096. SAMPLER3DBGRMAP: boolean;
  54097. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54098. EXPOSURE: boolean;
  54099. MULTIVIEW: boolean;
  54100. USEPHYSICALLIGHTFALLOFF: boolean;
  54101. USEGLTFLIGHTFALLOFF: boolean;
  54102. TWOSIDEDLIGHTING: boolean;
  54103. SHADOWFLOAT: boolean;
  54104. CLIPPLANE: boolean;
  54105. CLIPPLANE2: boolean;
  54106. CLIPPLANE3: boolean;
  54107. CLIPPLANE4: boolean;
  54108. CLIPPLANE5: boolean;
  54109. CLIPPLANE6: boolean;
  54110. POINTSIZE: boolean;
  54111. FOG: boolean;
  54112. LOGARITHMICDEPTH: boolean;
  54113. FORCENORMALFORWARD: boolean;
  54114. SPECULARAA: boolean;
  54115. CLEARCOAT: boolean;
  54116. CLEARCOAT_DEFAULTIOR: boolean;
  54117. CLEARCOAT_TEXTURE: boolean;
  54118. CLEARCOAT_TEXTUREDIRECTUV: number;
  54119. CLEARCOAT_BUMP: boolean;
  54120. CLEARCOAT_BUMPDIRECTUV: number;
  54121. CLEARCOAT_TINT: boolean;
  54122. CLEARCOAT_TINT_TEXTURE: boolean;
  54123. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54124. ANISOTROPIC: boolean;
  54125. ANISOTROPIC_TEXTURE: boolean;
  54126. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54127. BRDF_V_HEIGHT_CORRELATED: boolean;
  54128. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54129. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54130. SHEEN: boolean;
  54131. SHEEN_TEXTURE: boolean;
  54132. SHEEN_TEXTUREDIRECTUV: number;
  54133. SHEEN_LINKWITHALBEDO: boolean;
  54134. SHEEN_ROUGHNESS: boolean;
  54135. SHEEN_ALBEDOSCALING: boolean;
  54136. SUBSURFACE: boolean;
  54137. SS_REFRACTION: boolean;
  54138. SS_TRANSLUCENCY: boolean;
  54139. SS_SCATERRING: boolean;
  54140. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54141. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54142. SS_REFRACTIONMAP_3D: boolean;
  54143. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54144. SS_LODINREFRACTIONALPHA: boolean;
  54145. SS_GAMMAREFRACTION: boolean;
  54146. SS_RGBDREFRACTION: boolean;
  54147. SS_LINEARSPECULARREFRACTION: boolean;
  54148. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54149. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54150. UNLIT: boolean;
  54151. DEBUGMODE: number;
  54152. /**
  54153. * Initializes the PBR Material defines.
  54154. */
  54155. constructor();
  54156. /**
  54157. * Resets the PBR Material defines.
  54158. */
  54159. reset(): void;
  54160. }
  54161. /**
  54162. * The Physically based material base class of BJS.
  54163. *
  54164. * This offers the main features of a standard PBR material.
  54165. * For more information, please refer to the documentation :
  54166. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54167. */
  54168. export abstract class PBRBaseMaterial extends PushMaterial {
  54169. /**
  54170. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54171. */
  54172. static readonly PBRMATERIAL_OPAQUE: number;
  54173. /**
  54174. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54175. */
  54176. static readonly PBRMATERIAL_ALPHATEST: number;
  54177. /**
  54178. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54179. */
  54180. static readonly PBRMATERIAL_ALPHABLEND: number;
  54181. /**
  54182. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54183. * They are also discarded below the alpha cutoff threshold to improve performances.
  54184. */
  54185. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54186. /**
  54187. * Defines the default value of how much AO map is occluding the analytical lights
  54188. * (point spot...).
  54189. */
  54190. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54191. /**
  54192. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54193. */
  54194. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54195. /**
  54196. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54197. * to enhance interoperability with other engines.
  54198. */
  54199. static readonly LIGHTFALLOFF_GLTF: number;
  54200. /**
  54201. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54202. * to enhance interoperability with other materials.
  54203. */
  54204. static readonly LIGHTFALLOFF_STANDARD: number;
  54205. /**
  54206. * Intensity of the direct lights e.g. the four lights available in your scene.
  54207. * This impacts both the direct diffuse and specular highlights.
  54208. */
  54209. protected _directIntensity: number;
  54210. /**
  54211. * Intensity of the emissive part of the material.
  54212. * This helps controlling the emissive effect without modifying the emissive color.
  54213. */
  54214. protected _emissiveIntensity: number;
  54215. /**
  54216. * Intensity of the environment e.g. how much the environment will light the object
  54217. * either through harmonics for rough material or through the refelction for shiny ones.
  54218. */
  54219. protected _environmentIntensity: number;
  54220. /**
  54221. * This is a special control allowing the reduction of the specular highlights coming from the
  54222. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54223. */
  54224. protected _specularIntensity: number;
  54225. /**
  54226. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54227. */
  54228. private _lightingInfos;
  54229. /**
  54230. * Debug Control allowing disabling the bump map on this material.
  54231. */
  54232. protected _disableBumpMap: boolean;
  54233. /**
  54234. * AKA Diffuse Texture in standard nomenclature.
  54235. */
  54236. protected _albedoTexture: Nullable<BaseTexture>;
  54237. /**
  54238. * AKA Occlusion Texture in other nomenclature.
  54239. */
  54240. protected _ambientTexture: Nullable<BaseTexture>;
  54241. /**
  54242. * AKA Occlusion Texture Intensity in other nomenclature.
  54243. */
  54244. protected _ambientTextureStrength: number;
  54245. /**
  54246. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54247. * 1 means it completely occludes it
  54248. * 0 mean it has no impact
  54249. */
  54250. protected _ambientTextureImpactOnAnalyticalLights: number;
  54251. /**
  54252. * Stores the alpha values in a texture.
  54253. */
  54254. protected _opacityTexture: Nullable<BaseTexture>;
  54255. /**
  54256. * Stores the reflection values in a texture.
  54257. */
  54258. protected _reflectionTexture: Nullable<BaseTexture>;
  54259. /**
  54260. * Stores the emissive values in a texture.
  54261. */
  54262. protected _emissiveTexture: Nullable<BaseTexture>;
  54263. /**
  54264. * AKA Specular texture in other nomenclature.
  54265. */
  54266. protected _reflectivityTexture: Nullable<BaseTexture>;
  54267. /**
  54268. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54269. */
  54270. protected _metallicTexture: Nullable<BaseTexture>;
  54271. /**
  54272. * Specifies the metallic scalar of the metallic/roughness workflow.
  54273. * Can also be used to scale the metalness values of the metallic texture.
  54274. */
  54275. protected _metallic: Nullable<number>;
  54276. /**
  54277. * Specifies the roughness scalar of the metallic/roughness workflow.
  54278. * Can also be used to scale the roughness values of the metallic texture.
  54279. */
  54280. protected _roughness: Nullable<number>;
  54281. /**
  54282. * Specifies the an F0 factor to help configuring the material F0.
  54283. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54284. * to 0.5 the previously hard coded value stays the same.
  54285. * Can also be used to scale the F0 values of the metallic texture.
  54286. */
  54287. protected _metallicF0Factor: number;
  54288. /**
  54289. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54290. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54291. * your expectation as it multiplies with the texture data.
  54292. */
  54293. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  54294. /**
  54295. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54296. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54297. */
  54298. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54299. /**
  54300. * Stores surface normal data used to displace a mesh in a texture.
  54301. */
  54302. protected _bumpTexture: Nullable<BaseTexture>;
  54303. /**
  54304. * Stores the pre-calculated light information of a mesh in a texture.
  54305. */
  54306. protected _lightmapTexture: Nullable<BaseTexture>;
  54307. /**
  54308. * The color of a material in ambient lighting.
  54309. */
  54310. protected _ambientColor: Color3;
  54311. /**
  54312. * AKA Diffuse Color in other nomenclature.
  54313. */
  54314. protected _albedoColor: Color3;
  54315. /**
  54316. * AKA Specular Color in other nomenclature.
  54317. */
  54318. protected _reflectivityColor: Color3;
  54319. /**
  54320. * The color applied when light is reflected from a material.
  54321. */
  54322. protected _reflectionColor: Color3;
  54323. /**
  54324. * The color applied when light is emitted from a material.
  54325. */
  54326. protected _emissiveColor: Color3;
  54327. /**
  54328. * AKA Glossiness in other nomenclature.
  54329. */
  54330. protected _microSurface: number;
  54331. /**
  54332. * Specifies that the material will use the light map as a show map.
  54333. */
  54334. protected _useLightmapAsShadowmap: boolean;
  54335. /**
  54336. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54337. * makes the reflect vector face the model (under horizon).
  54338. */
  54339. protected _useHorizonOcclusion: boolean;
  54340. /**
  54341. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54342. * too much the area relying on ambient texture to define their ambient occlusion.
  54343. */
  54344. protected _useRadianceOcclusion: boolean;
  54345. /**
  54346. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54347. */
  54348. protected _useAlphaFromAlbedoTexture: boolean;
  54349. /**
  54350. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54351. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54352. */
  54353. protected _useSpecularOverAlpha: boolean;
  54354. /**
  54355. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54356. */
  54357. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54358. /**
  54359. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54360. */
  54361. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54362. /**
  54363. * Specifies if the metallic texture contains the roughness information in its green channel.
  54364. */
  54365. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54366. /**
  54367. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54368. */
  54369. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54370. /**
  54371. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54372. */
  54373. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54374. /**
  54375. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54376. */
  54377. protected _useAmbientInGrayScale: boolean;
  54378. /**
  54379. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54380. * The material will try to infer what glossiness each pixel should be.
  54381. */
  54382. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54383. /**
  54384. * Defines the falloff type used in this material.
  54385. * It by default is Physical.
  54386. */
  54387. protected _lightFalloff: number;
  54388. /**
  54389. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54390. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54391. */
  54392. protected _useRadianceOverAlpha: boolean;
  54393. /**
  54394. * Allows using an object space normal map (instead of tangent space).
  54395. */
  54396. protected _useObjectSpaceNormalMap: boolean;
  54397. /**
  54398. * Allows using the bump map in parallax mode.
  54399. */
  54400. protected _useParallax: boolean;
  54401. /**
  54402. * Allows using the bump map in parallax occlusion mode.
  54403. */
  54404. protected _useParallaxOcclusion: boolean;
  54405. /**
  54406. * Controls the scale bias of the parallax mode.
  54407. */
  54408. protected _parallaxScaleBias: number;
  54409. /**
  54410. * If sets to true, disables all the lights affecting the material.
  54411. */
  54412. protected _disableLighting: boolean;
  54413. /**
  54414. * Number of Simultaneous lights allowed on the material.
  54415. */
  54416. protected _maxSimultaneousLights: number;
  54417. /**
  54418. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54419. */
  54420. protected _invertNormalMapX: boolean;
  54421. /**
  54422. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54423. */
  54424. protected _invertNormalMapY: boolean;
  54425. /**
  54426. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54427. */
  54428. protected _twoSidedLighting: boolean;
  54429. /**
  54430. * Defines the alpha limits in alpha test mode.
  54431. */
  54432. protected _alphaCutOff: number;
  54433. /**
  54434. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54435. */
  54436. protected _forceAlphaTest: boolean;
  54437. /**
  54438. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54439. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54440. */
  54441. protected _useAlphaFresnel: boolean;
  54442. /**
  54443. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54444. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54445. */
  54446. protected _useLinearAlphaFresnel: boolean;
  54447. /**
  54448. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54449. * from cos thetav and roughness:
  54450. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54451. */
  54452. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54453. /**
  54454. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54455. */
  54456. protected _forceIrradianceInFragment: boolean;
  54457. /**
  54458. * Force normal to face away from face.
  54459. */
  54460. protected _forceNormalForward: boolean;
  54461. /**
  54462. * Enables specular anti aliasing in the PBR shader.
  54463. * It will both interacts on the Geometry for analytical and IBL lighting.
  54464. * It also prefilter the roughness map based on the bump values.
  54465. */
  54466. protected _enableSpecularAntiAliasing: boolean;
  54467. /**
  54468. * Default configuration related to image processing available in the PBR Material.
  54469. */
  54470. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54471. /**
  54472. * Keep track of the image processing observer to allow dispose and replace.
  54473. */
  54474. private _imageProcessingObserver;
  54475. /**
  54476. * Attaches a new image processing configuration to the PBR Material.
  54477. * @param configuration
  54478. */
  54479. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54480. /**
  54481. * Stores the available render targets.
  54482. */
  54483. private _renderTargets;
  54484. /**
  54485. * Sets the global ambient color for the material used in lighting calculations.
  54486. */
  54487. private _globalAmbientColor;
  54488. /**
  54489. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54490. */
  54491. private _useLogarithmicDepth;
  54492. /**
  54493. * If set to true, no lighting calculations will be applied.
  54494. */
  54495. private _unlit;
  54496. private _debugMode;
  54497. /**
  54498. * @hidden
  54499. * This is reserved for the inspector.
  54500. * Defines the material debug mode.
  54501. * It helps seeing only some components of the material while troubleshooting.
  54502. */
  54503. debugMode: number;
  54504. /**
  54505. * @hidden
  54506. * This is reserved for the inspector.
  54507. * Specify from where on screen the debug mode should start.
  54508. * The value goes from -1 (full screen) to 1 (not visible)
  54509. * It helps with side by side comparison against the final render
  54510. * This defaults to -1
  54511. */
  54512. private debugLimit;
  54513. /**
  54514. * @hidden
  54515. * This is reserved for the inspector.
  54516. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54517. * You can use the factor to better multiply the final value.
  54518. */
  54519. private debugFactor;
  54520. /**
  54521. * Defines the clear coat layer parameters for the material.
  54522. */
  54523. readonly clearCoat: PBRClearCoatConfiguration;
  54524. /**
  54525. * Defines the anisotropic parameters for the material.
  54526. */
  54527. readonly anisotropy: PBRAnisotropicConfiguration;
  54528. /**
  54529. * Defines the BRDF parameters for the material.
  54530. */
  54531. readonly brdf: PBRBRDFConfiguration;
  54532. /**
  54533. * Defines the Sheen parameters for the material.
  54534. */
  54535. readonly sheen: PBRSheenConfiguration;
  54536. /**
  54537. * Defines the SubSurface parameters for the material.
  54538. */
  54539. readonly subSurface: PBRSubSurfaceConfiguration;
  54540. protected _rebuildInParallel: boolean;
  54541. /**
  54542. * Instantiates a new PBRMaterial instance.
  54543. *
  54544. * @param name The material name
  54545. * @param scene The scene the material will be use in.
  54546. */
  54547. constructor(name: string, scene: Scene);
  54548. /**
  54549. * Gets a boolean indicating that current material needs to register RTT
  54550. */
  54551. get hasRenderTargetTextures(): boolean;
  54552. /**
  54553. * Gets the name of the material class.
  54554. */
  54555. getClassName(): string;
  54556. /**
  54557. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54558. */
  54559. get useLogarithmicDepth(): boolean;
  54560. /**
  54561. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54562. */
  54563. set useLogarithmicDepth(value: boolean);
  54564. /**
  54565. * Returns true if alpha blending should be disabled.
  54566. */
  54567. protected get _disableAlphaBlending(): boolean;
  54568. /**
  54569. * Specifies whether or not this material should be rendered in alpha blend mode.
  54570. */
  54571. needAlphaBlending(): boolean;
  54572. /**
  54573. * Specifies whether or not this material should be rendered in alpha test mode.
  54574. */
  54575. needAlphaTesting(): boolean;
  54576. /**
  54577. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54578. */
  54579. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54580. /**
  54581. * Gets the texture used for the alpha test.
  54582. */
  54583. getAlphaTestTexture(): Nullable<BaseTexture>;
  54584. /**
  54585. * Specifies that the submesh is ready to be used.
  54586. * @param mesh - BJS mesh.
  54587. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54588. * @param useInstances - Specifies that instances should be used.
  54589. * @returns - boolean indicating that the submesh is ready or not.
  54590. */
  54591. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54592. /**
  54593. * Specifies if the material uses metallic roughness workflow.
  54594. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54595. */
  54596. isMetallicWorkflow(): boolean;
  54597. private _prepareEffect;
  54598. private _prepareDefines;
  54599. /**
  54600. * Force shader compilation
  54601. */
  54602. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54603. /**
  54604. * Initializes the uniform buffer layout for the shader.
  54605. */
  54606. buildUniformLayout(): void;
  54607. /**
  54608. * Unbinds the material from the mesh
  54609. */
  54610. unbind(): void;
  54611. /**
  54612. * Binds the submesh data.
  54613. * @param world - The world matrix.
  54614. * @param mesh - The BJS mesh.
  54615. * @param subMesh - A submesh of the BJS mesh.
  54616. */
  54617. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54618. /**
  54619. * Returns the animatable textures.
  54620. * @returns - Array of animatable textures.
  54621. */
  54622. getAnimatables(): IAnimatable[];
  54623. /**
  54624. * Returns the texture used for reflections.
  54625. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54626. */
  54627. private _getReflectionTexture;
  54628. /**
  54629. * Returns an array of the actively used textures.
  54630. * @returns - Array of BaseTextures
  54631. */
  54632. getActiveTextures(): BaseTexture[];
  54633. /**
  54634. * Checks to see if a texture is used in the material.
  54635. * @param texture - Base texture to use.
  54636. * @returns - Boolean specifying if a texture is used in the material.
  54637. */
  54638. hasTexture(texture: BaseTexture): boolean;
  54639. /**
  54640. * Disposes the resources of the material.
  54641. * @param forceDisposeEffect - Forces the disposal of effects.
  54642. * @param forceDisposeTextures - Forces the disposal of all textures.
  54643. */
  54644. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54645. }
  54646. }
  54647. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54648. import { Nullable } from "babylonjs/types";
  54649. import { Scene } from "babylonjs/scene";
  54650. import { Color3 } from "babylonjs/Maths/math.color";
  54651. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54652. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54654. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54655. /**
  54656. * The Physically based material of BJS.
  54657. *
  54658. * This offers the main features of a standard PBR material.
  54659. * For more information, please refer to the documentation :
  54660. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54661. */
  54662. export class PBRMaterial extends PBRBaseMaterial {
  54663. /**
  54664. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54665. */
  54666. static readonly PBRMATERIAL_OPAQUE: number;
  54667. /**
  54668. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54669. */
  54670. static readonly PBRMATERIAL_ALPHATEST: number;
  54671. /**
  54672. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54673. */
  54674. static readonly PBRMATERIAL_ALPHABLEND: number;
  54675. /**
  54676. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54677. * They are also discarded below the alpha cutoff threshold to improve performances.
  54678. */
  54679. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54680. /**
  54681. * Defines the default value of how much AO map is occluding the analytical lights
  54682. * (point spot...).
  54683. */
  54684. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54685. /**
  54686. * Intensity of the direct lights e.g. the four lights available in your scene.
  54687. * This impacts both the direct diffuse and specular highlights.
  54688. */
  54689. directIntensity: number;
  54690. /**
  54691. * Intensity of the emissive part of the material.
  54692. * This helps controlling the emissive effect without modifying the emissive color.
  54693. */
  54694. emissiveIntensity: number;
  54695. /**
  54696. * Intensity of the environment e.g. how much the environment will light the object
  54697. * either through harmonics for rough material or through the refelction for shiny ones.
  54698. */
  54699. environmentIntensity: number;
  54700. /**
  54701. * This is a special control allowing the reduction of the specular highlights coming from the
  54702. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54703. */
  54704. specularIntensity: number;
  54705. /**
  54706. * Debug Control allowing disabling the bump map on this material.
  54707. */
  54708. disableBumpMap: boolean;
  54709. /**
  54710. * AKA Diffuse Texture in standard nomenclature.
  54711. */
  54712. albedoTexture: BaseTexture;
  54713. /**
  54714. * AKA Occlusion Texture in other nomenclature.
  54715. */
  54716. ambientTexture: BaseTexture;
  54717. /**
  54718. * AKA Occlusion Texture Intensity in other nomenclature.
  54719. */
  54720. ambientTextureStrength: number;
  54721. /**
  54722. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54723. * 1 means it completely occludes it
  54724. * 0 mean it has no impact
  54725. */
  54726. ambientTextureImpactOnAnalyticalLights: number;
  54727. /**
  54728. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54729. */
  54730. opacityTexture: BaseTexture;
  54731. /**
  54732. * Stores the reflection values in a texture.
  54733. */
  54734. reflectionTexture: Nullable<BaseTexture>;
  54735. /**
  54736. * Stores the emissive values in a texture.
  54737. */
  54738. emissiveTexture: BaseTexture;
  54739. /**
  54740. * AKA Specular texture in other nomenclature.
  54741. */
  54742. reflectivityTexture: BaseTexture;
  54743. /**
  54744. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54745. */
  54746. metallicTexture: BaseTexture;
  54747. /**
  54748. * Specifies the metallic scalar of the metallic/roughness workflow.
  54749. * Can also be used to scale the metalness values of the metallic texture.
  54750. */
  54751. metallic: Nullable<number>;
  54752. /**
  54753. * Specifies the roughness scalar of the metallic/roughness workflow.
  54754. * Can also be used to scale the roughness values of the metallic texture.
  54755. */
  54756. roughness: Nullable<number>;
  54757. /**
  54758. * Specifies the an F0 factor to help configuring the material F0.
  54759. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54760. * to 0.5 the previously hard coded value stays the same.
  54761. * Can also be used to scale the F0 values of the metallic texture.
  54762. */
  54763. metallicF0Factor: number;
  54764. /**
  54765. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54766. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54767. * your expectation as it multiplies with the texture data.
  54768. */
  54769. useMetallicF0FactorFromMetallicTexture: boolean;
  54770. /**
  54771. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54772. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54773. */
  54774. microSurfaceTexture: BaseTexture;
  54775. /**
  54776. * Stores surface normal data used to displace a mesh in a texture.
  54777. */
  54778. bumpTexture: BaseTexture;
  54779. /**
  54780. * Stores the pre-calculated light information of a mesh in a texture.
  54781. */
  54782. lightmapTexture: BaseTexture;
  54783. /**
  54784. * Stores the refracted light information in a texture.
  54785. */
  54786. get refractionTexture(): Nullable<BaseTexture>;
  54787. set refractionTexture(value: Nullable<BaseTexture>);
  54788. /**
  54789. * The color of a material in ambient lighting.
  54790. */
  54791. ambientColor: Color3;
  54792. /**
  54793. * AKA Diffuse Color in other nomenclature.
  54794. */
  54795. albedoColor: Color3;
  54796. /**
  54797. * AKA Specular Color in other nomenclature.
  54798. */
  54799. reflectivityColor: Color3;
  54800. /**
  54801. * The color reflected from the material.
  54802. */
  54803. reflectionColor: Color3;
  54804. /**
  54805. * The color emitted from the material.
  54806. */
  54807. emissiveColor: Color3;
  54808. /**
  54809. * AKA Glossiness in other nomenclature.
  54810. */
  54811. microSurface: number;
  54812. /**
  54813. * source material index of refraction (IOR)' / 'destination material IOR.
  54814. */
  54815. get indexOfRefraction(): number;
  54816. set indexOfRefraction(value: number);
  54817. /**
  54818. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54819. */
  54820. get invertRefractionY(): boolean;
  54821. set invertRefractionY(value: boolean);
  54822. /**
  54823. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54824. * Materials half opaque for instance using refraction could benefit from this control.
  54825. */
  54826. get linkRefractionWithTransparency(): boolean;
  54827. set linkRefractionWithTransparency(value: boolean);
  54828. /**
  54829. * If true, the light map contains occlusion information instead of lighting info.
  54830. */
  54831. useLightmapAsShadowmap: boolean;
  54832. /**
  54833. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54834. */
  54835. useAlphaFromAlbedoTexture: boolean;
  54836. /**
  54837. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54838. */
  54839. forceAlphaTest: boolean;
  54840. /**
  54841. * Defines the alpha limits in alpha test mode.
  54842. */
  54843. alphaCutOff: number;
  54844. /**
  54845. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54846. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54847. */
  54848. useSpecularOverAlpha: boolean;
  54849. /**
  54850. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54851. */
  54852. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54853. /**
  54854. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54855. */
  54856. useRoughnessFromMetallicTextureAlpha: boolean;
  54857. /**
  54858. * Specifies if the metallic texture contains the roughness information in its green channel.
  54859. */
  54860. useRoughnessFromMetallicTextureGreen: boolean;
  54861. /**
  54862. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54863. */
  54864. useMetallnessFromMetallicTextureBlue: boolean;
  54865. /**
  54866. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54867. */
  54868. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54869. /**
  54870. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54871. */
  54872. useAmbientInGrayScale: boolean;
  54873. /**
  54874. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54875. * The material will try to infer what glossiness each pixel should be.
  54876. */
  54877. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54878. /**
  54879. * BJS is using an harcoded light falloff based on a manually sets up range.
  54880. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54881. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54882. */
  54883. get usePhysicalLightFalloff(): boolean;
  54884. /**
  54885. * BJS is using an harcoded light falloff based on a manually sets up range.
  54886. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54887. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54888. */
  54889. set usePhysicalLightFalloff(value: boolean);
  54890. /**
  54891. * In order to support the falloff compatibility with gltf, a special mode has been added
  54892. * to reproduce the gltf light falloff.
  54893. */
  54894. get useGLTFLightFalloff(): boolean;
  54895. /**
  54896. * In order to support the falloff compatibility with gltf, a special mode has been added
  54897. * to reproduce the gltf light falloff.
  54898. */
  54899. set useGLTFLightFalloff(value: boolean);
  54900. /**
  54901. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54902. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54903. */
  54904. useRadianceOverAlpha: boolean;
  54905. /**
  54906. * Allows using an object space normal map (instead of tangent space).
  54907. */
  54908. useObjectSpaceNormalMap: boolean;
  54909. /**
  54910. * Allows using the bump map in parallax mode.
  54911. */
  54912. useParallax: boolean;
  54913. /**
  54914. * Allows using the bump map in parallax occlusion mode.
  54915. */
  54916. useParallaxOcclusion: boolean;
  54917. /**
  54918. * Controls the scale bias of the parallax mode.
  54919. */
  54920. parallaxScaleBias: number;
  54921. /**
  54922. * If sets to true, disables all the lights affecting the material.
  54923. */
  54924. disableLighting: boolean;
  54925. /**
  54926. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54927. */
  54928. forceIrradianceInFragment: boolean;
  54929. /**
  54930. * Number of Simultaneous lights allowed on the material.
  54931. */
  54932. maxSimultaneousLights: number;
  54933. /**
  54934. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54935. */
  54936. invertNormalMapX: boolean;
  54937. /**
  54938. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54939. */
  54940. invertNormalMapY: boolean;
  54941. /**
  54942. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54943. */
  54944. twoSidedLighting: boolean;
  54945. /**
  54946. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54947. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54948. */
  54949. useAlphaFresnel: boolean;
  54950. /**
  54951. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54952. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54953. */
  54954. useLinearAlphaFresnel: boolean;
  54955. /**
  54956. * Let user defines the brdf lookup texture used for IBL.
  54957. * A default 8bit version is embedded but you could point at :
  54958. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54959. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54960. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54961. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54962. */
  54963. environmentBRDFTexture: Nullable<BaseTexture>;
  54964. /**
  54965. * Force normal to face away from face.
  54966. */
  54967. forceNormalForward: boolean;
  54968. /**
  54969. * Enables specular anti aliasing in the PBR shader.
  54970. * It will both interacts on the Geometry for analytical and IBL lighting.
  54971. * It also prefilter the roughness map based on the bump values.
  54972. */
  54973. enableSpecularAntiAliasing: boolean;
  54974. /**
  54975. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54976. * makes the reflect vector face the model (under horizon).
  54977. */
  54978. useHorizonOcclusion: boolean;
  54979. /**
  54980. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54981. * too much the area relying on ambient texture to define their ambient occlusion.
  54982. */
  54983. useRadianceOcclusion: boolean;
  54984. /**
  54985. * If set to true, no lighting calculations will be applied.
  54986. */
  54987. unlit: boolean;
  54988. /**
  54989. * Gets the image processing configuration used either in this material.
  54990. */
  54991. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54992. /**
  54993. * Sets the Default image processing configuration used either in the this material.
  54994. *
  54995. * If sets to null, the scene one is in use.
  54996. */
  54997. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54998. /**
  54999. * Gets wether the color curves effect is enabled.
  55000. */
  55001. get cameraColorCurvesEnabled(): boolean;
  55002. /**
  55003. * Sets wether the color curves effect is enabled.
  55004. */
  55005. set cameraColorCurvesEnabled(value: boolean);
  55006. /**
  55007. * Gets wether the color grading effect is enabled.
  55008. */
  55009. get cameraColorGradingEnabled(): boolean;
  55010. /**
  55011. * Gets wether the color grading effect is enabled.
  55012. */
  55013. set cameraColorGradingEnabled(value: boolean);
  55014. /**
  55015. * Gets wether tonemapping is enabled or not.
  55016. */
  55017. get cameraToneMappingEnabled(): boolean;
  55018. /**
  55019. * Sets wether tonemapping is enabled or not
  55020. */
  55021. set cameraToneMappingEnabled(value: boolean);
  55022. /**
  55023. * The camera exposure used on this material.
  55024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55025. * This corresponds to a photographic exposure.
  55026. */
  55027. get cameraExposure(): number;
  55028. /**
  55029. * The camera exposure used on this material.
  55030. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55031. * This corresponds to a photographic exposure.
  55032. */
  55033. set cameraExposure(value: number);
  55034. /**
  55035. * Gets The camera contrast used on this material.
  55036. */
  55037. get cameraContrast(): number;
  55038. /**
  55039. * Sets The camera contrast used on this material.
  55040. */
  55041. set cameraContrast(value: number);
  55042. /**
  55043. * Gets the Color Grading 2D Lookup Texture.
  55044. */
  55045. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55046. /**
  55047. * Sets the Color Grading 2D Lookup Texture.
  55048. */
  55049. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55050. /**
  55051. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55052. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55053. * 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;
  55054. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55055. */
  55056. get cameraColorCurves(): Nullable<ColorCurves>;
  55057. /**
  55058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55060. * 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;
  55061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55062. */
  55063. set cameraColorCurves(value: Nullable<ColorCurves>);
  55064. /**
  55065. * Instantiates a new PBRMaterial instance.
  55066. *
  55067. * @param name The material name
  55068. * @param scene The scene the material will be use in.
  55069. */
  55070. constructor(name: string, scene: Scene);
  55071. /**
  55072. * Returns the name of this material class.
  55073. */
  55074. getClassName(): string;
  55075. /**
  55076. * Makes a duplicate of the current material.
  55077. * @param name - name to use for the new material.
  55078. */
  55079. clone(name: string): PBRMaterial;
  55080. /**
  55081. * Serializes this PBR Material.
  55082. * @returns - An object with the serialized material.
  55083. */
  55084. serialize(): any;
  55085. /**
  55086. * Parses a PBR Material from a serialized object.
  55087. * @param source - Serialized object.
  55088. * @param scene - BJS scene instance.
  55089. * @param rootUrl - url for the scene object
  55090. * @returns - PBRMaterial
  55091. */
  55092. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55093. }
  55094. }
  55095. declare module "babylonjs/Misc/dds" {
  55096. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55098. import { Nullable } from "babylonjs/types";
  55099. import { Scene } from "babylonjs/scene";
  55100. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  55101. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55102. /**
  55103. * Direct draw surface info
  55104. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55105. */
  55106. export interface DDSInfo {
  55107. /**
  55108. * Width of the texture
  55109. */
  55110. width: number;
  55111. /**
  55112. * Width of the texture
  55113. */
  55114. height: number;
  55115. /**
  55116. * Number of Mipmaps for the texture
  55117. * @see https://en.wikipedia.org/wiki/Mipmap
  55118. */
  55119. mipmapCount: number;
  55120. /**
  55121. * If the textures format is a known fourCC format
  55122. * @see https://www.fourcc.org/
  55123. */
  55124. isFourCC: boolean;
  55125. /**
  55126. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55127. */
  55128. isRGB: boolean;
  55129. /**
  55130. * If the texture is a lumincance format
  55131. */
  55132. isLuminance: boolean;
  55133. /**
  55134. * If this is a cube texture
  55135. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55136. */
  55137. isCube: boolean;
  55138. /**
  55139. * If the texture is a compressed format eg. FOURCC_DXT1
  55140. */
  55141. isCompressed: boolean;
  55142. /**
  55143. * The dxgiFormat of the texture
  55144. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55145. */
  55146. dxgiFormat: number;
  55147. /**
  55148. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55149. */
  55150. textureType: number;
  55151. /**
  55152. * Sphericle polynomial created for the dds texture
  55153. */
  55154. sphericalPolynomial?: SphericalPolynomial;
  55155. }
  55156. /**
  55157. * Class used to provide DDS decompression tools
  55158. */
  55159. export class DDSTools {
  55160. /**
  55161. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55162. */
  55163. static StoreLODInAlphaChannel: boolean;
  55164. /**
  55165. * Gets DDS information from an array buffer
  55166. * @param data defines the array buffer view to read data from
  55167. * @returns the DDS information
  55168. */
  55169. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55170. private static _FloatView;
  55171. private static _Int32View;
  55172. private static _ToHalfFloat;
  55173. private static _FromHalfFloat;
  55174. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55175. private static _GetHalfFloatRGBAArrayBuffer;
  55176. private static _GetFloatRGBAArrayBuffer;
  55177. private static _GetFloatAsUIntRGBAArrayBuffer;
  55178. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55179. private static _GetRGBAArrayBuffer;
  55180. private static _ExtractLongWordOrder;
  55181. private static _GetRGBArrayBuffer;
  55182. private static _GetLuminanceArrayBuffer;
  55183. /**
  55184. * Uploads DDS Levels to a Babylon Texture
  55185. * @hidden
  55186. */
  55187. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55188. }
  55189. module "babylonjs/Engines/thinEngine" {
  55190. interface ThinEngine {
  55191. /**
  55192. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55193. * @param rootUrl defines the url where the file to load is located
  55194. * @param scene defines the current scene
  55195. * @param lodScale defines scale to apply to the mip map selection
  55196. * @param lodOffset defines offset to apply to the mip map selection
  55197. * @param onLoad defines an optional callback raised when the texture is loaded
  55198. * @param onError defines an optional callback raised if there is an issue to load the texture
  55199. * @param format defines the format of the data
  55200. * @param forcedExtension defines the extension to use to pick the right loader
  55201. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55202. * @returns the cube texture as an InternalTexture
  55203. */
  55204. 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;
  55205. }
  55206. }
  55207. }
  55208. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  55209. import { Nullable } from "babylonjs/types";
  55210. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55211. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55212. /**
  55213. * Implementation of the DDS Texture Loader.
  55214. * @hidden
  55215. */
  55216. export class _DDSTextureLoader implements IInternalTextureLoader {
  55217. /**
  55218. * Defines wether the loader supports cascade loading the different faces.
  55219. */
  55220. readonly supportCascades: boolean;
  55221. /**
  55222. * This returns if the loader support the current file information.
  55223. * @param extension defines the file extension of the file being loaded
  55224. * @returns true if the loader can load the specified file
  55225. */
  55226. canLoad(extension: string): boolean;
  55227. /**
  55228. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55229. * @param data contains the texture data
  55230. * @param texture defines the BabylonJS internal texture
  55231. * @param createPolynomials will be true if polynomials have been requested
  55232. * @param onLoad defines the callback to trigger once the texture is ready
  55233. * @param onError defines the callback to trigger in case of error
  55234. */
  55235. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55236. /**
  55237. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55238. * @param data contains the texture data
  55239. * @param texture defines the BabylonJS internal texture
  55240. * @param callback defines the method to call once ready to upload
  55241. */
  55242. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55243. }
  55244. }
  55245. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  55246. import { Nullable } from "babylonjs/types";
  55247. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55248. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55249. /**
  55250. * Implementation of the ENV Texture Loader.
  55251. * @hidden
  55252. */
  55253. export class _ENVTextureLoader implements IInternalTextureLoader {
  55254. /**
  55255. * Defines wether the loader supports cascade loading the different faces.
  55256. */
  55257. readonly supportCascades: boolean;
  55258. /**
  55259. * This returns if the loader support the current file information.
  55260. * @param extension defines the file extension of the file being loaded
  55261. * @returns true if the loader can load the specified file
  55262. */
  55263. canLoad(extension: string): boolean;
  55264. /**
  55265. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55266. * @param data contains the texture data
  55267. * @param texture defines the BabylonJS internal texture
  55268. * @param createPolynomials will be true if polynomials have been requested
  55269. * @param onLoad defines the callback to trigger once the texture is ready
  55270. * @param onError defines the callback to trigger in case of error
  55271. */
  55272. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55273. /**
  55274. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55275. * @param data contains the texture data
  55276. * @param texture defines the BabylonJS internal texture
  55277. * @param callback defines the method to call once ready to upload
  55278. */
  55279. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55280. }
  55281. }
  55282. declare module "babylonjs/Misc/khronosTextureContainer" {
  55283. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55284. /**
  55285. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55286. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55287. */
  55288. export class KhronosTextureContainer {
  55289. /** contents of the KTX container file */
  55290. data: ArrayBufferView;
  55291. private static HEADER_LEN;
  55292. private static COMPRESSED_2D;
  55293. private static COMPRESSED_3D;
  55294. private static TEX_2D;
  55295. private static TEX_3D;
  55296. /**
  55297. * Gets the openGL type
  55298. */
  55299. glType: number;
  55300. /**
  55301. * Gets the openGL type size
  55302. */
  55303. glTypeSize: number;
  55304. /**
  55305. * Gets the openGL format
  55306. */
  55307. glFormat: number;
  55308. /**
  55309. * Gets the openGL internal format
  55310. */
  55311. glInternalFormat: number;
  55312. /**
  55313. * Gets the base internal format
  55314. */
  55315. glBaseInternalFormat: number;
  55316. /**
  55317. * Gets image width in pixel
  55318. */
  55319. pixelWidth: number;
  55320. /**
  55321. * Gets image height in pixel
  55322. */
  55323. pixelHeight: number;
  55324. /**
  55325. * Gets image depth in pixels
  55326. */
  55327. pixelDepth: number;
  55328. /**
  55329. * Gets the number of array elements
  55330. */
  55331. numberOfArrayElements: number;
  55332. /**
  55333. * Gets the number of faces
  55334. */
  55335. numberOfFaces: number;
  55336. /**
  55337. * Gets the number of mipmap levels
  55338. */
  55339. numberOfMipmapLevels: number;
  55340. /**
  55341. * Gets the bytes of key value data
  55342. */
  55343. bytesOfKeyValueData: number;
  55344. /**
  55345. * Gets the load type
  55346. */
  55347. loadType: number;
  55348. /**
  55349. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55350. */
  55351. isInvalid: boolean;
  55352. /**
  55353. * Creates a new KhronosTextureContainer
  55354. * @param data contents of the KTX container file
  55355. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55356. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55357. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55358. */
  55359. constructor(
  55360. /** contents of the KTX container file */
  55361. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55362. /**
  55363. * Uploads KTX content to a Babylon Texture.
  55364. * It is assumed that the texture has already been created & is currently bound
  55365. * @hidden
  55366. */
  55367. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55368. private _upload2DCompressedLevels;
  55369. /**
  55370. * Checks if the given data starts with a KTX file identifier.
  55371. * @param data the data to check
  55372. * @returns true if the data is a KTX file or false otherwise
  55373. */
  55374. static IsValid(data: ArrayBufferView): boolean;
  55375. }
  55376. }
  55377. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55378. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55379. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55380. /**
  55381. * Class for loading KTX2 files
  55382. * !!! Experimental Extension Subject to Changes !!!
  55383. * @hidden
  55384. */
  55385. export class KhronosTextureContainer2 {
  55386. private static _ModulePromise;
  55387. private static _TranscodeFormat;
  55388. constructor(engine: ThinEngine);
  55389. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55390. private _determineTranscodeFormat;
  55391. /**
  55392. * Checks if the given data starts with a KTX2 file identifier.
  55393. * @param data the data to check
  55394. * @returns true if the data is a KTX2 file or false otherwise
  55395. */
  55396. static IsValid(data: ArrayBufferView): boolean;
  55397. }
  55398. }
  55399. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55400. import { Nullable } from "babylonjs/types";
  55401. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55402. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55403. /**
  55404. * Implementation of the KTX Texture Loader.
  55405. * @hidden
  55406. */
  55407. export class _KTXTextureLoader implements IInternalTextureLoader {
  55408. /**
  55409. * Defines wether the loader supports cascade loading the different faces.
  55410. */
  55411. readonly supportCascades: boolean;
  55412. /**
  55413. * This returns if the loader support the current file information.
  55414. * @param extension defines the file extension of the file being loaded
  55415. * @returns true if the loader can load the specified file
  55416. */
  55417. canLoad(extension: string): boolean;
  55418. /**
  55419. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55420. * @param data contains the texture data
  55421. * @param texture defines the BabylonJS internal texture
  55422. * @param createPolynomials will be true if polynomials have been requested
  55423. * @param onLoad defines the callback to trigger once the texture is ready
  55424. * @param onError defines the callback to trigger in case of error
  55425. */
  55426. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55427. /**
  55428. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55429. * @param data contains the texture data
  55430. * @param texture defines the BabylonJS internal texture
  55431. * @param callback defines the method to call once ready to upload
  55432. */
  55433. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55434. }
  55435. }
  55436. declare module "babylonjs/Helpers/sceneHelpers" {
  55437. import { Nullable } from "babylonjs/types";
  55438. import { Mesh } from "babylonjs/Meshes/mesh";
  55439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55440. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55441. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55442. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55443. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55444. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55445. import "babylonjs/Meshes/Builders/boxBuilder";
  55446. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55447. /** @hidden */
  55448. export var _forceSceneHelpersToBundle: boolean;
  55449. module "babylonjs/scene" {
  55450. interface Scene {
  55451. /**
  55452. * Creates a default light for the scene.
  55453. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55454. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55455. */
  55456. createDefaultLight(replace?: boolean): void;
  55457. /**
  55458. * Creates a default camera for the scene.
  55459. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55460. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55461. * @param replace has default false, when true replaces the active camera in the scene
  55462. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55463. */
  55464. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55465. /**
  55466. * Creates a default camera and a default light.
  55467. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55468. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55469. * @param replace has the default false, when true replaces the active camera/light in the scene
  55470. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55471. */
  55472. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55473. /**
  55474. * Creates a new sky box
  55475. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55476. * @param environmentTexture defines the texture to use as environment texture
  55477. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55478. * @param scale defines the overall scale of the skybox
  55479. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55480. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55481. * @returns a new mesh holding the sky box
  55482. */
  55483. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55484. /**
  55485. * Creates a new environment
  55486. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55487. * @param options defines the options you can use to configure the environment
  55488. * @returns the new EnvironmentHelper
  55489. */
  55490. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55491. /**
  55492. * Creates a new VREXperienceHelper
  55493. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55494. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55495. * @returns a new VREXperienceHelper
  55496. */
  55497. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55498. /**
  55499. * Creates a new WebXRDefaultExperience
  55500. * @see http://doc.babylonjs.com/how_to/webxr
  55501. * @param options experience options
  55502. * @returns a promise for a new WebXRDefaultExperience
  55503. */
  55504. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55505. }
  55506. }
  55507. }
  55508. declare module "babylonjs/Helpers/videoDome" {
  55509. import { Scene } from "babylonjs/scene";
  55510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55511. import { Mesh } from "babylonjs/Meshes/mesh";
  55512. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55513. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55514. import "babylonjs/Meshes/Builders/sphereBuilder";
  55515. /**
  55516. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55517. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55518. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55519. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55520. */
  55521. export class VideoDome extends TransformNode {
  55522. /**
  55523. * Define the video source as a Monoscopic panoramic 360 video.
  55524. */
  55525. static readonly MODE_MONOSCOPIC: number;
  55526. /**
  55527. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55528. */
  55529. static readonly MODE_TOPBOTTOM: number;
  55530. /**
  55531. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55532. */
  55533. static readonly MODE_SIDEBYSIDE: number;
  55534. private _halfDome;
  55535. private _useDirectMapping;
  55536. /**
  55537. * The video texture being displayed on the sphere
  55538. */
  55539. protected _videoTexture: VideoTexture;
  55540. /**
  55541. * Gets the video texture being displayed on the sphere
  55542. */
  55543. get videoTexture(): VideoTexture;
  55544. /**
  55545. * The skybox material
  55546. */
  55547. protected _material: BackgroundMaterial;
  55548. /**
  55549. * The surface used for the skybox
  55550. */
  55551. protected _mesh: Mesh;
  55552. /**
  55553. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55554. */
  55555. private _halfDomeMask;
  55556. /**
  55557. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55558. * Also see the options.resolution property.
  55559. */
  55560. get fovMultiplier(): number;
  55561. set fovMultiplier(value: number);
  55562. private _videoMode;
  55563. /**
  55564. * Gets or set the current video mode for the video. It can be:
  55565. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55566. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55567. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55568. */
  55569. get videoMode(): number;
  55570. set videoMode(value: number);
  55571. /**
  55572. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55573. *
  55574. */
  55575. get halfDome(): boolean;
  55576. /**
  55577. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55578. */
  55579. set halfDome(enabled: boolean);
  55580. /**
  55581. * Oberserver used in Stereoscopic VR Mode.
  55582. */
  55583. private _onBeforeCameraRenderObserver;
  55584. /**
  55585. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55586. * @param name Element's name, child elements will append suffixes for their own names.
  55587. * @param urlsOrVideo defines the url(s) or the video element to use
  55588. * @param options An object containing optional or exposed sub element properties
  55589. */
  55590. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55591. resolution?: number;
  55592. clickToPlay?: boolean;
  55593. autoPlay?: boolean;
  55594. loop?: boolean;
  55595. size?: number;
  55596. poster?: string;
  55597. faceForward?: boolean;
  55598. useDirectMapping?: boolean;
  55599. halfDomeMode?: boolean;
  55600. }, scene: Scene);
  55601. private _changeVideoMode;
  55602. /**
  55603. * Releases resources associated with this node.
  55604. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55605. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55606. */
  55607. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55608. }
  55609. }
  55610. declare module "babylonjs/Helpers/index" {
  55611. export * from "babylonjs/Helpers/environmentHelper";
  55612. export * from "babylonjs/Helpers/photoDome";
  55613. export * from "babylonjs/Helpers/sceneHelpers";
  55614. export * from "babylonjs/Helpers/videoDome";
  55615. }
  55616. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55617. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55618. import { IDisposable } from "babylonjs/scene";
  55619. import { Engine } from "babylonjs/Engines/engine";
  55620. /**
  55621. * This class can be used to get instrumentation data from a Babylon engine
  55622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55623. */
  55624. export class EngineInstrumentation implements IDisposable {
  55625. /**
  55626. * Define the instrumented engine.
  55627. */
  55628. engine: Engine;
  55629. private _captureGPUFrameTime;
  55630. private _gpuFrameTimeToken;
  55631. private _gpuFrameTime;
  55632. private _captureShaderCompilationTime;
  55633. private _shaderCompilationTime;
  55634. private _onBeginFrameObserver;
  55635. private _onEndFrameObserver;
  55636. private _onBeforeShaderCompilationObserver;
  55637. private _onAfterShaderCompilationObserver;
  55638. /**
  55639. * Gets the perf counter used for GPU frame time
  55640. */
  55641. get gpuFrameTimeCounter(): PerfCounter;
  55642. /**
  55643. * Gets the GPU frame time capture status
  55644. */
  55645. get captureGPUFrameTime(): boolean;
  55646. /**
  55647. * Enable or disable the GPU frame time capture
  55648. */
  55649. set captureGPUFrameTime(value: boolean);
  55650. /**
  55651. * Gets the perf counter used for shader compilation time
  55652. */
  55653. get shaderCompilationTimeCounter(): PerfCounter;
  55654. /**
  55655. * Gets the shader compilation time capture status
  55656. */
  55657. get captureShaderCompilationTime(): boolean;
  55658. /**
  55659. * Enable or disable the shader compilation time capture
  55660. */
  55661. set captureShaderCompilationTime(value: boolean);
  55662. /**
  55663. * Instantiates a new engine instrumentation.
  55664. * This class can be used to get instrumentation data from a Babylon engine
  55665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55666. * @param engine Defines the engine to instrument
  55667. */
  55668. constructor(
  55669. /**
  55670. * Define the instrumented engine.
  55671. */
  55672. engine: Engine);
  55673. /**
  55674. * Dispose and release associated resources.
  55675. */
  55676. dispose(): void;
  55677. }
  55678. }
  55679. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55680. import { Scene, IDisposable } from "babylonjs/scene";
  55681. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55682. /**
  55683. * This class can be used to get instrumentation data from a Babylon engine
  55684. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55685. */
  55686. export class SceneInstrumentation implements IDisposable {
  55687. /**
  55688. * Defines the scene to instrument
  55689. */
  55690. scene: Scene;
  55691. private _captureActiveMeshesEvaluationTime;
  55692. private _activeMeshesEvaluationTime;
  55693. private _captureRenderTargetsRenderTime;
  55694. private _renderTargetsRenderTime;
  55695. private _captureFrameTime;
  55696. private _frameTime;
  55697. private _captureRenderTime;
  55698. private _renderTime;
  55699. private _captureInterFrameTime;
  55700. private _interFrameTime;
  55701. private _captureParticlesRenderTime;
  55702. private _particlesRenderTime;
  55703. private _captureSpritesRenderTime;
  55704. private _spritesRenderTime;
  55705. private _capturePhysicsTime;
  55706. private _physicsTime;
  55707. private _captureAnimationsTime;
  55708. private _animationsTime;
  55709. private _captureCameraRenderTime;
  55710. private _cameraRenderTime;
  55711. private _onBeforeActiveMeshesEvaluationObserver;
  55712. private _onAfterActiveMeshesEvaluationObserver;
  55713. private _onBeforeRenderTargetsRenderObserver;
  55714. private _onAfterRenderTargetsRenderObserver;
  55715. private _onAfterRenderObserver;
  55716. private _onBeforeDrawPhaseObserver;
  55717. private _onAfterDrawPhaseObserver;
  55718. private _onBeforeAnimationsObserver;
  55719. private _onBeforeParticlesRenderingObserver;
  55720. private _onAfterParticlesRenderingObserver;
  55721. private _onBeforeSpritesRenderingObserver;
  55722. private _onAfterSpritesRenderingObserver;
  55723. private _onBeforePhysicsObserver;
  55724. private _onAfterPhysicsObserver;
  55725. private _onAfterAnimationsObserver;
  55726. private _onBeforeCameraRenderObserver;
  55727. private _onAfterCameraRenderObserver;
  55728. /**
  55729. * Gets the perf counter used for active meshes evaluation time
  55730. */
  55731. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55732. /**
  55733. * Gets the active meshes evaluation time capture status
  55734. */
  55735. get captureActiveMeshesEvaluationTime(): boolean;
  55736. /**
  55737. * Enable or disable the active meshes evaluation time capture
  55738. */
  55739. set captureActiveMeshesEvaluationTime(value: boolean);
  55740. /**
  55741. * Gets the perf counter used for render targets render time
  55742. */
  55743. get renderTargetsRenderTimeCounter(): PerfCounter;
  55744. /**
  55745. * Gets the render targets render time capture status
  55746. */
  55747. get captureRenderTargetsRenderTime(): boolean;
  55748. /**
  55749. * Enable or disable the render targets render time capture
  55750. */
  55751. set captureRenderTargetsRenderTime(value: boolean);
  55752. /**
  55753. * Gets the perf counter used for particles render time
  55754. */
  55755. get particlesRenderTimeCounter(): PerfCounter;
  55756. /**
  55757. * Gets the particles render time capture status
  55758. */
  55759. get captureParticlesRenderTime(): boolean;
  55760. /**
  55761. * Enable or disable the particles render time capture
  55762. */
  55763. set captureParticlesRenderTime(value: boolean);
  55764. /**
  55765. * Gets the perf counter used for sprites render time
  55766. */
  55767. get spritesRenderTimeCounter(): PerfCounter;
  55768. /**
  55769. * Gets the sprites render time capture status
  55770. */
  55771. get captureSpritesRenderTime(): boolean;
  55772. /**
  55773. * Enable or disable the sprites render time capture
  55774. */
  55775. set captureSpritesRenderTime(value: boolean);
  55776. /**
  55777. * Gets the perf counter used for physics time
  55778. */
  55779. get physicsTimeCounter(): PerfCounter;
  55780. /**
  55781. * Gets the physics time capture status
  55782. */
  55783. get capturePhysicsTime(): boolean;
  55784. /**
  55785. * Enable or disable the physics time capture
  55786. */
  55787. set capturePhysicsTime(value: boolean);
  55788. /**
  55789. * Gets the perf counter used for animations time
  55790. */
  55791. get animationsTimeCounter(): PerfCounter;
  55792. /**
  55793. * Gets the animations time capture status
  55794. */
  55795. get captureAnimationsTime(): boolean;
  55796. /**
  55797. * Enable or disable the animations time capture
  55798. */
  55799. set captureAnimationsTime(value: boolean);
  55800. /**
  55801. * Gets the perf counter used for frame time capture
  55802. */
  55803. get frameTimeCounter(): PerfCounter;
  55804. /**
  55805. * Gets the frame time capture status
  55806. */
  55807. get captureFrameTime(): boolean;
  55808. /**
  55809. * Enable or disable the frame time capture
  55810. */
  55811. set captureFrameTime(value: boolean);
  55812. /**
  55813. * Gets the perf counter used for inter-frames time capture
  55814. */
  55815. get interFrameTimeCounter(): PerfCounter;
  55816. /**
  55817. * Gets the inter-frames time capture status
  55818. */
  55819. get captureInterFrameTime(): boolean;
  55820. /**
  55821. * Enable or disable the inter-frames time capture
  55822. */
  55823. set captureInterFrameTime(value: boolean);
  55824. /**
  55825. * Gets the perf counter used for render time capture
  55826. */
  55827. get renderTimeCounter(): PerfCounter;
  55828. /**
  55829. * Gets the render time capture status
  55830. */
  55831. get captureRenderTime(): boolean;
  55832. /**
  55833. * Enable or disable the render time capture
  55834. */
  55835. set captureRenderTime(value: boolean);
  55836. /**
  55837. * Gets the perf counter used for camera render time capture
  55838. */
  55839. get cameraRenderTimeCounter(): PerfCounter;
  55840. /**
  55841. * Gets the camera render time capture status
  55842. */
  55843. get captureCameraRenderTime(): boolean;
  55844. /**
  55845. * Enable or disable the camera render time capture
  55846. */
  55847. set captureCameraRenderTime(value: boolean);
  55848. /**
  55849. * Gets the perf counter used for draw calls
  55850. */
  55851. get drawCallsCounter(): PerfCounter;
  55852. /**
  55853. * Instantiates a new scene instrumentation.
  55854. * This class can be used to get instrumentation data from a Babylon engine
  55855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55856. * @param scene Defines the scene to instrument
  55857. */
  55858. constructor(
  55859. /**
  55860. * Defines the scene to instrument
  55861. */
  55862. scene: Scene);
  55863. /**
  55864. * Dispose and release associated resources.
  55865. */
  55866. dispose(): void;
  55867. }
  55868. }
  55869. declare module "babylonjs/Instrumentation/index" {
  55870. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55871. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55872. export * from "babylonjs/Instrumentation/timeToken";
  55873. }
  55874. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55875. /** @hidden */
  55876. export var glowMapGenerationPixelShader: {
  55877. name: string;
  55878. shader: string;
  55879. };
  55880. }
  55881. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55882. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55883. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55884. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55885. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55886. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55887. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55888. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55889. /** @hidden */
  55890. export var glowMapGenerationVertexShader: {
  55891. name: string;
  55892. shader: string;
  55893. };
  55894. }
  55895. declare module "babylonjs/Layers/effectLayer" {
  55896. import { Observable } from "babylonjs/Misc/observable";
  55897. import { Nullable } from "babylonjs/types";
  55898. import { Camera } from "babylonjs/Cameras/camera";
  55899. import { Scene } from "babylonjs/scene";
  55900. import { ISize } from "babylonjs/Maths/math.size";
  55901. import { Color4 } from "babylonjs/Maths/math.color";
  55902. import { Engine } from "babylonjs/Engines/engine";
  55903. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55905. import { Mesh } from "babylonjs/Meshes/mesh";
  55906. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55908. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55909. import { Effect } from "babylonjs/Materials/effect";
  55910. import { Material } from "babylonjs/Materials/material";
  55911. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55912. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55913. /**
  55914. * Effect layer options. This helps customizing the behaviour
  55915. * of the effect layer.
  55916. */
  55917. export interface IEffectLayerOptions {
  55918. /**
  55919. * Multiplication factor apply to the canvas size to compute the render target size
  55920. * used to generated the objects (the smaller the faster).
  55921. */
  55922. mainTextureRatio: number;
  55923. /**
  55924. * Enforces a fixed size texture to ensure effect stability across devices.
  55925. */
  55926. mainTextureFixedSize?: number;
  55927. /**
  55928. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55929. */
  55930. alphaBlendingMode: number;
  55931. /**
  55932. * The camera attached to the layer.
  55933. */
  55934. camera: Nullable<Camera>;
  55935. /**
  55936. * The rendering group to draw the layer in.
  55937. */
  55938. renderingGroupId: number;
  55939. }
  55940. /**
  55941. * The effect layer Helps adding post process effect blended with the main pass.
  55942. *
  55943. * This can be for instance use to generate glow or higlight effects on the scene.
  55944. *
  55945. * The effect layer class can not be used directly and is intented to inherited from to be
  55946. * customized per effects.
  55947. */
  55948. export abstract class EffectLayer {
  55949. private _vertexBuffers;
  55950. private _indexBuffer;
  55951. private _cachedDefines;
  55952. private _effectLayerMapGenerationEffect;
  55953. private _effectLayerOptions;
  55954. private _mergeEffect;
  55955. protected _scene: Scene;
  55956. protected _engine: Engine;
  55957. protected _maxSize: number;
  55958. protected _mainTextureDesiredSize: ISize;
  55959. protected _mainTexture: RenderTargetTexture;
  55960. protected _shouldRender: boolean;
  55961. protected _postProcesses: PostProcess[];
  55962. protected _textures: BaseTexture[];
  55963. protected _emissiveTextureAndColor: {
  55964. texture: Nullable<BaseTexture>;
  55965. color: Color4;
  55966. };
  55967. /**
  55968. * The name of the layer
  55969. */
  55970. name: string;
  55971. /**
  55972. * The clear color of the texture used to generate the glow map.
  55973. */
  55974. neutralColor: Color4;
  55975. /**
  55976. * Specifies whether the highlight layer is enabled or not.
  55977. */
  55978. isEnabled: boolean;
  55979. /**
  55980. * Gets the camera attached to the layer.
  55981. */
  55982. get camera(): Nullable<Camera>;
  55983. /**
  55984. * Gets the rendering group id the layer should render in.
  55985. */
  55986. get renderingGroupId(): number;
  55987. set renderingGroupId(renderingGroupId: number);
  55988. /**
  55989. * An event triggered when the effect layer has been disposed.
  55990. */
  55991. onDisposeObservable: Observable<EffectLayer>;
  55992. /**
  55993. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55994. */
  55995. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55996. /**
  55997. * An event triggered when the generated texture is being merged in the scene.
  55998. */
  55999. onBeforeComposeObservable: Observable<EffectLayer>;
  56000. /**
  56001. * An event triggered when the mesh is rendered into the effect render target.
  56002. */
  56003. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56004. /**
  56005. * An event triggered after the mesh has been rendered into the effect render target.
  56006. */
  56007. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56008. /**
  56009. * An event triggered when the generated texture has been merged in the scene.
  56010. */
  56011. onAfterComposeObservable: Observable<EffectLayer>;
  56012. /**
  56013. * An event triggered when the efffect layer changes its size.
  56014. */
  56015. onSizeChangedObservable: Observable<EffectLayer>;
  56016. /** @hidden */
  56017. static _SceneComponentInitialization: (scene: Scene) => void;
  56018. /**
  56019. * Instantiates a new effect Layer and references it in the scene.
  56020. * @param name The name of the layer
  56021. * @param scene The scene to use the layer in
  56022. */
  56023. constructor(
  56024. /** The Friendly of the effect in the scene */
  56025. name: string, scene: Scene);
  56026. /**
  56027. * Get the effect name of the layer.
  56028. * @return The effect name
  56029. */
  56030. abstract getEffectName(): string;
  56031. /**
  56032. * Checks for the readiness of the element composing the layer.
  56033. * @param subMesh the mesh to check for
  56034. * @param useInstances specify whether or not to use instances to render the mesh
  56035. * @return true if ready otherwise, false
  56036. */
  56037. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56038. /**
  56039. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56040. * @returns true if the effect requires stencil during the main canvas render pass.
  56041. */
  56042. abstract needStencil(): boolean;
  56043. /**
  56044. * Create the merge effect. This is the shader use to blit the information back
  56045. * to the main canvas at the end of the scene rendering.
  56046. * @returns The effect containing the shader used to merge the effect on the main canvas
  56047. */
  56048. protected abstract _createMergeEffect(): Effect;
  56049. /**
  56050. * Creates the render target textures and post processes used in the effect layer.
  56051. */
  56052. protected abstract _createTextureAndPostProcesses(): void;
  56053. /**
  56054. * Implementation specific of rendering the generating effect on the main canvas.
  56055. * @param effect The effect used to render through
  56056. */
  56057. protected abstract _internalRender(effect: Effect): void;
  56058. /**
  56059. * Sets the required values for both the emissive texture and and the main color.
  56060. */
  56061. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56062. /**
  56063. * Free any resources and references associated to a mesh.
  56064. * Internal use
  56065. * @param mesh The mesh to free.
  56066. */
  56067. abstract _disposeMesh(mesh: Mesh): void;
  56068. /**
  56069. * Serializes this layer (Glow or Highlight for example)
  56070. * @returns a serialized layer object
  56071. */
  56072. abstract serialize?(): any;
  56073. /**
  56074. * Initializes the effect layer with the required options.
  56075. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56076. */
  56077. protected _init(options: Partial<IEffectLayerOptions>): void;
  56078. /**
  56079. * Generates the index buffer of the full screen quad blending to the main canvas.
  56080. */
  56081. private _generateIndexBuffer;
  56082. /**
  56083. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56084. */
  56085. private _generateVertexBuffer;
  56086. /**
  56087. * Sets the main texture desired size which is the closest power of two
  56088. * of the engine canvas size.
  56089. */
  56090. private _setMainTextureSize;
  56091. /**
  56092. * Creates the main texture for the effect layer.
  56093. */
  56094. protected _createMainTexture(): void;
  56095. /**
  56096. * Adds specific effects defines.
  56097. * @param defines The defines to add specifics to.
  56098. */
  56099. protected _addCustomEffectDefines(defines: string[]): void;
  56100. /**
  56101. * Checks for the readiness of the element composing the layer.
  56102. * @param subMesh the mesh to check for
  56103. * @param useInstances specify whether or not to use instances to render the mesh
  56104. * @param emissiveTexture the associated emissive texture used to generate the glow
  56105. * @return true if ready otherwise, false
  56106. */
  56107. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56108. /**
  56109. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56110. */
  56111. render(): void;
  56112. /**
  56113. * Determine if a given mesh will be used in the current effect.
  56114. * @param mesh mesh to test
  56115. * @returns true if the mesh will be used
  56116. */
  56117. hasMesh(mesh: AbstractMesh): boolean;
  56118. /**
  56119. * Returns true if the layer contains information to display, otherwise false.
  56120. * @returns true if the glow layer should be rendered
  56121. */
  56122. shouldRender(): boolean;
  56123. /**
  56124. * Returns true if the mesh should render, otherwise false.
  56125. * @param mesh The mesh to render
  56126. * @returns true if it should render otherwise false
  56127. */
  56128. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56129. /**
  56130. * Returns true if the mesh can be rendered, otherwise false.
  56131. * @param mesh The mesh to render
  56132. * @param material The material used on the mesh
  56133. * @returns true if it can be rendered otherwise false
  56134. */
  56135. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56136. /**
  56137. * Returns true if the mesh should render, otherwise false.
  56138. * @param mesh The mesh to render
  56139. * @returns true if it should render otherwise false
  56140. */
  56141. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56142. /**
  56143. * Renders the submesh passed in parameter to the generation map.
  56144. */
  56145. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56146. /**
  56147. * Defines whether the current material of the mesh should be use to render the effect.
  56148. * @param mesh defines the current mesh to render
  56149. */
  56150. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56151. /**
  56152. * Rebuild the required buffers.
  56153. * @hidden Internal use only.
  56154. */
  56155. _rebuild(): void;
  56156. /**
  56157. * Dispose only the render target textures and post process.
  56158. */
  56159. private _disposeTextureAndPostProcesses;
  56160. /**
  56161. * Dispose the highlight layer and free resources.
  56162. */
  56163. dispose(): void;
  56164. /**
  56165. * Gets the class name of the effect layer
  56166. * @returns the string with the class name of the effect layer
  56167. */
  56168. getClassName(): string;
  56169. /**
  56170. * Creates an effect layer from parsed effect layer data
  56171. * @param parsedEffectLayer defines effect layer data
  56172. * @param scene defines the current scene
  56173. * @param rootUrl defines the root URL containing the effect layer information
  56174. * @returns a parsed effect Layer
  56175. */
  56176. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56177. }
  56178. }
  56179. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  56180. import { Scene } from "babylonjs/scene";
  56181. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56182. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56183. import { AbstractScene } from "babylonjs/abstractScene";
  56184. module "babylonjs/abstractScene" {
  56185. interface AbstractScene {
  56186. /**
  56187. * The list of effect layers (highlights/glow) added to the scene
  56188. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56189. * @see http://doc.babylonjs.com/how_to/glow_layer
  56190. */
  56191. effectLayers: Array<EffectLayer>;
  56192. /**
  56193. * Removes the given effect layer from this scene.
  56194. * @param toRemove defines the effect layer to remove
  56195. * @returns the index of the removed effect layer
  56196. */
  56197. removeEffectLayer(toRemove: EffectLayer): number;
  56198. /**
  56199. * Adds the given effect layer to this scene
  56200. * @param newEffectLayer defines the effect layer to add
  56201. */
  56202. addEffectLayer(newEffectLayer: EffectLayer): void;
  56203. }
  56204. }
  56205. /**
  56206. * Defines the layer scene component responsible to manage any effect layers
  56207. * in a given scene.
  56208. */
  56209. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56210. /**
  56211. * The component name helpfull to identify the component in the list of scene components.
  56212. */
  56213. readonly name: string;
  56214. /**
  56215. * The scene the component belongs to.
  56216. */
  56217. scene: Scene;
  56218. private _engine;
  56219. private _renderEffects;
  56220. private _needStencil;
  56221. private _previousStencilState;
  56222. /**
  56223. * Creates a new instance of the component for the given scene
  56224. * @param scene Defines the scene to register the component in
  56225. */
  56226. constructor(scene: Scene);
  56227. /**
  56228. * Registers the component in a given scene
  56229. */
  56230. register(): void;
  56231. /**
  56232. * Rebuilds the elements related to this component in case of
  56233. * context lost for instance.
  56234. */
  56235. rebuild(): void;
  56236. /**
  56237. * Serializes the component data to the specified json object
  56238. * @param serializationObject The object to serialize to
  56239. */
  56240. serialize(serializationObject: any): void;
  56241. /**
  56242. * Adds all the elements from the container to the scene
  56243. * @param container the container holding the elements
  56244. */
  56245. addFromContainer(container: AbstractScene): void;
  56246. /**
  56247. * Removes all the elements in the container from the scene
  56248. * @param container contains the elements to remove
  56249. * @param dispose if the removed element should be disposed (default: false)
  56250. */
  56251. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56252. /**
  56253. * Disposes the component and the associated ressources.
  56254. */
  56255. dispose(): void;
  56256. private _isReadyForMesh;
  56257. private _renderMainTexture;
  56258. private _setStencil;
  56259. private _setStencilBack;
  56260. private _draw;
  56261. private _drawCamera;
  56262. private _drawRenderingGroup;
  56263. }
  56264. }
  56265. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  56266. /** @hidden */
  56267. export var glowMapMergePixelShader: {
  56268. name: string;
  56269. shader: string;
  56270. };
  56271. }
  56272. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  56273. /** @hidden */
  56274. export var glowMapMergeVertexShader: {
  56275. name: string;
  56276. shader: string;
  56277. };
  56278. }
  56279. declare module "babylonjs/Layers/glowLayer" {
  56280. import { Nullable } from "babylonjs/types";
  56281. import { Camera } from "babylonjs/Cameras/camera";
  56282. import { Scene } from "babylonjs/scene";
  56283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56285. import { Mesh } from "babylonjs/Meshes/mesh";
  56286. import { Texture } from "babylonjs/Materials/Textures/texture";
  56287. import { Effect } from "babylonjs/Materials/effect";
  56288. import { Material } from "babylonjs/Materials/material";
  56289. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56290. import { Color4 } from "babylonjs/Maths/math.color";
  56291. import "babylonjs/Shaders/glowMapMerge.fragment";
  56292. import "babylonjs/Shaders/glowMapMerge.vertex";
  56293. import "babylonjs/Layers/effectLayerSceneComponent";
  56294. module "babylonjs/abstractScene" {
  56295. interface AbstractScene {
  56296. /**
  56297. * Return a the first highlight layer of the scene with a given name.
  56298. * @param name The name of the highlight layer to look for.
  56299. * @return The highlight layer if found otherwise null.
  56300. */
  56301. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56302. }
  56303. }
  56304. /**
  56305. * Glow layer options. This helps customizing the behaviour
  56306. * of the glow layer.
  56307. */
  56308. export interface IGlowLayerOptions {
  56309. /**
  56310. * Multiplication factor apply to the canvas size to compute the render target size
  56311. * used to generated the glowing objects (the smaller the faster).
  56312. */
  56313. mainTextureRatio: number;
  56314. /**
  56315. * Enforces a fixed size texture to ensure resize independant blur.
  56316. */
  56317. mainTextureFixedSize?: number;
  56318. /**
  56319. * How big is the kernel of the blur texture.
  56320. */
  56321. blurKernelSize: number;
  56322. /**
  56323. * The camera attached to the layer.
  56324. */
  56325. camera: Nullable<Camera>;
  56326. /**
  56327. * Enable MSAA by chosing the number of samples.
  56328. */
  56329. mainTextureSamples?: number;
  56330. /**
  56331. * The rendering group to draw the layer in.
  56332. */
  56333. renderingGroupId: number;
  56334. }
  56335. /**
  56336. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56337. *
  56338. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56339. *
  56340. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56341. */
  56342. export class GlowLayer extends EffectLayer {
  56343. /**
  56344. * Effect Name of the layer.
  56345. */
  56346. static readonly EffectName: string;
  56347. /**
  56348. * The default blur kernel size used for the glow.
  56349. */
  56350. static DefaultBlurKernelSize: number;
  56351. /**
  56352. * The default texture size ratio used for the glow.
  56353. */
  56354. static DefaultTextureRatio: number;
  56355. /**
  56356. * Sets the kernel size of the blur.
  56357. */
  56358. set blurKernelSize(value: number);
  56359. /**
  56360. * Gets the kernel size of the blur.
  56361. */
  56362. get blurKernelSize(): number;
  56363. /**
  56364. * Sets the glow intensity.
  56365. */
  56366. set intensity(value: number);
  56367. /**
  56368. * Gets the glow intensity.
  56369. */
  56370. get intensity(): number;
  56371. private _options;
  56372. private _intensity;
  56373. private _horizontalBlurPostprocess1;
  56374. private _verticalBlurPostprocess1;
  56375. private _horizontalBlurPostprocess2;
  56376. private _verticalBlurPostprocess2;
  56377. private _blurTexture1;
  56378. private _blurTexture2;
  56379. private _postProcesses1;
  56380. private _postProcesses2;
  56381. private _includedOnlyMeshes;
  56382. private _excludedMeshes;
  56383. private _meshesUsingTheirOwnMaterials;
  56384. /**
  56385. * Callback used to let the user override the color selection on a per mesh basis
  56386. */
  56387. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56388. /**
  56389. * Callback used to let the user override the texture selection on a per mesh basis
  56390. */
  56391. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56392. /**
  56393. * Instantiates a new glow Layer and references it to the scene.
  56394. * @param name The name of the layer
  56395. * @param scene The scene to use the layer in
  56396. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56397. */
  56398. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56399. /**
  56400. * Get the effect name of the layer.
  56401. * @return The effect name
  56402. */
  56403. getEffectName(): string;
  56404. /**
  56405. * Create the merge effect. This is the shader use to blit the information back
  56406. * to the main canvas at the end of the scene rendering.
  56407. */
  56408. protected _createMergeEffect(): Effect;
  56409. /**
  56410. * Creates the render target textures and post processes used in the glow layer.
  56411. */
  56412. protected _createTextureAndPostProcesses(): void;
  56413. /**
  56414. * Checks for the readiness of the element composing the layer.
  56415. * @param subMesh the mesh to check for
  56416. * @param useInstances specify wether or not to use instances to render the mesh
  56417. * @param emissiveTexture the associated emissive texture used to generate the glow
  56418. * @return true if ready otherwise, false
  56419. */
  56420. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56421. /**
  56422. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56423. */
  56424. needStencil(): boolean;
  56425. /**
  56426. * Returns true if the mesh can be rendered, otherwise false.
  56427. * @param mesh The mesh to render
  56428. * @param material The material used on the mesh
  56429. * @returns true if it can be rendered otherwise false
  56430. */
  56431. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56432. /**
  56433. * Implementation specific of rendering the generating effect on the main canvas.
  56434. * @param effect The effect used to render through
  56435. */
  56436. protected _internalRender(effect: Effect): void;
  56437. /**
  56438. * Sets the required values for both the emissive texture and and the main color.
  56439. */
  56440. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56441. /**
  56442. * Returns true if the mesh should render, otherwise false.
  56443. * @param mesh The mesh to render
  56444. * @returns true if it should render otherwise false
  56445. */
  56446. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56447. /**
  56448. * Adds specific effects defines.
  56449. * @param defines The defines to add specifics to.
  56450. */
  56451. protected _addCustomEffectDefines(defines: string[]): void;
  56452. /**
  56453. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56454. * @param mesh The mesh to exclude from the glow layer
  56455. */
  56456. addExcludedMesh(mesh: Mesh): void;
  56457. /**
  56458. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56459. * @param mesh The mesh to remove
  56460. */
  56461. removeExcludedMesh(mesh: Mesh): void;
  56462. /**
  56463. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56464. * @param mesh The mesh to include in the glow layer
  56465. */
  56466. addIncludedOnlyMesh(mesh: Mesh): void;
  56467. /**
  56468. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56469. * @param mesh The mesh to remove
  56470. */
  56471. removeIncludedOnlyMesh(mesh: Mesh): void;
  56472. /**
  56473. * Determine if a given mesh will be used in the glow layer
  56474. * @param mesh The mesh to test
  56475. * @returns true if the mesh will be highlighted by the current glow layer
  56476. */
  56477. hasMesh(mesh: AbstractMesh): boolean;
  56478. /**
  56479. * Defines whether the current material of the mesh should be use to render the effect.
  56480. * @param mesh defines the current mesh to render
  56481. */
  56482. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56483. /**
  56484. * Add a mesh to be rendered through its own material and not with emissive only.
  56485. * @param mesh The mesh for which we need to use its material
  56486. */
  56487. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56488. /**
  56489. * Remove a mesh from being rendered through its own material and not with emissive only.
  56490. * @param mesh The mesh for which we need to not use its material
  56491. */
  56492. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56493. /**
  56494. * Free any resources and references associated to a mesh.
  56495. * Internal use
  56496. * @param mesh The mesh to free.
  56497. * @hidden
  56498. */
  56499. _disposeMesh(mesh: Mesh): void;
  56500. /**
  56501. * Gets the class name of the effect layer
  56502. * @returns the string with the class name of the effect layer
  56503. */
  56504. getClassName(): string;
  56505. /**
  56506. * Serializes this glow layer
  56507. * @returns a serialized glow layer object
  56508. */
  56509. serialize(): any;
  56510. /**
  56511. * Creates a Glow Layer from parsed glow layer data
  56512. * @param parsedGlowLayer defines glow layer data
  56513. * @param scene defines the current scene
  56514. * @param rootUrl defines the root URL containing the glow layer information
  56515. * @returns a parsed Glow Layer
  56516. */
  56517. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56518. }
  56519. }
  56520. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56521. /** @hidden */
  56522. export var glowBlurPostProcessPixelShader: {
  56523. name: string;
  56524. shader: string;
  56525. };
  56526. }
  56527. declare module "babylonjs/Layers/highlightLayer" {
  56528. import { Observable } from "babylonjs/Misc/observable";
  56529. import { Nullable } from "babylonjs/types";
  56530. import { Camera } from "babylonjs/Cameras/camera";
  56531. import { Scene } from "babylonjs/scene";
  56532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56534. import { Mesh } from "babylonjs/Meshes/mesh";
  56535. import { Effect } from "babylonjs/Materials/effect";
  56536. import { Material } from "babylonjs/Materials/material";
  56537. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56538. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56539. import "babylonjs/Shaders/glowMapMerge.fragment";
  56540. import "babylonjs/Shaders/glowMapMerge.vertex";
  56541. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56542. module "babylonjs/abstractScene" {
  56543. interface AbstractScene {
  56544. /**
  56545. * Return a the first highlight layer of the scene with a given name.
  56546. * @param name The name of the highlight layer to look for.
  56547. * @return The highlight layer if found otherwise null.
  56548. */
  56549. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56550. }
  56551. }
  56552. /**
  56553. * Highlight layer options. This helps customizing the behaviour
  56554. * of the highlight layer.
  56555. */
  56556. export interface IHighlightLayerOptions {
  56557. /**
  56558. * Multiplication factor apply to the canvas size to compute the render target size
  56559. * used to generated the glowing objects (the smaller the faster).
  56560. */
  56561. mainTextureRatio: number;
  56562. /**
  56563. * Enforces a fixed size texture to ensure resize independant blur.
  56564. */
  56565. mainTextureFixedSize?: number;
  56566. /**
  56567. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56568. * of the picture to blur (the smaller the faster).
  56569. */
  56570. blurTextureSizeRatio: number;
  56571. /**
  56572. * How big in texel of the blur texture is the vertical blur.
  56573. */
  56574. blurVerticalSize: number;
  56575. /**
  56576. * How big in texel of the blur texture is the horizontal blur.
  56577. */
  56578. blurHorizontalSize: number;
  56579. /**
  56580. * Alpha blending mode used to apply the blur. Default is combine.
  56581. */
  56582. alphaBlendingMode: number;
  56583. /**
  56584. * The camera attached to the layer.
  56585. */
  56586. camera: Nullable<Camera>;
  56587. /**
  56588. * Should we display highlight as a solid stroke?
  56589. */
  56590. isStroke?: boolean;
  56591. /**
  56592. * The rendering group to draw the layer in.
  56593. */
  56594. renderingGroupId: number;
  56595. }
  56596. /**
  56597. * The highlight layer Helps adding a glow effect around a mesh.
  56598. *
  56599. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56600. * glowy meshes to your scene.
  56601. *
  56602. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56603. */
  56604. export class HighlightLayer extends EffectLayer {
  56605. name: string;
  56606. /**
  56607. * Effect Name of the highlight layer.
  56608. */
  56609. static readonly EffectName: string;
  56610. /**
  56611. * The neutral color used during the preparation of the glow effect.
  56612. * This is black by default as the blend operation is a blend operation.
  56613. */
  56614. static NeutralColor: Color4;
  56615. /**
  56616. * Stencil value used for glowing meshes.
  56617. */
  56618. static GlowingMeshStencilReference: number;
  56619. /**
  56620. * Stencil value used for the other meshes in the scene.
  56621. */
  56622. static NormalMeshStencilReference: number;
  56623. /**
  56624. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56625. */
  56626. innerGlow: boolean;
  56627. /**
  56628. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56629. */
  56630. outerGlow: boolean;
  56631. /**
  56632. * Specifies the horizontal size of the blur.
  56633. */
  56634. set blurHorizontalSize(value: number);
  56635. /**
  56636. * Specifies the vertical size of the blur.
  56637. */
  56638. set blurVerticalSize(value: number);
  56639. /**
  56640. * Gets the horizontal size of the blur.
  56641. */
  56642. get blurHorizontalSize(): number;
  56643. /**
  56644. * Gets the vertical size of the blur.
  56645. */
  56646. get blurVerticalSize(): number;
  56647. /**
  56648. * An event triggered when the highlight layer is being blurred.
  56649. */
  56650. onBeforeBlurObservable: Observable<HighlightLayer>;
  56651. /**
  56652. * An event triggered when the highlight layer has been blurred.
  56653. */
  56654. onAfterBlurObservable: Observable<HighlightLayer>;
  56655. private _instanceGlowingMeshStencilReference;
  56656. private _options;
  56657. private _downSamplePostprocess;
  56658. private _horizontalBlurPostprocess;
  56659. private _verticalBlurPostprocess;
  56660. private _blurTexture;
  56661. private _meshes;
  56662. private _excludedMeshes;
  56663. /**
  56664. * Instantiates a new highlight Layer and references it to the scene..
  56665. * @param name The name of the layer
  56666. * @param scene The scene to use the layer in
  56667. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56668. */
  56669. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56670. /**
  56671. * Get the effect name of the layer.
  56672. * @return The effect name
  56673. */
  56674. getEffectName(): string;
  56675. /**
  56676. * Create the merge effect. This is the shader use to blit the information back
  56677. * to the main canvas at the end of the scene rendering.
  56678. */
  56679. protected _createMergeEffect(): Effect;
  56680. /**
  56681. * Creates the render target textures and post processes used in the highlight layer.
  56682. */
  56683. protected _createTextureAndPostProcesses(): void;
  56684. /**
  56685. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56686. */
  56687. needStencil(): boolean;
  56688. /**
  56689. * Checks for the readiness of the element composing the layer.
  56690. * @param subMesh the mesh to check for
  56691. * @param useInstances specify wether or not to use instances to render the mesh
  56692. * @param emissiveTexture the associated emissive texture used to generate the glow
  56693. * @return true if ready otherwise, false
  56694. */
  56695. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56696. /**
  56697. * Implementation specific of rendering the generating effect on the main canvas.
  56698. * @param effect The effect used to render through
  56699. */
  56700. protected _internalRender(effect: Effect): void;
  56701. /**
  56702. * Returns true if the layer contains information to display, otherwise false.
  56703. */
  56704. shouldRender(): boolean;
  56705. /**
  56706. * Returns true if the mesh should render, otherwise false.
  56707. * @param mesh The mesh to render
  56708. * @returns true if it should render otherwise false
  56709. */
  56710. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56711. /**
  56712. * Adds specific effects defines.
  56713. * @param defines The defines to add specifics to.
  56714. */
  56715. protected _addCustomEffectDefines(defines: string[]): void;
  56716. /**
  56717. * Sets the required values for both the emissive texture and and the main color.
  56718. */
  56719. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56720. /**
  56721. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56722. * @param mesh The mesh to exclude from the highlight layer
  56723. */
  56724. addExcludedMesh(mesh: Mesh): void;
  56725. /**
  56726. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56727. * @param mesh The mesh to highlight
  56728. */
  56729. removeExcludedMesh(mesh: Mesh): void;
  56730. /**
  56731. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56732. * @param mesh mesh to test
  56733. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56734. */
  56735. hasMesh(mesh: AbstractMesh): boolean;
  56736. /**
  56737. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56738. * @param mesh The mesh to highlight
  56739. * @param color The color of the highlight
  56740. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56741. */
  56742. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56743. /**
  56744. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56745. * @param mesh The mesh to highlight
  56746. */
  56747. removeMesh(mesh: Mesh): void;
  56748. /**
  56749. * Remove all the meshes currently referenced in the highlight layer
  56750. */
  56751. removeAllMeshes(): void;
  56752. /**
  56753. * Force the stencil to the normal expected value for none glowing parts
  56754. */
  56755. private _defaultStencilReference;
  56756. /**
  56757. * Free any resources and references associated to a mesh.
  56758. * Internal use
  56759. * @param mesh The mesh to free.
  56760. * @hidden
  56761. */
  56762. _disposeMesh(mesh: Mesh): void;
  56763. /**
  56764. * Dispose the highlight layer and free resources.
  56765. */
  56766. dispose(): void;
  56767. /**
  56768. * Gets the class name of the effect layer
  56769. * @returns the string with the class name of the effect layer
  56770. */
  56771. getClassName(): string;
  56772. /**
  56773. * Serializes this Highlight layer
  56774. * @returns a serialized Highlight layer object
  56775. */
  56776. serialize(): any;
  56777. /**
  56778. * Creates a Highlight layer from parsed Highlight layer data
  56779. * @param parsedHightlightLayer defines the Highlight layer data
  56780. * @param scene defines the current scene
  56781. * @param rootUrl defines the root URL containing the Highlight layer information
  56782. * @returns a parsed Highlight layer
  56783. */
  56784. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56785. }
  56786. }
  56787. declare module "babylonjs/Layers/layerSceneComponent" {
  56788. import { Scene } from "babylonjs/scene";
  56789. import { ISceneComponent } from "babylonjs/sceneComponent";
  56790. import { Layer } from "babylonjs/Layers/layer";
  56791. import { AbstractScene } from "babylonjs/abstractScene";
  56792. module "babylonjs/abstractScene" {
  56793. interface AbstractScene {
  56794. /**
  56795. * The list of layers (background and foreground) of the scene
  56796. */
  56797. layers: Array<Layer>;
  56798. }
  56799. }
  56800. /**
  56801. * Defines the layer scene component responsible to manage any layers
  56802. * in a given scene.
  56803. */
  56804. export class LayerSceneComponent implements ISceneComponent {
  56805. /**
  56806. * The component name helpfull to identify the component in the list of scene components.
  56807. */
  56808. readonly name: string;
  56809. /**
  56810. * The scene the component belongs to.
  56811. */
  56812. scene: Scene;
  56813. private _engine;
  56814. /**
  56815. * Creates a new instance of the component for the given scene
  56816. * @param scene Defines the scene to register the component in
  56817. */
  56818. constructor(scene: Scene);
  56819. /**
  56820. * Registers the component in a given scene
  56821. */
  56822. register(): void;
  56823. /**
  56824. * Rebuilds the elements related to this component in case of
  56825. * context lost for instance.
  56826. */
  56827. rebuild(): void;
  56828. /**
  56829. * Disposes the component and the associated ressources.
  56830. */
  56831. dispose(): void;
  56832. private _draw;
  56833. private _drawCameraPredicate;
  56834. private _drawCameraBackground;
  56835. private _drawCameraForeground;
  56836. private _drawRenderTargetPredicate;
  56837. private _drawRenderTargetBackground;
  56838. private _drawRenderTargetForeground;
  56839. /**
  56840. * Adds all the elements from the container to the scene
  56841. * @param container the container holding the elements
  56842. */
  56843. addFromContainer(container: AbstractScene): void;
  56844. /**
  56845. * Removes all the elements in the container from the scene
  56846. * @param container contains the elements to remove
  56847. * @param dispose if the removed element should be disposed (default: false)
  56848. */
  56849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56850. }
  56851. }
  56852. declare module "babylonjs/Shaders/layer.fragment" {
  56853. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56854. /** @hidden */
  56855. export var layerPixelShader: {
  56856. name: string;
  56857. shader: string;
  56858. };
  56859. }
  56860. declare module "babylonjs/Shaders/layer.vertex" {
  56861. /** @hidden */
  56862. export var layerVertexShader: {
  56863. name: string;
  56864. shader: string;
  56865. };
  56866. }
  56867. declare module "babylonjs/Layers/layer" {
  56868. import { Observable } from "babylonjs/Misc/observable";
  56869. import { Nullable } from "babylonjs/types";
  56870. import { Scene } from "babylonjs/scene";
  56871. import { Vector2 } from "babylonjs/Maths/math.vector";
  56872. import { Color4 } from "babylonjs/Maths/math.color";
  56873. import { Texture } from "babylonjs/Materials/Textures/texture";
  56874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56875. import "babylonjs/Shaders/layer.fragment";
  56876. import "babylonjs/Shaders/layer.vertex";
  56877. /**
  56878. * This represents a full screen 2d layer.
  56879. * This can be useful to display a picture in the background of your scene for instance.
  56880. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56881. */
  56882. export class Layer {
  56883. /**
  56884. * Define the name of the layer.
  56885. */
  56886. name: string;
  56887. /**
  56888. * Define the texture the layer should display.
  56889. */
  56890. texture: Nullable<Texture>;
  56891. /**
  56892. * Is the layer in background or foreground.
  56893. */
  56894. isBackground: boolean;
  56895. /**
  56896. * Define the color of the layer (instead of texture).
  56897. */
  56898. color: Color4;
  56899. /**
  56900. * Define the scale of the layer in order to zoom in out of the texture.
  56901. */
  56902. scale: Vector2;
  56903. /**
  56904. * Define an offset for the layer in order to shift the texture.
  56905. */
  56906. offset: Vector2;
  56907. /**
  56908. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56909. */
  56910. alphaBlendingMode: number;
  56911. /**
  56912. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56913. * Alpha test will not mix with the background color in case of transparency.
  56914. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56915. */
  56916. alphaTest: boolean;
  56917. /**
  56918. * Define a mask to restrict the layer to only some of the scene cameras.
  56919. */
  56920. layerMask: number;
  56921. /**
  56922. * Define the list of render target the layer is visible into.
  56923. */
  56924. renderTargetTextures: RenderTargetTexture[];
  56925. /**
  56926. * Define if the layer is only used in renderTarget or if it also
  56927. * renders in the main frame buffer of the canvas.
  56928. */
  56929. renderOnlyInRenderTargetTextures: boolean;
  56930. private _scene;
  56931. private _vertexBuffers;
  56932. private _indexBuffer;
  56933. private _effect;
  56934. private _previousDefines;
  56935. /**
  56936. * An event triggered when the layer is disposed.
  56937. */
  56938. onDisposeObservable: Observable<Layer>;
  56939. private _onDisposeObserver;
  56940. /**
  56941. * Back compatibility with callback before the onDisposeObservable existed.
  56942. * The set callback will be triggered when the layer has been disposed.
  56943. */
  56944. set onDispose(callback: () => void);
  56945. /**
  56946. * An event triggered before rendering the scene
  56947. */
  56948. onBeforeRenderObservable: Observable<Layer>;
  56949. private _onBeforeRenderObserver;
  56950. /**
  56951. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56952. * The set callback will be triggered just before rendering the layer.
  56953. */
  56954. set onBeforeRender(callback: () => void);
  56955. /**
  56956. * An event triggered after rendering the scene
  56957. */
  56958. onAfterRenderObservable: Observable<Layer>;
  56959. private _onAfterRenderObserver;
  56960. /**
  56961. * Back compatibility with callback before the onAfterRenderObservable existed.
  56962. * The set callback will be triggered just after rendering the layer.
  56963. */
  56964. set onAfterRender(callback: () => void);
  56965. /**
  56966. * Instantiates a new layer.
  56967. * This represents a full screen 2d layer.
  56968. * This can be useful to display a picture in the background of your scene for instance.
  56969. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56970. * @param name Define the name of the layer in the scene
  56971. * @param imgUrl Define the url of the texture to display in the layer
  56972. * @param scene Define the scene the layer belongs to
  56973. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56974. * @param color Defines a color for the layer
  56975. */
  56976. constructor(
  56977. /**
  56978. * Define the name of the layer.
  56979. */
  56980. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56981. private _createIndexBuffer;
  56982. /** @hidden */
  56983. _rebuild(): void;
  56984. /**
  56985. * Renders the layer in the scene.
  56986. */
  56987. render(): void;
  56988. /**
  56989. * Disposes and releases the associated ressources.
  56990. */
  56991. dispose(): void;
  56992. }
  56993. }
  56994. declare module "babylonjs/Layers/index" {
  56995. export * from "babylonjs/Layers/effectLayer";
  56996. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56997. export * from "babylonjs/Layers/glowLayer";
  56998. export * from "babylonjs/Layers/highlightLayer";
  56999. export * from "babylonjs/Layers/layer";
  57000. export * from "babylonjs/Layers/layerSceneComponent";
  57001. }
  57002. declare module "babylonjs/Shaders/lensFlare.fragment" {
  57003. /** @hidden */
  57004. export var lensFlarePixelShader: {
  57005. name: string;
  57006. shader: string;
  57007. };
  57008. }
  57009. declare module "babylonjs/Shaders/lensFlare.vertex" {
  57010. /** @hidden */
  57011. export var lensFlareVertexShader: {
  57012. name: string;
  57013. shader: string;
  57014. };
  57015. }
  57016. declare module "babylonjs/LensFlares/lensFlareSystem" {
  57017. import { Scene } from "babylonjs/scene";
  57018. import { Vector3 } from "babylonjs/Maths/math.vector";
  57019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57020. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  57021. import "babylonjs/Shaders/lensFlare.fragment";
  57022. import "babylonjs/Shaders/lensFlare.vertex";
  57023. import { Viewport } from "babylonjs/Maths/math.viewport";
  57024. /**
  57025. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57026. * It is usually composed of several `lensFlare`.
  57027. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57028. */
  57029. export class LensFlareSystem {
  57030. /**
  57031. * Define the name of the lens flare system
  57032. */
  57033. name: string;
  57034. /**
  57035. * List of lens flares used in this system.
  57036. */
  57037. lensFlares: LensFlare[];
  57038. /**
  57039. * Define a limit from the border the lens flare can be visible.
  57040. */
  57041. borderLimit: number;
  57042. /**
  57043. * Define a viewport border we do not want to see the lens flare in.
  57044. */
  57045. viewportBorder: number;
  57046. /**
  57047. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57048. */
  57049. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57050. /**
  57051. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57052. */
  57053. layerMask: number;
  57054. /**
  57055. * Define the id of the lens flare system in the scene.
  57056. * (equal to name by default)
  57057. */
  57058. id: string;
  57059. private _scene;
  57060. private _emitter;
  57061. private _vertexBuffers;
  57062. private _indexBuffer;
  57063. private _effect;
  57064. private _positionX;
  57065. private _positionY;
  57066. private _isEnabled;
  57067. /** @hidden */
  57068. static _SceneComponentInitialization: (scene: Scene) => void;
  57069. /**
  57070. * Instantiates a lens flare system.
  57071. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57072. * It is usually composed of several `lensFlare`.
  57073. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57074. * @param name Define the name of the lens flare system in the scene
  57075. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57076. * @param scene Define the scene the lens flare system belongs to
  57077. */
  57078. constructor(
  57079. /**
  57080. * Define the name of the lens flare system
  57081. */
  57082. name: string, emitter: any, scene: Scene);
  57083. /**
  57084. * Define if the lens flare system is enabled.
  57085. */
  57086. get isEnabled(): boolean;
  57087. set isEnabled(value: boolean);
  57088. /**
  57089. * Get the scene the effects belongs to.
  57090. * @returns the scene holding the lens flare system
  57091. */
  57092. getScene(): Scene;
  57093. /**
  57094. * Get the emitter of the lens flare system.
  57095. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57096. * @returns the emitter of the lens flare system
  57097. */
  57098. getEmitter(): any;
  57099. /**
  57100. * Set the emitter of the lens flare system.
  57101. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57102. * @param newEmitter Define the new emitter of the system
  57103. */
  57104. setEmitter(newEmitter: any): void;
  57105. /**
  57106. * Get the lens flare system emitter position.
  57107. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57108. * @returns the position
  57109. */
  57110. getEmitterPosition(): Vector3;
  57111. /**
  57112. * @hidden
  57113. */
  57114. computeEffectivePosition(globalViewport: Viewport): boolean;
  57115. /** @hidden */
  57116. _isVisible(): boolean;
  57117. /**
  57118. * @hidden
  57119. */
  57120. render(): boolean;
  57121. /**
  57122. * Dispose and release the lens flare with its associated resources.
  57123. */
  57124. dispose(): void;
  57125. /**
  57126. * Parse a lens flare system from a JSON repressentation
  57127. * @param parsedLensFlareSystem Define the JSON to parse
  57128. * @param scene Define the scene the parsed system should be instantiated in
  57129. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57130. * @returns the parsed system
  57131. */
  57132. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57133. /**
  57134. * Serialize the current Lens Flare System into a JSON representation.
  57135. * @returns the serialized JSON
  57136. */
  57137. serialize(): any;
  57138. }
  57139. }
  57140. declare module "babylonjs/LensFlares/lensFlare" {
  57141. import { Nullable } from "babylonjs/types";
  57142. import { Color3 } from "babylonjs/Maths/math.color";
  57143. import { Texture } from "babylonjs/Materials/Textures/texture";
  57144. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57145. /**
  57146. * This represents one of the lens effect in a `lensFlareSystem`.
  57147. * It controls one of the indiviual texture used in the effect.
  57148. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57149. */
  57150. export class LensFlare {
  57151. /**
  57152. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57153. */
  57154. size: number;
  57155. /**
  57156. * 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.
  57157. */
  57158. position: number;
  57159. /**
  57160. * Define the lens color.
  57161. */
  57162. color: Color3;
  57163. /**
  57164. * Define the lens texture.
  57165. */
  57166. texture: Nullable<Texture>;
  57167. /**
  57168. * Define the alpha mode to render this particular lens.
  57169. */
  57170. alphaMode: number;
  57171. private _system;
  57172. /**
  57173. * Creates a new Lens Flare.
  57174. * This represents one of the lens effect in a `lensFlareSystem`.
  57175. * It controls one of the indiviual texture used in the effect.
  57176. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57177. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57178. * @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.
  57179. * @param color Define the lens color
  57180. * @param imgUrl Define the lens texture url
  57181. * @param system Define the `lensFlareSystem` this flare is part of
  57182. * @returns The newly created Lens Flare
  57183. */
  57184. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57185. /**
  57186. * Instantiates a new Lens Flare.
  57187. * This represents one of the lens effect in a `lensFlareSystem`.
  57188. * It controls one of the indiviual texture used in the effect.
  57189. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57190. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57191. * @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.
  57192. * @param color Define the lens color
  57193. * @param imgUrl Define the lens texture url
  57194. * @param system Define the `lensFlareSystem` this flare is part of
  57195. */
  57196. constructor(
  57197. /**
  57198. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57199. */
  57200. size: number,
  57201. /**
  57202. * 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.
  57203. */
  57204. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57205. /**
  57206. * Dispose and release the lens flare with its associated resources.
  57207. */
  57208. dispose(): void;
  57209. }
  57210. }
  57211. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  57212. import { Nullable } from "babylonjs/types";
  57213. import { Scene } from "babylonjs/scene";
  57214. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57215. import { AbstractScene } from "babylonjs/abstractScene";
  57216. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57217. module "babylonjs/abstractScene" {
  57218. interface AbstractScene {
  57219. /**
  57220. * The list of lens flare system added to the scene
  57221. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57222. */
  57223. lensFlareSystems: Array<LensFlareSystem>;
  57224. /**
  57225. * Removes the given lens flare system from this scene.
  57226. * @param toRemove The lens flare system to remove
  57227. * @returns The index of the removed lens flare system
  57228. */
  57229. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57230. /**
  57231. * Adds the given lens flare system to this scene
  57232. * @param newLensFlareSystem The lens flare system to add
  57233. */
  57234. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57235. /**
  57236. * Gets a lens flare system using its name
  57237. * @param name defines the name to look for
  57238. * @returns the lens flare system or null if not found
  57239. */
  57240. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57241. /**
  57242. * Gets a lens flare system using its id
  57243. * @param id defines the id to look for
  57244. * @returns the lens flare system or null if not found
  57245. */
  57246. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57247. }
  57248. }
  57249. /**
  57250. * Defines the lens flare scene component responsible to manage any lens flares
  57251. * in a given scene.
  57252. */
  57253. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57254. /**
  57255. * The component name helpfull to identify the component in the list of scene components.
  57256. */
  57257. readonly name: string;
  57258. /**
  57259. * The scene the component belongs to.
  57260. */
  57261. scene: Scene;
  57262. /**
  57263. * Creates a new instance of the component for the given scene
  57264. * @param scene Defines the scene to register the component in
  57265. */
  57266. constructor(scene: Scene);
  57267. /**
  57268. * Registers the component in a given scene
  57269. */
  57270. register(): void;
  57271. /**
  57272. * Rebuilds the elements related to this component in case of
  57273. * context lost for instance.
  57274. */
  57275. rebuild(): void;
  57276. /**
  57277. * Adds all the elements from the container to the scene
  57278. * @param container the container holding the elements
  57279. */
  57280. addFromContainer(container: AbstractScene): void;
  57281. /**
  57282. * Removes all the elements in the container from the scene
  57283. * @param container contains the elements to remove
  57284. * @param dispose if the removed element should be disposed (default: false)
  57285. */
  57286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57287. /**
  57288. * Serializes the component data to the specified json object
  57289. * @param serializationObject The object to serialize to
  57290. */
  57291. serialize(serializationObject: any): void;
  57292. /**
  57293. * Disposes the component and the associated ressources.
  57294. */
  57295. dispose(): void;
  57296. private _draw;
  57297. }
  57298. }
  57299. declare module "babylonjs/LensFlares/index" {
  57300. export * from "babylonjs/LensFlares/lensFlare";
  57301. export * from "babylonjs/LensFlares/lensFlareSystem";
  57302. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  57303. }
  57304. declare module "babylonjs/Shaders/depth.fragment" {
  57305. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  57306. /** @hidden */
  57307. export var depthPixelShader: {
  57308. name: string;
  57309. shader: string;
  57310. };
  57311. }
  57312. declare module "babylonjs/Shaders/depth.vertex" {
  57313. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57314. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57315. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57316. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57318. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57319. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57320. /** @hidden */
  57321. export var depthVertexShader: {
  57322. name: string;
  57323. shader: string;
  57324. };
  57325. }
  57326. declare module "babylonjs/Rendering/depthRenderer" {
  57327. import { Nullable } from "babylonjs/types";
  57328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57329. import { Scene } from "babylonjs/scene";
  57330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57331. import { Camera } from "babylonjs/Cameras/camera";
  57332. import "babylonjs/Shaders/depth.fragment";
  57333. import "babylonjs/Shaders/depth.vertex";
  57334. /**
  57335. * This represents a depth renderer in Babylon.
  57336. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57337. */
  57338. export class DepthRenderer {
  57339. private _scene;
  57340. private _depthMap;
  57341. private _effect;
  57342. private readonly _storeNonLinearDepth;
  57343. private readonly _clearColor;
  57344. /** Get if the depth renderer is using packed depth or not */
  57345. readonly isPacked: boolean;
  57346. private _cachedDefines;
  57347. private _camera;
  57348. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57349. enabled: boolean;
  57350. /**
  57351. * Specifiess that the depth renderer will only be used within
  57352. * the camera it is created for.
  57353. * This can help forcing its rendering during the camera processing.
  57354. */
  57355. useOnlyInActiveCamera: boolean;
  57356. /** @hidden */
  57357. static _SceneComponentInitialization: (scene: Scene) => void;
  57358. /**
  57359. * Instantiates a depth renderer
  57360. * @param scene The scene the renderer belongs to
  57361. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57362. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57363. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57364. */
  57365. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57366. /**
  57367. * Creates the depth rendering effect and checks if the effect is ready.
  57368. * @param subMesh The submesh to be used to render the depth map of
  57369. * @param useInstances If multiple world instances should be used
  57370. * @returns if the depth renderer is ready to render the depth map
  57371. */
  57372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57373. /**
  57374. * Gets the texture which the depth map will be written to.
  57375. * @returns The depth map texture
  57376. */
  57377. getDepthMap(): RenderTargetTexture;
  57378. /**
  57379. * Disposes of the depth renderer.
  57380. */
  57381. dispose(): void;
  57382. }
  57383. }
  57384. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57385. /** @hidden */
  57386. export var minmaxReduxPixelShader: {
  57387. name: string;
  57388. shader: string;
  57389. };
  57390. }
  57391. declare module "babylonjs/Misc/minMaxReducer" {
  57392. import { Nullable } from "babylonjs/types";
  57393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57394. import { Camera } from "babylonjs/Cameras/camera";
  57395. import { Observer } from "babylonjs/Misc/observable";
  57396. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57397. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57398. import { Observable } from "babylonjs/Misc/observable";
  57399. import "babylonjs/Shaders/minmaxRedux.fragment";
  57400. /**
  57401. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57402. * and maximum values from all values of the texture.
  57403. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57404. * The source values are read from the red channel of the texture.
  57405. */
  57406. export class MinMaxReducer {
  57407. /**
  57408. * Observable triggered when the computation has been performed
  57409. */
  57410. onAfterReductionPerformed: Observable<{
  57411. min: number;
  57412. max: number;
  57413. }>;
  57414. protected _camera: Camera;
  57415. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57416. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57417. protected _postProcessManager: PostProcessManager;
  57418. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57419. protected _forceFullscreenViewport: boolean;
  57420. /**
  57421. * Creates a min/max reducer
  57422. * @param camera The camera to use for the post processes
  57423. */
  57424. constructor(camera: Camera);
  57425. /**
  57426. * Gets the texture used to read the values from.
  57427. */
  57428. get sourceTexture(): Nullable<RenderTargetTexture>;
  57429. /**
  57430. * Sets the source texture to read the values from.
  57431. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57432. * because in such textures '1' value must not be taken into account to compute the maximum
  57433. * as this value is used to clear the texture.
  57434. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57435. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57436. * @param depthRedux Indicates if the texture is a depth texture or not
  57437. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57438. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57439. */
  57440. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57441. /**
  57442. * Defines the refresh rate of the computation.
  57443. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57444. */
  57445. get refreshRate(): number;
  57446. set refreshRate(value: number);
  57447. protected _activated: boolean;
  57448. /**
  57449. * Gets the activation status of the reducer
  57450. */
  57451. get activated(): boolean;
  57452. /**
  57453. * Activates the reduction computation.
  57454. * When activated, the observers registered in onAfterReductionPerformed are
  57455. * called after the compuation is performed
  57456. */
  57457. activate(): void;
  57458. /**
  57459. * Deactivates the reduction computation.
  57460. */
  57461. deactivate(): void;
  57462. /**
  57463. * Disposes the min/max reducer
  57464. * @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.
  57465. */
  57466. dispose(disposeAll?: boolean): void;
  57467. }
  57468. }
  57469. declare module "babylonjs/Misc/depthReducer" {
  57470. import { Nullable } from "babylonjs/types";
  57471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57472. import { Camera } from "babylonjs/Cameras/camera";
  57473. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57474. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57475. /**
  57476. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57477. */
  57478. export class DepthReducer extends MinMaxReducer {
  57479. private _depthRenderer;
  57480. private _depthRendererId;
  57481. /**
  57482. * Gets the depth renderer used for the computation.
  57483. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57484. */
  57485. get depthRenderer(): Nullable<DepthRenderer>;
  57486. /**
  57487. * Creates a depth reducer
  57488. * @param camera The camera used to render the depth texture
  57489. */
  57490. constructor(camera: Camera);
  57491. /**
  57492. * Sets the depth renderer to use to generate the depth map
  57493. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57494. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57495. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57496. */
  57497. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57498. /** @hidden */
  57499. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57500. /**
  57501. * Activates the reduction computation.
  57502. * When activated, the observers registered in onAfterReductionPerformed are
  57503. * called after the compuation is performed
  57504. */
  57505. activate(): void;
  57506. /**
  57507. * Deactivates the reduction computation.
  57508. */
  57509. deactivate(): void;
  57510. /**
  57511. * Disposes the depth reducer
  57512. * @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.
  57513. */
  57514. dispose(disposeAll?: boolean): void;
  57515. }
  57516. }
  57517. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57518. import { Nullable } from "babylonjs/types";
  57519. import { Scene } from "babylonjs/scene";
  57520. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57523. import { Effect } from "babylonjs/Materials/effect";
  57524. import "babylonjs/Shaders/shadowMap.fragment";
  57525. import "babylonjs/Shaders/shadowMap.vertex";
  57526. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57527. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57528. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57529. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57530. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57531. /**
  57532. * A CSM implementation allowing casting shadows on large scenes.
  57533. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57534. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57535. */
  57536. export class CascadedShadowGenerator extends ShadowGenerator {
  57537. private static readonly frustumCornersNDCSpace;
  57538. /**
  57539. * Name of the CSM class
  57540. */
  57541. static CLASSNAME: string;
  57542. /**
  57543. * Defines the default number of cascades used by the CSM.
  57544. */
  57545. static readonly DEFAULT_CASCADES_COUNT: number;
  57546. /**
  57547. * Defines the minimum number of cascades used by the CSM.
  57548. */
  57549. static readonly MIN_CASCADES_COUNT: number;
  57550. /**
  57551. * Defines the maximum number of cascades used by the CSM.
  57552. */
  57553. static readonly MAX_CASCADES_COUNT: number;
  57554. protected _validateFilter(filter: number): number;
  57555. /**
  57556. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57557. */
  57558. penumbraDarkness: number;
  57559. private _numCascades;
  57560. /**
  57561. * Gets or set the number of cascades used by the CSM.
  57562. */
  57563. get numCascades(): number;
  57564. set numCascades(value: number);
  57565. /**
  57566. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57567. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57568. */
  57569. stabilizeCascades: boolean;
  57570. private _freezeShadowCastersBoundingInfo;
  57571. private _freezeShadowCastersBoundingInfoObservable;
  57572. /**
  57573. * Enables or disables the shadow casters bounding info computation.
  57574. * If your shadow casters don't move, you can disable this feature.
  57575. * If it is enabled, the bounding box computation is done every frame.
  57576. */
  57577. get freezeShadowCastersBoundingInfo(): boolean;
  57578. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57579. private _scbiMin;
  57580. private _scbiMax;
  57581. protected _computeShadowCastersBoundingInfo(): void;
  57582. protected _shadowCastersBoundingInfo: BoundingInfo;
  57583. /**
  57584. * Gets or sets the shadow casters bounding info.
  57585. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57586. * so that the system won't overwrite the bounds you provide
  57587. */
  57588. get shadowCastersBoundingInfo(): BoundingInfo;
  57589. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57590. protected _breaksAreDirty: boolean;
  57591. protected _minDistance: number;
  57592. protected _maxDistance: number;
  57593. /**
  57594. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57595. *
  57596. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57597. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57598. * @param min minimal distance for the breaks (default to 0.)
  57599. * @param max maximal distance for the breaks (default to 1.)
  57600. */
  57601. setMinMaxDistance(min: number, max: number): void;
  57602. /** Gets the minimal distance used in the cascade break computation */
  57603. get minDistance(): number;
  57604. /** Gets the maximal distance used in the cascade break computation */
  57605. get maxDistance(): number;
  57606. /**
  57607. * Gets the class name of that object
  57608. * @returns "CascadedShadowGenerator"
  57609. */
  57610. getClassName(): string;
  57611. private _cascadeMinExtents;
  57612. private _cascadeMaxExtents;
  57613. /**
  57614. * Gets a cascade minimum extents
  57615. * @param cascadeIndex index of the cascade
  57616. * @returns the minimum cascade extents
  57617. */
  57618. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57619. /**
  57620. * Gets a cascade maximum extents
  57621. * @param cascadeIndex index of the cascade
  57622. * @returns the maximum cascade extents
  57623. */
  57624. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57625. private _cascades;
  57626. private _currentLayer;
  57627. private _viewSpaceFrustumsZ;
  57628. private _viewMatrices;
  57629. private _projectionMatrices;
  57630. private _transformMatrices;
  57631. private _transformMatricesAsArray;
  57632. private _frustumLengths;
  57633. private _lightSizeUVCorrection;
  57634. private _depthCorrection;
  57635. private _frustumCornersWorldSpace;
  57636. private _frustumCenter;
  57637. private _shadowCameraPos;
  57638. private _shadowMaxZ;
  57639. /**
  57640. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57641. * It defaults to camera.maxZ
  57642. */
  57643. get shadowMaxZ(): number;
  57644. /**
  57645. * Sets the shadow max z distance.
  57646. */
  57647. set shadowMaxZ(value: number);
  57648. protected _debug: boolean;
  57649. /**
  57650. * Gets or sets the debug flag.
  57651. * When enabled, the cascades are materialized by different colors on the screen.
  57652. */
  57653. get debug(): boolean;
  57654. set debug(dbg: boolean);
  57655. private _depthClamp;
  57656. /**
  57657. * Gets or sets the depth clamping value.
  57658. *
  57659. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57660. * to account for the shadow casters far away.
  57661. *
  57662. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57663. */
  57664. get depthClamp(): boolean;
  57665. set depthClamp(value: boolean);
  57666. private _cascadeBlendPercentage;
  57667. /**
  57668. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57669. * It defaults to 0.1 (10% blending).
  57670. */
  57671. get cascadeBlendPercentage(): number;
  57672. set cascadeBlendPercentage(value: number);
  57673. private _lambda;
  57674. /**
  57675. * Gets or set the lambda parameter.
  57676. * This parameter is used to split the camera frustum and create the cascades.
  57677. * 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.
  57678. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57679. */
  57680. get lambda(): number;
  57681. set lambda(value: number);
  57682. /**
  57683. * Gets the view matrix corresponding to a given cascade
  57684. * @param cascadeNum cascade to retrieve the view matrix from
  57685. * @returns the cascade view matrix
  57686. */
  57687. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57688. /**
  57689. * Gets the projection matrix corresponding to a given cascade
  57690. * @param cascadeNum cascade to retrieve the projection matrix from
  57691. * @returns the cascade projection matrix
  57692. */
  57693. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57694. /**
  57695. * Gets the transformation matrix corresponding to a given cascade
  57696. * @param cascadeNum cascade to retrieve the transformation matrix from
  57697. * @returns the cascade transformation matrix
  57698. */
  57699. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57700. private _depthRenderer;
  57701. /**
  57702. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57703. *
  57704. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57705. *
  57706. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57707. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57708. * @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
  57709. */
  57710. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57711. private _depthReducer;
  57712. private _autoCalcDepthBounds;
  57713. /**
  57714. * Gets or sets the autoCalcDepthBounds property.
  57715. *
  57716. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57717. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57718. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57719. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57720. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57721. */
  57722. get autoCalcDepthBounds(): boolean;
  57723. set autoCalcDepthBounds(value: boolean);
  57724. /**
  57725. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57726. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57727. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57728. * for setting the refresh rate on the renderer yourself!
  57729. */
  57730. get autoCalcDepthBoundsRefreshRate(): number;
  57731. set autoCalcDepthBoundsRefreshRate(value: number);
  57732. /**
  57733. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57734. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57735. * you change the camera near/far planes!
  57736. */
  57737. splitFrustum(): void;
  57738. private _splitFrustum;
  57739. private _computeMatrices;
  57740. private _computeFrustumInWorldSpace;
  57741. private _computeCascadeFrustum;
  57742. /**
  57743. * Support test.
  57744. */
  57745. static get IsSupported(): boolean;
  57746. /** @hidden */
  57747. static _SceneComponentInitialization: (scene: Scene) => void;
  57748. /**
  57749. * Creates a Cascaded Shadow Generator object.
  57750. * A ShadowGenerator is the required tool to use the shadows.
  57751. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57752. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57753. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57754. * @param light The directional light object generating the shadows.
  57755. * @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.
  57756. */
  57757. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57758. protected _initializeGenerator(): void;
  57759. protected _createTargetRenderTexture(): void;
  57760. protected _initializeShadowMap(): void;
  57761. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57762. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57763. /**
  57764. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57765. * @param defines Defines of the material we want to update
  57766. * @param lightIndex Index of the light in the enabled light list of the material
  57767. */
  57768. prepareDefines(defines: any, lightIndex: number): void;
  57769. /**
  57770. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57771. * defined in the generator but impacting the effect).
  57772. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57773. * @param effect The effect we are binfing the information for
  57774. */
  57775. bindShadowLight(lightIndex: string, effect: Effect): void;
  57776. /**
  57777. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57778. * (eq to view projection * shadow projection matrices)
  57779. * @returns The transform matrix used to create the shadow map
  57780. */
  57781. getTransformMatrix(): Matrix;
  57782. /**
  57783. * Disposes the ShadowGenerator.
  57784. * Returns nothing.
  57785. */
  57786. dispose(): void;
  57787. /**
  57788. * Serializes the shadow generator setup to a json object.
  57789. * @returns The serialized JSON object
  57790. */
  57791. serialize(): any;
  57792. /**
  57793. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57794. * @param parsedShadowGenerator The JSON object to parse
  57795. * @param scene The scene to create the shadow map for
  57796. * @returns The parsed shadow generator
  57797. */
  57798. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57799. }
  57800. }
  57801. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57802. import { Scene } from "babylonjs/scene";
  57803. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57804. import { AbstractScene } from "babylonjs/abstractScene";
  57805. /**
  57806. * Defines the shadow generator component responsible to manage any shadow generators
  57807. * in a given scene.
  57808. */
  57809. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57810. /**
  57811. * The component name helpfull to identify the component in the list of scene components.
  57812. */
  57813. readonly name: string;
  57814. /**
  57815. * The scene the component belongs to.
  57816. */
  57817. scene: Scene;
  57818. /**
  57819. * Creates a new instance of the component for the given scene
  57820. * @param scene Defines the scene to register the component in
  57821. */
  57822. constructor(scene: Scene);
  57823. /**
  57824. * Registers the component in a given scene
  57825. */
  57826. register(): void;
  57827. /**
  57828. * Rebuilds the elements related to this component in case of
  57829. * context lost for instance.
  57830. */
  57831. rebuild(): void;
  57832. /**
  57833. * Serializes the component data to the specified json object
  57834. * @param serializationObject The object to serialize to
  57835. */
  57836. serialize(serializationObject: any): void;
  57837. /**
  57838. * Adds all the elements from the container to the scene
  57839. * @param container the container holding the elements
  57840. */
  57841. addFromContainer(container: AbstractScene): void;
  57842. /**
  57843. * Removes all the elements in the container from the scene
  57844. * @param container contains the elements to remove
  57845. * @param dispose if the removed element should be disposed (default: false)
  57846. */
  57847. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57848. /**
  57849. * Rebuilds the elements related to this component in case of
  57850. * context lost for instance.
  57851. */
  57852. dispose(): void;
  57853. private _gatherRenderTargets;
  57854. }
  57855. }
  57856. declare module "babylonjs/Lights/Shadows/index" {
  57857. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57858. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57859. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57860. }
  57861. declare module "babylonjs/Lights/pointLight" {
  57862. import { Scene } from "babylonjs/scene";
  57863. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57865. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57866. import { Effect } from "babylonjs/Materials/effect";
  57867. /**
  57868. * A point light is a light defined by an unique point in world space.
  57869. * The light is emitted in every direction from this point.
  57870. * A good example of a point light is a standard light bulb.
  57871. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57872. */
  57873. export class PointLight extends ShadowLight {
  57874. private _shadowAngle;
  57875. /**
  57876. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57877. * This specifies what angle the shadow will use to be created.
  57878. *
  57879. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57880. */
  57881. get shadowAngle(): number;
  57882. /**
  57883. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57884. * This specifies what angle the shadow will use to be created.
  57885. *
  57886. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57887. */
  57888. set shadowAngle(value: number);
  57889. /**
  57890. * Gets the direction if it has been set.
  57891. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57892. */
  57893. get direction(): Vector3;
  57894. /**
  57895. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57896. */
  57897. set direction(value: Vector3);
  57898. /**
  57899. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57900. * A PointLight emits the light in every direction.
  57901. * It can cast shadows.
  57902. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57903. * ```javascript
  57904. * var pointLight = new PointLight("pl", camera.position, scene);
  57905. * ```
  57906. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57907. * @param name The light friendly name
  57908. * @param position The position of the point light in the scene
  57909. * @param scene The scene the lights belongs to
  57910. */
  57911. constructor(name: string, position: Vector3, scene: Scene);
  57912. /**
  57913. * Returns the string "PointLight"
  57914. * @returns the class name
  57915. */
  57916. getClassName(): string;
  57917. /**
  57918. * Returns the integer 0.
  57919. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57920. */
  57921. getTypeID(): number;
  57922. /**
  57923. * Specifies wether or not the shadowmap should be a cube texture.
  57924. * @returns true if the shadowmap needs to be a cube texture.
  57925. */
  57926. needCube(): boolean;
  57927. /**
  57928. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57929. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57930. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57931. */
  57932. getShadowDirection(faceIndex?: number): Vector3;
  57933. /**
  57934. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57935. * - fov = PI / 2
  57936. * - aspect ratio : 1.0
  57937. * - z-near and far equal to the active camera minZ and maxZ.
  57938. * Returns the PointLight.
  57939. */
  57940. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57941. protected _buildUniformLayout(): void;
  57942. /**
  57943. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57944. * @param effect The effect to update
  57945. * @param lightIndex The index of the light in the effect to update
  57946. * @returns The point light
  57947. */
  57948. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57949. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57950. /**
  57951. * Prepares the list of defines specific to the light type.
  57952. * @param defines the list of defines
  57953. * @param lightIndex defines the index of the light for the effect
  57954. */
  57955. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57956. }
  57957. }
  57958. declare module "babylonjs/Lights/index" {
  57959. export * from "babylonjs/Lights/light";
  57960. export * from "babylonjs/Lights/shadowLight";
  57961. export * from "babylonjs/Lights/Shadows/index";
  57962. export * from "babylonjs/Lights/directionalLight";
  57963. export * from "babylonjs/Lights/hemisphericLight";
  57964. export * from "babylonjs/Lights/pointLight";
  57965. export * from "babylonjs/Lights/spotLight";
  57966. }
  57967. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57968. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57969. /**
  57970. * Header information of HDR texture files.
  57971. */
  57972. export interface HDRInfo {
  57973. /**
  57974. * The height of the texture in pixels.
  57975. */
  57976. height: number;
  57977. /**
  57978. * The width of the texture in pixels.
  57979. */
  57980. width: number;
  57981. /**
  57982. * The index of the beginning of the data in the binary file.
  57983. */
  57984. dataPosition: number;
  57985. }
  57986. /**
  57987. * This groups tools to convert HDR texture to native colors array.
  57988. */
  57989. export class HDRTools {
  57990. private static Ldexp;
  57991. private static Rgbe2float;
  57992. private static readStringLine;
  57993. /**
  57994. * Reads header information from an RGBE texture stored in a native array.
  57995. * More information on this format are available here:
  57996. * https://en.wikipedia.org/wiki/RGBE_image_format
  57997. *
  57998. * @param uint8array The binary file stored in native array.
  57999. * @return The header information.
  58000. */
  58001. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58002. /**
  58003. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58004. * This RGBE texture needs to store the information as a panorama.
  58005. *
  58006. * More information on this format are available here:
  58007. * https://en.wikipedia.org/wiki/RGBE_image_format
  58008. *
  58009. * @param buffer The binary file stored in an array buffer.
  58010. * @param size The expected size of the extracted cubemap.
  58011. * @return The Cube Map information.
  58012. */
  58013. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58014. /**
  58015. * Returns the pixels data extracted from an RGBE texture.
  58016. * This pixels will be stored left to right up to down in the R G B order in one array.
  58017. *
  58018. * More information on this format are available here:
  58019. * https://en.wikipedia.org/wiki/RGBE_image_format
  58020. *
  58021. * @param uint8array The binary file stored in an array buffer.
  58022. * @param hdrInfo The header information of the file.
  58023. * @return The pixels data in RGB right to left up to down order.
  58024. */
  58025. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58026. private static RGBE_ReadPixels_RLE;
  58027. }
  58028. }
  58029. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  58030. import { Nullable } from "babylonjs/types";
  58031. import { Scene } from "babylonjs/scene";
  58032. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58034. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58035. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58036. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58037. /**
  58038. * This represents a texture coming from an HDR input.
  58039. *
  58040. * The only supported format is currently panorama picture stored in RGBE format.
  58041. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58042. */
  58043. export class HDRCubeTexture extends BaseTexture {
  58044. private static _facesMapping;
  58045. private _generateHarmonics;
  58046. private _noMipmap;
  58047. private _textureMatrix;
  58048. private _size;
  58049. private _onLoad;
  58050. private _onError;
  58051. /**
  58052. * The texture URL.
  58053. */
  58054. url: string;
  58055. /**
  58056. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58057. */
  58058. coordinatesMode: number;
  58059. protected _isBlocking: boolean;
  58060. /**
  58061. * Sets wether or not the texture is blocking during loading.
  58062. */
  58063. set isBlocking(value: boolean);
  58064. /**
  58065. * Gets wether or not the texture is blocking during loading.
  58066. */
  58067. get isBlocking(): boolean;
  58068. protected _rotationY: number;
  58069. /**
  58070. * Sets texture matrix rotation angle around Y axis in radians.
  58071. */
  58072. set rotationY(value: number);
  58073. /**
  58074. * Gets texture matrix rotation angle around Y axis radians.
  58075. */
  58076. get rotationY(): number;
  58077. /**
  58078. * Gets or sets the center of the bounding box associated with the cube texture
  58079. * It must define where the camera used to render the texture was set
  58080. */
  58081. boundingBoxPosition: Vector3;
  58082. private _boundingBoxSize;
  58083. /**
  58084. * Gets or sets the size of the bounding box associated with the cube texture
  58085. * When defined, the cubemap will switch to local mode
  58086. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58087. * @example https://www.babylonjs-playground.com/#RNASML
  58088. */
  58089. set boundingBoxSize(value: Vector3);
  58090. get boundingBoxSize(): Vector3;
  58091. /**
  58092. * Instantiates an HDRTexture from the following parameters.
  58093. *
  58094. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58095. * @param sceneOrEngine The scene or engine the texture will be used in
  58096. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58097. * @param noMipmap Forces to not generate the mipmap if true
  58098. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58099. * @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)
  58100. * @param reserved Reserved flag for internal use.
  58101. */
  58102. 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>);
  58103. /**
  58104. * Get the current class name of the texture useful for serialization or dynamic coding.
  58105. * @returns "HDRCubeTexture"
  58106. */
  58107. getClassName(): string;
  58108. /**
  58109. * Occurs when the file is raw .hdr file.
  58110. */
  58111. private loadTexture;
  58112. clone(): HDRCubeTexture;
  58113. delayLoad(): void;
  58114. /**
  58115. * Get the texture reflection matrix used to rotate/transform the reflection.
  58116. * @returns the reflection matrix
  58117. */
  58118. getReflectionTextureMatrix(): Matrix;
  58119. /**
  58120. * Set the texture reflection matrix used to rotate/transform the reflection.
  58121. * @param value Define the reflection matrix to set
  58122. */
  58123. setReflectionTextureMatrix(value: Matrix): void;
  58124. /**
  58125. * Parses a JSON representation of an HDR Texture in order to create the texture
  58126. * @param parsedTexture Define the JSON representation
  58127. * @param scene Define the scene the texture should be created in
  58128. * @param rootUrl Define the root url in case we need to load relative dependencies
  58129. * @returns the newly created texture after parsing
  58130. */
  58131. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58132. serialize(): any;
  58133. }
  58134. }
  58135. declare module "babylonjs/Physics/physicsEngine" {
  58136. import { Nullable } from "babylonjs/types";
  58137. import { Vector3 } from "babylonjs/Maths/math.vector";
  58138. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58139. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  58140. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  58141. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58142. /**
  58143. * Class used to control physics engine
  58144. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58145. */
  58146. export class PhysicsEngine implements IPhysicsEngine {
  58147. private _physicsPlugin;
  58148. /**
  58149. * Global value used to control the smallest number supported by the simulation
  58150. */
  58151. static Epsilon: number;
  58152. private _impostors;
  58153. private _joints;
  58154. private _subTimeStep;
  58155. /**
  58156. * Gets the gravity vector used by the simulation
  58157. */
  58158. gravity: Vector3;
  58159. /**
  58160. * Factory used to create the default physics plugin.
  58161. * @returns The default physics plugin
  58162. */
  58163. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58164. /**
  58165. * Creates a new Physics Engine
  58166. * @param gravity defines the gravity vector used by the simulation
  58167. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58168. */
  58169. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58170. /**
  58171. * Sets the gravity vector used by the simulation
  58172. * @param gravity defines the gravity vector to use
  58173. */
  58174. setGravity(gravity: Vector3): void;
  58175. /**
  58176. * Set the time step of the physics engine.
  58177. * Default is 1/60.
  58178. * To slow it down, enter 1/600 for example.
  58179. * To speed it up, 1/30
  58180. * @param newTimeStep defines the new timestep to apply to this world.
  58181. */
  58182. setTimeStep(newTimeStep?: number): void;
  58183. /**
  58184. * Get the time step of the physics engine.
  58185. * @returns the current time step
  58186. */
  58187. getTimeStep(): number;
  58188. /**
  58189. * Set the sub time step of the physics engine.
  58190. * Default is 0 meaning there is no sub steps
  58191. * To increase physics resolution precision, set a small value (like 1 ms)
  58192. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58193. */
  58194. setSubTimeStep(subTimeStep?: number): void;
  58195. /**
  58196. * Get the sub time step of the physics engine.
  58197. * @returns the current sub time step
  58198. */
  58199. getSubTimeStep(): number;
  58200. /**
  58201. * Release all resources
  58202. */
  58203. dispose(): void;
  58204. /**
  58205. * Gets the name of the current physics plugin
  58206. * @returns the name of the plugin
  58207. */
  58208. getPhysicsPluginName(): string;
  58209. /**
  58210. * Adding a new impostor for the impostor tracking.
  58211. * This will be done by the impostor itself.
  58212. * @param impostor the impostor to add
  58213. */
  58214. addImpostor(impostor: PhysicsImpostor): void;
  58215. /**
  58216. * Remove an impostor from the engine.
  58217. * This impostor and its mesh will not longer be updated by the physics engine.
  58218. * @param impostor the impostor to remove
  58219. */
  58220. removeImpostor(impostor: PhysicsImpostor): void;
  58221. /**
  58222. * Add a joint to the physics engine
  58223. * @param mainImpostor defines the main impostor to which the joint is added.
  58224. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58225. * @param joint defines the joint that will connect both impostors.
  58226. */
  58227. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58228. /**
  58229. * Removes a joint from the simulation
  58230. * @param mainImpostor defines the impostor used with the joint
  58231. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58232. * @param joint defines the joint to remove
  58233. */
  58234. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58235. /**
  58236. * Called by the scene. No need to call it.
  58237. * @param delta defines the timespam between frames
  58238. */
  58239. _step(delta: number): void;
  58240. /**
  58241. * Gets the current plugin used to run the simulation
  58242. * @returns current plugin
  58243. */
  58244. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58245. /**
  58246. * Gets the list of physic impostors
  58247. * @returns an array of PhysicsImpostor
  58248. */
  58249. getImpostors(): Array<PhysicsImpostor>;
  58250. /**
  58251. * Gets the impostor for a physics enabled object
  58252. * @param object defines the object impersonated by the impostor
  58253. * @returns the PhysicsImpostor or null if not found
  58254. */
  58255. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58256. /**
  58257. * Gets the impostor for a physics body object
  58258. * @param body defines physics body used by the impostor
  58259. * @returns the PhysicsImpostor or null if not found
  58260. */
  58261. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58262. /**
  58263. * Does a raycast in the physics world
  58264. * @param from when should the ray start?
  58265. * @param to when should the ray end?
  58266. * @returns PhysicsRaycastResult
  58267. */
  58268. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58269. }
  58270. }
  58271. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  58272. import { Nullable } from "babylonjs/types";
  58273. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58275. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58276. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58277. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58278. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58279. /** @hidden */
  58280. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58281. private _useDeltaForWorldStep;
  58282. world: any;
  58283. name: string;
  58284. private _physicsMaterials;
  58285. private _fixedTimeStep;
  58286. private _cannonRaycastResult;
  58287. private _raycastResult;
  58288. private _physicsBodysToRemoveAfterStep;
  58289. BJSCANNON: any;
  58290. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58291. setGravity(gravity: Vector3): void;
  58292. setTimeStep(timeStep: number): void;
  58293. getTimeStep(): number;
  58294. executeStep(delta: number): void;
  58295. private _removeMarkedPhysicsBodiesFromWorld;
  58296. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58297. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58298. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58299. private _processChildMeshes;
  58300. removePhysicsBody(impostor: PhysicsImpostor): void;
  58301. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58302. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58303. private _addMaterial;
  58304. private _checkWithEpsilon;
  58305. private _createShape;
  58306. private _createHeightmap;
  58307. private _minus90X;
  58308. private _plus90X;
  58309. private _tmpPosition;
  58310. private _tmpDeltaPosition;
  58311. private _tmpUnityRotation;
  58312. private _updatePhysicsBodyTransformation;
  58313. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58314. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58315. isSupported(): boolean;
  58316. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58317. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58318. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58319. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58320. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58321. getBodyMass(impostor: PhysicsImpostor): number;
  58322. getBodyFriction(impostor: PhysicsImpostor): number;
  58323. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58324. getBodyRestitution(impostor: PhysicsImpostor): number;
  58325. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58326. sleepBody(impostor: PhysicsImpostor): void;
  58327. wakeUpBody(impostor: PhysicsImpostor): void;
  58328. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58329. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58330. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58331. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58332. getRadius(impostor: PhysicsImpostor): number;
  58333. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58334. dispose(): void;
  58335. private _extendNamespace;
  58336. /**
  58337. * Does a raycast in the physics world
  58338. * @param from when should the ray start?
  58339. * @param to when should the ray end?
  58340. * @returns PhysicsRaycastResult
  58341. */
  58342. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58343. }
  58344. }
  58345. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  58346. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58347. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58348. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58350. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58351. import { Nullable } from "babylonjs/types";
  58352. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58353. /** @hidden */
  58354. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58355. private _useDeltaForWorldStep;
  58356. world: any;
  58357. name: string;
  58358. BJSOIMO: any;
  58359. private _raycastResult;
  58360. private _fixedTimeStep;
  58361. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58362. setGravity(gravity: Vector3): void;
  58363. setTimeStep(timeStep: number): void;
  58364. getTimeStep(): number;
  58365. private _tmpImpostorsArray;
  58366. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58367. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58368. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58369. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58370. private _tmpPositionVector;
  58371. removePhysicsBody(impostor: PhysicsImpostor): void;
  58372. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58373. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58374. isSupported(): boolean;
  58375. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58376. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58377. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58378. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58379. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58380. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58381. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58382. getBodyMass(impostor: PhysicsImpostor): number;
  58383. getBodyFriction(impostor: PhysicsImpostor): number;
  58384. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58385. getBodyRestitution(impostor: PhysicsImpostor): number;
  58386. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58387. sleepBody(impostor: PhysicsImpostor): void;
  58388. wakeUpBody(impostor: PhysicsImpostor): void;
  58389. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58390. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58391. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58392. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58393. getRadius(impostor: PhysicsImpostor): number;
  58394. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58395. dispose(): void;
  58396. /**
  58397. * Does a raycast in the physics world
  58398. * @param from when should the ray start?
  58399. * @param to when should the ray end?
  58400. * @returns PhysicsRaycastResult
  58401. */
  58402. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58403. }
  58404. }
  58405. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58406. import { Nullable } from "babylonjs/types";
  58407. import { Scene } from "babylonjs/scene";
  58408. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58409. import { Color4 } from "babylonjs/Maths/math.color";
  58410. import { Mesh } from "babylonjs/Meshes/mesh";
  58411. /**
  58412. * Class containing static functions to help procedurally build meshes
  58413. */
  58414. export class RibbonBuilder {
  58415. /**
  58416. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58417. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58418. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58419. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58420. * * 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
  58421. * * 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
  58422. * * 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
  58423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58424. * * 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
  58425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58426. * * 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
  58427. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58428. * * 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
  58429. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58431. * @param name defines the name of the mesh
  58432. * @param options defines the options used to create the mesh
  58433. * @param scene defines the hosting scene
  58434. * @returns the ribbon mesh
  58435. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58436. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58437. */
  58438. static CreateRibbon(name: string, options: {
  58439. pathArray: Vector3[][];
  58440. closeArray?: boolean;
  58441. closePath?: boolean;
  58442. offset?: number;
  58443. updatable?: boolean;
  58444. sideOrientation?: number;
  58445. frontUVs?: Vector4;
  58446. backUVs?: Vector4;
  58447. instance?: Mesh;
  58448. invertUV?: boolean;
  58449. uvs?: Vector2[];
  58450. colors?: Color4[];
  58451. }, scene?: Nullable<Scene>): Mesh;
  58452. }
  58453. }
  58454. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58455. import { Nullable } from "babylonjs/types";
  58456. import { Scene } from "babylonjs/scene";
  58457. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58458. import { Mesh } from "babylonjs/Meshes/mesh";
  58459. /**
  58460. * Class containing static functions to help procedurally build meshes
  58461. */
  58462. export class ShapeBuilder {
  58463. /**
  58464. * 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.
  58465. * * 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.
  58466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58467. * * 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.
  58468. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58469. * * 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
  58470. * * 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
  58471. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58473. * * 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
  58474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58476. * @param name defines the name of the mesh
  58477. * @param options defines the options used to create the mesh
  58478. * @param scene defines the hosting scene
  58479. * @returns the extruded shape mesh
  58480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58482. */
  58483. static ExtrudeShape(name: string, options: {
  58484. shape: Vector3[];
  58485. path: Vector3[];
  58486. scale?: number;
  58487. rotation?: number;
  58488. cap?: number;
  58489. updatable?: boolean;
  58490. sideOrientation?: number;
  58491. frontUVs?: Vector4;
  58492. backUVs?: Vector4;
  58493. instance?: Mesh;
  58494. invertUV?: boolean;
  58495. }, scene?: Nullable<Scene>): Mesh;
  58496. /**
  58497. * Creates an custom extruded shape mesh.
  58498. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58499. * * 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.
  58500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58501. * * 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
  58502. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58503. * * 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
  58504. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58505. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58506. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  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 custom extruded shape mesh
  58518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58521. */
  58522. static ExtrudeShapeCustom(name: string, options: {
  58523. shape: Vector3[];
  58524. path: Vector3[];
  58525. scaleFunction?: any;
  58526. rotationFunction?: any;
  58527. ribbonCloseArray?: boolean;
  58528. ribbonClosePath?: boolean;
  58529. cap?: number;
  58530. updatable?: boolean;
  58531. sideOrientation?: number;
  58532. frontUVs?: Vector4;
  58533. backUVs?: Vector4;
  58534. instance?: Mesh;
  58535. invertUV?: boolean;
  58536. }, scene?: Nullable<Scene>): Mesh;
  58537. private static _ExtrudeShapeGeneric;
  58538. }
  58539. }
  58540. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58541. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58542. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58543. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58544. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58545. import { Nullable } from "babylonjs/types";
  58546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58547. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58548. /**
  58549. * AmmoJS Physics plugin
  58550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58551. * @see https://github.com/kripken/ammo.js/
  58552. */
  58553. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58554. private _useDeltaForWorldStep;
  58555. /**
  58556. * Reference to the Ammo library
  58557. */
  58558. bjsAMMO: any;
  58559. /**
  58560. * Created ammoJS world which physics bodies are added to
  58561. */
  58562. world: any;
  58563. /**
  58564. * Name of the plugin
  58565. */
  58566. name: string;
  58567. private _timeStep;
  58568. private _fixedTimeStep;
  58569. private _maxSteps;
  58570. private _tmpQuaternion;
  58571. private _tmpAmmoTransform;
  58572. private _tmpAmmoQuaternion;
  58573. private _tmpAmmoConcreteContactResultCallback;
  58574. private _collisionConfiguration;
  58575. private _dispatcher;
  58576. private _overlappingPairCache;
  58577. private _solver;
  58578. private _softBodySolver;
  58579. private _tmpAmmoVectorA;
  58580. private _tmpAmmoVectorB;
  58581. private _tmpAmmoVectorC;
  58582. private _tmpAmmoVectorD;
  58583. private _tmpContactCallbackResult;
  58584. private _tmpAmmoVectorRCA;
  58585. private _tmpAmmoVectorRCB;
  58586. private _raycastResult;
  58587. private static readonly DISABLE_COLLISION_FLAG;
  58588. private static readonly KINEMATIC_FLAG;
  58589. private static readonly DISABLE_DEACTIVATION_FLAG;
  58590. /**
  58591. * Initializes the ammoJS plugin
  58592. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58593. * @param ammoInjection can be used to inject your own ammo reference
  58594. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58595. */
  58596. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58597. /**
  58598. * Sets the gravity of the physics world (m/(s^2))
  58599. * @param gravity Gravity to set
  58600. */
  58601. setGravity(gravity: Vector3): void;
  58602. /**
  58603. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58604. * @param timeStep timestep to use in seconds
  58605. */
  58606. setTimeStep(timeStep: number): void;
  58607. /**
  58608. * 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)
  58609. * @param fixedTimeStep fixedTimeStep to use in seconds
  58610. */
  58611. setFixedTimeStep(fixedTimeStep: number): void;
  58612. /**
  58613. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58614. * @param maxSteps the maximum number of steps by the physics engine per frame
  58615. */
  58616. setMaxSteps(maxSteps: number): void;
  58617. /**
  58618. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58619. * @returns the current timestep in seconds
  58620. */
  58621. getTimeStep(): number;
  58622. /**
  58623. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58624. */
  58625. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58626. private _isImpostorInContact;
  58627. private _isImpostorPairInContact;
  58628. private _stepSimulation;
  58629. /**
  58630. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58631. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58632. * After the step the babylon meshes are set to the position of the physics imposters
  58633. * @param delta amount of time to step forward
  58634. * @param impostors array of imposters to update before/after the step
  58635. */
  58636. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58637. /**
  58638. * Update babylon mesh to match physics world object
  58639. * @param impostor imposter to match
  58640. */
  58641. private _afterSoftStep;
  58642. /**
  58643. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58644. * @param impostor imposter to match
  58645. */
  58646. private _ropeStep;
  58647. /**
  58648. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58649. * @param impostor imposter to match
  58650. */
  58651. private _softbodyOrClothStep;
  58652. private _tmpMatrix;
  58653. /**
  58654. * Applies an impulse on the imposter
  58655. * @param impostor imposter to apply impulse to
  58656. * @param force amount of force to be applied to the imposter
  58657. * @param contactPoint the location to apply the impulse on the imposter
  58658. */
  58659. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58660. /**
  58661. * Applies a force on the imposter
  58662. * @param impostor imposter to apply force
  58663. * @param force amount of force to be applied to the imposter
  58664. * @param contactPoint the location to apply the force on the imposter
  58665. */
  58666. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58667. /**
  58668. * Creates a physics body using the plugin
  58669. * @param impostor the imposter to create the physics body on
  58670. */
  58671. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58672. /**
  58673. * Removes the physics body from the imposter and disposes of the body's memory
  58674. * @param impostor imposter to remove the physics body from
  58675. */
  58676. removePhysicsBody(impostor: PhysicsImpostor): void;
  58677. /**
  58678. * Generates a joint
  58679. * @param impostorJoint the imposter joint to create the joint with
  58680. */
  58681. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58682. /**
  58683. * Removes a joint
  58684. * @param impostorJoint the imposter joint to remove the joint from
  58685. */
  58686. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58687. private _addMeshVerts;
  58688. /**
  58689. * Initialise the soft body vertices to match its object's (mesh) vertices
  58690. * Softbody vertices (nodes) are in world space and to match this
  58691. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58692. * @param impostor to create the softbody for
  58693. */
  58694. private _softVertexData;
  58695. /**
  58696. * Create an impostor's soft body
  58697. * @param impostor to create the softbody for
  58698. */
  58699. private _createSoftbody;
  58700. /**
  58701. * Create cloth for an impostor
  58702. * @param impostor to create the softbody for
  58703. */
  58704. private _createCloth;
  58705. /**
  58706. * Create rope for an impostor
  58707. * @param impostor to create the softbody for
  58708. */
  58709. private _createRope;
  58710. /**
  58711. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58712. * @param impostor to create the custom physics shape for
  58713. */
  58714. private _createCustom;
  58715. private _addHullVerts;
  58716. private _createShape;
  58717. /**
  58718. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58719. * @param impostor imposter containing the physics body and babylon object
  58720. */
  58721. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58722. /**
  58723. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58724. * @param impostor imposter containing the physics body and babylon object
  58725. * @param newPosition new position
  58726. * @param newRotation new rotation
  58727. */
  58728. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58729. /**
  58730. * If this plugin is supported
  58731. * @returns true if its supported
  58732. */
  58733. isSupported(): boolean;
  58734. /**
  58735. * Sets the linear velocity of the physics body
  58736. * @param impostor imposter to set the velocity on
  58737. * @param velocity velocity to set
  58738. */
  58739. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58740. /**
  58741. * Sets the angular velocity of the physics body
  58742. * @param impostor imposter to set the velocity on
  58743. * @param velocity velocity to set
  58744. */
  58745. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58746. /**
  58747. * gets the linear velocity
  58748. * @param impostor imposter to get linear velocity from
  58749. * @returns linear velocity
  58750. */
  58751. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58752. /**
  58753. * gets the angular velocity
  58754. * @param impostor imposter to get angular velocity from
  58755. * @returns angular velocity
  58756. */
  58757. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58758. /**
  58759. * Sets the mass of physics body
  58760. * @param impostor imposter to set the mass on
  58761. * @param mass mass to set
  58762. */
  58763. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58764. /**
  58765. * Gets the mass of the physics body
  58766. * @param impostor imposter to get the mass from
  58767. * @returns mass
  58768. */
  58769. getBodyMass(impostor: PhysicsImpostor): number;
  58770. /**
  58771. * Gets friction of the impostor
  58772. * @param impostor impostor to get friction from
  58773. * @returns friction value
  58774. */
  58775. getBodyFriction(impostor: PhysicsImpostor): number;
  58776. /**
  58777. * Sets friction of the impostor
  58778. * @param impostor impostor to set friction on
  58779. * @param friction friction value
  58780. */
  58781. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58782. /**
  58783. * Gets restitution of the impostor
  58784. * @param impostor impostor to get restitution from
  58785. * @returns restitution value
  58786. */
  58787. getBodyRestitution(impostor: PhysicsImpostor): number;
  58788. /**
  58789. * Sets resitution of the impostor
  58790. * @param impostor impostor to set resitution on
  58791. * @param restitution resitution value
  58792. */
  58793. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58794. /**
  58795. * Gets pressure inside the impostor
  58796. * @param impostor impostor to get pressure from
  58797. * @returns pressure value
  58798. */
  58799. getBodyPressure(impostor: PhysicsImpostor): number;
  58800. /**
  58801. * Sets pressure inside a soft body impostor
  58802. * Cloth and rope must remain 0 pressure
  58803. * @param impostor impostor to set pressure on
  58804. * @param pressure pressure value
  58805. */
  58806. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58807. /**
  58808. * Gets stiffness of the impostor
  58809. * @param impostor impostor to get stiffness from
  58810. * @returns pressure value
  58811. */
  58812. getBodyStiffness(impostor: PhysicsImpostor): number;
  58813. /**
  58814. * Sets stiffness of the impostor
  58815. * @param impostor impostor to set stiffness on
  58816. * @param stiffness stiffness value from 0 to 1
  58817. */
  58818. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58819. /**
  58820. * Gets velocityIterations of the impostor
  58821. * @param impostor impostor to get velocity iterations from
  58822. * @returns velocityIterations value
  58823. */
  58824. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58825. /**
  58826. * Sets velocityIterations of the impostor
  58827. * @param impostor impostor to set velocity iterations on
  58828. * @param velocityIterations velocityIterations value
  58829. */
  58830. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58831. /**
  58832. * Gets positionIterations of the impostor
  58833. * @param impostor impostor to get position iterations from
  58834. * @returns positionIterations value
  58835. */
  58836. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58837. /**
  58838. * Sets positionIterations of the impostor
  58839. * @param impostor impostor to set position on
  58840. * @param positionIterations positionIterations value
  58841. */
  58842. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58843. /**
  58844. * Append an anchor to a cloth object
  58845. * @param impostor is the cloth impostor to add anchor to
  58846. * @param otherImpostor is the rigid impostor to anchor to
  58847. * @param width ratio across width from 0 to 1
  58848. * @param height ratio up height from 0 to 1
  58849. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58850. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58851. */
  58852. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58853. /**
  58854. * Append an hook to a rope object
  58855. * @param impostor is the rope impostor to add hook to
  58856. * @param otherImpostor is the rigid impostor to hook to
  58857. * @param length ratio along the rope from 0 to 1
  58858. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58859. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58860. */
  58861. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58862. /**
  58863. * Sleeps the physics body and stops it from being active
  58864. * @param impostor impostor to sleep
  58865. */
  58866. sleepBody(impostor: PhysicsImpostor): void;
  58867. /**
  58868. * Activates the physics body
  58869. * @param impostor impostor to activate
  58870. */
  58871. wakeUpBody(impostor: PhysicsImpostor): void;
  58872. /**
  58873. * Updates the distance parameters of the joint
  58874. * @param joint joint to update
  58875. * @param maxDistance maximum distance of the joint
  58876. * @param minDistance minimum distance of the joint
  58877. */
  58878. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58879. /**
  58880. * Sets a motor on the joint
  58881. * @param joint joint to set motor on
  58882. * @param speed speed of the motor
  58883. * @param maxForce maximum force of the motor
  58884. * @param motorIndex index of the motor
  58885. */
  58886. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58887. /**
  58888. * Sets the motors limit
  58889. * @param joint joint to set limit on
  58890. * @param upperLimit upper limit
  58891. * @param lowerLimit lower limit
  58892. */
  58893. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58894. /**
  58895. * Syncs the position and rotation of a mesh with the impostor
  58896. * @param mesh mesh to sync
  58897. * @param impostor impostor to update the mesh with
  58898. */
  58899. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58900. /**
  58901. * Gets the radius of the impostor
  58902. * @param impostor impostor to get radius from
  58903. * @returns the radius
  58904. */
  58905. getRadius(impostor: PhysicsImpostor): number;
  58906. /**
  58907. * Gets the box size of the impostor
  58908. * @param impostor impostor to get box size from
  58909. * @param result the resulting box size
  58910. */
  58911. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58912. /**
  58913. * Disposes of the impostor
  58914. */
  58915. dispose(): void;
  58916. /**
  58917. * Does a raycast in the physics world
  58918. * @param from when should the ray start?
  58919. * @param to when should the ray end?
  58920. * @returns PhysicsRaycastResult
  58921. */
  58922. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58923. }
  58924. }
  58925. declare module "babylonjs/Probes/reflectionProbe" {
  58926. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58927. import { Vector3 } from "babylonjs/Maths/math.vector";
  58928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58929. import { Nullable } from "babylonjs/types";
  58930. import { Scene } from "babylonjs/scene";
  58931. module "babylonjs/abstractScene" {
  58932. interface AbstractScene {
  58933. /**
  58934. * The list of reflection probes added to the scene
  58935. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58936. */
  58937. reflectionProbes: Array<ReflectionProbe>;
  58938. /**
  58939. * Removes the given reflection probe from this scene.
  58940. * @param toRemove The reflection probe to remove
  58941. * @returns The index of the removed reflection probe
  58942. */
  58943. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58944. /**
  58945. * Adds the given reflection probe to this scene.
  58946. * @param newReflectionProbe The reflection probe to add
  58947. */
  58948. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58949. }
  58950. }
  58951. /**
  58952. * Class used to generate realtime reflection / refraction cube textures
  58953. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58954. */
  58955. export class ReflectionProbe {
  58956. /** defines the name of the probe */
  58957. name: string;
  58958. private _scene;
  58959. private _renderTargetTexture;
  58960. private _projectionMatrix;
  58961. private _viewMatrix;
  58962. private _target;
  58963. private _add;
  58964. private _attachedMesh;
  58965. private _invertYAxis;
  58966. /** Gets or sets probe position (center of the cube map) */
  58967. position: Vector3;
  58968. /**
  58969. * Creates a new reflection probe
  58970. * @param name defines the name of the probe
  58971. * @param size defines the texture resolution (for each face)
  58972. * @param scene defines the hosting scene
  58973. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58974. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58975. */
  58976. constructor(
  58977. /** defines the name of the probe */
  58978. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58979. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58980. get samples(): number;
  58981. set samples(value: number);
  58982. /** Gets or sets the refresh rate to use (on every frame by default) */
  58983. get refreshRate(): number;
  58984. set refreshRate(value: number);
  58985. /**
  58986. * Gets the hosting scene
  58987. * @returns a Scene
  58988. */
  58989. getScene(): Scene;
  58990. /** Gets the internal CubeTexture used to render to */
  58991. get cubeTexture(): RenderTargetTexture;
  58992. /** Gets the list of meshes to render */
  58993. get renderList(): Nullable<AbstractMesh[]>;
  58994. /**
  58995. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58996. * @param mesh defines the mesh to attach to
  58997. */
  58998. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58999. /**
  59000. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59001. * @param renderingGroupId The rendering group id corresponding to its index
  59002. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59003. */
  59004. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59005. /**
  59006. * Clean all associated resources
  59007. */
  59008. dispose(): void;
  59009. /**
  59010. * Converts the reflection probe information to a readable string for debug purpose.
  59011. * @param fullDetails Supports for multiple levels of logging within scene loading
  59012. * @returns the human readable reflection probe info
  59013. */
  59014. toString(fullDetails?: boolean): string;
  59015. /**
  59016. * Get the class name of the relfection probe.
  59017. * @returns "ReflectionProbe"
  59018. */
  59019. getClassName(): string;
  59020. /**
  59021. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59022. * @returns The JSON representation of the texture
  59023. */
  59024. serialize(): any;
  59025. /**
  59026. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59027. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59028. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59029. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59030. * @returns The parsed reflection probe if successful
  59031. */
  59032. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59033. }
  59034. }
  59035. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  59036. /** @hidden */
  59037. export var _BabylonLoaderRegistered: boolean;
  59038. /**
  59039. * Helps setting up some configuration for the babylon file loader.
  59040. */
  59041. export class BabylonFileLoaderConfiguration {
  59042. /**
  59043. * The loader does not allow injecting custom physix engine into the plugins.
  59044. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59045. * So you could set this variable to your engine import to make it work.
  59046. */
  59047. static LoaderInjectedPhysicsEngine: any;
  59048. }
  59049. }
  59050. declare module "babylonjs/Loading/Plugins/index" {
  59051. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  59052. }
  59053. declare module "babylonjs/Loading/index" {
  59054. export * from "babylonjs/Loading/loadingScreen";
  59055. export * from "babylonjs/Loading/Plugins/index";
  59056. export * from "babylonjs/Loading/sceneLoader";
  59057. export * from "babylonjs/Loading/sceneLoaderFlags";
  59058. }
  59059. declare module "babylonjs/Materials/Background/index" {
  59060. export * from "babylonjs/Materials/Background/backgroundMaterial";
  59061. }
  59062. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  59063. import { Scene } from "babylonjs/scene";
  59064. import { Color3 } from "babylonjs/Maths/math.color";
  59065. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59067. /**
  59068. * The Physically based simple base material of BJS.
  59069. *
  59070. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59071. * It is used as the base class for both the specGloss and metalRough conventions.
  59072. */
  59073. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59074. /**
  59075. * Number of Simultaneous lights allowed on the material.
  59076. */
  59077. maxSimultaneousLights: number;
  59078. /**
  59079. * If sets to true, disables all the lights affecting the material.
  59080. */
  59081. disableLighting: boolean;
  59082. /**
  59083. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59084. */
  59085. environmentTexture: BaseTexture;
  59086. /**
  59087. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59088. */
  59089. invertNormalMapX: boolean;
  59090. /**
  59091. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59092. */
  59093. invertNormalMapY: boolean;
  59094. /**
  59095. * Normal map used in the model.
  59096. */
  59097. normalTexture: BaseTexture;
  59098. /**
  59099. * Emissivie color used to self-illuminate the model.
  59100. */
  59101. emissiveColor: Color3;
  59102. /**
  59103. * Emissivie texture used to self-illuminate the model.
  59104. */
  59105. emissiveTexture: BaseTexture;
  59106. /**
  59107. * Occlusion Channel Strenght.
  59108. */
  59109. occlusionStrength: number;
  59110. /**
  59111. * Occlusion Texture of the material (adding extra occlusion effects).
  59112. */
  59113. occlusionTexture: BaseTexture;
  59114. /**
  59115. * Defines the alpha limits in alpha test mode.
  59116. */
  59117. alphaCutOff: number;
  59118. /**
  59119. * Gets the current double sided mode.
  59120. */
  59121. get doubleSided(): boolean;
  59122. /**
  59123. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59124. */
  59125. set doubleSided(value: boolean);
  59126. /**
  59127. * Stores the pre-calculated light information of a mesh in a texture.
  59128. */
  59129. lightmapTexture: BaseTexture;
  59130. /**
  59131. * If true, the light map contains occlusion information instead of lighting info.
  59132. */
  59133. useLightmapAsShadowmap: boolean;
  59134. /**
  59135. * Instantiates a new PBRMaterial instance.
  59136. *
  59137. * @param name The material name
  59138. * @param scene The scene the material will be use in.
  59139. */
  59140. constructor(name: string, scene: Scene);
  59141. getClassName(): string;
  59142. }
  59143. }
  59144. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  59145. import { Scene } from "babylonjs/scene";
  59146. import { Color3 } from "babylonjs/Maths/math.color";
  59147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59148. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59149. /**
  59150. * The PBR material of BJS following the metal roughness convention.
  59151. *
  59152. * This fits to the PBR convention in the GLTF definition:
  59153. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59154. */
  59155. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59156. /**
  59157. * The base color has two different interpretations depending on the value of metalness.
  59158. * When the material is a metal, the base color is the specific measured reflectance value
  59159. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59160. * of the material.
  59161. */
  59162. baseColor: Color3;
  59163. /**
  59164. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59165. * well as opacity information in the alpha channel.
  59166. */
  59167. baseTexture: BaseTexture;
  59168. /**
  59169. * Specifies the metallic scalar value of the material.
  59170. * Can also be used to scale the metalness values of the metallic texture.
  59171. */
  59172. metallic: number;
  59173. /**
  59174. * Specifies the roughness scalar value of the material.
  59175. * Can also be used to scale the roughness values of the metallic texture.
  59176. */
  59177. roughness: number;
  59178. /**
  59179. * Texture containing both the metallic value in the B channel and the
  59180. * roughness value in the G channel to keep better precision.
  59181. */
  59182. metallicRoughnessTexture: BaseTexture;
  59183. /**
  59184. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59185. *
  59186. * @param name The material name
  59187. * @param scene The scene the material will be use in.
  59188. */
  59189. constructor(name: string, scene: Scene);
  59190. /**
  59191. * Return the currrent class name of the material.
  59192. */
  59193. getClassName(): string;
  59194. /**
  59195. * Makes a duplicate of the current material.
  59196. * @param name - name to use for the new material.
  59197. */
  59198. clone(name: string): PBRMetallicRoughnessMaterial;
  59199. /**
  59200. * Serialize the material to a parsable JSON object.
  59201. */
  59202. serialize(): any;
  59203. /**
  59204. * Parses a JSON object correponding to the serialize function.
  59205. */
  59206. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59207. }
  59208. }
  59209. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  59210. import { Scene } from "babylonjs/scene";
  59211. import { Color3 } from "babylonjs/Maths/math.color";
  59212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59213. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59214. /**
  59215. * The PBR material of BJS following the specular glossiness convention.
  59216. *
  59217. * This fits to the PBR convention in the GLTF definition:
  59218. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59219. */
  59220. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59221. /**
  59222. * Specifies the diffuse color of the material.
  59223. */
  59224. diffuseColor: Color3;
  59225. /**
  59226. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59227. * channel.
  59228. */
  59229. diffuseTexture: BaseTexture;
  59230. /**
  59231. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59232. */
  59233. specularColor: Color3;
  59234. /**
  59235. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59236. */
  59237. glossiness: number;
  59238. /**
  59239. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59240. */
  59241. specularGlossinessTexture: BaseTexture;
  59242. /**
  59243. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59244. *
  59245. * @param name The material name
  59246. * @param scene The scene the material will be use in.
  59247. */
  59248. constructor(name: string, scene: Scene);
  59249. /**
  59250. * Return the currrent class name of the material.
  59251. */
  59252. getClassName(): string;
  59253. /**
  59254. * Makes a duplicate of the current material.
  59255. * @param name - name to use for the new material.
  59256. */
  59257. clone(name: string): PBRSpecularGlossinessMaterial;
  59258. /**
  59259. * Serialize the material to a parsable JSON object.
  59260. */
  59261. serialize(): any;
  59262. /**
  59263. * Parses a JSON object correponding to the serialize function.
  59264. */
  59265. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59266. }
  59267. }
  59268. declare module "babylonjs/Materials/PBR/index" {
  59269. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59270. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59271. export * from "babylonjs/Materials/PBR/pbrMaterial";
  59272. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  59273. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  59274. }
  59275. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  59276. import { Nullable } from "babylonjs/types";
  59277. import { Scene } from "babylonjs/scene";
  59278. import { Matrix } from "babylonjs/Maths/math.vector";
  59279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59280. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59281. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59282. /**
  59283. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59284. * It can help converting any input color in a desired output one. This can then be used to create effects
  59285. * from sepia, black and white to sixties or futuristic rendering...
  59286. *
  59287. * The only supported format is currently 3dl.
  59288. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59289. */
  59290. export class ColorGradingTexture extends BaseTexture {
  59291. /**
  59292. * The texture URL.
  59293. */
  59294. url: string;
  59295. /**
  59296. * Empty line regex stored for GC.
  59297. */
  59298. private static _noneEmptyLineRegex;
  59299. private _textureMatrix;
  59300. private _onLoad;
  59301. /**
  59302. * Instantiates a ColorGradingTexture from the following parameters.
  59303. *
  59304. * @param url The location of the color gradind data (currently only supporting 3dl)
  59305. * @param sceneOrEngine The scene or engine the texture will be used in
  59306. * @param onLoad defines a callback triggered when the texture has been loaded
  59307. */
  59308. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59309. /**
  59310. * Fires the onload event from the constructor if requested.
  59311. */
  59312. private _triggerOnLoad;
  59313. /**
  59314. * Returns the texture matrix used in most of the material.
  59315. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59316. */
  59317. getTextureMatrix(): Matrix;
  59318. /**
  59319. * Occurs when the file being loaded is a .3dl LUT file.
  59320. */
  59321. private load3dlTexture;
  59322. /**
  59323. * Starts the loading process of the texture.
  59324. */
  59325. private loadTexture;
  59326. /**
  59327. * Clones the color gradind texture.
  59328. */
  59329. clone(): ColorGradingTexture;
  59330. /**
  59331. * Called during delayed load for textures.
  59332. */
  59333. delayLoad(): void;
  59334. /**
  59335. * Parses a color grading texture serialized by Babylon.
  59336. * @param parsedTexture The texture information being parsedTexture
  59337. * @param scene The scene to load the texture in
  59338. * @param rootUrl The root url of the data assets to load
  59339. * @return A color gradind texture
  59340. */
  59341. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59342. /**
  59343. * Serializes the LUT texture to json format.
  59344. */
  59345. serialize(): any;
  59346. }
  59347. }
  59348. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  59349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59350. import { Scene } from "babylonjs/scene";
  59351. import { Nullable } from "babylonjs/types";
  59352. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59353. /**
  59354. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59355. */
  59356. export class EquiRectangularCubeTexture extends BaseTexture {
  59357. /** The six faces of the cube. */
  59358. private static _FacesMapping;
  59359. private _noMipmap;
  59360. private _onLoad;
  59361. private _onError;
  59362. /** The size of the cubemap. */
  59363. private _size;
  59364. /** The buffer of the image. */
  59365. private _buffer;
  59366. /** The width of the input image. */
  59367. private _width;
  59368. /** The height of the input image. */
  59369. private _height;
  59370. /** The URL to the image. */
  59371. url: string;
  59372. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59373. coordinatesMode: number;
  59374. /**
  59375. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59376. * @param url The location of the image
  59377. * @param scene The scene the texture will be used in
  59378. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59379. * @param noMipmap Forces to not generate the mipmap if true
  59380. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59381. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59382. * @param onLoad — defines a callback called when texture is loaded
  59383. * @param onError — defines a callback called if there is an error
  59384. */
  59385. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59386. /**
  59387. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59388. */
  59389. private loadImage;
  59390. /**
  59391. * Convert the image buffer into a cubemap and create a CubeTexture.
  59392. */
  59393. private loadTexture;
  59394. /**
  59395. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59396. * @param buffer The ArrayBuffer that should be converted.
  59397. * @returns The buffer as Float32Array.
  59398. */
  59399. private getFloat32ArrayFromArrayBuffer;
  59400. /**
  59401. * Get the current class name of the texture useful for serialization or dynamic coding.
  59402. * @returns "EquiRectangularCubeTexture"
  59403. */
  59404. getClassName(): string;
  59405. /**
  59406. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59407. * @returns A clone of the current EquiRectangularCubeTexture.
  59408. */
  59409. clone(): EquiRectangularCubeTexture;
  59410. }
  59411. }
  59412. declare module "babylonjs/Misc/tga" {
  59413. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59414. /**
  59415. * Based on jsTGALoader - Javascript loader for TGA file
  59416. * By Vincent Thibault
  59417. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59418. */
  59419. export class TGATools {
  59420. private static _TYPE_INDEXED;
  59421. private static _TYPE_RGB;
  59422. private static _TYPE_GREY;
  59423. private static _TYPE_RLE_INDEXED;
  59424. private static _TYPE_RLE_RGB;
  59425. private static _TYPE_RLE_GREY;
  59426. private static _ORIGIN_MASK;
  59427. private static _ORIGIN_SHIFT;
  59428. private static _ORIGIN_BL;
  59429. private static _ORIGIN_BR;
  59430. private static _ORIGIN_UL;
  59431. private static _ORIGIN_UR;
  59432. /**
  59433. * Gets the header of a TGA file
  59434. * @param data defines the TGA data
  59435. * @returns the header
  59436. */
  59437. static GetTGAHeader(data: Uint8Array): any;
  59438. /**
  59439. * Uploads TGA content to a Babylon Texture
  59440. * @hidden
  59441. */
  59442. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59443. /** @hidden */
  59444. 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;
  59445. /** @hidden */
  59446. 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;
  59447. /** @hidden */
  59448. 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;
  59449. /** @hidden */
  59450. 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;
  59451. /** @hidden */
  59452. 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;
  59453. /** @hidden */
  59454. 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;
  59455. }
  59456. }
  59457. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59458. import { Nullable } from "babylonjs/types";
  59459. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59460. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59461. /**
  59462. * Implementation of the TGA Texture Loader.
  59463. * @hidden
  59464. */
  59465. export class _TGATextureLoader implements IInternalTextureLoader {
  59466. /**
  59467. * Defines wether the loader supports cascade loading the different faces.
  59468. */
  59469. readonly supportCascades: boolean;
  59470. /**
  59471. * This returns if the loader support the current file information.
  59472. * @param extension defines the file extension of the file being loaded
  59473. * @returns true if the loader can load the specified file
  59474. */
  59475. canLoad(extension: string): boolean;
  59476. /**
  59477. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59478. * @param data contains the texture data
  59479. * @param texture defines the BabylonJS internal texture
  59480. * @param createPolynomials will be true if polynomials have been requested
  59481. * @param onLoad defines the callback to trigger once the texture is ready
  59482. * @param onError defines the callback to trigger in case of error
  59483. */
  59484. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59485. /**
  59486. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59487. * @param data contains the texture data
  59488. * @param texture defines the BabylonJS internal texture
  59489. * @param callback defines the method to call once ready to upload
  59490. */
  59491. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59492. }
  59493. }
  59494. declare module "babylonjs/Misc/basis" {
  59495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59496. /**
  59497. * Info about the .basis files
  59498. */
  59499. class BasisFileInfo {
  59500. /**
  59501. * If the file has alpha
  59502. */
  59503. hasAlpha: boolean;
  59504. /**
  59505. * Info about each image of the basis file
  59506. */
  59507. images: Array<{
  59508. levels: Array<{
  59509. width: number;
  59510. height: number;
  59511. transcodedPixels: ArrayBufferView;
  59512. }>;
  59513. }>;
  59514. }
  59515. /**
  59516. * Result of transcoding a basis file
  59517. */
  59518. class TranscodeResult {
  59519. /**
  59520. * Info about the .basis file
  59521. */
  59522. fileInfo: BasisFileInfo;
  59523. /**
  59524. * Format to use when loading the file
  59525. */
  59526. format: number;
  59527. }
  59528. /**
  59529. * Configuration options for the Basis transcoder
  59530. */
  59531. export class BasisTranscodeConfiguration {
  59532. /**
  59533. * Supported compression formats used to determine the supported output format of the transcoder
  59534. */
  59535. supportedCompressionFormats?: {
  59536. /**
  59537. * etc1 compression format
  59538. */
  59539. etc1?: boolean;
  59540. /**
  59541. * s3tc compression format
  59542. */
  59543. s3tc?: boolean;
  59544. /**
  59545. * pvrtc compression format
  59546. */
  59547. pvrtc?: boolean;
  59548. /**
  59549. * etc2 compression format
  59550. */
  59551. etc2?: boolean;
  59552. };
  59553. /**
  59554. * If mipmap levels should be loaded for transcoded images (Default: true)
  59555. */
  59556. loadMipmapLevels?: boolean;
  59557. /**
  59558. * Index of a single image to load (Default: all images)
  59559. */
  59560. loadSingleImage?: number;
  59561. }
  59562. /**
  59563. * Used to load .Basis files
  59564. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59565. */
  59566. export class BasisTools {
  59567. private static _IgnoreSupportedFormats;
  59568. /**
  59569. * URL to use when loading the basis transcoder
  59570. */
  59571. static JSModuleURL: string;
  59572. /**
  59573. * URL to use when loading the wasm module for the transcoder
  59574. */
  59575. static WasmModuleURL: string;
  59576. /**
  59577. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59578. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59579. * @returns internal format corresponding to the Basis format
  59580. */
  59581. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59582. private static _WorkerPromise;
  59583. private static _Worker;
  59584. private static _actionId;
  59585. private static _CreateWorkerAsync;
  59586. /**
  59587. * Transcodes a loaded image file to compressed pixel data
  59588. * @param data image data to transcode
  59589. * @param config configuration options for the transcoding
  59590. * @returns a promise resulting in the transcoded image
  59591. */
  59592. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59593. /**
  59594. * Loads a texture from the transcode result
  59595. * @param texture texture load to
  59596. * @param transcodeResult the result of transcoding the basis file to load from
  59597. */
  59598. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59599. }
  59600. }
  59601. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59602. import { Nullable } from "babylonjs/types";
  59603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59605. /**
  59606. * Loader for .basis file format
  59607. */
  59608. export class _BasisTextureLoader implements IInternalTextureLoader {
  59609. /**
  59610. * Defines whether the loader supports cascade loading the different faces.
  59611. */
  59612. readonly supportCascades: boolean;
  59613. /**
  59614. * This returns if the loader support the current file information.
  59615. * @param extension defines the file extension of the file being loaded
  59616. * @returns true if the loader can load the specified file
  59617. */
  59618. canLoad(extension: string): boolean;
  59619. /**
  59620. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59621. * @param data contains the texture data
  59622. * @param texture defines the BabylonJS internal texture
  59623. * @param createPolynomials will be true if polynomials have been requested
  59624. * @param onLoad defines the callback to trigger once the texture is ready
  59625. * @param onError defines the callback to trigger in case of error
  59626. */
  59627. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59628. /**
  59629. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59630. * @param data contains the texture data
  59631. * @param texture defines the BabylonJS internal texture
  59632. * @param callback defines the method to call once ready to upload
  59633. */
  59634. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59635. }
  59636. }
  59637. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59638. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59639. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59640. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59641. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59642. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59643. }
  59644. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59645. import { Scene } from "babylonjs/scene";
  59646. import { Texture } from "babylonjs/Materials/Textures/texture";
  59647. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59648. /**
  59649. * 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.
  59650. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59651. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59652. */
  59653. export class CustomProceduralTexture extends ProceduralTexture {
  59654. private _animate;
  59655. private _time;
  59656. private _config;
  59657. private _texturePath;
  59658. /**
  59659. * Instantiates a new Custom Procedural Texture.
  59660. * 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.
  59661. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59662. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59663. * @param name Define the name of the texture
  59664. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59665. * @param size Define the size of the texture to create
  59666. * @param scene Define the scene the texture belongs to
  59667. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59668. * @param generateMipMaps Define if the texture should creates mip maps or not
  59669. */
  59670. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59671. private _loadJson;
  59672. /**
  59673. * Is the texture ready to be used ? (rendered at least once)
  59674. * @returns true if ready, otherwise, false.
  59675. */
  59676. isReady(): boolean;
  59677. /**
  59678. * Render the texture to its associated render target.
  59679. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59680. */
  59681. render(useCameraPostProcess?: boolean): void;
  59682. /**
  59683. * Update the list of dependant textures samplers in the shader.
  59684. */
  59685. updateTextures(): void;
  59686. /**
  59687. * Update the uniform values of the procedural texture in the shader.
  59688. */
  59689. updateShaderUniforms(): void;
  59690. /**
  59691. * Define if the texture animates or not.
  59692. */
  59693. get animate(): boolean;
  59694. set animate(value: boolean);
  59695. }
  59696. }
  59697. declare module "babylonjs/Shaders/noise.fragment" {
  59698. /** @hidden */
  59699. export var noisePixelShader: {
  59700. name: string;
  59701. shader: string;
  59702. };
  59703. }
  59704. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59705. import { Nullable } from "babylonjs/types";
  59706. import { Scene } from "babylonjs/scene";
  59707. import { Texture } from "babylonjs/Materials/Textures/texture";
  59708. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59709. import "babylonjs/Shaders/noise.fragment";
  59710. /**
  59711. * Class used to generate noise procedural textures
  59712. */
  59713. export class NoiseProceduralTexture extends ProceduralTexture {
  59714. private _time;
  59715. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59716. brightness: number;
  59717. /** Defines the number of octaves to process */
  59718. octaves: number;
  59719. /** Defines the level of persistence (0.8 by default) */
  59720. persistence: number;
  59721. /** Gets or sets animation speed factor (default is 1) */
  59722. animationSpeedFactor: number;
  59723. /**
  59724. * Creates a new NoiseProceduralTexture
  59725. * @param name defines the name fo the texture
  59726. * @param size defines the size of the texture (default is 256)
  59727. * @param scene defines the hosting scene
  59728. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59729. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59730. */
  59731. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59732. private _updateShaderUniforms;
  59733. protected _getDefines(): string;
  59734. /** Generate the current state of the procedural texture */
  59735. render(useCameraPostProcess?: boolean): void;
  59736. /**
  59737. * Serializes this noise procedural texture
  59738. * @returns a serialized noise procedural texture object
  59739. */
  59740. serialize(): any;
  59741. /**
  59742. * Clone the texture.
  59743. * @returns the cloned texture
  59744. */
  59745. clone(): NoiseProceduralTexture;
  59746. /**
  59747. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59748. * @param parsedTexture defines parsed texture data
  59749. * @param scene defines the current scene
  59750. * @param rootUrl defines the root URL containing noise procedural texture information
  59751. * @returns a parsed NoiseProceduralTexture
  59752. */
  59753. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59754. }
  59755. }
  59756. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59757. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59758. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59759. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59760. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59761. }
  59762. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59763. import { Nullable } from "babylonjs/types";
  59764. import { Scene } from "babylonjs/scene";
  59765. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59767. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59768. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59769. /**
  59770. * Raw cube texture where the raw buffers are passed in
  59771. */
  59772. export class RawCubeTexture extends CubeTexture {
  59773. /**
  59774. * Creates a cube texture where the raw buffers are passed in.
  59775. * @param scene defines the scene the texture is attached to
  59776. * @param data defines the array of data to use to create each face
  59777. * @param size defines the size of the textures
  59778. * @param format defines the format of the data
  59779. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59780. * @param generateMipMaps defines if the engine should generate the mip levels
  59781. * @param invertY defines if data must be stored with Y axis inverted
  59782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59783. * @param compression defines the compression used (null by default)
  59784. */
  59785. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59786. /**
  59787. * Updates the raw cube texture.
  59788. * @param data defines the data to store
  59789. * @param format defines the data format
  59790. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59791. * @param invertY defines if data must be stored with Y axis inverted
  59792. * @param compression defines the compression used (null by default)
  59793. * @param level defines which level of the texture to update
  59794. */
  59795. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59796. /**
  59797. * Updates a raw cube texture with RGBD encoded data.
  59798. * @param data defines the array of data [mipmap][face] to use to create each face
  59799. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59800. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59801. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59802. * @returns a promsie that resolves when the operation is complete
  59803. */
  59804. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59805. /**
  59806. * Clones the raw cube texture.
  59807. * @return a new cube texture
  59808. */
  59809. clone(): CubeTexture;
  59810. /** @hidden */
  59811. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59812. }
  59813. }
  59814. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59815. import { Scene } from "babylonjs/scene";
  59816. import { Texture } from "babylonjs/Materials/Textures/texture";
  59817. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59818. /**
  59819. * Class used to store 3D textures containing user data
  59820. */
  59821. export class RawTexture3D extends Texture {
  59822. /** Gets or sets the texture format to use */
  59823. format: number;
  59824. /**
  59825. * Create a new RawTexture3D
  59826. * @param data defines the data of the texture
  59827. * @param width defines the width of the texture
  59828. * @param height defines the height of the texture
  59829. * @param depth defines the depth of the texture
  59830. * @param format defines the texture format to use
  59831. * @param scene defines the hosting scene
  59832. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59833. * @param invertY defines if texture must be stored with Y axis inverted
  59834. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59835. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59836. */
  59837. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59838. /** Gets or sets the texture format to use */
  59839. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59840. /**
  59841. * Update the texture with new data
  59842. * @param data defines the data to store in the texture
  59843. */
  59844. update(data: ArrayBufferView): void;
  59845. }
  59846. }
  59847. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59848. import { Scene } from "babylonjs/scene";
  59849. import { Texture } from "babylonjs/Materials/Textures/texture";
  59850. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59851. /**
  59852. * Class used to store 2D array textures containing user data
  59853. */
  59854. export class RawTexture2DArray extends Texture {
  59855. /** Gets or sets the texture format to use */
  59856. format: number;
  59857. /**
  59858. * Create a new RawTexture2DArray
  59859. * @param data defines the data of the texture
  59860. * @param width defines the width of the texture
  59861. * @param height defines the height of the texture
  59862. * @param depth defines the number of layers of the texture
  59863. * @param format defines the texture format to use
  59864. * @param scene defines the hosting scene
  59865. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59866. * @param invertY defines if texture must be stored with Y axis inverted
  59867. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59868. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59869. */
  59870. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59871. /** Gets or sets the texture format to use */
  59872. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59873. /**
  59874. * Update the texture with new data
  59875. * @param data defines the data to store in the texture
  59876. */
  59877. update(data: ArrayBufferView): void;
  59878. }
  59879. }
  59880. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59881. import { Scene } from "babylonjs/scene";
  59882. import { Plane } from "babylonjs/Maths/math.plane";
  59883. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59884. /**
  59885. * Creates a refraction texture used by refraction channel of the standard material.
  59886. * It is like a mirror but to see through a material.
  59887. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59888. */
  59889. export class RefractionTexture extends RenderTargetTexture {
  59890. /**
  59891. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59892. * 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.
  59893. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59894. */
  59895. refractionPlane: Plane;
  59896. /**
  59897. * Define how deep under the surface we should see.
  59898. */
  59899. depth: number;
  59900. /**
  59901. * Creates a refraction texture used by refraction channel of the standard material.
  59902. * It is like a mirror but to see through a material.
  59903. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59904. * @param name Define the texture name
  59905. * @param size Define the size of the underlying texture
  59906. * @param scene Define the scene the refraction belongs to
  59907. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59908. */
  59909. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59910. /**
  59911. * Clone the refraction texture.
  59912. * @returns the cloned texture
  59913. */
  59914. clone(): RefractionTexture;
  59915. /**
  59916. * Serialize the texture to a JSON representation you could use in Parse later on
  59917. * @returns the serialized JSON representation
  59918. */
  59919. serialize(): any;
  59920. }
  59921. }
  59922. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59923. import { Nullable } from "babylonjs/types";
  59924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59925. import { Matrix } from "babylonjs/Maths/math.vector";
  59926. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59927. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59928. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59929. import { Scene } from "babylonjs/scene";
  59930. /**
  59931. * Defines the options related to the creation of an HtmlElementTexture
  59932. */
  59933. export interface IHtmlElementTextureOptions {
  59934. /**
  59935. * Defines wether mip maps should be created or not.
  59936. */
  59937. generateMipMaps?: boolean;
  59938. /**
  59939. * Defines the sampling mode of the texture.
  59940. */
  59941. samplingMode?: number;
  59942. /**
  59943. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59944. */
  59945. engine: Nullable<ThinEngine>;
  59946. /**
  59947. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59948. */
  59949. scene: Nullable<Scene>;
  59950. }
  59951. /**
  59952. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59953. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59954. * is automatically managed.
  59955. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59956. * in your application.
  59957. *
  59958. * As the update is not automatic, you need to call them manually.
  59959. */
  59960. export class HtmlElementTexture extends BaseTexture {
  59961. /**
  59962. * The texture URL.
  59963. */
  59964. element: HTMLVideoElement | HTMLCanvasElement;
  59965. private static readonly DefaultOptions;
  59966. private _textureMatrix;
  59967. private _isVideo;
  59968. private _generateMipMaps;
  59969. private _samplingMode;
  59970. /**
  59971. * Instantiates a HtmlElementTexture from the following parameters.
  59972. *
  59973. * @param name Defines the name of the texture
  59974. * @param element Defines the video or canvas the texture is filled with
  59975. * @param options Defines the other none mandatory texture creation options
  59976. */
  59977. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59978. private _createInternalTexture;
  59979. /**
  59980. * Returns the texture matrix used in most of the material.
  59981. */
  59982. getTextureMatrix(): Matrix;
  59983. /**
  59984. * Updates the content of the texture.
  59985. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59986. */
  59987. update(invertY?: Nullable<boolean>): void;
  59988. }
  59989. }
  59990. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59991. import { Vector2 } from "babylonjs/Maths/math.vector";
  59992. /**
  59993. * Defines the basic options interface of a TexturePacker Frame
  59994. */
  59995. export interface ITexturePackerFrame {
  59996. /**
  59997. * The frame ID
  59998. */
  59999. id: number;
  60000. /**
  60001. * The frames Scale
  60002. */
  60003. scale: Vector2;
  60004. /**
  60005. * The Frames offset
  60006. */
  60007. offset: Vector2;
  60008. }
  60009. /**
  60010. * This is a support class for frame Data on texture packer sets.
  60011. */
  60012. export class TexturePackerFrame implements ITexturePackerFrame {
  60013. /**
  60014. * The frame ID
  60015. */
  60016. id: number;
  60017. /**
  60018. * The frames Scale
  60019. */
  60020. scale: Vector2;
  60021. /**
  60022. * The Frames offset
  60023. */
  60024. offset: Vector2;
  60025. /**
  60026. * Initializes a texture package frame.
  60027. * @param id The numerical frame identifier
  60028. * @param scale Scalar Vector2 for UV frame
  60029. * @param offset Vector2 for the frame position in UV units.
  60030. * @returns TexturePackerFrame
  60031. */
  60032. constructor(id: number, scale: Vector2, offset: Vector2);
  60033. }
  60034. }
  60035. declare module "babylonjs/Materials/Textures/Packer/packer" {
  60036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60037. import { Scene } from "babylonjs/scene";
  60038. import { Nullable } from "babylonjs/types";
  60039. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  60040. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  60041. /**
  60042. * Defines the basic options interface of a TexturePacker
  60043. */
  60044. export interface ITexturePackerOptions {
  60045. /**
  60046. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60047. */
  60048. map?: string[];
  60049. /**
  60050. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60051. */
  60052. uvsIn?: string;
  60053. /**
  60054. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60055. */
  60056. uvsOut?: string;
  60057. /**
  60058. * number representing the layout style. Defaults to LAYOUT_STRIP
  60059. */
  60060. layout?: number;
  60061. /**
  60062. * number of columns if using custom column count layout(2). This defaults to 4.
  60063. */
  60064. colnum?: number;
  60065. /**
  60066. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60067. */
  60068. updateInputMeshes?: boolean;
  60069. /**
  60070. * boolean flag to dispose all the source textures. Defaults to true.
  60071. */
  60072. disposeSources?: boolean;
  60073. /**
  60074. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60075. */
  60076. fillBlanks?: boolean;
  60077. /**
  60078. * string value representing the context fill style color. Defaults to 'black'.
  60079. */
  60080. customFillColor?: string;
  60081. /**
  60082. * Width and Height Value of each Frame in the TexturePacker Sets
  60083. */
  60084. frameSize?: number;
  60085. /**
  60086. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60087. */
  60088. paddingRatio?: number;
  60089. /**
  60090. * Number that declares the fill method for the padding gutter.
  60091. */
  60092. paddingMode?: number;
  60093. /**
  60094. * If in SUBUV_COLOR padding mode what color to use.
  60095. */
  60096. paddingColor?: Color3 | Color4;
  60097. }
  60098. /**
  60099. * Defines the basic interface of a TexturePacker JSON File
  60100. */
  60101. export interface ITexturePackerJSON {
  60102. /**
  60103. * The frame ID
  60104. */
  60105. name: string;
  60106. /**
  60107. * The base64 channel data
  60108. */
  60109. sets: any;
  60110. /**
  60111. * The options of the Packer
  60112. */
  60113. options: ITexturePackerOptions;
  60114. /**
  60115. * The frame data of the Packer
  60116. */
  60117. frames: Array<number>;
  60118. }
  60119. /**
  60120. * This is a support class that generates a series of packed texture sets.
  60121. * @see https://doc.babylonjs.com/babylon101/materials
  60122. */
  60123. export class TexturePacker {
  60124. /** Packer Layout Constant 0 */
  60125. static readonly LAYOUT_STRIP: number;
  60126. /** Packer Layout Constant 1 */
  60127. static readonly LAYOUT_POWER2: number;
  60128. /** Packer Layout Constant 2 */
  60129. static readonly LAYOUT_COLNUM: number;
  60130. /** Packer Layout Constant 0 */
  60131. static readonly SUBUV_WRAP: number;
  60132. /** Packer Layout Constant 1 */
  60133. static readonly SUBUV_EXTEND: number;
  60134. /** Packer Layout Constant 2 */
  60135. static readonly SUBUV_COLOR: number;
  60136. /** The Name of the Texture Package */
  60137. name: string;
  60138. /** The scene scope of the TexturePacker */
  60139. scene: Scene;
  60140. /** The Meshes to target */
  60141. meshes: AbstractMesh[];
  60142. /** Arguments passed with the Constructor */
  60143. options: ITexturePackerOptions;
  60144. /** The promise that is started upon initialization */
  60145. promise: Nullable<Promise<TexturePacker | string>>;
  60146. /** The Container object for the channel sets that are generated */
  60147. sets: object;
  60148. /** The Container array for the frames that are generated */
  60149. frames: TexturePackerFrame[];
  60150. /** The expected number of textures the system is parsing. */
  60151. private _expecting;
  60152. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60153. private _paddingValue;
  60154. /**
  60155. * Initializes a texture package series from an array of meshes or a single mesh.
  60156. * @param name The name of the package
  60157. * @param meshes The target meshes to compose the package from
  60158. * @param options The arguments that texture packer should follow while building.
  60159. * @param scene The scene which the textures are scoped to.
  60160. * @returns TexturePacker
  60161. */
  60162. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60163. /**
  60164. * Starts the package process
  60165. * @param resolve The promises resolution function
  60166. * @returns TexturePacker
  60167. */
  60168. private _createFrames;
  60169. /**
  60170. * Calculates the Size of the Channel Sets
  60171. * @returns Vector2
  60172. */
  60173. private _calculateSize;
  60174. /**
  60175. * Calculates the UV data for the frames.
  60176. * @param baseSize the base frameSize
  60177. * @param padding the base frame padding
  60178. * @param dtSize size of the Dynamic Texture for that channel
  60179. * @param dtUnits is 1/dtSize
  60180. * @param update flag to update the input meshes
  60181. */
  60182. private _calculateMeshUVFrames;
  60183. /**
  60184. * Calculates the frames Offset.
  60185. * @param index of the frame
  60186. * @returns Vector2
  60187. */
  60188. private _getFrameOffset;
  60189. /**
  60190. * Updates a Mesh to the frame data
  60191. * @param mesh that is the target
  60192. * @param frameID or the frame index
  60193. */
  60194. private _updateMeshUV;
  60195. /**
  60196. * Updates a Meshes materials to use the texture packer channels
  60197. * @param m is the mesh to target
  60198. * @param force all channels on the packer to be set.
  60199. */
  60200. private _updateTextureReferences;
  60201. /**
  60202. * Public method to set a Mesh to a frame
  60203. * @param m that is the target
  60204. * @param frameID or the frame index
  60205. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60206. */
  60207. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60208. /**
  60209. * Starts the async promise to compile the texture packer.
  60210. * @returns Promise<void>
  60211. */
  60212. processAsync(): Promise<void>;
  60213. /**
  60214. * Disposes all textures associated with this packer
  60215. */
  60216. dispose(): void;
  60217. /**
  60218. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60219. * @param imageType is the image type to use.
  60220. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60221. */
  60222. download(imageType?: string, quality?: number): void;
  60223. /**
  60224. * Public method to load a texturePacker JSON file.
  60225. * @param data of the JSON file in string format.
  60226. */
  60227. updateFromJSON(data: string): void;
  60228. }
  60229. }
  60230. declare module "babylonjs/Materials/Textures/Packer/index" {
  60231. export * from "babylonjs/Materials/Textures/Packer/packer";
  60232. export * from "babylonjs/Materials/Textures/Packer/frame";
  60233. }
  60234. declare module "babylonjs/Materials/Textures/index" {
  60235. export * from "babylonjs/Materials/Textures/baseTexture";
  60236. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  60237. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  60238. export * from "babylonjs/Materials/Textures/cubeTexture";
  60239. export * from "babylonjs/Materials/Textures/dynamicTexture";
  60240. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60241. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  60242. export * from "babylonjs/Materials/Textures/internalTexture";
  60243. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  60244. export * from "babylonjs/Materials/Textures/Loaders/index";
  60245. export * from "babylonjs/Materials/Textures/mirrorTexture";
  60246. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  60247. export * from "babylonjs/Materials/Textures/Procedurals/index";
  60248. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  60249. export * from "babylonjs/Materials/Textures/rawTexture";
  60250. export * from "babylonjs/Materials/Textures/rawTexture3D";
  60251. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  60252. export * from "babylonjs/Materials/Textures/refractionTexture";
  60253. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  60254. export * from "babylonjs/Materials/Textures/texture";
  60255. export * from "babylonjs/Materials/Textures/videoTexture";
  60256. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  60257. export * from "babylonjs/Materials/Textures/Packer/index";
  60258. }
  60259. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  60260. /**
  60261. * Enum used to define the target of a block
  60262. */
  60263. export enum NodeMaterialBlockTargets {
  60264. /** Vertex shader */
  60265. Vertex = 1,
  60266. /** Fragment shader */
  60267. Fragment = 2,
  60268. /** Neutral */
  60269. Neutral = 4,
  60270. /** Vertex and Fragment */
  60271. VertexAndFragment = 3
  60272. }
  60273. }
  60274. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  60275. /**
  60276. * Defines the kind of connection point for node based material
  60277. */
  60278. export enum NodeMaterialBlockConnectionPointTypes {
  60279. /** Float */
  60280. Float = 1,
  60281. /** Int */
  60282. Int = 2,
  60283. /** Vector2 */
  60284. Vector2 = 4,
  60285. /** Vector3 */
  60286. Vector3 = 8,
  60287. /** Vector4 */
  60288. Vector4 = 16,
  60289. /** Color3 */
  60290. Color3 = 32,
  60291. /** Color4 */
  60292. Color4 = 64,
  60293. /** Matrix */
  60294. Matrix = 128,
  60295. /** Custom object */
  60296. Object = 256,
  60297. /** Detect type based on connection */
  60298. AutoDetect = 1024,
  60299. /** Output type that will be defined by input type */
  60300. BasedOnInput = 2048
  60301. }
  60302. }
  60303. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  60304. /**
  60305. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  60306. */
  60307. export enum NodeMaterialBlockConnectionPointMode {
  60308. /** Value is an uniform */
  60309. Uniform = 0,
  60310. /** Value is a mesh attribute */
  60311. Attribute = 1,
  60312. /** Value is a varying between vertex and fragment shaders */
  60313. Varying = 2,
  60314. /** Mode is undefined */
  60315. Undefined = 3
  60316. }
  60317. }
  60318. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  60319. /**
  60320. * Enum used to define system values e.g. values automatically provided by the system
  60321. */
  60322. export enum NodeMaterialSystemValues {
  60323. /** World */
  60324. World = 1,
  60325. /** View */
  60326. View = 2,
  60327. /** Projection */
  60328. Projection = 3,
  60329. /** ViewProjection */
  60330. ViewProjection = 4,
  60331. /** WorldView */
  60332. WorldView = 5,
  60333. /** WorldViewProjection */
  60334. WorldViewProjection = 6,
  60335. /** CameraPosition */
  60336. CameraPosition = 7,
  60337. /** Fog Color */
  60338. FogColor = 8,
  60339. /** Delta time */
  60340. DeltaTime = 9
  60341. }
  60342. }
  60343. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  60344. /**
  60345. * Enum used to define the material modes
  60346. */
  60347. export enum NodeMaterialModes {
  60348. /** Regular material */
  60349. Material = 0,
  60350. /** For post process */
  60351. PostProcess = 1
  60352. }
  60353. }
  60354. declare module "babylonjs/Materials/Node/Enums/index" {
  60355. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60356. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60357. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  60358. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60359. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  60360. }
  60361. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  60362. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60363. /**
  60364. * Root class for all node material optimizers
  60365. */
  60366. export class NodeMaterialOptimizer {
  60367. /**
  60368. * Function used to optimize a NodeMaterial graph
  60369. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  60370. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  60371. */
  60372. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  60373. }
  60374. }
  60375. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  60376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60379. import { Scene } from "babylonjs/scene";
  60380. /**
  60381. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60382. */
  60383. export class TransformBlock extends NodeMaterialBlock {
  60384. /**
  60385. * Defines the value to use to complement W value to transform it to a Vector4
  60386. */
  60387. complementW: number;
  60388. /**
  60389. * Defines the value to use to complement z value to transform it to a Vector4
  60390. */
  60391. complementZ: number;
  60392. /**
  60393. * Creates a new TransformBlock
  60394. * @param name defines the block name
  60395. */
  60396. constructor(name: string);
  60397. /**
  60398. * Gets the current class name
  60399. * @returns the class name
  60400. */
  60401. getClassName(): string;
  60402. /**
  60403. * Gets the vector input
  60404. */
  60405. get vector(): NodeMaterialConnectionPoint;
  60406. /**
  60407. * Gets the output component
  60408. */
  60409. get output(): NodeMaterialConnectionPoint;
  60410. /**
  60411. * Gets the xyz output component
  60412. */
  60413. get xyz(): NodeMaterialConnectionPoint;
  60414. /**
  60415. * Gets the matrix transform input
  60416. */
  60417. get transform(): NodeMaterialConnectionPoint;
  60418. protected _buildBlock(state: NodeMaterialBuildState): this;
  60419. serialize(): any;
  60420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60421. protected _dumpPropertiesCode(): string;
  60422. }
  60423. }
  60424. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60425. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60426. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60428. /**
  60429. * Block used to output the vertex position
  60430. */
  60431. export class VertexOutputBlock extends NodeMaterialBlock {
  60432. /**
  60433. * Creates a new VertexOutputBlock
  60434. * @param name defines the block name
  60435. */
  60436. constructor(name: string);
  60437. /**
  60438. * Gets the current class name
  60439. * @returns the class name
  60440. */
  60441. getClassName(): string;
  60442. /**
  60443. * Gets the vector input component
  60444. */
  60445. get vector(): NodeMaterialConnectionPoint;
  60446. protected _buildBlock(state: NodeMaterialBuildState): this;
  60447. }
  60448. }
  60449. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60453. /**
  60454. * Block used to output the final color
  60455. */
  60456. export class FragmentOutputBlock extends NodeMaterialBlock {
  60457. /**
  60458. * Create a new FragmentOutputBlock
  60459. * @param name defines the block name
  60460. */
  60461. constructor(name: string);
  60462. /**
  60463. * Gets the current class name
  60464. * @returns the class name
  60465. */
  60466. getClassName(): string;
  60467. /**
  60468. * Gets the rgba input component
  60469. */
  60470. get rgba(): NodeMaterialConnectionPoint;
  60471. /**
  60472. * Gets the rgb input component
  60473. */
  60474. get rgb(): NodeMaterialConnectionPoint;
  60475. /**
  60476. * Gets the a input component
  60477. */
  60478. get a(): NodeMaterialConnectionPoint;
  60479. protected _buildBlock(state: NodeMaterialBuildState): this;
  60480. }
  60481. }
  60482. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  60483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60488. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60489. import { Effect } from "babylonjs/Materials/effect";
  60490. import { Mesh } from "babylonjs/Meshes/mesh";
  60491. import { Nullable } from "babylonjs/types";
  60492. import { Scene } from "babylonjs/scene";
  60493. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60494. /**
  60495. * Base block used to read a reflection texture from a sampler
  60496. */
  60497. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  60498. /** @hidden */
  60499. _define3DName: string;
  60500. /** @hidden */
  60501. _defineCubicName: string;
  60502. /** @hidden */
  60503. _defineExplicitName: string;
  60504. /** @hidden */
  60505. _defineProjectionName: string;
  60506. /** @hidden */
  60507. _defineLocalCubicName: string;
  60508. /** @hidden */
  60509. _defineSphericalName: string;
  60510. /** @hidden */
  60511. _definePlanarName: string;
  60512. /** @hidden */
  60513. _defineEquirectangularName: string;
  60514. /** @hidden */
  60515. _defineMirroredEquirectangularFixedName: string;
  60516. /** @hidden */
  60517. _defineEquirectangularFixedName: string;
  60518. /** @hidden */
  60519. _defineSkyboxName: string;
  60520. /** @hidden */
  60521. _defineOppositeZ: string;
  60522. /** @hidden */
  60523. _cubeSamplerName: string;
  60524. /** @hidden */
  60525. _2DSamplerName: string;
  60526. protected _positionUVWName: string;
  60527. protected _directionWName: string;
  60528. protected _reflectionVectorName: string;
  60529. /** @hidden */
  60530. _reflectionCoordsName: string;
  60531. /** @hidden */
  60532. _reflectionMatrixName: string;
  60533. protected _reflectionColorName: string;
  60534. /**
  60535. * Gets or sets the texture associated with the node
  60536. */
  60537. texture: Nullable<BaseTexture>;
  60538. /**
  60539. * Create a new ReflectionTextureBaseBlock
  60540. * @param name defines the block name
  60541. */
  60542. constructor(name: string);
  60543. /**
  60544. * Gets the current class name
  60545. * @returns the class name
  60546. */
  60547. getClassName(): string;
  60548. /**
  60549. * Gets the world position input component
  60550. */
  60551. abstract get position(): NodeMaterialConnectionPoint;
  60552. /**
  60553. * Gets the world position input component
  60554. */
  60555. abstract get worldPosition(): NodeMaterialConnectionPoint;
  60556. /**
  60557. * Gets the world normal input component
  60558. */
  60559. abstract get worldNormal(): NodeMaterialConnectionPoint;
  60560. /**
  60561. * Gets the world input component
  60562. */
  60563. abstract get world(): NodeMaterialConnectionPoint;
  60564. /**
  60565. * Gets the camera (or eye) position component
  60566. */
  60567. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  60568. /**
  60569. * Gets the view input component
  60570. */
  60571. abstract get view(): NodeMaterialConnectionPoint;
  60572. protected _getTexture(): Nullable<BaseTexture>;
  60573. autoConfigure(material: NodeMaterial): void;
  60574. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60575. isReady(): boolean;
  60576. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60577. /**
  60578. * Gets the code to inject in the vertex shader
  60579. * @param state current state of the node material building
  60580. * @returns the shader code
  60581. */
  60582. handleVertexSide(state: NodeMaterialBuildState): string;
  60583. /**
  60584. * Handles the inits for the fragment code path
  60585. * @param state node material build state
  60586. */
  60587. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  60588. /**
  60589. * Generates the reflection coords code for the fragment code path
  60590. * @param worldNormalVarName name of the world normal variable
  60591. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  60592. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  60593. * @returns the shader code
  60594. */
  60595. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  60596. /**
  60597. * Generates the reflection color code for the fragment code path
  60598. * @param lodVarName name of the lod variable
  60599. * @param swizzleLookupTexture swizzle to use for the final color variable
  60600. * @returns the shader code
  60601. */
  60602. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  60603. /**
  60604. * Generates the code corresponding to the connected output points
  60605. * @param state node material build state
  60606. * @param varName name of the variable to output
  60607. * @returns the shader code
  60608. */
  60609. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  60610. protected _buildBlock(state: NodeMaterialBuildState): this;
  60611. protected _dumpPropertiesCode(): string;
  60612. serialize(): any;
  60613. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60614. }
  60615. }
  60616. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  60617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60618. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60619. import { Nullable } from "babylonjs/types";
  60620. /**
  60621. * Defines a connection point to be used for points with a custom object type
  60622. */
  60623. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  60624. private _blockType;
  60625. private _blockName;
  60626. private _nameForCheking?;
  60627. /**
  60628. * Creates a new connection point
  60629. * @param name defines the connection point name
  60630. * @param ownerBlock defines the block hosting this connection point
  60631. * @param direction defines the direction of the connection point
  60632. */
  60633. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  60634. /**
  60635. * Gets a number indicating if the current point can be connected to another point
  60636. * @param connectionPoint defines the other connection point
  60637. * @returns a number defining the compatibility state
  60638. */
  60639. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60640. /**
  60641. * Creates a block suitable to be used as an input for this input point.
  60642. * If null is returned, a block based on the point type will be created.
  60643. * @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
  60644. */
  60645. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  60646. }
  60647. }
  60648. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  60649. /**
  60650. * Enum defining the type of properties that can be edited in the property pages in the NME
  60651. */
  60652. export enum PropertyTypeForEdition {
  60653. /** property is a boolean */
  60654. Boolean = 0,
  60655. /** property is a float */
  60656. Float = 1,
  60657. /** property is a Vector2 */
  60658. Vector2 = 2,
  60659. /** property is a list of values */
  60660. List = 3
  60661. }
  60662. /**
  60663. * Interface that defines an option in a variable of type list
  60664. */
  60665. export interface IEditablePropertyListOption {
  60666. /** label of the option */
  60667. "label": string;
  60668. /** value of the option */
  60669. "value": number;
  60670. }
  60671. /**
  60672. * Interface that defines the options available for an editable property
  60673. */
  60674. export interface IEditablePropertyOption {
  60675. /** min value */
  60676. "min"?: number;
  60677. /** max value */
  60678. "max"?: number;
  60679. /** notifiers: indicates which actions to take when the property is changed */
  60680. "notifiers"?: {
  60681. /** the material should be rebuilt */
  60682. "rebuild"?: boolean;
  60683. /** the preview should be updated */
  60684. "update"?: boolean;
  60685. };
  60686. /** list of the options for a variable of type list */
  60687. "options"?: IEditablePropertyListOption[];
  60688. }
  60689. /**
  60690. * Interface that describes an editable property
  60691. */
  60692. export interface IPropertyDescriptionForEdition {
  60693. /** name of the property */
  60694. "propertyName": string;
  60695. /** display name of the property */
  60696. "displayName": string;
  60697. /** type of the property */
  60698. "type": PropertyTypeForEdition;
  60699. /** group of the property - all properties with the same group value will be displayed in a specific section */
  60700. "groupName": string;
  60701. /** options for the property */
  60702. "options": IEditablePropertyOption;
  60703. }
  60704. /**
  60705. * Decorator that flags a property in a node material block as being editable
  60706. */
  60707. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  60708. }
  60709. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  60710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60712. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60714. import { Nullable } from "babylonjs/types";
  60715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60716. import { Mesh } from "babylonjs/Meshes/mesh";
  60717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60718. import { Effect } from "babylonjs/Materials/effect";
  60719. import { Scene } from "babylonjs/scene";
  60720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60721. /**
  60722. * Block used to implement the refraction part of the sub surface module of the PBR material
  60723. */
  60724. export class RefractionBlock extends NodeMaterialBlock {
  60725. /** @hidden */
  60726. _define3DName: string;
  60727. /** @hidden */
  60728. _refractionMatrixName: string;
  60729. /** @hidden */
  60730. _defineLODRefractionAlpha: string;
  60731. /** @hidden */
  60732. _defineLinearSpecularRefraction: string;
  60733. /** @hidden */
  60734. _defineOppositeZ: string;
  60735. /** @hidden */
  60736. _cubeSamplerName: string;
  60737. /** @hidden */
  60738. _2DSamplerName: string;
  60739. /** @hidden */
  60740. _vRefractionMicrosurfaceInfosName: string;
  60741. /** @hidden */
  60742. _vRefractionInfosName: string;
  60743. private _scene;
  60744. /**
  60745. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60746. * Materials half opaque for instance using refraction could benefit from this control.
  60747. */
  60748. linkRefractionWithTransparency: boolean;
  60749. /**
  60750. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60751. */
  60752. invertRefractionY: boolean;
  60753. /**
  60754. * Gets or sets the texture associated with the node
  60755. */
  60756. texture: Nullable<BaseTexture>;
  60757. /**
  60758. * Create a new RefractionBlock
  60759. * @param name defines the block name
  60760. */
  60761. constructor(name: string);
  60762. /**
  60763. * Gets the current class name
  60764. * @returns the class name
  60765. */
  60766. getClassName(): string;
  60767. /**
  60768. * Gets the intensity input component
  60769. */
  60770. get intensity(): NodeMaterialConnectionPoint;
  60771. /**
  60772. * Gets the index of refraction input component
  60773. */
  60774. get indexOfRefraction(): NodeMaterialConnectionPoint;
  60775. /**
  60776. * Gets the tint at distance input component
  60777. */
  60778. get tintAtDistance(): NodeMaterialConnectionPoint;
  60779. /**
  60780. * Gets the view input component
  60781. */
  60782. get view(): NodeMaterialConnectionPoint;
  60783. /**
  60784. * Gets the refraction object output component
  60785. */
  60786. get refraction(): NodeMaterialConnectionPoint;
  60787. /**
  60788. * Returns true if the block has a texture
  60789. */
  60790. get hasTexture(): boolean;
  60791. protected _getTexture(): Nullable<BaseTexture>;
  60792. autoConfigure(material: NodeMaterial): void;
  60793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60794. isReady(): boolean;
  60795. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  60796. /**
  60797. * Gets the main code of the block (fragment side)
  60798. * @param state current state of the node material building
  60799. * @returns the shader code
  60800. */
  60801. getCode(state: NodeMaterialBuildState): string;
  60802. protected _buildBlock(state: NodeMaterialBuildState): this;
  60803. protected _dumpPropertiesCode(): string;
  60804. serialize(): any;
  60805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60806. }
  60807. }
  60808. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  60809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60811. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60812. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60814. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60816. import { Nullable } from "babylonjs/types";
  60817. import { Scene } from "babylonjs/scene";
  60818. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60819. /**
  60820. * Base block used as input for post process
  60821. */
  60822. export class CurrentScreenBlock extends NodeMaterialBlock {
  60823. private _samplerName;
  60824. private _linearDefineName;
  60825. private _gammaDefineName;
  60826. private _mainUVName;
  60827. private _tempTextureRead;
  60828. /**
  60829. * Gets or sets the texture associated with the node
  60830. */
  60831. texture: Nullable<BaseTexture>;
  60832. /**
  60833. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60834. */
  60835. convertToGammaSpace: boolean;
  60836. /**
  60837. * Gets or sets a boolean indicating if content needs to be converted to linear space
  60838. */
  60839. convertToLinearSpace: boolean;
  60840. /**
  60841. * Create a new CurrentScreenBlock
  60842. * @param name defines the block name
  60843. */
  60844. constructor(name: string);
  60845. /**
  60846. * Gets the current class name
  60847. * @returns the class name
  60848. */
  60849. getClassName(): string;
  60850. /**
  60851. * Gets the uv input component
  60852. */
  60853. get uv(): NodeMaterialConnectionPoint;
  60854. /**
  60855. * Gets the rgba output component
  60856. */
  60857. get rgba(): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Gets the rgb output component
  60860. */
  60861. get rgb(): NodeMaterialConnectionPoint;
  60862. /**
  60863. * Gets the r output component
  60864. */
  60865. get r(): NodeMaterialConnectionPoint;
  60866. /**
  60867. * Gets the g output component
  60868. */
  60869. get g(): NodeMaterialConnectionPoint;
  60870. /**
  60871. * Gets the b output component
  60872. */
  60873. get b(): NodeMaterialConnectionPoint;
  60874. /**
  60875. * Gets the a output component
  60876. */
  60877. get a(): NodeMaterialConnectionPoint;
  60878. /**
  60879. * Initialize the block and prepare the context for build
  60880. * @param state defines the state that will be used for the build
  60881. */
  60882. initialize(state: NodeMaterialBuildState): void;
  60883. get target(): NodeMaterialBlockTargets;
  60884. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60885. isReady(): boolean;
  60886. private _injectVertexCode;
  60887. private _writeTextureRead;
  60888. private _writeOutput;
  60889. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60890. serialize(): any;
  60891. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60892. }
  60893. }
  60894. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60895. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60896. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60897. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60898. /**
  60899. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60900. */
  60901. export class VectorMergerBlock extends NodeMaterialBlock {
  60902. /**
  60903. * Create a new VectorMergerBlock
  60904. * @param name defines the block name
  60905. */
  60906. constructor(name: string);
  60907. /**
  60908. * Gets the current class name
  60909. * @returns the class name
  60910. */
  60911. getClassName(): string;
  60912. /**
  60913. * Gets the xyz component (input)
  60914. */
  60915. get xyzIn(): NodeMaterialConnectionPoint;
  60916. /**
  60917. * Gets the xy component (input)
  60918. */
  60919. get xyIn(): NodeMaterialConnectionPoint;
  60920. /**
  60921. * Gets the x component (input)
  60922. */
  60923. get x(): NodeMaterialConnectionPoint;
  60924. /**
  60925. * Gets the y component (input)
  60926. */
  60927. get y(): NodeMaterialConnectionPoint;
  60928. /**
  60929. * Gets the z component (input)
  60930. */
  60931. get z(): NodeMaterialConnectionPoint;
  60932. /**
  60933. * Gets the w component (input)
  60934. */
  60935. get w(): NodeMaterialConnectionPoint;
  60936. /**
  60937. * Gets the xyzw component (output)
  60938. */
  60939. get xyzw(): NodeMaterialConnectionPoint;
  60940. /**
  60941. * Gets the xyz component (output)
  60942. */
  60943. get xyzOut(): NodeMaterialConnectionPoint;
  60944. /**
  60945. * Gets the xy component (output)
  60946. */
  60947. get xyOut(): NodeMaterialConnectionPoint;
  60948. /**
  60949. * Gets the xy component (output)
  60950. * @deprecated Please use xyOut instead.
  60951. */
  60952. get xy(): NodeMaterialConnectionPoint;
  60953. /**
  60954. * Gets the xyz component (output)
  60955. * @deprecated Please use xyzOut instead.
  60956. */
  60957. get xyz(): NodeMaterialConnectionPoint;
  60958. protected _buildBlock(state: NodeMaterialBuildState): this;
  60959. }
  60960. }
  60961. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  60962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60965. import { Vector2 } from "babylonjs/Maths/math.vector";
  60966. import { Scene } from "babylonjs/scene";
  60967. /**
  60968. * Block used to remap a float from a range to a new one
  60969. */
  60970. export class RemapBlock extends NodeMaterialBlock {
  60971. /**
  60972. * Gets or sets the source range
  60973. */
  60974. sourceRange: Vector2;
  60975. /**
  60976. * Gets or sets the target range
  60977. */
  60978. targetRange: Vector2;
  60979. /**
  60980. * Creates a new RemapBlock
  60981. * @param name defines the block name
  60982. */
  60983. constructor(name: string);
  60984. /**
  60985. * Gets the current class name
  60986. * @returns the class name
  60987. */
  60988. getClassName(): string;
  60989. /**
  60990. * Gets the input component
  60991. */
  60992. get input(): NodeMaterialConnectionPoint;
  60993. /**
  60994. * Gets the source min input component
  60995. */
  60996. get sourceMin(): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Gets the source max input component
  60999. */
  61000. get sourceMax(): NodeMaterialConnectionPoint;
  61001. /**
  61002. * Gets the target min input component
  61003. */
  61004. get targetMin(): NodeMaterialConnectionPoint;
  61005. /**
  61006. * Gets the target max input component
  61007. */
  61008. get targetMax(): NodeMaterialConnectionPoint;
  61009. /**
  61010. * Gets the output component
  61011. */
  61012. get output(): NodeMaterialConnectionPoint;
  61013. protected _buildBlock(state: NodeMaterialBuildState): this;
  61014. protected _dumpPropertiesCode(): string;
  61015. serialize(): any;
  61016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61017. }
  61018. }
  61019. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61023. /**
  61024. * Block used to multiply 2 values
  61025. */
  61026. export class MultiplyBlock extends NodeMaterialBlock {
  61027. /**
  61028. * Creates a new MultiplyBlock
  61029. * @param name defines the block name
  61030. */
  61031. constructor(name: string);
  61032. /**
  61033. * Gets the current class name
  61034. * @returns the class name
  61035. */
  61036. getClassName(): string;
  61037. /**
  61038. * Gets the left operand input component
  61039. */
  61040. get left(): NodeMaterialConnectionPoint;
  61041. /**
  61042. * Gets the right operand input component
  61043. */
  61044. get right(): NodeMaterialConnectionPoint;
  61045. /**
  61046. * Gets the output component
  61047. */
  61048. get output(): NodeMaterialConnectionPoint;
  61049. protected _buildBlock(state: NodeMaterialBuildState): this;
  61050. }
  61051. }
  61052. declare module "babylonjs/Materials/Node/nodeMaterial" {
  61053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61054. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  61055. import { Scene } from "babylonjs/scene";
  61056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61057. import { Matrix } from "babylonjs/Maths/math.vector";
  61058. import { Mesh } from "babylonjs/Meshes/mesh";
  61059. import { Engine } from "babylonjs/Engines/engine";
  61060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61061. import { Observable } from "babylonjs/Misc/observable";
  61062. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61063. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  61064. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61065. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  61066. import { Nullable } from "babylonjs/types";
  61067. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61068. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61069. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61070. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61071. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  61072. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61073. import { Camera } from "babylonjs/Cameras/camera";
  61074. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  61075. /**
  61076. * Interface used to configure the node material editor
  61077. */
  61078. export interface INodeMaterialEditorOptions {
  61079. /** Define the URl to load node editor script */
  61080. editorURL?: string;
  61081. }
  61082. /** @hidden */
  61083. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  61084. NORMAL: boolean;
  61085. TANGENT: boolean;
  61086. UV1: boolean;
  61087. /** BONES */
  61088. NUM_BONE_INFLUENCERS: number;
  61089. BonesPerMesh: number;
  61090. BONETEXTURE: boolean;
  61091. /** MORPH TARGETS */
  61092. MORPHTARGETS: boolean;
  61093. MORPHTARGETS_NORMAL: boolean;
  61094. MORPHTARGETS_TANGENT: boolean;
  61095. MORPHTARGETS_UV: boolean;
  61096. NUM_MORPH_INFLUENCERS: number;
  61097. /** IMAGE PROCESSING */
  61098. IMAGEPROCESSING: boolean;
  61099. VIGNETTE: boolean;
  61100. VIGNETTEBLENDMODEMULTIPLY: boolean;
  61101. VIGNETTEBLENDMODEOPAQUE: boolean;
  61102. TONEMAPPING: boolean;
  61103. TONEMAPPING_ACES: boolean;
  61104. CONTRAST: boolean;
  61105. EXPOSURE: boolean;
  61106. COLORCURVES: boolean;
  61107. COLORGRADING: boolean;
  61108. COLORGRADING3D: boolean;
  61109. SAMPLER3DGREENDEPTH: boolean;
  61110. SAMPLER3DBGRMAP: boolean;
  61111. IMAGEPROCESSINGPOSTPROCESS: boolean;
  61112. /** MISC. */
  61113. BUMPDIRECTUV: number;
  61114. constructor();
  61115. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  61116. }
  61117. /**
  61118. * Class used to configure NodeMaterial
  61119. */
  61120. export interface INodeMaterialOptions {
  61121. /**
  61122. * Defines if blocks should emit comments
  61123. */
  61124. emitComments: boolean;
  61125. }
  61126. /**
  61127. * Class used to create a node based material built by assembling shader blocks
  61128. */
  61129. export class NodeMaterial extends PushMaterial {
  61130. private static _BuildIdGenerator;
  61131. private _options;
  61132. private _vertexCompilationState;
  61133. private _fragmentCompilationState;
  61134. private _sharedData;
  61135. private _buildId;
  61136. private _buildWasSuccessful;
  61137. private _cachedWorldViewMatrix;
  61138. private _cachedWorldViewProjectionMatrix;
  61139. private _optimizers;
  61140. private _animationFrame;
  61141. /** Define the Url to load node editor script */
  61142. static EditorURL: string;
  61143. /** Define the Url to load snippets */
  61144. static SnippetUrl: string;
  61145. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  61146. static IgnoreTexturesAtLoadTime: boolean;
  61147. private BJSNODEMATERIALEDITOR;
  61148. /** Get the inspector from bundle or global */
  61149. private _getGlobalNodeMaterialEditor;
  61150. /**
  61151. * Snippet ID if the material was created from the snippet server
  61152. */
  61153. snippetId: string;
  61154. /**
  61155. * Gets or sets data used by visual editor
  61156. * @see https://nme.babylonjs.com
  61157. */
  61158. editorData: any;
  61159. /**
  61160. * 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)
  61161. */
  61162. ignoreAlpha: boolean;
  61163. /**
  61164. * Defines the maximum number of lights that can be used in the material
  61165. */
  61166. maxSimultaneousLights: number;
  61167. /**
  61168. * Observable raised when the material is built
  61169. */
  61170. onBuildObservable: Observable<NodeMaterial>;
  61171. /**
  61172. * Gets or sets the root nodes of the material vertex shader
  61173. */
  61174. _vertexOutputNodes: NodeMaterialBlock[];
  61175. /**
  61176. * Gets or sets the root nodes of the material fragment (pixel) shader
  61177. */
  61178. _fragmentOutputNodes: NodeMaterialBlock[];
  61179. /** Gets or sets options to control the node material overall behavior */
  61180. get options(): INodeMaterialOptions;
  61181. set options(options: INodeMaterialOptions);
  61182. /**
  61183. * Default configuration related to image processing available in the standard Material.
  61184. */
  61185. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61186. /**
  61187. * Gets the image processing configuration used either in this material.
  61188. */
  61189. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  61190. /**
  61191. * Sets the Default image processing configuration used either in the this material.
  61192. *
  61193. * If sets to null, the scene one is in use.
  61194. */
  61195. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  61196. /**
  61197. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  61198. */
  61199. attachedBlocks: NodeMaterialBlock[];
  61200. /**
  61201. * Specifies the mode of the node material
  61202. * @hidden
  61203. */
  61204. _mode: NodeMaterialModes;
  61205. /**
  61206. * Gets the mode property
  61207. */
  61208. get mode(): NodeMaterialModes;
  61209. /**
  61210. * Create a new node based material
  61211. * @param name defines the material name
  61212. * @param scene defines the hosting scene
  61213. * @param options defines creation option
  61214. */
  61215. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  61216. /**
  61217. * Gets the current class name of the material e.g. "NodeMaterial"
  61218. * @returns the class name
  61219. */
  61220. getClassName(): string;
  61221. /**
  61222. * Keep track of the image processing observer to allow dispose and replace.
  61223. */
  61224. private _imageProcessingObserver;
  61225. /**
  61226. * Attaches a new image processing configuration to the Standard Material.
  61227. * @param configuration
  61228. */
  61229. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61230. /**
  61231. * Get a block by its name
  61232. * @param name defines the name of the block to retrieve
  61233. * @returns the required block or null if not found
  61234. */
  61235. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  61236. /**
  61237. * Get a block by its name
  61238. * @param predicate defines the predicate used to find the good candidate
  61239. * @returns the required block or null if not found
  61240. */
  61241. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  61242. /**
  61243. * Get an input block by its name
  61244. * @param predicate defines the predicate used to find the good candidate
  61245. * @returns the required input block or null if not found
  61246. */
  61247. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  61248. /**
  61249. * Gets the list of input blocks attached to this material
  61250. * @returns an array of InputBlocks
  61251. */
  61252. getInputBlocks(): InputBlock[];
  61253. /**
  61254. * Adds a new optimizer to the list of optimizers
  61255. * @param optimizer defines the optimizers to add
  61256. * @returns the current material
  61257. */
  61258. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  61259. /**
  61260. * Remove an optimizer from the list of optimizers
  61261. * @param optimizer defines the optimizers to remove
  61262. * @returns the current material
  61263. */
  61264. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  61265. /**
  61266. * Add a new block to the list of output nodes
  61267. * @param node defines the node to add
  61268. * @returns the current material
  61269. */
  61270. addOutputNode(node: NodeMaterialBlock): this;
  61271. /**
  61272. * Remove a block from the list of root nodes
  61273. * @param node defines the node to remove
  61274. * @returns the current material
  61275. */
  61276. removeOutputNode(node: NodeMaterialBlock): this;
  61277. private _addVertexOutputNode;
  61278. private _removeVertexOutputNode;
  61279. private _addFragmentOutputNode;
  61280. private _removeFragmentOutputNode;
  61281. /**
  61282. * Specifies if the material will require alpha blending
  61283. * @returns a boolean specifying if alpha blending is needed
  61284. */
  61285. needAlphaBlending(): boolean;
  61286. /**
  61287. * Specifies if this material should be rendered in alpha test mode
  61288. * @returns a boolean specifying if an alpha test is needed.
  61289. */
  61290. needAlphaTesting(): boolean;
  61291. private _initializeBlock;
  61292. private _resetDualBlocks;
  61293. /**
  61294. * Remove a block from the current node material
  61295. * @param block defines the block to remove
  61296. */
  61297. removeBlock(block: NodeMaterialBlock): void;
  61298. /**
  61299. * Build the material and generates the inner effect
  61300. * @param verbose defines if the build should log activity
  61301. */
  61302. build(verbose?: boolean): void;
  61303. /**
  61304. * Runs an otpimization phase to try to improve the shader code
  61305. */
  61306. optimize(): void;
  61307. private _prepareDefinesForAttributes;
  61308. /**
  61309. * Create a post process from the material
  61310. * @param camera The camera to apply the render pass to.
  61311. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  61312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61313. * @param engine The engine which the post process will be applied. (default: current engine)
  61314. * @param reusable If the post process can be reused on the same frame. (default: false)
  61315. * @param textureType Type of textures used when performing the post process. (default: 0)
  61316. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  61317. * @returns the post process created
  61318. */
  61319. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  61320. private _processDefines;
  61321. /**
  61322. * Get if the submesh is ready to be used and all its information available.
  61323. * Child classes can use it to update shaders
  61324. * @param mesh defines the mesh to check
  61325. * @param subMesh defines which submesh to check
  61326. * @param useInstances specifies that instances should be used
  61327. * @returns a boolean indicating that the submesh is ready or not
  61328. */
  61329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61330. /**
  61331. * Get a string representing the shaders built by the current node graph
  61332. */
  61333. get compiledShaders(): string;
  61334. /**
  61335. * Binds the world matrix to the material
  61336. * @param world defines the world transformation matrix
  61337. */
  61338. bindOnlyWorldMatrix(world: Matrix): void;
  61339. /**
  61340. * Binds the submesh to this material by preparing the effect and shader to draw
  61341. * @param world defines the world transformation matrix
  61342. * @param mesh defines the mesh containing the submesh
  61343. * @param subMesh defines the submesh to bind the material to
  61344. */
  61345. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61346. /**
  61347. * Gets the active textures from the material
  61348. * @returns an array of textures
  61349. */
  61350. getActiveTextures(): BaseTexture[];
  61351. /**
  61352. * Gets the list of texture blocks
  61353. * @returns an array of texture blocks
  61354. */
  61355. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  61356. /**
  61357. * Specifies if the material uses a texture
  61358. * @param texture defines the texture to check against the material
  61359. * @returns a boolean specifying if the material uses the texture
  61360. */
  61361. hasTexture(texture: BaseTexture): boolean;
  61362. /**
  61363. * Disposes the material
  61364. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61365. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  61366. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  61367. */
  61368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  61369. /** Creates the node editor window. */
  61370. private _createNodeEditor;
  61371. /**
  61372. * Launch the node material editor
  61373. * @param config Define the configuration of the editor
  61374. * @return a promise fulfilled when the node editor is visible
  61375. */
  61376. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  61377. /**
  61378. * Clear the current material
  61379. */
  61380. clear(): void;
  61381. /**
  61382. * Clear the current material and set it to a default state
  61383. */
  61384. setToDefault(): void;
  61385. /**
  61386. * Clear the current material and set it to a default state for post process
  61387. */
  61388. setToDefaultPostProcess(): void;
  61389. /**
  61390. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  61391. * @param url defines the url to load from
  61392. * @returns a promise that will fullfil when the material is fully loaded
  61393. */
  61394. loadAsync(url: string): Promise<void>;
  61395. private _gatherBlocks;
  61396. /**
  61397. * Generate a string containing the code declaration required to create an equivalent of this material
  61398. * @returns a string
  61399. */
  61400. generateCode(): string;
  61401. /**
  61402. * Serializes this material in a JSON representation
  61403. * @returns the serialized material object
  61404. */
  61405. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  61406. private _restoreConnections;
  61407. /**
  61408. * Clear the current graph and load a new one from a serialization object
  61409. * @param source defines the JSON representation of the material
  61410. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61411. */
  61412. loadFromSerialization(source: any, rootUrl?: string): void;
  61413. /**
  61414. * Makes a duplicate of the current material.
  61415. * @param name - name to use for the new material.
  61416. */
  61417. clone(name: string): NodeMaterial;
  61418. /**
  61419. * Creates a node material from parsed material data
  61420. * @param source defines the JSON representation of the material
  61421. * @param scene defines the hosting scene
  61422. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61423. * @returns a new node material
  61424. */
  61425. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  61426. /**
  61427. * Creates a node material from a snippet saved in a remote file
  61428. * @param name defines the name of the material to create
  61429. * @param url defines the url to load from
  61430. * @param scene defines the hosting scene
  61431. * @returns a promise that will resolve to the new node material
  61432. */
  61433. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  61434. /**
  61435. * Creates a node material from a snippet saved by the node material editor
  61436. * @param snippetId defines the snippet to load
  61437. * @param scene defines the hosting scene
  61438. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61439. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  61440. * @returns a promise that will resolve to the new node material
  61441. */
  61442. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  61443. /**
  61444. * Creates a new node material set to default basic configuration
  61445. * @param name defines the name of the material
  61446. * @param scene defines the hosting scene
  61447. * @returns a new NodeMaterial
  61448. */
  61449. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  61450. }
  61451. }
  61452. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  61453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61455. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61456. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61458. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61459. import { Effect } from "babylonjs/Materials/effect";
  61460. import { Mesh } from "babylonjs/Meshes/mesh";
  61461. import { Nullable } from "babylonjs/types";
  61462. import { Texture } from "babylonjs/Materials/Textures/texture";
  61463. import { Scene } from "babylonjs/scene";
  61464. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61465. /**
  61466. * Block used to read a texture from a sampler
  61467. */
  61468. export class TextureBlock extends NodeMaterialBlock {
  61469. private _defineName;
  61470. private _linearDefineName;
  61471. private _gammaDefineName;
  61472. private _tempTextureRead;
  61473. private _samplerName;
  61474. private _transformedUVName;
  61475. private _textureTransformName;
  61476. private _textureInfoName;
  61477. private _mainUVName;
  61478. private _mainUVDefineName;
  61479. /**
  61480. * Gets or sets the texture associated with the node
  61481. */
  61482. texture: Nullable<Texture>;
  61483. /**
  61484. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  61485. */
  61486. convertToGammaSpace: boolean;
  61487. /**
  61488. * Gets or sets a boolean indicating if content needs to be converted to linear space
  61489. */
  61490. convertToLinearSpace: boolean;
  61491. /**
  61492. * Create a new TextureBlock
  61493. * @param name defines the block name
  61494. */
  61495. constructor(name: string);
  61496. /**
  61497. * Gets the current class name
  61498. * @returns the class name
  61499. */
  61500. getClassName(): string;
  61501. /**
  61502. * Gets the uv input component
  61503. */
  61504. get uv(): NodeMaterialConnectionPoint;
  61505. /**
  61506. * Gets the rgba output component
  61507. */
  61508. get rgba(): NodeMaterialConnectionPoint;
  61509. /**
  61510. * Gets the rgb output component
  61511. */
  61512. get rgb(): NodeMaterialConnectionPoint;
  61513. /**
  61514. * Gets the r output component
  61515. */
  61516. get r(): NodeMaterialConnectionPoint;
  61517. /**
  61518. * Gets the g output component
  61519. */
  61520. get g(): NodeMaterialConnectionPoint;
  61521. /**
  61522. * Gets the b output component
  61523. */
  61524. get b(): NodeMaterialConnectionPoint;
  61525. /**
  61526. * Gets the a output component
  61527. */
  61528. get a(): NodeMaterialConnectionPoint;
  61529. get target(): NodeMaterialBlockTargets;
  61530. autoConfigure(material: NodeMaterial): void;
  61531. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61532. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61533. isReady(): boolean;
  61534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61535. private get _isMixed();
  61536. private _injectVertexCode;
  61537. private _writeTextureRead;
  61538. private _writeOutput;
  61539. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61540. protected _dumpPropertiesCode(): string;
  61541. serialize(): any;
  61542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61543. }
  61544. }
  61545. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  61546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61548. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61549. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61550. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61551. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61552. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  61553. import { Scene } from "babylonjs/scene";
  61554. /**
  61555. * Class used to store shared data between 2 NodeMaterialBuildState
  61556. */
  61557. export class NodeMaterialBuildStateSharedData {
  61558. /**
  61559. * Gets the list of emitted varyings
  61560. */
  61561. temps: string[];
  61562. /**
  61563. * Gets the list of emitted varyings
  61564. */
  61565. varyings: string[];
  61566. /**
  61567. * Gets the varying declaration string
  61568. */
  61569. varyingDeclaration: string;
  61570. /**
  61571. * Input blocks
  61572. */
  61573. inputBlocks: InputBlock[];
  61574. /**
  61575. * Input blocks
  61576. */
  61577. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  61578. /**
  61579. * Bindable blocks (Blocks that need to set data to the effect)
  61580. */
  61581. bindableBlocks: NodeMaterialBlock[];
  61582. /**
  61583. * List of blocks that can provide a compilation fallback
  61584. */
  61585. blocksWithFallbacks: NodeMaterialBlock[];
  61586. /**
  61587. * List of blocks that can provide a define update
  61588. */
  61589. blocksWithDefines: NodeMaterialBlock[];
  61590. /**
  61591. * List of blocks that can provide a repeatable content
  61592. */
  61593. repeatableContentBlocks: NodeMaterialBlock[];
  61594. /**
  61595. * List of blocks that can provide a dynamic list of uniforms
  61596. */
  61597. dynamicUniformBlocks: NodeMaterialBlock[];
  61598. /**
  61599. * List of blocks that can block the isReady function for the material
  61600. */
  61601. blockingBlocks: NodeMaterialBlock[];
  61602. /**
  61603. * Gets the list of animated inputs
  61604. */
  61605. animatedInputs: InputBlock[];
  61606. /**
  61607. * Build Id used to avoid multiple recompilations
  61608. */
  61609. buildId: number;
  61610. /** List of emitted variables */
  61611. variableNames: {
  61612. [key: string]: number;
  61613. };
  61614. /** List of emitted defines */
  61615. defineNames: {
  61616. [key: string]: number;
  61617. };
  61618. /** Should emit comments? */
  61619. emitComments: boolean;
  61620. /** Emit build activity */
  61621. verbose: boolean;
  61622. /** Gets or sets the hosting scene */
  61623. scene: Scene;
  61624. /**
  61625. * Gets the compilation hints emitted at compilation time
  61626. */
  61627. hints: {
  61628. needWorldViewMatrix: boolean;
  61629. needWorldViewProjectionMatrix: boolean;
  61630. needAlphaBlending: boolean;
  61631. needAlphaTesting: boolean;
  61632. };
  61633. /**
  61634. * List of compilation checks
  61635. */
  61636. checks: {
  61637. emitVertex: boolean;
  61638. emitFragment: boolean;
  61639. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  61640. };
  61641. /** Creates a new shared data */
  61642. constructor();
  61643. /**
  61644. * Emits console errors and exceptions if there is a failing check
  61645. */
  61646. emitErrors(): void;
  61647. }
  61648. }
  61649. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  61650. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61651. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61652. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  61653. /**
  61654. * Class used to store node based material build state
  61655. */
  61656. export class NodeMaterialBuildState {
  61657. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  61658. supportUniformBuffers: boolean;
  61659. /**
  61660. * Gets the list of emitted attributes
  61661. */
  61662. attributes: string[];
  61663. /**
  61664. * Gets the list of emitted uniforms
  61665. */
  61666. uniforms: string[];
  61667. /**
  61668. * Gets the list of emitted constants
  61669. */
  61670. constants: string[];
  61671. /**
  61672. * Gets the list of emitted samplers
  61673. */
  61674. samplers: string[];
  61675. /**
  61676. * Gets the list of emitted functions
  61677. */
  61678. functions: {
  61679. [key: string]: string;
  61680. };
  61681. /**
  61682. * Gets the list of emitted extensions
  61683. */
  61684. extensions: {
  61685. [key: string]: string;
  61686. };
  61687. /**
  61688. * Gets the target of the compilation state
  61689. */
  61690. target: NodeMaterialBlockTargets;
  61691. /**
  61692. * Gets the list of emitted counters
  61693. */
  61694. counters: {
  61695. [key: string]: number;
  61696. };
  61697. /**
  61698. * Shared data between multiple NodeMaterialBuildState instances
  61699. */
  61700. sharedData: NodeMaterialBuildStateSharedData;
  61701. /** @hidden */
  61702. _vertexState: NodeMaterialBuildState;
  61703. /** @hidden */
  61704. _attributeDeclaration: string;
  61705. /** @hidden */
  61706. _uniformDeclaration: string;
  61707. /** @hidden */
  61708. _constantDeclaration: string;
  61709. /** @hidden */
  61710. _samplerDeclaration: string;
  61711. /** @hidden */
  61712. _varyingTransfer: string;
  61713. /** @hidden */
  61714. _injectAtEnd: string;
  61715. private _repeatableContentAnchorIndex;
  61716. /** @hidden */
  61717. _builtCompilationString: string;
  61718. /**
  61719. * Gets the emitted compilation strings
  61720. */
  61721. compilationString: string;
  61722. /**
  61723. * Finalize the compilation strings
  61724. * @param state defines the current compilation state
  61725. */
  61726. finalize(state: NodeMaterialBuildState): void;
  61727. /** @hidden */
  61728. get _repeatableContentAnchor(): string;
  61729. /** @hidden */
  61730. _getFreeVariableName(prefix: string): string;
  61731. /** @hidden */
  61732. _getFreeDefineName(prefix: string): string;
  61733. /** @hidden */
  61734. _excludeVariableName(name: string): void;
  61735. /** @hidden */
  61736. _emit2DSampler(name: string): void;
  61737. /** @hidden */
  61738. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  61739. /** @hidden */
  61740. _emitExtension(name: string, extension: string, define?: string): void;
  61741. /** @hidden */
  61742. _emitFunction(name: string, code: string, comments: string): void;
  61743. /** @hidden */
  61744. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  61745. replaceStrings?: {
  61746. search: RegExp;
  61747. replace: string;
  61748. }[];
  61749. repeatKey?: string;
  61750. }): string;
  61751. /** @hidden */
  61752. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  61753. repeatKey?: string;
  61754. removeAttributes?: boolean;
  61755. removeUniforms?: boolean;
  61756. removeVaryings?: boolean;
  61757. removeIfDef?: boolean;
  61758. replaceStrings?: {
  61759. search: RegExp;
  61760. replace: string;
  61761. }[];
  61762. }, storeKey?: string): void;
  61763. /** @hidden */
  61764. _registerTempVariable(name: string): boolean;
  61765. /** @hidden */
  61766. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  61767. /** @hidden */
  61768. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  61769. /** @hidden */
  61770. _emitFloat(value: number): string;
  61771. }
  61772. }
  61773. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  61774. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61776. import { Nullable } from "babylonjs/types";
  61777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61778. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61779. import { Effect } from "babylonjs/Materials/effect";
  61780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61781. import { Mesh } from "babylonjs/Meshes/mesh";
  61782. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61783. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61784. import { Scene } from "babylonjs/scene";
  61785. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61786. /**
  61787. * Defines a block that can be used inside a node based material
  61788. */
  61789. export class NodeMaterialBlock {
  61790. private _buildId;
  61791. private _buildTarget;
  61792. private _target;
  61793. private _isFinalMerger;
  61794. private _isInput;
  61795. protected _isUnique: boolean;
  61796. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  61797. inputsAreExclusive: boolean;
  61798. /** @hidden */
  61799. _codeVariableName: string;
  61800. /** @hidden */
  61801. _inputs: NodeMaterialConnectionPoint[];
  61802. /** @hidden */
  61803. _outputs: NodeMaterialConnectionPoint[];
  61804. /** @hidden */
  61805. _preparationId: number;
  61806. /**
  61807. * Gets or sets the name of the block
  61808. */
  61809. name: string;
  61810. /**
  61811. * Gets or sets the unique id of the node
  61812. */
  61813. uniqueId: number;
  61814. /**
  61815. * Gets or sets the comments associated with this block
  61816. */
  61817. comments: string;
  61818. /**
  61819. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  61820. */
  61821. get isUnique(): boolean;
  61822. /**
  61823. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  61824. */
  61825. get isFinalMerger(): boolean;
  61826. /**
  61827. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  61828. */
  61829. get isInput(): boolean;
  61830. /**
  61831. * Gets or sets the build Id
  61832. */
  61833. get buildId(): number;
  61834. set buildId(value: number);
  61835. /**
  61836. * Gets or sets the target of the block
  61837. */
  61838. get target(): NodeMaterialBlockTargets;
  61839. set target(value: NodeMaterialBlockTargets);
  61840. /**
  61841. * Gets the list of input points
  61842. */
  61843. get inputs(): NodeMaterialConnectionPoint[];
  61844. /** Gets the list of output points */
  61845. get outputs(): NodeMaterialConnectionPoint[];
  61846. /**
  61847. * Find an input by its name
  61848. * @param name defines the name of the input to look for
  61849. * @returns the input or null if not found
  61850. */
  61851. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61852. /**
  61853. * Find an output by its name
  61854. * @param name defines the name of the outputto look for
  61855. * @returns the output or null if not found
  61856. */
  61857. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61858. /**
  61859. * Creates a new NodeMaterialBlock
  61860. * @param name defines the block name
  61861. * @param target defines the target of that block (Vertex by default)
  61862. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  61863. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  61864. */
  61865. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  61866. /**
  61867. * Initialize the block and prepare the context for build
  61868. * @param state defines the state that will be used for the build
  61869. */
  61870. initialize(state: NodeMaterialBuildState): void;
  61871. /**
  61872. * Bind data to effect. Will only be called for blocks with isBindable === true
  61873. * @param effect defines the effect to bind data to
  61874. * @param nodeMaterial defines the hosting NodeMaterial
  61875. * @param mesh defines the mesh that will be rendered
  61876. * @param subMesh defines the submesh that will be rendered
  61877. */
  61878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61879. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  61880. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  61881. protected _writeFloat(value: number): string;
  61882. /**
  61883. * Gets the current class name e.g. "NodeMaterialBlock"
  61884. * @returns the class name
  61885. */
  61886. getClassName(): string;
  61887. /**
  61888. * Register a new input. Must be called inside a block constructor
  61889. * @param name defines the connection point name
  61890. * @param type defines the connection point type
  61891. * @param isOptional defines a boolean indicating that this input can be omitted
  61892. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61893. * @param point an already created connection point. If not provided, create a new one
  61894. * @returns the current block
  61895. */
  61896. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61897. /**
  61898. * Register a new output. Must be called inside a block constructor
  61899. * @param name defines the connection point name
  61900. * @param type defines the connection point type
  61901. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61902. * @param point an already created connection point. If not provided, create a new one
  61903. * @returns the current block
  61904. */
  61905. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61906. /**
  61907. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61908. * @param forOutput defines an optional connection point to check compatibility with
  61909. * @returns the first available input or null
  61910. */
  61911. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61912. /**
  61913. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61914. * @param forBlock defines an optional block to check compatibility with
  61915. * @returns the first available input or null
  61916. */
  61917. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61918. /**
  61919. * Gets the sibling of the given output
  61920. * @param current defines the current output
  61921. * @returns the next output in the list or null
  61922. */
  61923. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61924. /**
  61925. * Connect current block with another block
  61926. * @param other defines the block to connect with
  61927. * @param options define the various options to help pick the right connections
  61928. * @returns the current block
  61929. */
  61930. connectTo(other: NodeMaterialBlock, options?: {
  61931. input?: string;
  61932. output?: string;
  61933. outputSwizzle?: string;
  61934. }): this | undefined;
  61935. protected _buildBlock(state: NodeMaterialBuildState): void;
  61936. /**
  61937. * Add uniforms, samplers and uniform buffers at compilation time
  61938. * @param state defines the state to update
  61939. * @param nodeMaterial defines the node material requesting the update
  61940. * @param defines defines the material defines to update
  61941. * @param uniformBuffers defines the list of uniform buffer names
  61942. */
  61943. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61944. /**
  61945. * Add potential fallbacks if shader compilation fails
  61946. * @param mesh defines the mesh to be rendered
  61947. * @param fallbacks defines the current prioritized list of fallbacks
  61948. */
  61949. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61950. /**
  61951. * Initialize defines for shader compilation
  61952. * @param mesh defines the mesh to be rendered
  61953. * @param nodeMaterial defines the node material requesting the update
  61954. * @param defines defines the material defines to update
  61955. * @param useInstances specifies that instances should be used
  61956. */
  61957. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61958. /**
  61959. * Update defines for shader compilation
  61960. * @param mesh defines the mesh to be rendered
  61961. * @param nodeMaterial defines the node material requesting the update
  61962. * @param defines defines the material defines to update
  61963. * @param useInstances specifies that instances should be used
  61964. */
  61965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61966. /**
  61967. * Lets the block try to connect some inputs automatically
  61968. * @param material defines the hosting NodeMaterial
  61969. */
  61970. autoConfigure(material: NodeMaterial): void;
  61971. /**
  61972. * Function called when a block is declared as repeatable content generator
  61973. * @param vertexShaderState defines the current compilation state for the vertex shader
  61974. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61975. * @param mesh defines the mesh to be rendered
  61976. * @param defines defines the material defines to update
  61977. */
  61978. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61979. /**
  61980. * Checks if the block is ready
  61981. * @param mesh defines the mesh to be rendered
  61982. * @param nodeMaterial defines the node material requesting the update
  61983. * @param defines defines the material defines to update
  61984. * @param useInstances specifies that instances should be used
  61985. * @returns true if the block is ready
  61986. */
  61987. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61988. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61989. private _processBuild;
  61990. /**
  61991. * Compile the current node and generate the shader code
  61992. * @param state defines the current compilation state (uniforms, samplers, current string)
  61993. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61994. * @returns true if already built
  61995. */
  61996. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61997. protected _inputRename(name: string): string;
  61998. protected _outputRename(name: string): string;
  61999. protected _dumpPropertiesCode(): string;
  62000. /** @hidden */
  62001. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  62002. /** @hidden */
  62003. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  62004. /**
  62005. * Clone the current block to a new identical block
  62006. * @param scene defines the hosting scene
  62007. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  62008. * @returns a copy of the current block
  62009. */
  62010. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  62011. /**
  62012. * Serializes this block in a JSON representation
  62013. * @returns the serialized block object
  62014. */
  62015. serialize(): any;
  62016. /** @hidden */
  62017. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62018. private _deserializePortDisplayNames;
  62019. /**
  62020. * Release resources
  62021. */
  62022. dispose(): void;
  62023. }
  62024. }
  62025. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  62026. /**
  62027. * Enum defining the type of animations supported by InputBlock
  62028. */
  62029. export enum AnimatedInputBlockTypes {
  62030. /** No animation */
  62031. None = 0,
  62032. /** Time based animation. Will only work for floats */
  62033. Time = 1
  62034. }
  62035. }
  62036. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  62037. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62038. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  62039. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  62040. import { Nullable } from "babylonjs/types";
  62041. import { Effect } from "babylonjs/Materials/effect";
  62042. import { Matrix } from "babylonjs/Maths/math.vector";
  62043. import { Scene } from "babylonjs/scene";
  62044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62046. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  62047. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62048. import { Observable } from "babylonjs/Misc/observable";
  62049. /**
  62050. * Block used to expose an input value
  62051. */
  62052. export class InputBlock extends NodeMaterialBlock {
  62053. private _mode;
  62054. private _associatedVariableName;
  62055. private _storedValue;
  62056. private _valueCallback;
  62057. private _type;
  62058. private _animationType;
  62059. /** Gets or set a value used to limit the range of float values */
  62060. min: number;
  62061. /** Gets or set a value used to limit the range of float values */
  62062. max: number;
  62063. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  62064. isBoolean: boolean;
  62065. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  62066. matrixMode: number;
  62067. /** @hidden */
  62068. _systemValue: Nullable<NodeMaterialSystemValues>;
  62069. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  62070. visibleInInspector: boolean;
  62071. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  62072. isConstant: boolean;
  62073. /** Gets or sets the group to use to display this block in the Inspector */
  62074. groupInInspector: string;
  62075. /** Gets an observable raised when the value is changed */
  62076. onValueChangedObservable: Observable<InputBlock>;
  62077. /**
  62078. * Gets or sets the connection point type (default is float)
  62079. */
  62080. get type(): NodeMaterialBlockConnectionPointTypes;
  62081. /**
  62082. * Creates a new InputBlock
  62083. * @param name defines the block name
  62084. * @param target defines the target of that block (Vertex by default)
  62085. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  62086. */
  62087. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  62088. /**
  62089. * Gets the output component
  62090. */
  62091. get output(): NodeMaterialConnectionPoint;
  62092. /**
  62093. * Set the source of this connection point to a vertex attribute
  62094. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  62095. * @returns the current connection point
  62096. */
  62097. setAsAttribute(attributeName?: string): InputBlock;
  62098. /**
  62099. * Set the source of this connection point to a system value
  62100. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  62101. * @returns the current connection point
  62102. */
  62103. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  62104. /**
  62105. * Gets or sets the value of that point.
  62106. * Please note that this value will be ignored if valueCallback is defined
  62107. */
  62108. get value(): any;
  62109. set value(value: any);
  62110. /**
  62111. * Gets or sets a callback used to get the value of that point.
  62112. * Please note that setting this value will force the connection point to ignore the value property
  62113. */
  62114. get valueCallback(): () => any;
  62115. set valueCallback(value: () => any);
  62116. /**
  62117. * Gets or sets the associated variable name in the shader
  62118. */
  62119. get associatedVariableName(): string;
  62120. set associatedVariableName(value: string);
  62121. /** Gets or sets the type of animation applied to the input */
  62122. get animationType(): AnimatedInputBlockTypes;
  62123. set animationType(value: AnimatedInputBlockTypes);
  62124. /**
  62125. * Gets a boolean indicating that this connection point not defined yet
  62126. */
  62127. get isUndefined(): boolean;
  62128. /**
  62129. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  62130. * In this case the connection point name must be the name of the uniform to use.
  62131. * Can only be set on inputs
  62132. */
  62133. get isUniform(): boolean;
  62134. set isUniform(value: boolean);
  62135. /**
  62136. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  62137. * In this case the connection point name must be the name of the attribute to use
  62138. * Can only be set on inputs
  62139. */
  62140. get isAttribute(): boolean;
  62141. set isAttribute(value: boolean);
  62142. /**
  62143. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  62144. * Can only be set on exit points
  62145. */
  62146. get isVarying(): boolean;
  62147. set isVarying(value: boolean);
  62148. /**
  62149. * Gets a boolean indicating that the current connection point is a system value
  62150. */
  62151. get isSystemValue(): boolean;
  62152. /**
  62153. * Gets or sets the current well known value or null if not defined as a system value
  62154. */
  62155. get systemValue(): Nullable<NodeMaterialSystemValues>;
  62156. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  62157. /**
  62158. * Gets the current class name
  62159. * @returns the class name
  62160. */
  62161. getClassName(): string;
  62162. /**
  62163. * Animate the input if animationType !== None
  62164. * @param scene defines the rendering scene
  62165. */
  62166. animate(scene: Scene): void;
  62167. private _emitDefine;
  62168. initialize(state: NodeMaterialBuildState): void;
  62169. /**
  62170. * Set the input block to its default value (based on its type)
  62171. */
  62172. setDefaultValue(): void;
  62173. private _emitConstant;
  62174. private _emit;
  62175. /** @hidden */
  62176. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  62177. /** @hidden */
  62178. _transmit(effect: Effect, scene: Scene): void;
  62179. protected _buildBlock(state: NodeMaterialBuildState): void;
  62180. protected _dumpPropertiesCode(): string;
  62181. dispose(): void;
  62182. serialize(): any;
  62183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62184. }
  62185. }
  62186. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  62187. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  62188. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  62189. import { Nullable } from "babylonjs/types";
  62190. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62191. import { Observable } from "babylonjs/Misc/observable";
  62192. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62193. /**
  62194. * Enum used to define the compatibility state between two connection points
  62195. */
  62196. export enum NodeMaterialConnectionPointCompatibilityStates {
  62197. /** Points are compatibles */
  62198. Compatible = 0,
  62199. /** Points are incompatible because of their types */
  62200. TypeIncompatible = 1,
  62201. /** Points are incompatible because of their targets (vertex vs fragment) */
  62202. TargetIncompatible = 2
  62203. }
  62204. /**
  62205. * Defines the direction of a connection point
  62206. */
  62207. export enum NodeMaterialConnectionPointDirection {
  62208. /** Input */
  62209. Input = 0,
  62210. /** Output */
  62211. Output = 1
  62212. }
  62213. /**
  62214. * Defines a connection point for a block
  62215. */
  62216. export class NodeMaterialConnectionPoint {
  62217. /** @hidden */
  62218. _ownerBlock: NodeMaterialBlock;
  62219. /** @hidden */
  62220. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  62221. private _endpoints;
  62222. private _associatedVariableName;
  62223. private _direction;
  62224. /** @hidden */
  62225. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  62226. /** @hidden */
  62227. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  62228. private _type;
  62229. /** @hidden */
  62230. _enforceAssociatedVariableName: boolean;
  62231. /** Gets the direction of the point */
  62232. get direction(): NodeMaterialConnectionPointDirection;
  62233. /** Indicates that this connection point needs dual validation before being connected to another point */
  62234. needDualDirectionValidation: boolean;
  62235. /**
  62236. * Gets or sets the additional types supported by this connection point
  62237. */
  62238. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  62239. /**
  62240. * Gets or sets the additional types excluded by this connection point
  62241. */
  62242. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  62243. /**
  62244. * Observable triggered when this point is connected
  62245. */
  62246. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  62247. /**
  62248. * Gets or sets the associated variable name in the shader
  62249. */
  62250. get associatedVariableName(): string;
  62251. set associatedVariableName(value: string);
  62252. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  62253. get innerType(): NodeMaterialBlockConnectionPointTypes;
  62254. /**
  62255. * Gets or sets the connection point type (default is float)
  62256. */
  62257. get type(): NodeMaterialBlockConnectionPointTypes;
  62258. set type(value: NodeMaterialBlockConnectionPointTypes);
  62259. /**
  62260. * Gets or sets the connection point name
  62261. */
  62262. name: string;
  62263. /**
  62264. * Gets or sets the connection point name
  62265. */
  62266. displayName: string;
  62267. /**
  62268. * Gets or sets a boolean indicating that this connection point can be omitted
  62269. */
  62270. isOptional: boolean;
  62271. /**
  62272. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  62273. */
  62274. define: string;
  62275. /** @hidden */
  62276. _prioritizeVertex: boolean;
  62277. private _target;
  62278. /** Gets or sets the target of that connection point */
  62279. get target(): NodeMaterialBlockTargets;
  62280. set target(value: NodeMaterialBlockTargets);
  62281. /**
  62282. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  62283. */
  62284. get isConnected(): boolean;
  62285. /**
  62286. * Gets a boolean indicating that the current point is connected to an input block
  62287. */
  62288. get isConnectedToInputBlock(): boolean;
  62289. /**
  62290. * Gets a the connected input block (if any)
  62291. */
  62292. get connectInputBlock(): Nullable<InputBlock>;
  62293. /** Get the other side of the connection (if any) */
  62294. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  62295. /** Get the block that owns this connection point */
  62296. get ownerBlock(): NodeMaterialBlock;
  62297. /** Get the block connected on the other side of this connection (if any) */
  62298. get sourceBlock(): Nullable<NodeMaterialBlock>;
  62299. /** Get the block connected on the endpoints of this connection (if any) */
  62300. get connectedBlocks(): Array<NodeMaterialBlock>;
  62301. /** Gets the list of connected endpoints */
  62302. get endpoints(): NodeMaterialConnectionPoint[];
  62303. /** Gets a boolean indicating if that output point is connected to at least one input */
  62304. get hasEndpoints(): boolean;
  62305. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  62306. get isConnectedInVertexShader(): boolean;
  62307. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  62308. get isConnectedInFragmentShader(): boolean;
  62309. /**
  62310. * Creates a block suitable to be used as an input for this input point.
  62311. * If null is returned, a block based on the point type will be created.
  62312. * @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
  62313. */
  62314. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  62315. /**
  62316. * Creates a new connection point
  62317. * @param name defines the connection point name
  62318. * @param ownerBlock defines the block hosting this connection point
  62319. * @param direction defines the direction of the connection point
  62320. */
  62321. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  62322. /**
  62323. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  62324. * @returns the class name
  62325. */
  62326. getClassName(): string;
  62327. /**
  62328. * Gets a boolean indicating if the current point can be connected to another point
  62329. * @param connectionPoint defines the other connection point
  62330. * @returns a boolean
  62331. */
  62332. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  62333. /**
  62334. * Gets a number indicating if the current point can be connected to another point
  62335. * @param connectionPoint defines the other connection point
  62336. * @returns a number defining the compatibility state
  62337. */
  62338. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  62339. /**
  62340. * Connect this point to another connection point
  62341. * @param connectionPoint defines the other connection point
  62342. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  62343. * @returns the current connection point
  62344. */
  62345. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  62346. /**
  62347. * Disconnect this point from one of his endpoint
  62348. * @param endpoint defines the other connection point
  62349. * @returns the current connection point
  62350. */
  62351. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  62352. /**
  62353. * Serializes this point in a JSON representation
  62354. * @param isInput defines if the connection point is an input (default is true)
  62355. * @returns the serialized point object
  62356. */
  62357. serialize(isInput?: boolean): any;
  62358. /**
  62359. * Release resources
  62360. */
  62361. dispose(): void;
  62362. }
  62363. }
  62364. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  62365. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62366. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62368. import { Mesh } from "babylonjs/Meshes/mesh";
  62369. import { Effect } from "babylonjs/Materials/effect";
  62370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62371. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62372. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62373. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62374. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62375. /**
  62376. * Block used to add support for vertex skinning (bones)
  62377. */
  62378. export class BonesBlock extends NodeMaterialBlock {
  62379. /**
  62380. * Creates a new BonesBlock
  62381. * @param name defines the block name
  62382. */
  62383. constructor(name: string);
  62384. /**
  62385. * Initialize the block and prepare the context for build
  62386. * @param state defines the state that will be used for the build
  62387. */
  62388. initialize(state: NodeMaterialBuildState): void;
  62389. /**
  62390. * Gets the current class name
  62391. * @returns the class name
  62392. */
  62393. getClassName(): string;
  62394. /**
  62395. * Gets the matrix indices input component
  62396. */
  62397. get matricesIndices(): NodeMaterialConnectionPoint;
  62398. /**
  62399. * Gets the matrix weights input component
  62400. */
  62401. get matricesWeights(): NodeMaterialConnectionPoint;
  62402. /**
  62403. * Gets the extra matrix indices input component
  62404. */
  62405. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62406. /**
  62407. * Gets the extra matrix weights input component
  62408. */
  62409. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62410. /**
  62411. * Gets the world input component
  62412. */
  62413. get world(): NodeMaterialConnectionPoint;
  62414. /**
  62415. * Gets the output component
  62416. */
  62417. get output(): NodeMaterialConnectionPoint;
  62418. autoConfigure(material: NodeMaterial): void;
  62419. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62422. protected _buildBlock(state: NodeMaterialBuildState): this;
  62423. }
  62424. }
  62425. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  62426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62430. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62431. /**
  62432. * Block used to add support for instances
  62433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62434. */
  62435. export class InstancesBlock extends NodeMaterialBlock {
  62436. /**
  62437. * Creates a new InstancesBlock
  62438. * @param name defines the block name
  62439. */
  62440. constructor(name: string);
  62441. /**
  62442. * Gets the current class name
  62443. * @returns the class name
  62444. */
  62445. getClassName(): string;
  62446. /**
  62447. * Gets the first world row input component
  62448. */
  62449. get world0(): NodeMaterialConnectionPoint;
  62450. /**
  62451. * Gets the second world row input component
  62452. */
  62453. get world1(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the third world row input component
  62456. */
  62457. get world2(): NodeMaterialConnectionPoint;
  62458. /**
  62459. * Gets the forth world row input component
  62460. */
  62461. get world3(): NodeMaterialConnectionPoint;
  62462. /**
  62463. * Gets the world input component
  62464. */
  62465. get world(): NodeMaterialConnectionPoint;
  62466. /**
  62467. * Gets the output component
  62468. */
  62469. get output(): NodeMaterialConnectionPoint;
  62470. /**
  62471. * Gets the isntanceID component
  62472. */
  62473. get instanceID(): NodeMaterialConnectionPoint;
  62474. autoConfigure(material: NodeMaterial): void;
  62475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  62476. protected _buildBlock(state: NodeMaterialBuildState): this;
  62477. }
  62478. }
  62479. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  62480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62484. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62485. import { Effect } from "babylonjs/Materials/effect";
  62486. import { Mesh } from "babylonjs/Meshes/mesh";
  62487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62488. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62489. /**
  62490. * Block used to add morph targets support to vertex shader
  62491. */
  62492. export class MorphTargetsBlock extends NodeMaterialBlock {
  62493. private _repeatableContentAnchor;
  62494. /**
  62495. * Create a new MorphTargetsBlock
  62496. * @param name defines the block name
  62497. */
  62498. constructor(name: string);
  62499. /**
  62500. * Gets the current class name
  62501. * @returns the class name
  62502. */
  62503. getClassName(): string;
  62504. /**
  62505. * Gets the position input component
  62506. */
  62507. get position(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the normal input component
  62510. */
  62511. get normal(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the tangent input component
  62514. */
  62515. get tangent(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the tangent input component
  62518. */
  62519. get uv(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the position output component
  62522. */
  62523. get positionOutput(): NodeMaterialConnectionPoint;
  62524. /**
  62525. * Gets the normal output component
  62526. */
  62527. get normalOutput(): NodeMaterialConnectionPoint;
  62528. /**
  62529. * Gets the tangent output component
  62530. */
  62531. get tangentOutput(): NodeMaterialConnectionPoint;
  62532. /**
  62533. * Gets the tangent output component
  62534. */
  62535. get uvOutput(): NodeMaterialConnectionPoint;
  62536. initialize(state: NodeMaterialBuildState): void;
  62537. autoConfigure(material: NodeMaterial): void;
  62538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62539. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62540. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62541. protected _buildBlock(state: NodeMaterialBuildState): this;
  62542. }
  62543. }
  62544. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  62545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62548. import { Nullable } from "babylonjs/types";
  62549. import { Scene } from "babylonjs/scene";
  62550. import { Effect } from "babylonjs/Materials/effect";
  62551. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62552. import { Mesh } from "babylonjs/Meshes/mesh";
  62553. import { Light } from "babylonjs/Lights/light";
  62554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62555. /**
  62556. * Block used to get data information from a light
  62557. */
  62558. export class LightInformationBlock extends NodeMaterialBlock {
  62559. private _lightDataUniformName;
  62560. private _lightColorUniformName;
  62561. private _lightTypeDefineName;
  62562. /**
  62563. * Gets or sets the light associated with this block
  62564. */
  62565. light: Nullable<Light>;
  62566. /**
  62567. * Creates a new LightInformationBlock
  62568. * @param name defines the block name
  62569. */
  62570. constructor(name: string);
  62571. /**
  62572. * Gets the current class name
  62573. * @returns the class name
  62574. */
  62575. getClassName(): string;
  62576. /**
  62577. * Gets the world position input component
  62578. */
  62579. get worldPosition(): NodeMaterialConnectionPoint;
  62580. /**
  62581. * Gets the direction output component
  62582. */
  62583. get direction(): NodeMaterialConnectionPoint;
  62584. /**
  62585. * Gets the direction output component
  62586. */
  62587. get color(): NodeMaterialConnectionPoint;
  62588. /**
  62589. * Gets the direction output component
  62590. */
  62591. get intensity(): NodeMaterialConnectionPoint;
  62592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62594. protected _buildBlock(state: NodeMaterialBuildState): this;
  62595. serialize(): any;
  62596. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62597. }
  62598. }
  62599. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  62600. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  62601. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  62602. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  62603. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  62604. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  62605. }
  62606. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  62607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62611. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62612. import { Effect } from "babylonjs/Materials/effect";
  62613. import { Mesh } from "babylonjs/Meshes/mesh";
  62614. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62615. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62616. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62617. /**
  62618. * Block used to add image processing support to fragment shader
  62619. */
  62620. export class ImageProcessingBlock extends NodeMaterialBlock {
  62621. /**
  62622. * Create a new ImageProcessingBlock
  62623. * @param name defines the block name
  62624. */
  62625. constructor(name: string);
  62626. /**
  62627. * Gets the current class name
  62628. * @returns the class name
  62629. */
  62630. getClassName(): string;
  62631. /**
  62632. * Gets the color input component
  62633. */
  62634. get color(): NodeMaterialConnectionPoint;
  62635. /**
  62636. * Gets the output component
  62637. */
  62638. get output(): NodeMaterialConnectionPoint;
  62639. /**
  62640. * Initialize the block and prepare the context for build
  62641. * @param state defines the state that will be used for the build
  62642. */
  62643. initialize(state: NodeMaterialBuildState): void;
  62644. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62646. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62647. protected _buildBlock(state: NodeMaterialBuildState): this;
  62648. }
  62649. }
  62650. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  62651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62654. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62656. import { Effect } from "babylonjs/Materials/effect";
  62657. import { Mesh } from "babylonjs/Meshes/mesh";
  62658. import { Scene } from "babylonjs/scene";
  62659. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  62660. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  62661. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  62662. /**
  62663. * Block used to pertub normals based on a normal map
  62664. */
  62665. export class PerturbNormalBlock extends NodeMaterialBlock {
  62666. private _tangentSpaceParameterName;
  62667. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62668. invertX: boolean;
  62669. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62670. invertY: boolean;
  62671. /**
  62672. * Create a new PerturbNormalBlock
  62673. * @param name defines the block name
  62674. */
  62675. constructor(name: string);
  62676. /**
  62677. * Gets the current class name
  62678. * @returns the class name
  62679. */
  62680. getClassName(): string;
  62681. /**
  62682. * Gets the world position input component
  62683. */
  62684. get worldPosition(): NodeMaterialConnectionPoint;
  62685. /**
  62686. * Gets the world normal input component
  62687. */
  62688. get worldNormal(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the world tangent input component
  62691. */
  62692. get worldTangent(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the uv input component
  62695. */
  62696. get uv(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the normal map color input component
  62699. */
  62700. get normalMapColor(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the strength input component
  62703. */
  62704. get strength(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the output component
  62707. */
  62708. get output(): NodeMaterialConnectionPoint;
  62709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62710. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62711. autoConfigure(material: NodeMaterial): void;
  62712. protected _buildBlock(state: NodeMaterialBuildState): this;
  62713. protected _dumpPropertiesCode(): string;
  62714. serialize(): any;
  62715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62716. }
  62717. }
  62718. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  62719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62720. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62722. /**
  62723. * Block used to discard a pixel if a value is smaller than a cutoff
  62724. */
  62725. export class DiscardBlock extends NodeMaterialBlock {
  62726. /**
  62727. * Create a new DiscardBlock
  62728. * @param name defines the block name
  62729. */
  62730. constructor(name: string);
  62731. /**
  62732. * Gets the current class name
  62733. * @returns the class name
  62734. */
  62735. getClassName(): string;
  62736. /**
  62737. * Gets the color input component
  62738. */
  62739. get value(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the cutoff input component
  62742. */
  62743. get cutoff(): NodeMaterialConnectionPoint;
  62744. protected _buildBlock(state: NodeMaterialBuildState): this;
  62745. }
  62746. }
  62747. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  62748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62751. /**
  62752. * Block used to test if the fragment shader is front facing
  62753. */
  62754. export class FrontFacingBlock extends NodeMaterialBlock {
  62755. /**
  62756. * Creates a new FrontFacingBlock
  62757. * @param name defines the block name
  62758. */
  62759. constructor(name: string);
  62760. /**
  62761. * Gets the current class name
  62762. * @returns the class name
  62763. */
  62764. getClassName(): string;
  62765. /**
  62766. * Gets the output component
  62767. */
  62768. get output(): NodeMaterialConnectionPoint;
  62769. protected _buildBlock(state: NodeMaterialBuildState): this;
  62770. }
  62771. }
  62772. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  62773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62776. /**
  62777. * Block used to get the derivative value on x and y of a given input
  62778. */
  62779. export class DerivativeBlock extends NodeMaterialBlock {
  62780. /**
  62781. * Create a new DerivativeBlock
  62782. * @param name defines the block name
  62783. */
  62784. constructor(name: string);
  62785. /**
  62786. * Gets the current class name
  62787. * @returns the class name
  62788. */
  62789. getClassName(): string;
  62790. /**
  62791. * Gets the input component
  62792. */
  62793. get input(): NodeMaterialConnectionPoint;
  62794. /**
  62795. * Gets the derivative output on x
  62796. */
  62797. get dx(): NodeMaterialConnectionPoint;
  62798. /**
  62799. * Gets the derivative output on y
  62800. */
  62801. get dy(): NodeMaterialConnectionPoint;
  62802. protected _buildBlock(state: NodeMaterialBuildState): this;
  62803. }
  62804. }
  62805. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  62806. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  62807. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  62808. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  62809. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  62810. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  62811. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  62812. }
  62813. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  62814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62816. import { Mesh } from "babylonjs/Meshes/mesh";
  62817. import { Effect } from "babylonjs/Materials/effect";
  62818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62820. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62821. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  62822. /**
  62823. * Block used to add support for scene fog
  62824. */
  62825. export class FogBlock extends NodeMaterialBlock {
  62826. private _fogDistanceName;
  62827. private _fogParameters;
  62828. /**
  62829. * Create a new FogBlock
  62830. * @param name defines the block name
  62831. */
  62832. constructor(name: string);
  62833. /**
  62834. * Gets the current class name
  62835. * @returns the class name
  62836. */
  62837. getClassName(): string;
  62838. /**
  62839. * Gets the world position input component
  62840. */
  62841. get worldPosition(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the view input component
  62844. */
  62845. get view(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the color input component
  62848. */
  62849. get input(): NodeMaterialConnectionPoint;
  62850. /**
  62851. * Gets the fog color input component
  62852. */
  62853. get fogColor(): NodeMaterialConnectionPoint;
  62854. /**
  62855. * Gets the output component
  62856. */
  62857. get output(): NodeMaterialConnectionPoint;
  62858. autoConfigure(material: NodeMaterial): void;
  62859. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62860. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62861. protected _buildBlock(state: NodeMaterialBuildState): this;
  62862. }
  62863. }
  62864. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  62865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62869. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62870. import { Effect } from "babylonjs/Materials/effect";
  62871. import { Mesh } from "babylonjs/Meshes/mesh";
  62872. import { Light } from "babylonjs/Lights/light";
  62873. import { Nullable } from "babylonjs/types";
  62874. import { Scene } from "babylonjs/scene";
  62875. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  62876. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  62877. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  62878. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62879. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  62880. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  62881. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  62882. /**
  62883. * Block used to add light in the fragment shader
  62884. */
  62885. export class LightBlock extends NodeMaterialBlock {
  62886. private _lightId;
  62887. /**
  62888. * Gets or sets the light associated with this block
  62889. */
  62890. light: Nullable<Light>;
  62891. /**
  62892. * Create a new LightBlock
  62893. * @param name defines the block name
  62894. */
  62895. constructor(name: string);
  62896. /**
  62897. * Gets the current class name
  62898. * @returns the class name
  62899. */
  62900. getClassName(): string;
  62901. /**
  62902. * Gets the world position input component
  62903. */
  62904. get worldPosition(): NodeMaterialConnectionPoint;
  62905. /**
  62906. * Gets the world normal input component
  62907. */
  62908. get worldNormal(): NodeMaterialConnectionPoint;
  62909. /**
  62910. * Gets the camera (or eye) position component
  62911. */
  62912. get cameraPosition(): NodeMaterialConnectionPoint;
  62913. /**
  62914. * Gets the glossiness component
  62915. */
  62916. get glossiness(): NodeMaterialConnectionPoint;
  62917. /**
  62918. * Gets the glossinness power component
  62919. */
  62920. get glossPower(): NodeMaterialConnectionPoint;
  62921. /**
  62922. * Gets the diffuse color component
  62923. */
  62924. get diffuseColor(): NodeMaterialConnectionPoint;
  62925. /**
  62926. * Gets the specular color component
  62927. */
  62928. get specularColor(): NodeMaterialConnectionPoint;
  62929. /**
  62930. * Gets the diffuse output component
  62931. */
  62932. get diffuseOutput(): NodeMaterialConnectionPoint;
  62933. /**
  62934. * Gets the specular output component
  62935. */
  62936. get specularOutput(): NodeMaterialConnectionPoint;
  62937. /**
  62938. * Gets the shadow output component
  62939. */
  62940. get shadow(): NodeMaterialConnectionPoint;
  62941. autoConfigure(material: NodeMaterial): void;
  62942. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62943. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62944. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62945. private _injectVertexCode;
  62946. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62947. serialize(): any;
  62948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62949. }
  62950. }
  62951. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  62952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62954. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62955. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  62956. /**
  62957. * Block used to read a reflection texture from a sampler
  62958. */
  62959. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62960. /**
  62961. * Create a new ReflectionTextureBlock
  62962. * @param name defines the block name
  62963. */
  62964. constructor(name: string);
  62965. /**
  62966. * Gets the current class name
  62967. * @returns the class name
  62968. */
  62969. getClassName(): string;
  62970. /**
  62971. * Gets the world position input component
  62972. */
  62973. get position(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the world position input component
  62976. */
  62977. get worldPosition(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the world normal input component
  62980. */
  62981. get worldNormal(): NodeMaterialConnectionPoint;
  62982. /**
  62983. * Gets the world input component
  62984. */
  62985. get world(): NodeMaterialConnectionPoint;
  62986. /**
  62987. * Gets the camera (or eye) position component
  62988. */
  62989. get cameraPosition(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the view input component
  62992. */
  62993. get view(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the rgb output component
  62996. */
  62997. get rgb(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the r output component
  63000. */
  63001. get r(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the g output component
  63004. */
  63005. get g(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the b output component
  63008. */
  63009. get b(): NodeMaterialConnectionPoint;
  63010. autoConfigure(material: NodeMaterial): void;
  63011. protected _buildBlock(state: NodeMaterialBuildState): this;
  63012. }
  63013. }
  63014. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  63015. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  63016. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  63017. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  63018. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  63019. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  63020. }
  63021. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  63022. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  63023. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  63024. }
  63025. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  63026. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63027. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63029. /**
  63030. * Block used to add 2 vectors
  63031. */
  63032. export class AddBlock extends NodeMaterialBlock {
  63033. /**
  63034. * Creates a new AddBlock
  63035. * @param name defines the block name
  63036. */
  63037. constructor(name: string);
  63038. /**
  63039. * Gets the current class name
  63040. * @returns the class name
  63041. */
  63042. getClassName(): string;
  63043. /**
  63044. * Gets the left operand input component
  63045. */
  63046. get left(): NodeMaterialConnectionPoint;
  63047. /**
  63048. * Gets the right operand input component
  63049. */
  63050. get right(): NodeMaterialConnectionPoint;
  63051. /**
  63052. * Gets the output component
  63053. */
  63054. get output(): NodeMaterialConnectionPoint;
  63055. protected _buildBlock(state: NodeMaterialBuildState): this;
  63056. }
  63057. }
  63058. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  63059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63062. /**
  63063. * Block used to scale a vector by a float
  63064. */
  63065. export class ScaleBlock extends NodeMaterialBlock {
  63066. /**
  63067. * Creates a new ScaleBlock
  63068. * @param name defines the block name
  63069. */
  63070. constructor(name: string);
  63071. /**
  63072. * Gets the current class name
  63073. * @returns the class name
  63074. */
  63075. getClassName(): string;
  63076. /**
  63077. * Gets the input component
  63078. */
  63079. get input(): NodeMaterialConnectionPoint;
  63080. /**
  63081. * Gets the factor input component
  63082. */
  63083. get factor(): NodeMaterialConnectionPoint;
  63084. /**
  63085. * Gets the output component
  63086. */
  63087. get output(): NodeMaterialConnectionPoint;
  63088. protected _buildBlock(state: NodeMaterialBuildState): this;
  63089. }
  63090. }
  63091. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  63092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63095. import { Scene } from "babylonjs/scene";
  63096. /**
  63097. * Block used to clamp a float
  63098. */
  63099. export class ClampBlock extends NodeMaterialBlock {
  63100. /** Gets or sets the minimum range */
  63101. minimum: number;
  63102. /** Gets or sets the maximum range */
  63103. maximum: number;
  63104. /**
  63105. * Creates a new ClampBlock
  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 value input component
  63116. */
  63117. get value(): NodeMaterialConnectionPoint;
  63118. /**
  63119. * Gets the output component
  63120. */
  63121. get output(): NodeMaterialConnectionPoint;
  63122. protected _buildBlock(state: NodeMaterialBuildState): this;
  63123. protected _dumpPropertiesCode(): string;
  63124. serialize(): any;
  63125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63126. }
  63127. }
  63128. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  63129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63132. /**
  63133. * Block used to apply a cross product between 2 vectors
  63134. */
  63135. export class CrossBlock extends NodeMaterialBlock {
  63136. /**
  63137. * Creates a new CrossBlock
  63138. * @param name defines the block name
  63139. */
  63140. constructor(name: string);
  63141. /**
  63142. * Gets the current class name
  63143. * @returns the class name
  63144. */
  63145. getClassName(): string;
  63146. /**
  63147. * Gets the left operand input component
  63148. */
  63149. get left(): NodeMaterialConnectionPoint;
  63150. /**
  63151. * Gets the right operand input component
  63152. */
  63153. get right(): NodeMaterialConnectionPoint;
  63154. /**
  63155. * Gets the output component
  63156. */
  63157. get output(): NodeMaterialConnectionPoint;
  63158. protected _buildBlock(state: NodeMaterialBuildState): this;
  63159. }
  63160. }
  63161. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  63162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63165. /**
  63166. * Block used to apply a dot product between 2 vectors
  63167. */
  63168. export class DotBlock extends NodeMaterialBlock {
  63169. /**
  63170. * Creates a new DotBlock
  63171. * @param name defines the block name
  63172. */
  63173. constructor(name: string);
  63174. /**
  63175. * Gets the current class name
  63176. * @returns the class name
  63177. */
  63178. getClassName(): string;
  63179. /**
  63180. * Gets the left operand input component
  63181. */
  63182. get left(): NodeMaterialConnectionPoint;
  63183. /**
  63184. * Gets the right operand input component
  63185. */
  63186. get right(): NodeMaterialConnectionPoint;
  63187. /**
  63188. * Gets the output component
  63189. */
  63190. get output(): NodeMaterialConnectionPoint;
  63191. protected _buildBlock(state: NodeMaterialBuildState): this;
  63192. }
  63193. }
  63194. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  63195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63198. /**
  63199. * Block used to normalize a vector
  63200. */
  63201. export class NormalizeBlock extends NodeMaterialBlock {
  63202. /**
  63203. * Creates a new NormalizeBlock
  63204. * @param name defines the block name
  63205. */
  63206. constructor(name: string);
  63207. /**
  63208. * Gets the current class name
  63209. * @returns the class name
  63210. */
  63211. getClassName(): string;
  63212. /**
  63213. * Gets the input component
  63214. */
  63215. get input(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the output component
  63218. */
  63219. get output(): NodeMaterialConnectionPoint;
  63220. protected _buildBlock(state: NodeMaterialBuildState): this;
  63221. }
  63222. }
  63223. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  63224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63227. import { Scene } from "babylonjs/scene";
  63228. /**
  63229. * Operations supported by the Trigonometry block
  63230. */
  63231. export enum TrigonometryBlockOperations {
  63232. /** Cos */
  63233. Cos = 0,
  63234. /** Sin */
  63235. Sin = 1,
  63236. /** Abs */
  63237. Abs = 2,
  63238. /** Exp */
  63239. Exp = 3,
  63240. /** Exp2 */
  63241. Exp2 = 4,
  63242. /** Round */
  63243. Round = 5,
  63244. /** Floor */
  63245. Floor = 6,
  63246. /** Ceiling */
  63247. Ceiling = 7,
  63248. /** Square root */
  63249. Sqrt = 8,
  63250. /** Log */
  63251. Log = 9,
  63252. /** Tangent */
  63253. Tan = 10,
  63254. /** Arc tangent */
  63255. ArcTan = 11,
  63256. /** Arc cosinus */
  63257. ArcCos = 12,
  63258. /** Arc sinus */
  63259. ArcSin = 13,
  63260. /** Fraction */
  63261. Fract = 14,
  63262. /** Sign */
  63263. Sign = 15,
  63264. /** To radians (from degrees) */
  63265. Radians = 16,
  63266. /** To degrees (from radians) */
  63267. Degrees = 17
  63268. }
  63269. /**
  63270. * Block used to apply trigonometry operation to floats
  63271. */
  63272. export class TrigonometryBlock extends NodeMaterialBlock {
  63273. /**
  63274. * Gets or sets the operation applied by the block
  63275. */
  63276. operation: TrigonometryBlockOperations;
  63277. /**
  63278. * Creates a new TrigonometryBlock
  63279. * @param name defines the block name
  63280. */
  63281. constructor(name: string);
  63282. /**
  63283. * Gets the current class name
  63284. * @returns the class name
  63285. */
  63286. getClassName(): string;
  63287. /**
  63288. * Gets the input component
  63289. */
  63290. get input(): NodeMaterialConnectionPoint;
  63291. /**
  63292. * Gets the output component
  63293. */
  63294. get output(): NodeMaterialConnectionPoint;
  63295. protected _buildBlock(state: NodeMaterialBuildState): this;
  63296. serialize(): any;
  63297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63298. protected _dumpPropertiesCode(): string;
  63299. }
  63300. }
  63301. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  63302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63305. /**
  63306. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63307. */
  63308. export class ColorMergerBlock extends NodeMaterialBlock {
  63309. /**
  63310. * Create a new ColorMergerBlock
  63311. * @param name defines the block name
  63312. */
  63313. constructor(name: string);
  63314. /**
  63315. * Gets the current class name
  63316. * @returns the class name
  63317. */
  63318. getClassName(): string;
  63319. /**
  63320. * Gets the rgb component (input)
  63321. */
  63322. get rgbIn(): NodeMaterialConnectionPoint;
  63323. /**
  63324. * Gets the r component (input)
  63325. */
  63326. get r(): NodeMaterialConnectionPoint;
  63327. /**
  63328. * Gets the g component (input)
  63329. */
  63330. get g(): NodeMaterialConnectionPoint;
  63331. /**
  63332. * Gets the b component (input)
  63333. */
  63334. get b(): NodeMaterialConnectionPoint;
  63335. /**
  63336. * Gets the a component (input)
  63337. */
  63338. get a(): NodeMaterialConnectionPoint;
  63339. /**
  63340. * Gets the rgba component (output)
  63341. */
  63342. get rgba(): NodeMaterialConnectionPoint;
  63343. /**
  63344. * Gets the rgb component (output)
  63345. */
  63346. get rgbOut(): NodeMaterialConnectionPoint;
  63347. /**
  63348. * Gets the rgb component (output)
  63349. * @deprecated Please use rgbOut instead.
  63350. */
  63351. get rgb(): NodeMaterialConnectionPoint;
  63352. protected _buildBlock(state: NodeMaterialBuildState): this;
  63353. }
  63354. }
  63355. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  63356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63359. /**
  63360. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  63361. */
  63362. export class ColorSplitterBlock extends NodeMaterialBlock {
  63363. /**
  63364. * Create a new ColorSplitterBlock
  63365. * @param name defines the block name
  63366. */
  63367. constructor(name: string);
  63368. /**
  63369. * Gets the current class name
  63370. * @returns the class name
  63371. */
  63372. getClassName(): string;
  63373. /**
  63374. * Gets the rgba component (input)
  63375. */
  63376. get rgba(): NodeMaterialConnectionPoint;
  63377. /**
  63378. * Gets the rgb component (input)
  63379. */
  63380. get rgbIn(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the rgb component (output)
  63383. */
  63384. get rgbOut(): NodeMaterialConnectionPoint;
  63385. /**
  63386. * Gets the r component (output)
  63387. */
  63388. get r(): NodeMaterialConnectionPoint;
  63389. /**
  63390. * Gets the g component (output)
  63391. */
  63392. get g(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the b component (output)
  63395. */
  63396. get b(): NodeMaterialConnectionPoint;
  63397. /**
  63398. * Gets the a component (output)
  63399. */
  63400. get a(): NodeMaterialConnectionPoint;
  63401. protected _inputRename(name: string): string;
  63402. protected _outputRename(name: string): string;
  63403. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63404. }
  63405. }
  63406. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  63407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63410. /**
  63411. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63412. */
  63413. export class VectorSplitterBlock extends NodeMaterialBlock {
  63414. /**
  63415. * Create a new VectorSplitterBlock
  63416. * @param name defines the block name
  63417. */
  63418. constructor(name: string);
  63419. /**
  63420. * Gets the current class name
  63421. * @returns the class name
  63422. */
  63423. getClassName(): string;
  63424. /**
  63425. * Gets the xyzw component (input)
  63426. */
  63427. get xyzw(): NodeMaterialConnectionPoint;
  63428. /**
  63429. * Gets the xyz component (input)
  63430. */
  63431. get xyzIn(): NodeMaterialConnectionPoint;
  63432. /**
  63433. * Gets the xy component (input)
  63434. */
  63435. get xyIn(): NodeMaterialConnectionPoint;
  63436. /**
  63437. * Gets the xyz component (output)
  63438. */
  63439. get xyzOut(): NodeMaterialConnectionPoint;
  63440. /**
  63441. * Gets the xy component (output)
  63442. */
  63443. get xyOut(): NodeMaterialConnectionPoint;
  63444. /**
  63445. * Gets the x component (output)
  63446. */
  63447. get x(): NodeMaterialConnectionPoint;
  63448. /**
  63449. * Gets the y component (output)
  63450. */
  63451. get y(): NodeMaterialConnectionPoint;
  63452. /**
  63453. * Gets the z component (output)
  63454. */
  63455. get z(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the w component (output)
  63458. */
  63459. get w(): NodeMaterialConnectionPoint;
  63460. protected _inputRename(name: string): string;
  63461. protected _outputRename(name: string): string;
  63462. protected _buildBlock(state: NodeMaterialBuildState): this;
  63463. }
  63464. }
  63465. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  63466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63469. /**
  63470. * Block used to lerp between 2 values
  63471. */
  63472. export class LerpBlock extends NodeMaterialBlock {
  63473. /**
  63474. * Creates a new LerpBlock
  63475. * @param name defines the block name
  63476. */
  63477. constructor(name: string);
  63478. /**
  63479. * Gets the current class name
  63480. * @returns the class name
  63481. */
  63482. getClassName(): string;
  63483. /**
  63484. * Gets the left operand input component
  63485. */
  63486. get left(): NodeMaterialConnectionPoint;
  63487. /**
  63488. * Gets the right operand input component
  63489. */
  63490. get right(): NodeMaterialConnectionPoint;
  63491. /**
  63492. * Gets the gradient operand input component
  63493. */
  63494. get gradient(): NodeMaterialConnectionPoint;
  63495. /**
  63496. * Gets the output component
  63497. */
  63498. get output(): NodeMaterialConnectionPoint;
  63499. protected _buildBlock(state: NodeMaterialBuildState): this;
  63500. }
  63501. }
  63502. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  63503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63506. /**
  63507. * Block used to divide 2 vectors
  63508. */
  63509. export class DivideBlock extends NodeMaterialBlock {
  63510. /**
  63511. * Creates a new DivideBlock
  63512. * @param name defines the block name
  63513. */
  63514. constructor(name: string);
  63515. /**
  63516. * Gets the current class name
  63517. * @returns the class name
  63518. */
  63519. getClassName(): string;
  63520. /**
  63521. * Gets the left operand input component
  63522. */
  63523. get left(): NodeMaterialConnectionPoint;
  63524. /**
  63525. * Gets the right operand input component
  63526. */
  63527. get right(): NodeMaterialConnectionPoint;
  63528. /**
  63529. * Gets the output component
  63530. */
  63531. get output(): NodeMaterialConnectionPoint;
  63532. protected _buildBlock(state: NodeMaterialBuildState): this;
  63533. }
  63534. }
  63535. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  63536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63539. /**
  63540. * Block used to subtract 2 vectors
  63541. */
  63542. export class SubtractBlock extends NodeMaterialBlock {
  63543. /**
  63544. * Creates a new SubtractBlock
  63545. * @param name defines the block name
  63546. */
  63547. constructor(name: string);
  63548. /**
  63549. * Gets the current class name
  63550. * @returns the class name
  63551. */
  63552. getClassName(): string;
  63553. /**
  63554. * Gets the left operand input component
  63555. */
  63556. get left(): NodeMaterialConnectionPoint;
  63557. /**
  63558. * Gets the right operand input component
  63559. */
  63560. get right(): NodeMaterialConnectionPoint;
  63561. /**
  63562. * Gets the output component
  63563. */
  63564. get output(): NodeMaterialConnectionPoint;
  63565. protected _buildBlock(state: NodeMaterialBuildState): this;
  63566. }
  63567. }
  63568. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  63569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63572. /**
  63573. * Block used to step a value
  63574. */
  63575. export class StepBlock extends NodeMaterialBlock {
  63576. /**
  63577. * Creates a new StepBlock
  63578. * @param name defines the block name
  63579. */
  63580. constructor(name: string);
  63581. /**
  63582. * Gets the current class name
  63583. * @returns the class name
  63584. */
  63585. getClassName(): string;
  63586. /**
  63587. * Gets the value operand input component
  63588. */
  63589. get value(): NodeMaterialConnectionPoint;
  63590. /**
  63591. * Gets the edge operand input component
  63592. */
  63593. get edge(): NodeMaterialConnectionPoint;
  63594. /**
  63595. * Gets the output component
  63596. */
  63597. get output(): NodeMaterialConnectionPoint;
  63598. protected _buildBlock(state: NodeMaterialBuildState): this;
  63599. }
  63600. }
  63601. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  63602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63605. /**
  63606. * Block used to get the opposite (1 - x) of a value
  63607. */
  63608. export class OneMinusBlock extends NodeMaterialBlock {
  63609. /**
  63610. * Creates a new OneMinusBlock
  63611. * @param name defines the block name
  63612. */
  63613. constructor(name: string);
  63614. /**
  63615. * Gets the current class name
  63616. * @returns the class name
  63617. */
  63618. getClassName(): string;
  63619. /**
  63620. * Gets the input component
  63621. */
  63622. get input(): NodeMaterialConnectionPoint;
  63623. /**
  63624. * Gets the output component
  63625. */
  63626. get output(): NodeMaterialConnectionPoint;
  63627. protected _buildBlock(state: NodeMaterialBuildState): this;
  63628. }
  63629. }
  63630. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  63631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63634. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63635. /**
  63636. * Block used to get the view direction
  63637. */
  63638. export class ViewDirectionBlock extends NodeMaterialBlock {
  63639. /**
  63640. * Creates a new ViewDirectionBlock
  63641. * @param name defines the block name
  63642. */
  63643. constructor(name: string);
  63644. /**
  63645. * Gets the current class name
  63646. * @returns the class name
  63647. */
  63648. getClassName(): string;
  63649. /**
  63650. * Gets the world position component
  63651. */
  63652. get worldPosition(): NodeMaterialConnectionPoint;
  63653. /**
  63654. * Gets the camera position component
  63655. */
  63656. get cameraPosition(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the output component
  63659. */
  63660. get output(): NodeMaterialConnectionPoint;
  63661. autoConfigure(material: NodeMaterial): void;
  63662. protected _buildBlock(state: NodeMaterialBuildState): this;
  63663. }
  63664. }
  63665. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  63666. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63667. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63668. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63669. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63670. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  63671. /**
  63672. * Block used to compute fresnel value
  63673. */
  63674. export class FresnelBlock extends NodeMaterialBlock {
  63675. /**
  63676. * Create a new FresnelBlock
  63677. * @param name defines the block name
  63678. */
  63679. constructor(name: string);
  63680. /**
  63681. * Gets the current class name
  63682. * @returns the class name
  63683. */
  63684. getClassName(): string;
  63685. /**
  63686. * Gets the world normal input component
  63687. */
  63688. get worldNormal(): NodeMaterialConnectionPoint;
  63689. /**
  63690. * Gets the view direction input component
  63691. */
  63692. get viewDirection(): NodeMaterialConnectionPoint;
  63693. /**
  63694. * Gets the bias input component
  63695. */
  63696. get bias(): NodeMaterialConnectionPoint;
  63697. /**
  63698. * Gets the camera (or eye) position component
  63699. */
  63700. get power(): NodeMaterialConnectionPoint;
  63701. /**
  63702. * Gets the fresnel output component
  63703. */
  63704. get fresnel(): NodeMaterialConnectionPoint;
  63705. autoConfigure(material: NodeMaterial): void;
  63706. protected _buildBlock(state: NodeMaterialBuildState): this;
  63707. }
  63708. }
  63709. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  63710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63713. /**
  63714. * Block used to get the max of 2 values
  63715. */
  63716. export class MaxBlock extends NodeMaterialBlock {
  63717. /**
  63718. * Creates a new MaxBlock
  63719. * @param name defines the block name
  63720. */
  63721. constructor(name: string);
  63722. /**
  63723. * Gets the current class name
  63724. * @returns the class name
  63725. */
  63726. getClassName(): string;
  63727. /**
  63728. * Gets the left operand input component
  63729. */
  63730. get left(): NodeMaterialConnectionPoint;
  63731. /**
  63732. * Gets the right operand input component
  63733. */
  63734. get right(): NodeMaterialConnectionPoint;
  63735. /**
  63736. * Gets the output component
  63737. */
  63738. get output(): NodeMaterialConnectionPoint;
  63739. protected _buildBlock(state: NodeMaterialBuildState): this;
  63740. }
  63741. }
  63742. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  63743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63746. /**
  63747. * Block used to get the min of 2 values
  63748. */
  63749. export class MinBlock extends NodeMaterialBlock {
  63750. /**
  63751. * Creates a new MinBlock
  63752. * @param name defines the block name
  63753. */
  63754. constructor(name: string);
  63755. /**
  63756. * Gets the current class name
  63757. * @returns the class name
  63758. */
  63759. getClassName(): string;
  63760. /**
  63761. * Gets the left operand input component
  63762. */
  63763. get left(): NodeMaterialConnectionPoint;
  63764. /**
  63765. * Gets the right operand input component
  63766. */
  63767. get right(): NodeMaterialConnectionPoint;
  63768. /**
  63769. * Gets the output component
  63770. */
  63771. get output(): NodeMaterialConnectionPoint;
  63772. protected _buildBlock(state: NodeMaterialBuildState): this;
  63773. }
  63774. }
  63775. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  63776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63778. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63779. /**
  63780. * Block used to get the distance between 2 values
  63781. */
  63782. export class DistanceBlock extends NodeMaterialBlock {
  63783. /**
  63784. * Creates a new DistanceBlock
  63785. * @param name defines the block name
  63786. */
  63787. constructor(name: string);
  63788. /**
  63789. * Gets the current class name
  63790. * @returns the class name
  63791. */
  63792. getClassName(): string;
  63793. /**
  63794. * Gets the left operand input component
  63795. */
  63796. get left(): NodeMaterialConnectionPoint;
  63797. /**
  63798. * Gets the right operand input component
  63799. */
  63800. get right(): NodeMaterialConnectionPoint;
  63801. /**
  63802. * Gets the output component
  63803. */
  63804. get output(): NodeMaterialConnectionPoint;
  63805. protected _buildBlock(state: NodeMaterialBuildState): this;
  63806. }
  63807. }
  63808. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  63809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63812. /**
  63813. * Block used to get the length of a vector
  63814. */
  63815. export class LengthBlock extends NodeMaterialBlock {
  63816. /**
  63817. * Creates a new LengthBlock
  63818. * @param name defines the block name
  63819. */
  63820. constructor(name: string);
  63821. /**
  63822. * Gets the current class name
  63823. * @returns the class name
  63824. */
  63825. getClassName(): string;
  63826. /**
  63827. * Gets the value input component
  63828. */
  63829. get value(): NodeMaterialConnectionPoint;
  63830. /**
  63831. * Gets the output component
  63832. */
  63833. get output(): NodeMaterialConnectionPoint;
  63834. protected _buildBlock(state: NodeMaterialBuildState): this;
  63835. }
  63836. }
  63837. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63841. /**
  63842. * Block used to get negative version of a value (i.e. x * -1)
  63843. */
  63844. export class NegateBlock extends NodeMaterialBlock {
  63845. /**
  63846. * Creates a new NegateBlock
  63847. * @param name defines the block name
  63848. */
  63849. constructor(name: string);
  63850. /**
  63851. * Gets the current class name
  63852. * @returns the class name
  63853. */
  63854. getClassName(): string;
  63855. /**
  63856. * Gets the value input component
  63857. */
  63858. get value(): NodeMaterialConnectionPoint;
  63859. /**
  63860. * Gets the output component
  63861. */
  63862. get output(): NodeMaterialConnectionPoint;
  63863. protected _buildBlock(state: NodeMaterialBuildState): this;
  63864. }
  63865. }
  63866. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63870. /**
  63871. * Block used to get the value of the first parameter raised to the power of the second
  63872. */
  63873. export class PowBlock extends NodeMaterialBlock {
  63874. /**
  63875. * Creates a new PowBlock
  63876. * @param name defines the block name
  63877. */
  63878. constructor(name: string);
  63879. /**
  63880. * Gets the current class name
  63881. * @returns the class name
  63882. */
  63883. getClassName(): string;
  63884. /**
  63885. * Gets the value operand input component
  63886. */
  63887. get value(): NodeMaterialConnectionPoint;
  63888. /**
  63889. * Gets the power operand input component
  63890. */
  63891. get power(): NodeMaterialConnectionPoint;
  63892. /**
  63893. * Gets the output component
  63894. */
  63895. get output(): NodeMaterialConnectionPoint;
  63896. protected _buildBlock(state: NodeMaterialBuildState): this;
  63897. }
  63898. }
  63899. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63904. /**
  63905. * Block used to get a random number
  63906. */
  63907. export class RandomNumberBlock extends NodeMaterialBlock {
  63908. /**
  63909. * Creates a new RandomNumberBlock
  63910. * @param name defines the block name
  63911. */
  63912. constructor(name: string);
  63913. /**
  63914. * Gets the current class name
  63915. * @returns the class name
  63916. */
  63917. getClassName(): string;
  63918. /**
  63919. * Gets the seed input component
  63920. */
  63921. get seed(): NodeMaterialConnectionPoint;
  63922. /**
  63923. * Gets the output component
  63924. */
  63925. get output(): NodeMaterialConnectionPoint;
  63926. protected _buildBlock(state: NodeMaterialBuildState): this;
  63927. }
  63928. }
  63929. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63933. /**
  63934. * Block used to compute arc tangent of 2 values
  63935. */
  63936. export class ArcTan2Block extends NodeMaterialBlock {
  63937. /**
  63938. * Creates a new ArcTan2Block
  63939. * @param name defines the block name
  63940. */
  63941. constructor(name: string);
  63942. /**
  63943. * Gets the current class name
  63944. * @returns the class name
  63945. */
  63946. getClassName(): string;
  63947. /**
  63948. * Gets the x operand input component
  63949. */
  63950. get x(): NodeMaterialConnectionPoint;
  63951. /**
  63952. * Gets the y operand input component
  63953. */
  63954. get y(): NodeMaterialConnectionPoint;
  63955. /**
  63956. * Gets the output component
  63957. */
  63958. get output(): NodeMaterialConnectionPoint;
  63959. protected _buildBlock(state: NodeMaterialBuildState): this;
  63960. }
  63961. }
  63962. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63966. /**
  63967. * Block used to smooth step a value
  63968. */
  63969. export class SmoothStepBlock extends NodeMaterialBlock {
  63970. /**
  63971. * Creates a new SmoothStepBlock
  63972. * @param name defines the block name
  63973. */
  63974. constructor(name: string);
  63975. /**
  63976. * Gets the current class name
  63977. * @returns the class name
  63978. */
  63979. getClassName(): string;
  63980. /**
  63981. * Gets the value operand input component
  63982. */
  63983. get value(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the first edge operand input component
  63986. */
  63987. get edge0(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the second edge operand input component
  63990. */
  63991. get edge1(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the output component
  63994. */
  63995. get output(): NodeMaterialConnectionPoint;
  63996. protected _buildBlock(state: NodeMaterialBuildState): this;
  63997. }
  63998. }
  63999. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  64000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64003. /**
  64004. * Block used to get the reciprocal (1 / x) of a value
  64005. */
  64006. export class ReciprocalBlock extends NodeMaterialBlock {
  64007. /**
  64008. * Creates a new ReciprocalBlock
  64009. * @param name defines the block name
  64010. */
  64011. constructor(name: string);
  64012. /**
  64013. * Gets the current class name
  64014. * @returns the class name
  64015. */
  64016. getClassName(): string;
  64017. /**
  64018. * Gets the input component
  64019. */
  64020. get input(): NodeMaterialConnectionPoint;
  64021. /**
  64022. * Gets the output component
  64023. */
  64024. get output(): NodeMaterialConnectionPoint;
  64025. protected _buildBlock(state: NodeMaterialBuildState): this;
  64026. }
  64027. }
  64028. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  64029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64032. /**
  64033. * Block used to replace a color by another one
  64034. */
  64035. export class ReplaceColorBlock extends NodeMaterialBlock {
  64036. /**
  64037. * Creates a new ReplaceColorBlock
  64038. * @param name defines the block name
  64039. */
  64040. constructor(name: string);
  64041. /**
  64042. * Gets the current class name
  64043. * @returns the class name
  64044. */
  64045. getClassName(): string;
  64046. /**
  64047. * Gets the value input component
  64048. */
  64049. get value(): NodeMaterialConnectionPoint;
  64050. /**
  64051. * Gets the reference input component
  64052. */
  64053. get reference(): NodeMaterialConnectionPoint;
  64054. /**
  64055. * Gets the distance input component
  64056. */
  64057. get distance(): NodeMaterialConnectionPoint;
  64058. /**
  64059. * Gets the replacement input component
  64060. */
  64061. get replacement(): NodeMaterialConnectionPoint;
  64062. /**
  64063. * Gets the output component
  64064. */
  64065. get output(): NodeMaterialConnectionPoint;
  64066. protected _buildBlock(state: NodeMaterialBuildState): this;
  64067. }
  64068. }
  64069. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  64070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64073. /**
  64074. * Block used to posterize a value
  64075. * @see https://en.wikipedia.org/wiki/Posterization
  64076. */
  64077. export class PosterizeBlock extends NodeMaterialBlock {
  64078. /**
  64079. * Creates a new PosterizeBlock
  64080. * @param name defines the block name
  64081. */
  64082. constructor(name: string);
  64083. /**
  64084. * Gets the current class name
  64085. * @returns the class name
  64086. */
  64087. getClassName(): string;
  64088. /**
  64089. * Gets the value input component
  64090. */
  64091. get value(): NodeMaterialConnectionPoint;
  64092. /**
  64093. * Gets the steps input component
  64094. */
  64095. get steps(): NodeMaterialConnectionPoint;
  64096. /**
  64097. * Gets the output component
  64098. */
  64099. get output(): NodeMaterialConnectionPoint;
  64100. protected _buildBlock(state: NodeMaterialBuildState): this;
  64101. }
  64102. }
  64103. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  64104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64107. import { Scene } from "babylonjs/scene";
  64108. /**
  64109. * Operations supported by the Wave block
  64110. */
  64111. export enum WaveBlockKind {
  64112. /** SawTooth */
  64113. SawTooth = 0,
  64114. /** Square */
  64115. Square = 1,
  64116. /** Triangle */
  64117. Triangle = 2
  64118. }
  64119. /**
  64120. * Block used to apply wave operation to floats
  64121. */
  64122. export class WaveBlock extends NodeMaterialBlock {
  64123. /**
  64124. * Gets or sets the kibnd of wave to be applied by the block
  64125. */
  64126. kind: WaveBlockKind;
  64127. /**
  64128. * Creates a new WaveBlock
  64129. * @param name defines the block name
  64130. */
  64131. constructor(name: string);
  64132. /**
  64133. * Gets the current class name
  64134. * @returns the class name
  64135. */
  64136. getClassName(): string;
  64137. /**
  64138. * Gets the input component
  64139. */
  64140. get input(): NodeMaterialConnectionPoint;
  64141. /**
  64142. * Gets the output component
  64143. */
  64144. get output(): NodeMaterialConnectionPoint;
  64145. protected _buildBlock(state: NodeMaterialBuildState): this;
  64146. serialize(): any;
  64147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64148. }
  64149. }
  64150. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  64151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64154. import { Color3 } from "babylonjs/Maths/math.color";
  64155. import { Scene } from "babylonjs/scene";
  64156. /**
  64157. * Class used to store a color step for the GradientBlock
  64158. */
  64159. export class GradientBlockColorStep {
  64160. /**
  64161. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  64162. */
  64163. step: number;
  64164. /**
  64165. * Gets or sets the color associated with this step
  64166. */
  64167. color: Color3;
  64168. /**
  64169. * Creates a new GradientBlockColorStep
  64170. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64171. * @param color defines the color associated with this step
  64172. */
  64173. constructor(
  64174. /**
  64175. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  64176. */
  64177. step: number,
  64178. /**
  64179. * Gets or sets the color associated with this step
  64180. */
  64181. color: Color3);
  64182. }
  64183. /**
  64184. * Block used to return a color from a gradient based on an input value between 0 and 1
  64185. */
  64186. export class GradientBlock extends NodeMaterialBlock {
  64187. /**
  64188. * Gets or sets the list of color steps
  64189. */
  64190. colorSteps: GradientBlockColorStep[];
  64191. /**
  64192. * Creates a new GradientBlock
  64193. * @param name defines the block name
  64194. */
  64195. constructor(name: string);
  64196. /**
  64197. * Gets the current class name
  64198. * @returns the class name
  64199. */
  64200. getClassName(): string;
  64201. /**
  64202. * Gets the gradient input component
  64203. */
  64204. get gradient(): NodeMaterialConnectionPoint;
  64205. /**
  64206. * Gets the output component
  64207. */
  64208. get output(): NodeMaterialConnectionPoint;
  64209. private _writeColorConstant;
  64210. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64211. serialize(): any;
  64212. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64213. protected _dumpPropertiesCode(): string;
  64214. }
  64215. }
  64216. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  64217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64220. /**
  64221. * Block used to normalize lerp between 2 values
  64222. */
  64223. export class NLerpBlock extends NodeMaterialBlock {
  64224. /**
  64225. * Creates a new NLerpBlock
  64226. * @param name defines the block name
  64227. */
  64228. constructor(name: string);
  64229. /**
  64230. * Gets the current class name
  64231. * @returns the class name
  64232. */
  64233. getClassName(): string;
  64234. /**
  64235. * Gets the left operand input component
  64236. */
  64237. get left(): NodeMaterialConnectionPoint;
  64238. /**
  64239. * Gets the right operand input component
  64240. */
  64241. get right(): NodeMaterialConnectionPoint;
  64242. /**
  64243. * Gets the gradient operand input component
  64244. */
  64245. get gradient(): NodeMaterialConnectionPoint;
  64246. /**
  64247. * Gets the output component
  64248. */
  64249. get output(): NodeMaterialConnectionPoint;
  64250. protected _buildBlock(state: NodeMaterialBuildState): this;
  64251. }
  64252. }
  64253. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  64254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64257. import { Scene } from "babylonjs/scene";
  64258. /**
  64259. * block used to Generate a Worley Noise 3D Noise Pattern
  64260. */
  64261. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64262. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64263. manhattanDistance: boolean;
  64264. /**
  64265. * Creates a new WorleyNoise3DBlock
  64266. * @param name defines the block name
  64267. */
  64268. constructor(name: string);
  64269. /**
  64270. * Gets the current class name
  64271. * @returns the class name
  64272. */
  64273. getClassName(): string;
  64274. /**
  64275. * Gets the seed input component
  64276. */
  64277. get seed(): NodeMaterialConnectionPoint;
  64278. /**
  64279. * Gets the jitter input component
  64280. */
  64281. get jitter(): NodeMaterialConnectionPoint;
  64282. /**
  64283. * Gets the output component
  64284. */
  64285. get output(): NodeMaterialConnectionPoint;
  64286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64287. /**
  64288. * Exposes the properties to the UI?
  64289. */
  64290. protected _dumpPropertiesCode(): string;
  64291. /**
  64292. * Exposes the properties to the Seralize?
  64293. */
  64294. serialize(): any;
  64295. /**
  64296. * Exposes the properties to the deseralize?
  64297. */
  64298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64299. }
  64300. }
  64301. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  64302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64305. /**
  64306. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64307. */
  64308. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64309. /**
  64310. * Creates a new SimplexPerlin3DBlock
  64311. * @param name defines the block name
  64312. */
  64313. constructor(name: string);
  64314. /**
  64315. * Gets the current class name
  64316. * @returns the class name
  64317. */
  64318. getClassName(): string;
  64319. /**
  64320. * Gets the seed operand input component
  64321. */
  64322. get seed(): NodeMaterialConnectionPoint;
  64323. /**
  64324. * Gets the output component
  64325. */
  64326. get output(): NodeMaterialConnectionPoint;
  64327. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64328. }
  64329. }
  64330. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  64331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64334. /**
  64335. * Block used to blend normals
  64336. */
  64337. export class NormalBlendBlock extends NodeMaterialBlock {
  64338. /**
  64339. * Creates a new NormalBlendBlock
  64340. * @param name defines the block name
  64341. */
  64342. constructor(name: string);
  64343. /**
  64344. * Gets the current class name
  64345. * @returns the class name
  64346. */
  64347. getClassName(): string;
  64348. /**
  64349. * Gets the first input component
  64350. */
  64351. get normalMap0(): NodeMaterialConnectionPoint;
  64352. /**
  64353. * Gets the second input component
  64354. */
  64355. get normalMap1(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the output component
  64358. */
  64359. get output(): NodeMaterialConnectionPoint;
  64360. protected _buildBlock(state: NodeMaterialBuildState): this;
  64361. }
  64362. }
  64363. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  64364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64367. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64368. /**
  64369. * Block used to rotate a 2d vector by a given angle
  64370. */
  64371. export class Rotate2dBlock extends NodeMaterialBlock {
  64372. /**
  64373. * Creates a new Rotate2dBlock
  64374. * @param name defines the block name
  64375. */
  64376. constructor(name: string);
  64377. /**
  64378. * Gets the current class name
  64379. * @returns the class name
  64380. */
  64381. getClassName(): string;
  64382. /**
  64383. * Gets the input vector
  64384. */
  64385. get input(): NodeMaterialConnectionPoint;
  64386. /**
  64387. * Gets the input angle
  64388. */
  64389. get angle(): NodeMaterialConnectionPoint;
  64390. /**
  64391. * Gets the output component
  64392. */
  64393. get output(): NodeMaterialConnectionPoint;
  64394. autoConfigure(material: NodeMaterial): void;
  64395. protected _buildBlock(state: NodeMaterialBuildState): this;
  64396. }
  64397. }
  64398. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  64399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64402. /**
  64403. * Block used to get the reflected vector from a direction and a normal
  64404. */
  64405. export class ReflectBlock extends NodeMaterialBlock {
  64406. /**
  64407. * Creates a new ReflectBlock
  64408. * @param name defines the block name
  64409. */
  64410. constructor(name: string);
  64411. /**
  64412. * Gets the current class name
  64413. * @returns the class name
  64414. */
  64415. getClassName(): string;
  64416. /**
  64417. * Gets the incident component
  64418. */
  64419. get incident(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the normal component
  64422. */
  64423. get normal(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the output component
  64426. */
  64427. get output(): NodeMaterialConnectionPoint;
  64428. protected _buildBlock(state: NodeMaterialBuildState): this;
  64429. }
  64430. }
  64431. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  64432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64435. /**
  64436. * Block used to get the refracted vector from a direction and a normal
  64437. */
  64438. export class RefractBlock extends NodeMaterialBlock {
  64439. /**
  64440. * Creates a new RefractBlock
  64441. * @param name defines the block name
  64442. */
  64443. constructor(name: string);
  64444. /**
  64445. * Gets the current class name
  64446. * @returns the class name
  64447. */
  64448. getClassName(): string;
  64449. /**
  64450. * Gets the incident component
  64451. */
  64452. get incident(): NodeMaterialConnectionPoint;
  64453. /**
  64454. * Gets the normal component
  64455. */
  64456. get normal(): NodeMaterialConnectionPoint;
  64457. /**
  64458. * Gets the index of refraction component
  64459. */
  64460. get ior(): NodeMaterialConnectionPoint;
  64461. /**
  64462. * Gets the output component
  64463. */
  64464. get output(): NodeMaterialConnectionPoint;
  64465. protected _buildBlock(state: NodeMaterialBuildState): this;
  64466. }
  64467. }
  64468. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  64469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64472. /**
  64473. * Block used to desaturate a color
  64474. */
  64475. export class DesaturateBlock extends NodeMaterialBlock {
  64476. /**
  64477. * Creates a new DesaturateBlock
  64478. * @param name defines the block name
  64479. */
  64480. constructor(name: string);
  64481. /**
  64482. * Gets the current class name
  64483. * @returns the class name
  64484. */
  64485. getClassName(): string;
  64486. /**
  64487. * Gets the color operand input component
  64488. */
  64489. get color(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the level operand input component
  64492. */
  64493. get level(): NodeMaterialConnectionPoint;
  64494. /**
  64495. * Gets the output component
  64496. */
  64497. get output(): NodeMaterialConnectionPoint;
  64498. protected _buildBlock(state: NodeMaterialBuildState): this;
  64499. }
  64500. }
  64501. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  64502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64505. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64506. import { Nullable } from "babylonjs/types";
  64507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64508. import { Scene } from "babylonjs/scene";
  64509. /**
  64510. * Block used to implement the ambient occlusion module of the PBR material
  64511. */
  64512. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64513. /**
  64514. * Create a new AmbientOcclusionBlock
  64515. * @param name defines the block name
  64516. */
  64517. constructor(name: string);
  64518. /**
  64519. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64520. */
  64521. useAmbientInGrayScale: boolean;
  64522. /**
  64523. * Initialize the block and prepare the context for build
  64524. * @param state defines the state that will be used for the build
  64525. */
  64526. initialize(state: NodeMaterialBuildState): void;
  64527. /**
  64528. * Gets the current class name
  64529. * @returns the class name
  64530. */
  64531. getClassName(): string;
  64532. /**
  64533. * Gets the texture input component
  64534. */
  64535. get texture(): NodeMaterialConnectionPoint;
  64536. /**
  64537. * Gets the texture intensity component
  64538. */
  64539. get intensity(): NodeMaterialConnectionPoint;
  64540. /**
  64541. * Gets the direct light intensity input component
  64542. */
  64543. get directLightIntensity(): NodeMaterialConnectionPoint;
  64544. /**
  64545. * Gets the ambient occlusion object output component
  64546. */
  64547. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64548. /**
  64549. * Gets the main code of the block (fragment side)
  64550. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64551. * @returns the shader code
  64552. */
  64553. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64555. protected _buildBlock(state: NodeMaterialBuildState): this;
  64556. protected _dumpPropertiesCode(): string;
  64557. serialize(): any;
  64558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64559. }
  64560. }
  64561. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  64562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64564. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64565. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64567. import { Nullable } from "babylonjs/types";
  64568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64569. import { Mesh } from "babylonjs/Meshes/mesh";
  64570. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64571. import { Effect } from "babylonjs/Materials/effect";
  64572. import { Scene } from "babylonjs/scene";
  64573. /**
  64574. * Block used to implement the reflection module of the PBR material
  64575. */
  64576. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64577. /** @hidden */
  64578. _defineLODReflectionAlpha: string;
  64579. /** @hidden */
  64580. _defineLinearSpecularReflection: string;
  64581. private _vEnvironmentIrradianceName;
  64582. /** @hidden */
  64583. _vReflectionMicrosurfaceInfosName: string;
  64584. /** @hidden */
  64585. _vReflectionInfosName: string;
  64586. private _scene;
  64587. /**
  64588. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64589. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64590. * It's less burden on the user side in the editor part.
  64591. */
  64592. /** @hidden */
  64593. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64594. /** @hidden */
  64595. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64596. /** @hidden */
  64597. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64598. /**
  64599. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64600. * diffuse part of the IBL.
  64601. */
  64602. useSphericalHarmonics: boolean;
  64603. /**
  64604. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64605. */
  64606. forceIrradianceInFragment: boolean;
  64607. /**
  64608. * Create a new ReflectionBlock
  64609. * @param name defines the block name
  64610. */
  64611. constructor(name: string);
  64612. /**
  64613. * Gets the current class name
  64614. * @returns the class name
  64615. */
  64616. getClassName(): string;
  64617. /**
  64618. * Gets the position input component
  64619. */
  64620. get position(): NodeMaterialConnectionPoint;
  64621. /**
  64622. * Gets the world position input component
  64623. */
  64624. get worldPosition(): NodeMaterialConnectionPoint;
  64625. /**
  64626. * Gets the world normal input component
  64627. */
  64628. get worldNormal(): NodeMaterialConnectionPoint;
  64629. /**
  64630. * Gets the world input component
  64631. */
  64632. get world(): NodeMaterialConnectionPoint;
  64633. /**
  64634. * Gets the camera (or eye) position component
  64635. */
  64636. get cameraPosition(): NodeMaterialConnectionPoint;
  64637. /**
  64638. * Gets the view input component
  64639. */
  64640. get view(): NodeMaterialConnectionPoint;
  64641. /**
  64642. * Gets the color input component
  64643. */
  64644. get color(): NodeMaterialConnectionPoint;
  64645. /**
  64646. * Gets the reflection object output component
  64647. */
  64648. get reflection(): NodeMaterialConnectionPoint;
  64649. /**
  64650. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64651. */
  64652. get hasTexture(): boolean;
  64653. /**
  64654. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64655. */
  64656. get reflectionColor(): string;
  64657. protected _getTexture(): Nullable<BaseTexture>;
  64658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64659. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64660. /**
  64661. * Gets the code to inject in the vertex shader
  64662. * @param state current state of the node material building
  64663. * @returns the shader code
  64664. */
  64665. handleVertexSide(state: NodeMaterialBuildState): string;
  64666. /**
  64667. * Gets the main code of the block (fragment side)
  64668. * @param state current state of the node material building
  64669. * @param normalVarName name of the existing variable corresponding to the normal
  64670. * @returns the shader code
  64671. */
  64672. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64673. protected _buildBlock(state: NodeMaterialBuildState): this;
  64674. protected _dumpPropertiesCode(): string;
  64675. serialize(): any;
  64676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64677. }
  64678. }
  64679. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  64680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64683. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64685. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64686. import { Scene } from "babylonjs/scene";
  64687. import { Nullable } from "babylonjs/types";
  64688. /**
  64689. * Block used to implement the sheen module of the PBR material
  64690. */
  64691. export class SheenBlock extends NodeMaterialBlock {
  64692. /**
  64693. * Create a new SheenBlock
  64694. * @param name defines the block name
  64695. */
  64696. constructor(name: string);
  64697. /**
  64698. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64699. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64700. * making it easier to setup and tweak the effect
  64701. */
  64702. albedoScaling: boolean;
  64703. /**
  64704. * Defines if the sheen is linked to the sheen color.
  64705. */
  64706. linkSheenWithAlbedo: boolean;
  64707. /**
  64708. * Initialize the block and prepare the context for build
  64709. * @param state defines the state that will be used for the build
  64710. */
  64711. initialize(state: NodeMaterialBuildState): void;
  64712. /**
  64713. * Gets the current class name
  64714. * @returns the class name
  64715. */
  64716. getClassName(): string;
  64717. /**
  64718. * Gets the intensity input component
  64719. */
  64720. get intensity(): NodeMaterialConnectionPoint;
  64721. /**
  64722. * Gets the color input component
  64723. */
  64724. get color(): NodeMaterialConnectionPoint;
  64725. /**
  64726. * Gets the roughness input component
  64727. */
  64728. get roughness(): NodeMaterialConnectionPoint;
  64729. /**
  64730. * Gets the texture input component
  64731. */
  64732. get texture(): NodeMaterialConnectionPoint;
  64733. /**
  64734. * Gets the sheen object output component
  64735. */
  64736. get sheen(): NodeMaterialConnectionPoint;
  64737. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64738. /**
  64739. * Gets the main code of the block (fragment side)
  64740. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64741. * @returns the shader code
  64742. */
  64743. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64744. protected _buildBlock(state: NodeMaterialBuildState): this;
  64745. protected _dumpPropertiesCode(): string;
  64746. serialize(): any;
  64747. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64748. }
  64749. }
  64750. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  64751. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64752. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64756. import { Scene } from "babylonjs/scene";
  64757. /**
  64758. * Block used to implement the reflectivity module of the PBR material
  64759. */
  64760. export class ReflectivityBlock extends NodeMaterialBlock {
  64761. /**
  64762. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64763. */
  64764. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64765. /**
  64766. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64767. */
  64768. useMetallnessFromMetallicTextureBlue: boolean;
  64769. /**
  64770. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64771. */
  64772. useRoughnessFromMetallicTextureAlpha: boolean;
  64773. /**
  64774. * Specifies if the metallic texture contains the roughness information in its green channel.
  64775. */
  64776. useRoughnessFromMetallicTextureGreen: boolean;
  64777. /**
  64778. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  64779. */
  64780. useMetallicF0FactorFromMetallicTexture: boolean;
  64781. /**
  64782. * Create a new ReflectivityBlock
  64783. * @param name defines the block name
  64784. */
  64785. constructor(name: string);
  64786. /**
  64787. * Initialize the block and prepare the context for build
  64788. * @param state defines the state that will be used for the build
  64789. */
  64790. initialize(state: NodeMaterialBuildState): void;
  64791. /**
  64792. * Gets the current class name
  64793. * @returns the class name
  64794. */
  64795. getClassName(): string;
  64796. /**
  64797. * Gets the metallic input component
  64798. */
  64799. get metallic(): NodeMaterialConnectionPoint;
  64800. /**
  64801. * Gets the roughness input component
  64802. */
  64803. get roughness(): NodeMaterialConnectionPoint;
  64804. /**
  64805. * Gets the texture input component
  64806. */
  64807. get texture(): NodeMaterialConnectionPoint;
  64808. /**
  64809. * Gets the reflectivity object output component
  64810. */
  64811. get reflectivity(): NodeMaterialConnectionPoint;
  64812. /**
  64813. * Gets the main code of the block (fragment side)
  64814. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64815. * @returns the shader code
  64816. */
  64817. getCode(aoIntensityVarName: string): string;
  64818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64819. protected _buildBlock(state: NodeMaterialBuildState): this;
  64820. protected _dumpPropertiesCode(): string;
  64821. serialize(): any;
  64822. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64823. }
  64824. }
  64825. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  64826. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64831. /**
  64832. * Block used to implement the anisotropy module of the PBR material
  64833. */
  64834. export class AnisotropyBlock extends NodeMaterialBlock {
  64835. /**
  64836. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64837. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64838. * It's less burden on the user side in the editor part.
  64839. */
  64840. /** @hidden */
  64841. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64842. /** @hidden */
  64843. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64844. /**
  64845. * Create a new AnisotropyBlock
  64846. * @param name defines the block name
  64847. */
  64848. constructor(name: string);
  64849. /**
  64850. * Initialize the block and prepare the context for build
  64851. * @param state defines the state that will be used for the build
  64852. */
  64853. initialize(state: NodeMaterialBuildState): void;
  64854. /**
  64855. * Gets the current class name
  64856. * @returns the class name
  64857. */
  64858. getClassName(): string;
  64859. /**
  64860. * Gets the intensity input component
  64861. */
  64862. get intensity(): NodeMaterialConnectionPoint;
  64863. /**
  64864. * Gets the direction input component
  64865. */
  64866. get direction(): NodeMaterialConnectionPoint;
  64867. /**
  64868. * Gets the texture input component
  64869. */
  64870. get texture(): NodeMaterialConnectionPoint;
  64871. /**
  64872. * Gets the uv input component
  64873. */
  64874. get uv(): NodeMaterialConnectionPoint;
  64875. /**
  64876. * Gets the worldTangent input component
  64877. */
  64878. get worldTangent(): NodeMaterialConnectionPoint;
  64879. /**
  64880. * Gets the anisotropy object output component
  64881. */
  64882. get anisotropy(): NodeMaterialConnectionPoint;
  64883. private _generateTBNSpace;
  64884. /**
  64885. * Gets the main code of the block (fragment side)
  64886. * @param state current state of the node material building
  64887. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64888. * @returns the shader code
  64889. */
  64890. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64892. protected _buildBlock(state: NodeMaterialBuildState): this;
  64893. }
  64894. }
  64895. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  64896. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64898. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64899. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64901. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64902. import { Nullable } from "babylonjs/types";
  64903. import { Mesh } from "babylonjs/Meshes/mesh";
  64904. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64905. import { Effect } from "babylonjs/Materials/effect";
  64906. /**
  64907. * Block used to implement the clear coat module of the PBR material
  64908. */
  64909. export class ClearCoatBlock extends NodeMaterialBlock {
  64910. private _scene;
  64911. /**
  64912. * Create a new ClearCoatBlock
  64913. * @param name defines the block name
  64914. */
  64915. constructor(name: string);
  64916. /**
  64917. * Initialize the block and prepare the context for build
  64918. * @param state defines the state that will be used for the build
  64919. */
  64920. initialize(state: NodeMaterialBuildState): void;
  64921. /**
  64922. * Gets the current class name
  64923. * @returns the class name
  64924. */
  64925. getClassName(): string;
  64926. /**
  64927. * Gets the intensity input component
  64928. */
  64929. get intensity(): NodeMaterialConnectionPoint;
  64930. /**
  64931. * Gets the roughness input component
  64932. */
  64933. get roughness(): NodeMaterialConnectionPoint;
  64934. /**
  64935. * Gets the ior input component
  64936. */
  64937. get ior(): NodeMaterialConnectionPoint;
  64938. /**
  64939. * Gets the texture input component
  64940. */
  64941. get texture(): NodeMaterialConnectionPoint;
  64942. /**
  64943. * Gets the bump texture input component
  64944. */
  64945. get bumpTexture(): NodeMaterialConnectionPoint;
  64946. /**
  64947. * Gets the uv input component
  64948. */
  64949. get uv(): NodeMaterialConnectionPoint;
  64950. /**
  64951. * Gets the tint color input component
  64952. */
  64953. get tintColor(): NodeMaterialConnectionPoint;
  64954. /**
  64955. * Gets the tint "at distance" input component
  64956. */
  64957. get tintAtDistance(): NodeMaterialConnectionPoint;
  64958. /**
  64959. * Gets the tint thickness input component
  64960. */
  64961. get tintThickness(): NodeMaterialConnectionPoint;
  64962. /**
  64963. * Gets the tint texture input component
  64964. */
  64965. get tintTexture(): NodeMaterialConnectionPoint;
  64966. /**
  64967. * Gets the world tangent input component
  64968. */
  64969. get worldTangent(): NodeMaterialConnectionPoint;
  64970. /**
  64971. * Gets the clear coat object output component
  64972. */
  64973. get clearcoat(): NodeMaterialConnectionPoint;
  64974. autoConfigure(material: NodeMaterial): void;
  64975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64976. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64977. private _generateTBNSpace;
  64978. /**
  64979. * Gets the main code of the block (fragment side)
  64980. * @param state current state of the node material building
  64981. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64982. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64983. * @param worldPosVarName name of the variable holding the world position
  64984. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64985. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64986. * @param worldNormalVarName name of the variable holding the world normal
  64987. * @returns the shader code
  64988. */
  64989. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64990. protected _buildBlock(state: NodeMaterialBuildState): this;
  64991. }
  64992. }
  64993. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  64994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64997. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64999. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65000. import { Nullable } from "babylonjs/types";
  65001. /**
  65002. * Block used to implement the sub surface module of the PBR material
  65003. */
  65004. export class SubSurfaceBlock extends NodeMaterialBlock {
  65005. /**
  65006. * Create a new SubSurfaceBlock
  65007. * @param name defines the block name
  65008. */
  65009. constructor(name: string);
  65010. /**
  65011. * Stores the intensity of the different subsurface effects in the thickness texture.
  65012. * * the green channel is the translucency intensity.
  65013. * * the blue channel is the scattering intensity.
  65014. * * the alpha channel is the refraction intensity.
  65015. */
  65016. useMaskFromThicknessTexture: boolean;
  65017. /**
  65018. * Initialize the block and prepare the context for build
  65019. * @param state defines the state that will be used for the build
  65020. */
  65021. initialize(state: NodeMaterialBuildState): void;
  65022. /**
  65023. * Gets the current class name
  65024. * @returns the class name
  65025. */
  65026. getClassName(): string;
  65027. /**
  65028. * Gets the min thickness input component
  65029. */
  65030. get minThickness(): NodeMaterialConnectionPoint;
  65031. /**
  65032. * Gets the max thickness input component
  65033. */
  65034. get maxThickness(): NodeMaterialConnectionPoint;
  65035. /**
  65036. * Gets the thickness texture component
  65037. */
  65038. get thicknessTexture(): NodeMaterialConnectionPoint;
  65039. /**
  65040. * Gets the tint color input component
  65041. */
  65042. get tintColor(): NodeMaterialConnectionPoint;
  65043. /**
  65044. * Gets the translucency intensity input component
  65045. */
  65046. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the translucency diffusion distance input component
  65049. */
  65050. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65051. /**
  65052. * Gets the refraction object parameters
  65053. */
  65054. get refraction(): NodeMaterialConnectionPoint;
  65055. /**
  65056. * Gets the sub surface object output component
  65057. */
  65058. get subsurface(): NodeMaterialConnectionPoint;
  65059. autoConfigure(material: NodeMaterial): void;
  65060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65061. /**
  65062. * Gets the main code of the block (fragment side)
  65063. * @param state current state of the node material building
  65064. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65065. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65066. * @param worldPosVarName name of the variable holding the world position
  65067. * @returns the shader code
  65068. */
  65069. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65070. protected _buildBlock(state: NodeMaterialBuildState): this;
  65071. }
  65072. }
  65073. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  65074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65077. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65078. import { Light } from "babylonjs/Lights/light";
  65079. import { Nullable } from "babylonjs/types";
  65080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65081. import { Effect } from "babylonjs/Materials/effect";
  65082. import { Mesh } from "babylonjs/Meshes/mesh";
  65083. import { Scene } from "babylonjs/scene";
  65084. /**
  65085. * Block used to implement the PBR metallic/roughness model
  65086. */
  65087. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65088. /**
  65089. * Gets or sets the light associated with this block
  65090. */
  65091. light: Nullable<Light>;
  65092. private _lightId;
  65093. private _scene;
  65094. private _environmentBRDFTexture;
  65095. private _environmentBrdfSamplerName;
  65096. private _vNormalWName;
  65097. private _invertNormalName;
  65098. /**
  65099. * Create a new ReflectionBlock
  65100. * @param name defines the block name
  65101. */
  65102. constructor(name: string);
  65103. /**
  65104. * Intensity of the direct lights e.g. the four lights available in your scene.
  65105. * This impacts both the direct diffuse and specular highlights.
  65106. */
  65107. directIntensity: number;
  65108. /**
  65109. * Intensity of the environment e.g. how much the environment will light the object
  65110. * either through harmonics for rough material or through the refelction for shiny ones.
  65111. */
  65112. environmentIntensity: number;
  65113. /**
  65114. * This is a special control allowing the reduction of the specular highlights coming from the
  65115. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65116. */
  65117. specularIntensity: number;
  65118. /**
  65119. * Defines the falloff type used in this material.
  65120. * It by default is Physical.
  65121. */
  65122. lightFalloff: number;
  65123. /**
  65124. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65125. */
  65126. useAlphaFromAlbedoTexture: boolean;
  65127. /**
  65128. * Specifies that alpha test should be used
  65129. */
  65130. useAlphaTest: boolean;
  65131. /**
  65132. * Defines the alpha limits in alpha test mode.
  65133. */
  65134. alphaTestCutoff: number;
  65135. /**
  65136. * Specifies that alpha blending should be used
  65137. */
  65138. useAlphaBlending: boolean;
  65139. /**
  65140. * Defines if the alpha value should be determined via the rgb values.
  65141. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65142. */
  65143. opacityRGB: boolean;
  65144. /**
  65145. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65146. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65147. */
  65148. useRadianceOverAlpha: boolean;
  65149. /**
  65150. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65151. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65152. */
  65153. useSpecularOverAlpha: boolean;
  65154. /**
  65155. * Enables specular anti aliasing in the PBR shader.
  65156. * It will both interacts on the Geometry for analytical and IBL lighting.
  65157. * It also prefilter the roughness map based on the bump values.
  65158. */
  65159. enableSpecularAntiAliasing: boolean;
  65160. /**
  65161. * Defines if the material uses energy conservation.
  65162. */
  65163. useEnergyConservation: boolean;
  65164. /**
  65165. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65166. * too much the area relying on ambient texture to define their ambient occlusion.
  65167. */
  65168. useRadianceOcclusion: boolean;
  65169. /**
  65170. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65171. * makes the reflect vector face the model (under horizon).
  65172. */
  65173. useHorizonOcclusion: boolean;
  65174. /**
  65175. * If set to true, no lighting calculations will be applied.
  65176. */
  65177. unlit: boolean;
  65178. /**
  65179. * Force normal to face away from face.
  65180. */
  65181. forceNormalForward: boolean;
  65182. /**
  65183. * Defines the material debug mode.
  65184. * It helps seeing only some components of the material while troubleshooting.
  65185. */
  65186. debugMode: number;
  65187. /**
  65188. * Specify from where on screen the debug mode should start.
  65189. * The value goes from -1 (full screen) to 1 (not visible)
  65190. * It helps with side by side comparison against the final render
  65191. * This defaults to 0
  65192. */
  65193. debugLimit: number;
  65194. /**
  65195. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65196. * You can use the factor to better multiply the final value.
  65197. */
  65198. debugFactor: number;
  65199. /**
  65200. * Initialize the block and prepare the context for build
  65201. * @param state defines the state that will be used for the build
  65202. */
  65203. initialize(state: NodeMaterialBuildState): void;
  65204. /**
  65205. * Gets the current class name
  65206. * @returns the class name
  65207. */
  65208. getClassName(): string;
  65209. /**
  65210. * Gets the world position input component
  65211. */
  65212. get worldPosition(): NodeMaterialConnectionPoint;
  65213. /**
  65214. * Gets the world normal input component
  65215. */
  65216. get worldNormal(): NodeMaterialConnectionPoint;
  65217. /**
  65218. * Gets the perturbed normal input component
  65219. */
  65220. get perturbedNormal(): NodeMaterialConnectionPoint;
  65221. /**
  65222. * Gets the camera position input component
  65223. */
  65224. get cameraPosition(): NodeMaterialConnectionPoint;
  65225. /**
  65226. * Gets the base color input component
  65227. */
  65228. get baseColor(): NodeMaterialConnectionPoint;
  65229. /**
  65230. * Gets the base texture input component
  65231. */
  65232. get baseTexture(): NodeMaterialConnectionPoint;
  65233. /**
  65234. * Gets the opacity texture input component
  65235. */
  65236. get opacityTexture(): NodeMaterialConnectionPoint;
  65237. /**
  65238. * Gets the ambient color input component
  65239. */
  65240. get ambientColor(): NodeMaterialConnectionPoint;
  65241. /**
  65242. * Gets the reflectivity object parameters
  65243. */
  65244. get reflectivity(): NodeMaterialConnectionPoint;
  65245. /**
  65246. * Gets the ambient occlusion object parameters
  65247. */
  65248. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65249. /**
  65250. * Gets the reflection object parameters
  65251. */
  65252. get reflection(): NodeMaterialConnectionPoint;
  65253. /**
  65254. * Gets the sheen object parameters
  65255. */
  65256. get sheen(): NodeMaterialConnectionPoint;
  65257. /**
  65258. * Gets the clear coat object parameters
  65259. */
  65260. get clearcoat(): NodeMaterialConnectionPoint;
  65261. /**
  65262. * Gets the sub surface object parameters
  65263. */
  65264. get subsurface(): NodeMaterialConnectionPoint;
  65265. /**
  65266. * Gets the anisotropy object parameters
  65267. */
  65268. get anisotropy(): NodeMaterialConnectionPoint;
  65269. /**
  65270. * Gets the ambient output component
  65271. */
  65272. get ambient(): NodeMaterialConnectionPoint;
  65273. /**
  65274. * Gets the diffuse output component
  65275. */
  65276. get diffuse(): NodeMaterialConnectionPoint;
  65277. /**
  65278. * Gets the specular output component
  65279. */
  65280. get specular(): NodeMaterialConnectionPoint;
  65281. /**
  65282. * Gets the sheen output component
  65283. */
  65284. get sheenDir(): NodeMaterialConnectionPoint;
  65285. /**
  65286. * Gets the clear coat output component
  65287. */
  65288. get clearcoatDir(): NodeMaterialConnectionPoint;
  65289. /**
  65290. * Gets the indirect diffuse output component
  65291. */
  65292. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the indirect specular output component
  65295. */
  65296. get specularIndirect(): NodeMaterialConnectionPoint;
  65297. /**
  65298. * Gets the indirect sheen output component
  65299. */
  65300. get sheenIndirect(): NodeMaterialConnectionPoint;
  65301. /**
  65302. * Gets the indirect clear coat output component
  65303. */
  65304. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65305. /**
  65306. * Gets the refraction output component
  65307. */
  65308. get refraction(): NodeMaterialConnectionPoint;
  65309. /**
  65310. * Gets the global lighting output component
  65311. */
  65312. get lighting(): NodeMaterialConnectionPoint;
  65313. /**
  65314. * Gets the shadow output component
  65315. */
  65316. get shadow(): NodeMaterialConnectionPoint;
  65317. /**
  65318. * Gets the alpha output component
  65319. */
  65320. get alpha(): NodeMaterialConnectionPoint;
  65321. autoConfigure(material: NodeMaterial): void;
  65322. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65323. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65324. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65325. private _injectVertexCode;
  65326. /**
  65327. * Gets the code corresponding to the albedo/opacity module
  65328. * @returns the shader code
  65329. */
  65330. getAlbedoOpacityCode(): string;
  65331. protected _buildBlock(state: NodeMaterialBuildState): this;
  65332. protected _dumpPropertiesCode(): string;
  65333. serialize(): any;
  65334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65335. }
  65336. }
  65337. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  65338. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  65339. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  65340. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  65341. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  65342. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  65343. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65344. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  65345. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  65346. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  65347. }
  65348. declare module "babylonjs/Materials/Node/Blocks/index" {
  65349. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  65350. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  65351. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  65352. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  65353. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  65354. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  65355. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  65356. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  65357. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  65358. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  65359. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  65360. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  65361. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  65362. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  65363. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  65364. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  65365. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  65366. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  65367. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  65368. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  65369. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  65370. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  65371. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  65372. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  65373. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  65374. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  65375. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  65376. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  65377. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  65378. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  65379. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  65380. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  65381. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  65382. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  65383. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  65384. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  65385. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  65386. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  65387. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  65388. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  65389. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  65390. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  65391. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  65392. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  65393. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  65394. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  65395. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  65396. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  65397. }
  65398. declare module "babylonjs/Materials/Node/Optimizers/index" {
  65399. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  65400. }
  65401. declare module "babylonjs/Materials/Node/index" {
  65402. export * from "babylonjs/Materials/Node/Enums/index";
  65403. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65404. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  65405. export * from "babylonjs/Materials/Node/nodeMaterial";
  65406. export * from "babylonjs/Materials/Node/Blocks/index";
  65407. export * from "babylonjs/Materials/Node/Optimizers/index";
  65408. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  65409. }
  65410. declare module "babylonjs/Materials/effectRenderer" {
  65411. import { Nullable } from "babylonjs/types";
  65412. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65413. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65414. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65415. import { Viewport } from "babylonjs/Maths/math.viewport";
  65416. import { Observable } from "babylonjs/Misc/observable";
  65417. import { Effect } from "babylonjs/Materials/effect";
  65418. import "babylonjs/Shaders/postprocess.vertex";
  65419. /**
  65420. * Effect Render Options
  65421. */
  65422. export interface IEffectRendererOptions {
  65423. /**
  65424. * Defines the vertices positions.
  65425. */
  65426. positions?: number[];
  65427. /**
  65428. * Defines the indices.
  65429. */
  65430. indices?: number[];
  65431. }
  65432. /**
  65433. * Helper class to render one or more effects.
  65434. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65435. */
  65436. export class EffectRenderer {
  65437. private engine;
  65438. private static _DefaultOptions;
  65439. private _vertexBuffers;
  65440. private _indexBuffer;
  65441. private _fullscreenViewport;
  65442. /**
  65443. * Creates an effect renderer
  65444. * @param engine the engine to use for rendering
  65445. * @param options defines the options of the effect renderer
  65446. */
  65447. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65448. /**
  65449. * Sets the current viewport in normalized coordinates 0-1
  65450. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65451. */
  65452. setViewport(viewport?: Viewport): void;
  65453. /**
  65454. * Binds the embedded attributes buffer to the effect.
  65455. * @param effect Defines the effect to bind the attributes for
  65456. */
  65457. bindBuffers(effect: Effect): void;
  65458. /**
  65459. * Sets the current effect wrapper to use during draw.
  65460. * The effect needs to be ready before calling this api.
  65461. * This also sets the default full screen position attribute.
  65462. * @param effectWrapper Defines the effect to draw with
  65463. */
  65464. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65465. /**
  65466. * Draws a full screen quad.
  65467. */
  65468. draw(): void;
  65469. private isRenderTargetTexture;
  65470. /**
  65471. * renders one or more effects to a specified texture
  65472. * @param effectWrapper the effect to renderer
  65473. * @param outputTexture texture to draw to, if null it will render to the screen.
  65474. */
  65475. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65476. /**
  65477. * Disposes of the effect renderer
  65478. */
  65479. dispose(): void;
  65480. }
  65481. /**
  65482. * Options to create an EffectWrapper
  65483. */
  65484. interface EffectWrapperCreationOptions {
  65485. /**
  65486. * Engine to use to create the effect
  65487. */
  65488. engine: ThinEngine;
  65489. /**
  65490. * Fragment shader for the effect
  65491. */
  65492. fragmentShader: string;
  65493. /**
  65494. * Vertex shader for the effect
  65495. */
  65496. vertexShader?: string;
  65497. /**
  65498. * Attributes to use in the shader
  65499. */
  65500. attributeNames?: Array<string>;
  65501. /**
  65502. * Uniforms to use in the shader
  65503. */
  65504. uniformNames?: Array<string>;
  65505. /**
  65506. * Texture sampler names to use in the shader
  65507. */
  65508. samplerNames?: Array<string>;
  65509. /**
  65510. * The friendly name of the effect displayed in Spector.
  65511. */
  65512. name?: string;
  65513. }
  65514. /**
  65515. * Wraps an effect to be used for rendering
  65516. */
  65517. export class EffectWrapper {
  65518. /**
  65519. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65520. */
  65521. onApplyObservable: Observable<{}>;
  65522. /**
  65523. * The underlying effect
  65524. */
  65525. effect: Effect;
  65526. /**
  65527. * Creates an effect to be renderer
  65528. * @param creationOptions options to create the effect
  65529. */
  65530. constructor(creationOptions: EffectWrapperCreationOptions);
  65531. /**
  65532. * Disposes of the effect wrapper
  65533. */
  65534. dispose(): void;
  65535. }
  65536. }
  65537. declare module "babylonjs/Materials/index" {
  65538. export * from "babylonjs/Materials/Background/index";
  65539. export * from "babylonjs/Materials/colorCurves";
  65540. export * from "babylonjs/Materials/iEffectFallbacks";
  65541. export * from "babylonjs/Materials/effectFallbacks";
  65542. export * from "babylonjs/Materials/effect";
  65543. export * from "babylonjs/Materials/fresnelParameters";
  65544. export * from "babylonjs/Materials/imageProcessingConfiguration";
  65545. export * from "babylonjs/Materials/material";
  65546. export * from "babylonjs/Materials/materialDefines";
  65547. export * from "babylonjs/Materials/materialHelper";
  65548. export * from "babylonjs/Materials/multiMaterial";
  65549. export * from "babylonjs/Materials/PBR/index";
  65550. export * from "babylonjs/Materials/pushMaterial";
  65551. export * from "babylonjs/Materials/shaderMaterial";
  65552. export * from "babylonjs/Materials/standardMaterial";
  65553. export * from "babylonjs/Materials/Textures/index";
  65554. export * from "babylonjs/Materials/uniformBuffer";
  65555. export * from "babylonjs/Materials/materialFlags";
  65556. export * from "babylonjs/Materials/Node/index";
  65557. export * from "babylonjs/Materials/effectRenderer";
  65558. export * from "babylonjs/Materials/shadowDepthWrapper";
  65559. }
  65560. declare module "babylonjs/Maths/index" {
  65561. export * from "babylonjs/Maths/math.scalar";
  65562. export * from "babylonjs/Maths/math";
  65563. export * from "babylonjs/Maths/sphericalPolynomial";
  65564. }
  65565. declare module "babylonjs/Misc/workerPool" {
  65566. import { IDisposable } from "babylonjs/scene";
  65567. /**
  65568. * Helper class to push actions to a pool of workers.
  65569. */
  65570. export class WorkerPool implements IDisposable {
  65571. private _workerInfos;
  65572. private _pendingActions;
  65573. /**
  65574. * Constructor
  65575. * @param workers Array of workers to use for actions
  65576. */
  65577. constructor(workers: Array<Worker>);
  65578. /**
  65579. * Terminates all workers and clears any pending actions.
  65580. */
  65581. dispose(): void;
  65582. /**
  65583. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65584. * pended until a worker has completed its action.
  65585. * @param action The action to perform. Call onComplete when the action is complete.
  65586. */
  65587. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65588. private _execute;
  65589. }
  65590. }
  65591. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  65592. import { IDisposable } from "babylonjs/scene";
  65593. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65594. /**
  65595. * Configuration for Draco compression
  65596. */
  65597. export interface IDracoCompressionConfiguration {
  65598. /**
  65599. * Configuration for the decoder.
  65600. */
  65601. decoder: {
  65602. /**
  65603. * The url to the WebAssembly module.
  65604. */
  65605. wasmUrl?: string;
  65606. /**
  65607. * The url to the WebAssembly binary.
  65608. */
  65609. wasmBinaryUrl?: string;
  65610. /**
  65611. * The url to the fallback JavaScript module.
  65612. */
  65613. fallbackUrl?: string;
  65614. };
  65615. }
  65616. /**
  65617. * Draco compression (https://google.github.io/draco/)
  65618. *
  65619. * This class wraps the Draco module.
  65620. *
  65621. * **Encoder**
  65622. *
  65623. * The encoder is not currently implemented.
  65624. *
  65625. * **Decoder**
  65626. *
  65627. * 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.
  65628. *
  65629. * To update the configuration, use the following code:
  65630. * ```javascript
  65631. * DracoCompression.Configuration = {
  65632. * decoder: {
  65633. * wasmUrl: "<url to the WebAssembly library>",
  65634. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65635. * fallbackUrl: "<url to the fallback JavaScript library>",
  65636. * }
  65637. * };
  65638. * ```
  65639. *
  65640. * 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.
  65641. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65642. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65643. *
  65644. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65645. * ```javascript
  65646. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65647. * ```
  65648. *
  65649. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65650. */
  65651. export class DracoCompression implements IDisposable {
  65652. private _workerPoolPromise?;
  65653. private _decoderModulePromise?;
  65654. /**
  65655. * The configuration. Defaults to the following urls:
  65656. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65657. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65658. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65659. */
  65660. static Configuration: IDracoCompressionConfiguration;
  65661. /**
  65662. * Returns true if the decoder configuration is available.
  65663. */
  65664. static get DecoderAvailable(): boolean;
  65665. /**
  65666. * Default number of workers to create when creating the draco compression object.
  65667. */
  65668. static DefaultNumWorkers: number;
  65669. private static GetDefaultNumWorkers;
  65670. private static _Default;
  65671. /**
  65672. * Default instance for the draco compression object.
  65673. */
  65674. static get Default(): DracoCompression;
  65675. /**
  65676. * Constructor
  65677. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65678. */
  65679. constructor(numWorkers?: number);
  65680. /**
  65681. * Stop all async operations and release resources.
  65682. */
  65683. dispose(): void;
  65684. /**
  65685. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65686. * @returns a promise that resolves when ready
  65687. */
  65688. whenReadyAsync(): Promise<void>;
  65689. /**
  65690. * Decode Draco compressed mesh data to vertex data.
  65691. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65692. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65693. * @returns A promise that resolves with the decoded vertex data
  65694. */
  65695. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65696. [kind: string]: number;
  65697. }): Promise<VertexData>;
  65698. }
  65699. }
  65700. declare module "babylonjs/Meshes/Compression/index" {
  65701. export * from "babylonjs/Meshes/Compression/dracoCompression";
  65702. }
  65703. declare module "babylonjs/Meshes/csg" {
  65704. import { Nullable } from "babylonjs/types";
  65705. import { Scene } from "babylonjs/scene";
  65706. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  65707. import { Mesh } from "babylonjs/Meshes/mesh";
  65708. import { Material } from "babylonjs/Materials/material";
  65709. /**
  65710. * Class for building Constructive Solid Geometry
  65711. */
  65712. export class CSG {
  65713. private polygons;
  65714. /**
  65715. * The world matrix
  65716. */
  65717. matrix: Matrix;
  65718. /**
  65719. * Stores the position
  65720. */
  65721. position: Vector3;
  65722. /**
  65723. * Stores the rotation
  65724. */
  65725. rotation: Vector3;
  65726. /**
  65727. * Stores the rotation quaternion
  65728. */
  65729. rotationQuaternion: Nullable<Quaternion>;
  65730. /**
  65731. * Stores the scaling vector
  65732. */
  65733. scaling: Vector3;
  65734. /**
  65735. * Convert the Mesh to CSG
  65736. * @param mesh The Mesh to convert to CSG
  65737. * @returns A new CSG from the Mesh
  65738. */
  65739. static FromMesh(mesh: Mesh): CSG;
  65740. /**
  65741. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65742. * @param polygons Polygons used to construct a CSG solid
  65743. */
  65744. private static FromPolygons;
  65745. /**
  65746. * Clones, or makes a deep copy, of the CSG
  65747. * @returns A new CSG
  65748. */
  65749. clone(): CSG;
  65750. /**
  65751. * Unions this CSG with another CSG
  65752. * @param csg The CSG to union against this CSG
  65753. * @returns The unioned CSG
  65754. */
  65755. union(csg: CSG): CSG;
  65756. /**
  65757. * Unions this CSG with another CSG in place
  65758. * @param csg The CSG to union against this CSG
  65759. */
  65760. unionInPlace(csg: CSG): void;
  65761. /**
  65762. * Subtracts this CSG with another CSG
  65763. * @param csg The CSG to subtract against this CSG
  65764. * @returns A new CSG
  65765. */
  65766. subtract(csg: CSG): CSG;
  65767. /**
  65768. * Subtracts this CSG with another CSG in place
  65769. * @param csg The CSG to subtact against this CSG
  65770. */
  65771. subtractInPlace(csg: CSG): void;
  65772. /**
  65773. * Intersect this CSG with another CSG
  65774. * @param csg The CSG to intersect against this CSG
  65775. * @returns A new CSG
  65776. */
  65777. intersect(csg: CSG): CSG;
  65778. /**
  65779. * Intersects this CSG with another CSG in place
  65780. * @param csg The CSG to intersect against this CSG
  65781. */
  65782. intersectInPlace(csg: CSG): void;
  65783. /**
  65784. * Return a new CSG solid with solid and empty space switched. This solid is
  65785. * not modified.
  65786. * @returns A new CSG solid with solid and empty space switched
  65787. */
  65788. inverse(): CSG;
  65789. /**
  65790. * Inverses the CSG in place
  65791. */
  65792. inverseInPlace(): void;
  65793. /**
  65794. * This is used to keep meshes transformations so they can be restored
  65795. * when we build back a Babylon Mesh
  65796. * NB : All CSG operations are performed in world coordinates
  65797. * @param csg The CSG to copy the transform attributes from
  65798. * @returns This CSG
  65799. */
  65800. copyTransformAttributes(csg: CSG): CSG;
  65801. /**
  65802. * Build Raw mesh from CSG
  65803. * Coordinates here are in world space
  65804. * @param name The name of the mesh geometry
  65805. * @param scene The Scene
  65806. * @param keepSubMeshes Specifies if the submeshes should be kept
  65807. * @returns A new Mesh
  65808. */
  65809. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65810. /**
  65811. * Build Mesh from CSG taking material and transforms into account
  65812. * @param name The name of the Mesh
  65813. * @param material The material of the Mesh
  65814. * @param scene The Scene
  65815. * @param keepSubMeshes Specifies if submeshes should be kept
  65816. * @returns The new Mesh
  65817. */
  65818. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65819. }
  65820. }
  65821. declare module "babylonjs/Meshes/trailMesh" {
  65822. import { Mesh } from "babylonjs/Meshes/mesh";
  65823. import { Scene } from "babylonjs/scene";
  65824. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65825. /**
  65826. * Class used to create a trail following a mesh
  65827. */
  65828. export class TrailMesh extends Mesh {
  65829. private _generator;
  65830. private _autoStart;
  65831. private _running;
  65832. private _diameter;
  65833. private _length;
  65834. private _sectionPolygonPointsCount;
  65835. private _sectionVectors;
  65836. private _sectionNormalVectors;
  65837. private _beforeRenderObserver;
  65838. /**
  65839. * @constructor
  65840. * @param name The value used by scene.getMeshByName() to do a lookup.
  65841. * @param generator The mesh or transform node to generate a trail.
  65842. * @param scene The scene to add this mesh to.
  65843. * @param diameter Diameter of trailing mesh. Default is 1.
  65844. * @param length Length of trailing mesh. Default is 60.
  65845. * @param autoStart Automatically start trailing mesh. Default true.
  65846. */
  65847. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65848. /**
  65849. * "TrailMesh"
  65850. * @returns "TrailMesh"
  65851. */
  65852. getClassName(): string;
  65853. private _createMesh;
  65854. /**
  65855. * Start trailing mesh.
  65856. */
  65857. start(): void;
  65858. /**
  65859. * Stop trailing mesh.
  65860. */
  65861. stop(): void;
  65862. /**
  65863. * Update trailing mesh geometry.
  65864. */
  65865. update(): void;
  65866. /**
  65867. * Returns a new TrailMesh object.
  65868. * @param name is a string, the name given to the new mesh
  65869. * @param newGenerator use new generator object for cloned trail mesh
  65870. * @returns a new mesh
  65871. */
  65872. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65873. /**
  65874. * Serializes this trail mesh
  65875. * @param serializationObject object to write serialization to
  65876. */
  65877. serialize(serializationObject: any): void;
  65878. /**
  65879. * Parses a serialized trail mesh
  65880. * @param parsedMesh the serialized mesh
  65881. * @param scene the scene to create the trail mesh in
  65882. * @returns the created trail mesh
  65883. */
  65884. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65885. }
  65886. }
  65887. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  65888. import { Nullable } from "babylonjs/types";
  65889. import { Scene } from "babylonjs/scene";
  65890. import { Vector4 } from "babylonjs/Maths/math.vector";
  65891. import { Color4 } from "babylonjs/Maths/math.color";
  65892. import { Mesh } from "babylonjs/Meshes/mesh";
  65893. /**
  65894. * Class containing static functions to help procedurally build meshes
  65895. */
  65896. export class TiledBoxBuilder {
  65897. /**
  65898. * Creates a box mesh
  65899. * 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)
  65900. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65902. * * 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
  65903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65904. * @param name defines the name of the mesh
  65905. * @param options defines the options used to create the mesh
  65906. * @param scene defines the hosting scene
  65907. * @returns the box mesh
  65908. */
  65909. static CreateTiledBox(name: string, options: {
  65910. pattern?: number;
  65911. width?: number;
  65912. height?: number;
  65913. depth?: number;
  65914. tileSize?: number;
  65915. tileWidth?: number;
  65916. tileHeight?: number;
  65917. alignHorizontal?: number;
  65918. alignVertical?: number;
  65919. faceUV?: Vector4[];
  65920. faceColors?: Color4[];
  65921. sideOrientation?: number;
  65922. updatable?: boolean;
  65923. }, scene?: Nullable<Scene>): Mesh;
  65924. }
  65925. }
  65926. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  65927. import { Vector4 } from "babylonjs/Maths/math.vector";
  65928. import { Mesh } from "babylonjs/Meshes/mesh";
  65929. /**
  65930. * Class containing static functions to help procedurally build meshes
  65931. */
  65932. export class TorusKnotBuilder {
  65933. /**
  65934. * Creates a torus knot mesh
  65935. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65936. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65937. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65938. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  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 torus knot mesh
  65946. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65947. */
  65948. static CreateTorusKnot(name: string, options: {
  65949. radius?: number;
  65950. tube?: number;
  65951. radialSegments?: number;
  65952. tubularSegments?: number;
  65953. p?: number;
  65954. q?: number;
  65955. updatable?: boolean;
  65956. sideOrientation?: number;
  65957. frontUVs?: Vector4;
  65958. backUVs?: Vector4;
  65959. }, scene: any): Mesh;
  65960. }
  65961. }
  65962. declare module "babylonjs/Meshes/polygonMesh" {
  65963. import { Scene } from "babylonjs/scene";
  65964. import { Vector2 } from "babylonjs/Maths/math.vector";
  65965. import { Mesh } from "babylonjs/Meshes/mesh";
  65966. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65967. import { Path2 } from "babylonjs/Maths/math.path";
  65968. /**
  65969. * Polygon
  65970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65971. */
  65972. export class Polygon {
  65973. /**
  65974. * Creates a rectangle
  65975. * @param xmin bottom X coord
  65976. * @param ymin bottom Y coord
  65977. * @param xmax top X coord
  65978. * @param ymax top Y coord
  65979. * @returns points that make the resulting rectation
  65980. */
  65981. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65982. /**
  65983. * Creates a circle
  65984. * @param radius radius of circle
  65985. * @param cx scale in x
  65986. * @param cy scale in y
  65987. * @param numberOfSides number of sides that make up the circle
  65988. * @returns points that make the resulting circle
  65989. */
  65990. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65991. /**
  65992. * Creates a polygon from input string
  65993. * @param input Input polygon data
  65994. * @returns the parsed points
  65995. */
  65996. static Parse(input: string): Vector2[];
  65997. /**
  65998. * Starts building a polygon from x and y coordinates
  65999. * @param x x coordinate
  66000. * @param y y coordinate
  66001. * @returns the started path2
  66002. */
  66003. static StartingAt(x: number, y: number): Path2;
  66004. }
  66005. /**
  66006. * Builds a polygon
  66007. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66008. */
  66009. export class PolygonMeshBuilder {
  66010. private _points;
  66011. private _outlinepoints;
  66012. private _holes;
  66013. private _name;
  66014. private _scene;
  66015. private _epoints;
  66016. private _eholes;
  66017. private _addToepoint;
  66018. /**
  66019. * Babylon reference to the earcut plugin.
  66020. */
  66021. bjsEarcut: any;
  66022. /**
  66023. * Creates a PolygonMeshBuilder
  66024. * @param name name of the builder
  66025. * @param contours Path of the polygon
  66026. * @param scene scene to add to when creating the mesh
  66027. * @param earcutInjection can be used to inject your own earcut reference
  66028. */
  66029. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66030. /**
  66031. * Adds a whole within the polygon
  66032. * @param hole Array of points defining the hole
  66033. * @returns this
  66034. */
  66035. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66036. /**
  66037. * Creates the polygon
  66038. * @param updatable If the mesh should be updatable
  66039. * @param depth The depth of the mesh created
  66040. * @returns the created mesh
  66041. */
  66042. build(updatable?: boolean, depth?: number): Mesh;
  66043. /**
  66044. * Creates the polygon
  66045. * @param depth The depth of the mesh created
  66046. * @returns the created VertexData
  66047. */
  66048. buildVertexData(depth?: number): VertexData;
  66049. /**
  66050. * Adds a side to the polygon
  66051. * @param positions points that make the polygon
  66052. * @param normals normals of the polygon
  66053. * @param uvs uvs of the polygon
  66054. * @param indices indices of the polygon
  66055. * @param bounds bounds of the polygon
  66056. * @param points points of the polygon
  66057. * @param depth depth of the polygon
  66058. * @param flip flip of the polygon
  66059. */
  66060. private addSide;
  66061. }
  66062. }
  66063. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  66064. import { Scene } from "babylonjs/scene";
  66065. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66066. import { Color4 } from "babylonjs/Maths/math.color";
  66067. import { Mesh } from "babylonjs/Meshes/mesh";
  66068. import { Nullable } from "babylonjs/types";
  66069. /**
  66070. * Class containing static functions to help procedurally build meshes
  66071. */
  66072. export class PolygonBuilder {
  66073. /**
  66074. * Creates a polygon mesh
  66075. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66076. * * 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
  66077. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66079. * * 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)
  66080. * * Remember you can only change the shape positions, not their number when updating a polygon
  66081. * @param name defines the name of the mesh
  66082. * @param options defines the options used to create the mesh
  66083. * @param scene defines the hosting scene
  66084. * @param earcutInjection can be used to inject your own earcut reference
  66085. * @returns the polygon mesh
  66086. */
  66087. static CreatePolygon(name: string, options: {
  66088. shape: Vector3[];
  66089. holes?: Vector3[][];
  66090. depth?: number;
  66091. faceUV?: Vector4[];
  66092. faceColors?: Color4[];
  66093. updatable?: boolean;
  66094. sideOrientation?: number;
  66095. frontUVs?: Vector4;
  66096. backUVs?: Vector4;
  66097. wrap?: boolean;
  66098. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66099. /**
  66100. * Creates an extruded polygon mesh, with depth in the Y direction.
  66101. * * 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)
  66102. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66103. * @param name defines the name of the mesh
  66104. * @param options defines the options used to create the mesh
  66105. * @param scene defines the hosting scene
  66106. * @param earcutInjection can be used to inject your own earcut reference
  66107. * @returns the polygon mesh
  66108. */
  66109. static ExtrudePolygon(name: string, options: {
  66110. shape: Vector3[];
  66111. holes?: Vector3[][];
  66112. depth?: number;
  66113. faceUV?: Vector4[];
  66114. faceColors?: Color4[];
  66115. updatable?: boolean;
  66116. sideOrientation?: number;
  66117. frontUVs?: Vector4;
  66118. backUVs?: Vector4;
  66119. wrap?: boolean;
  66120. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66121. }
  66122. }
  66123. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  66124. import { Scene } from "babylonjs/scene";
  66125. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66126. import { Mesh } from "babylonjs/Meshes/mesh";
  66127. import { Nullable } from "babylonjs/types";
  66128. /**
  66129. * Class containing static functions to help procedurally build meshes
  66130. */
  66131. export class LatheBuilder {
  66132. /**
  66133. * Creates lathe mesh.
  66134. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66135. * * 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
  66136. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66137. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66138. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66139. * * 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
  66140. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66141. * * 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
  66142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66143. * * 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
  66144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66146. * @param name defines the name of the mesh
  66147. * @param options defines the options used to create the mesh
  66148. * @param scene defines the hosting scene
  66149. * @returns the lathe mesh
  66150. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66151. */
  66152. static CreateLathe(name: string, options: {
  66153. shape: Vector3[];
  66154. radius?: number;
  66155. tessellation?: number;
  66156. clip?: number;
  66157. arc?: number;
  66158. closed?: boolean;
  66159. updatable?: boolean;
  66160. sideOrientation?: number;
  66161. frontUVs?: Vector4;
  66162. backUVs?: Vector4;
  66163. cap?: number;
  66164. invertUV?: boolean;
  66165. }, scene?: Nullable<Scene>): Mesh;
  66166. }
  66167. }
  66168. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  66169. import { Nullable } from "babylonjs/types";
  66170. import { Scene } from "babylonjs/scene";
  66171. import { Vector4 } from "babylonjs/Maths/math.vector";
  66172. import { Mesh } from "babylonjs/Meshes/mesh";
  66173. /**
  66174. * Class containing static functions to help procedurally build meshes
  66175. */
  66176. export class TiledPlaneBuilder {
  66177. /**
  66178. * Creates a tiled plane mesh
  66179. * * The parameter `pattern` will, depending on value, do nothing or
  66180. * * * flip (reflect about central vertical) alternate tiles across and up
  66181. * * * flip every tile on alternate rows
  66182. * * * rotate (180 degs) alternate tiles across and up
  66183. * * * rotate every tile on alternate rows
  66184. * * * flip and rotate alternate tiles across and up
  66185. * * * flip and rotate every tile on alternate rows
  66186. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66187. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66188. * * 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
  66189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66190. * * 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)
  66191. * * 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)
  66192. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66193. * @param name defines the name of the mesh
  66194. * @param options defines the options used to create the mesh
  66195. * @param scene defines the hosting scene
  66196. * @returns the box mesh
  66197. */
  66198. static CreateTiledPlane(name: string, options: {
  66199. pattern?: number;
  66200. tileSize?: number;
  66201. tileWidth?: number;
  66202. tileHeight?: number;
  66203. size?: number;
  66204. width?: number;
  66205. height?: number;
  66206. alignHorizontal?: number;
  66207. alignVertical?: number;
  66208. sideOrientation?: number;
  66209. frontUVs?: Vector4;
  66210. backUVs?: Vector4;
  66211. updatable?: boolean;
  66212. }, scene?: Nullable<Scene>): Mesh;
  66213. }
  66214. }
  66215. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  66216. import { Nullable } from "babylonjs/types";
  66217. import { Scene } from "babylonjs/scene";
  66218. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66219. import { Mesh } from "babylonjs/Meshes/mesh";
  66220. /**
  66221. * Class containing static functions to help procedurally build meshes
  66222. */
  66223. export class TubeBuilder {
  66224. /**
  66225. * Creates a tube mesh.
  66226. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66227. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66228. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66229. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66230. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66231. * * 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)
  66232. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66233. * * 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
  66234. * * 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
  66235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66236. * * 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
  66237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66239. * @param name defines the name of the mesh
  66240. * @param options defines the options used to create the mesh
  66241. * @param scene defines the hosting scene
  66242. * @returns the tube mesh
  66243. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66244. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66245. */
  66246. static CreateTube(name: string, options: {
  66247. path: Vector3[];
  66248. radius?: number;
  66249. tessellation?: number;
  66250. radiusFunction?: {
  66251. (i: number, distance: number): number;
  66252. };
  66253. cap?: number;
  66254. arc?: number;
  66255. updatable?: boolean;
  66256. sideOrientation?: number;
  66257. frontUVs?: Vector4;
  66258. backUVs?: Vector4;
  66259. instance?: Mesh;
  66260. invertUV?: boolean;
  66261. }, scene?: Nullable<Scene>): Mesh;
  66262. }
  66263. }
  66264. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  66265. import { Scene } from "babylonjs/scene";
  66266. import { Vector4 } from "babylonjs/Maths/math.vector";
  66267. import { Mesh } from "babylonjs/Meshes/mesh";
  66268. import { Nullable } from "babylonjs/types";
  66269. /**
  66270. * Class containing static functions to help procedurally build meshes
  66271. */
  66272. export class IcoSphereBuilder {
  66273. /**
  66274. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66275. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66276. * * 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`)
  66277. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66278. * * 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
  66279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66280. * * 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
  66281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66282. * @param name defines the name of the mesh
  66283. * @param options defines the options used to create the mesh
  66284. * @param scene defines the hosting scene
  66285. * @returns the icosahedron mesh
  66286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66287. */
  66288. static CreateIcoSphere(name: string, options: {
  66289. radius?: number;
  66290. radiusX?: number;
  66291. radiusY?: number;
  66292. radiusZ?: number;
  66293. flat?: boolean;
  66294. subdivisions?: number;
  66295. sideOrientation?: number;
  66296. frontUVs?: Vector4;
  66297. backUVs?: Vector4;
  66298. updatable?: boolean;
  66299. }, scene?: Nullable<Scene>): Mesh;
  66300. }
  66301. }
  66302. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  66303. import { Vector3 } from "babylonjs/Maths/math.vector";
  66304. import { Mesh } from "babylonjs/Meshes/mesh";
  66305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66306. /**
  66307. * Class containing static functions to help procedurally build meshes
  66308. */
  66309. export class DecalBuilder {
  66310. /**
  66311. * Creates a decal mesh.
  66312. * 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
  66313. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66314. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66315. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66316. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66317. * @param name defines the name of the mesh
  66318. * @param sourceMesh defines the mesh where the decal must be applied
  66319. * @param options defines the options used to create the mesh
  66320. * @param scene defines the hosting scene
  66321. * @returns the decal mesh
  66322. * @see https://doc.babylonjs.com/how_to/decals
  66323. */
  66324. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66325. position?: Vector3;
  66326. normal?: Vector3;
  66327. size?: Vector3;
  66328. angle?: number;
  66329. }): Mesh;
  66330. }
  66331. }
  66332. declare module "babylonjs/Meshes/meshBuilder" {
  66333. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  66334. import { Nullable } from "babylonjs/types";
  66335. import { Scene } from "babylonjs/scene";
  66336. import { Mesh } from "babylonjs/Meshes/mesh";
  66337. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  66338. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  66339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66340. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66341. import { Plane } from "babylonjs/Maths/math.plane";
  66342. /**
  66343. * Class containing static functions to help procedurally build meshes
  66344. */
  66345. export class MeshBuilder {
  66346. /**
  66347. * Creates a box mesh
  66348. * * The parameter `size` sets the size (float) of each box side (default 1)
  66349. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66350. * * 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)
  66351. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66353. * * 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
  66354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66355. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66356. * @param name defines the name of the mesh
  66357. * @param options defines the options used to create the mesh
  66358. * @param scene defines the hosting scene
  66359. * @returns the box mesh
  66360. */
  66361. static CreateBox(name: string, options: {
  66362. size?: number;
  66363. width?: number;
  66364. height?: number;
  66365. depth?: number;
  66366. faceUV?: Vector4[];
  66367. faceColors?: Color4[];
  66368. sideOrientation?: number;
  66369. frontUVs?: Vector4;
  66370. backUVs?: Vector4;
  66371. wrap?: boolean;
  66372. topBaseAt?: number;
  66373. bottomBaseAt?: number;
  66374. updatable?: boolean;
  66375. }, scene?: Nullable<Scene>): Mesh;
  66376. /**
  66377. * Creates a tiled box mesh
  66378. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66380. * @param name defines the name of the mesh
  66381. * @param options defines the options used to create the mesh
  66382. * @param scene defines the hosting scene
  66383. * @returns the tiled box mesh
  66384. */
  66385. static CreateTiledBox(name: string, options: {
  66386. pattern?: number;
  66387. size?: number;
  66388. width?: number;
  66389. height?: number;
  66390. depth: number;
  66391. tileSize?: number;
  66392. tileWidth?: number;
  66393. tileHeight?: number;
  66394. faceUV?: Vector4[];
  66395. faceColors?: Color4[];
  66396. alignHorizontal?: number;
  66397. alignVertical?: number;
  66398. sideOrientation?: number;
  66399. updatable?: boolean;
  66400. }, scene?: Nullable<Scene>): Mesh;
  66401. /**
  66402. * Creates a sphere mesh
  66403. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66404. * * 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`)
  66405. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66406. * * 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
  66407. * * 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)
  66408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66409. * * 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
  66410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66411. * @param name defines the name of the mesh
  66412. * @param options defines the options used to create the mesh
  66413. * @param scene defines the hosting scene
  66414. * @returns the sphere mesh
  66415. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66416. */
  66417. static CreateSphere(name: string, options: {
  66418. segments?: number;
  66419. diameter?: number;
  66420. diameterX?: number;
  66421. diameterY?: number;
  66422. diameterZ?: number;
  66423. arc?: number;
  66424. slice?: number;
  66425. sideOrientation?: number;
  66426. frontUVs?: Vector4;
  66427. backUVs?: Vector4;
  66428. updatable?: boolean;
  66429. }, scene?: Nullable<Scene>): Mesh;
  66430. /**
  66431. * Creates a plane polygonal mesh. By default, this is a disc
  66432. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66433. * * 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
  66434. * * 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
  66435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66436. * * 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
  66437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66438. * @param name defines the name of the mesh
  66439. * @param options defines the options used to create the mesh
  66440. * @param scene defines the hosting scene
  66441. * @returns the plane polygonal mesh
  66442. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66443. */
  66444. static CreateDisc(name: string, options: {
  66445. radius?: number;
  66446. tessellation?: number;
  66447. arc?: number;
  66448. updatable?: boolean;
  66449. sideOrientation?: number;
  66450. frontUVs?: Vector4;
  66451. backUVs?: Vector4;
  66452. }, scene?: Nullable<Scene>): Mesh;
  66453. /**
  66454. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66455. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66456. * * 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`)
  66457. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66458. * * 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
  66459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66460. * * 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
  66461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66462. * @param name defines the name of the mesh
  66463. * @param options defines the options used to create the mesh
  66464. * @param scene defines the hosting scene
  66465. * @returns the icosahedron mesh
  66466. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66467. */
  66468. static CreateIcoSphere(name: string, options: {
  66469. radius?: number;
  66470. radiusX?: number;
  66471. radiusY?: number;
  66472. radiusZ?: number;
  66473. flat?: boolean;
  66474. subdivisions?: number;
  66475. sideOrientation?: number;
  66476. frontUVs?: Vector4;
  66477. backUVs?: Vector4;
  66478. updatable?: boolean;
  66479. }, scene?: Nullable<Scene>): Mesh;
  66480. /**
  66481. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66482. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66483. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66484. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66485. * * 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
  66486. * * 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
  66487. * * 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
  66488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66489. * * 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
  66490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66491. * * 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
  66492. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66493. * * 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
  66494. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66496. * @param name defines the name of the mesh
  66497. * @param options defines the options used to create the mesh
  66498. * @param scene defines the hosting scene
  66499. * @returns the ribbon mesh
  66500. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66502. */
  66503. static CreateRibbon(name: string, options: {
  66504. pathArray: Vector3[][];
  66505. closeArray?: boolean;
  66506. closePath?: boolean;
  66507. offset?: number;
  66508. updatable?: boolean;
  66509. sideOrientation?: number;
  66510. frontUVs?: Vector4;
  66511. backUVs?: Vector4;
  66512. instance?: Mesh;
  66513. invertUV?: boolean;
  66514. uvs?: Vector2[];
  66515. colors?: Color4[];
  66516. }, scene?: Nullable<Scene>): Mesh;
  66517. /**
  66518. * Creates a cylinder or a cone mesh
  66519. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66520. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66521. * * 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.
  66522. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66523. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66524. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66525. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66526. * * 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).
  66527. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66528. * * 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).
  66529. * * 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
  66530. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66531. * * 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
  66532. * * 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.
  66533. * * If `enclose` is false, a ring surface is one element.
  66534. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66535. * * 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
  66536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66537. * * 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
  66538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66539. * @param name defines the name of the mesh
  66540. * @param options defines the options used to create the mesh
  66541. * @param scene defines the hosting scene
  66542. * @returns the cylinder mesh
  66543. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66544. */
  66545. static CreateCylinder(name: string, options: {
  66546. height?: number;
  66547. diameterTop?: number;
  66548. diameterBottom?: number;
  66549. diameter?: number;
  66550. tessellation?: number;
  66551. subdivisions?: number;
  66552. arc?: number;
  66553. faceColors?: Color4[];
  66554. faceUV?: Vector4[];
  66555. updatable?: boolean;
  66556. hasRings?: boolean;
  66557. enclose?: boolean;
  66558. cap?: number;
  66559. sideOrientation?: number;
  66560. frontUVs?: Vector4;
  66561. backUVs?: Vector4;
  66562. }, scene?: Nullable<Scene>): Mesh;
  66563. /**
  66564. * Creates a torus mesh
  66565. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66566. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66567. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66569. * * 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
  66570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66571. * @param name defines the name of the mesh
  66572. * @param options defines the options used to create the mesh
  66573. * @param scene defines the hosting scene
  66574. * @returns the torus mesh
  66575. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66576. */
  66577. static CreateTorus(name: string, options: {
  66578. diameter?: number;
  66579. thickness?: number;
  66580. tessellation?: number;
  66581. updatable?: boolean;
  66582. sideOrientation?: number;
  66583. frontUVs?: Vector4;
  66584. backUVs?: Vector4;
  66585. }, scene?: Nullable<Scene>): Mesh;
  66586. /**
  66587. * Creates a torus knot mesh
  66588. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66589. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66590. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66591. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66593. * * 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
  66594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66595. * @param name defines the name of the mesh
  66596. * @param options defines the options used to create the mesh
  66597. * @param scene defines the hosting scene
  66598. * @returns the torus knot mesh
  66599. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66600. */
  66601. static CreateTorusKnot(name: string, options: {
  66602. radius?: number;
  66603. tube?: number;
  66604. radialSegments?: number;
  66605. tubularSegments?: number;
  66606. p?: number;
  66607. q?: number;
  66608. updatable?: boolean;
  66609. sideOrientation?: number;
  66610. frontUVs?: Vector4;
  66611. backUVs?: Vector4;
  66612. }, scene?: Nullable<Scene>): Mesh;
  66613. /**
  66614. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66615. * * 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
  66616. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66617. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66618. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66619. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66620. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66621. * * 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
  66622. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66625. * @param name defines the name of the new line system
  66626. * @param options defines the options used to create the line system
  66627. * @param scene defines the hosting scene
  66628. * @returns a new line system mesh
  66629. */
  66630. static CreateLineSystem(name: string, options: {
  66631. lines: Vector3[][];
  66632. updatable?: boolean;
  66633. instance?: Nullable<LinesMesh>;
  66634. colors?: Nullable<Color4[][]>;
  66635. useVertexAlpha?: boolean;
  66636. }, scene: Nullable<Scene>): LinesMesh;
  66637. /**
  66638. * Creates a line mesh
  66639. * 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
  66640. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66641. * * The parameter `points` is an array successive Vector3
  66642. * * 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
  66643. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66644. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66645. * * When updating an instance, remember that only point positions can change, not the number of points
  66646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66648. * @param name defines the name of the new line system
  66649. * @param options defines the options used to create the line system
  66650. * @param scene defines the hosting scene
  66651. * @returns a new line mesh
  66652. */
  66653. static CreateLines(name: string, options: {
  66654. points: Vector3[];
  66655. updatable?: boolean;
  66656. instance?: Nullable<LinesMesh>;
  66657. colors?: Color4[];
  66658. useVertexAlpha?: boolean;
  66659. }, scene?: Nullable<Scene>): LinesMesh;
  66660. /**
  66661. * Creates a dashed line mesh
  66662. * * 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
  66663. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66664. * * The parameter `points` is an array successive Vector3
  66665. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66666. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66667. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66668. * * 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
  66669. * * When updating an instance, remember that only point positions can change, not the number of points
  66670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66671. * @param name defines the name of the mesh
  66672. * @param options defines the options used to create the mesh
  66673. * @param scene defines the hosting scene
  66674. * @returns the dashed line mesh
  66675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66676. */
  66677. static CreateDashedLines(name: string, options: {
  66678. points: Vector3[];
  66679. dashSize?: number;
  66680. gapSize?: number;
  66681. dashNb?: number;
  66682. updatable?: boolean;
  66683. instance?: LinesMesh;
  66684. }, scene?: Nullable<Scene>): LinesMesh;
  66685. /**
  66686. * 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.
  66687. * * 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.
  66688. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66689. * * 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.
  66690. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66691. * * 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
  66692. * * 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
  66693. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66695. * * 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
  66696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66698. * @param name defines the name of the mesh
  66699. * @param options defines the options used to create the mesh
  66700. * @param scene defines the hosting scene
  66701. * @returns the extruded shape mesh
  66702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66704. */
  66705. static ExtrudeShape(name: string, options: {
  66706. shape: Vector3[];
  66707. path: Vector3[];
  66708. scale?: number;
  66709. rotation?: number;
  66710. cap?: number;
  66711. updatable?: boolean;
  66712. sideOrientation?: number;
  66713. frontUVs?: Vector4;
  66714. backUVs?: Vector4;
  66715. instance?: Mesh;
  66716. invertUV?: boolean;
  66717. }, scene?: Nullable<Scene>): Mesh;
  66718. /**
  66719. * Creates an custom extruded shape mesh.
  66720. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66721. * * 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.
  66722. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66723. * * 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
  66724. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66725. * * 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
  66726. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66727. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66728. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  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 custom extruded shape mesh
  66740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66742. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66743. */
  66744. static ExtrudeShapeCustom(name: string, options: {
  66745. shape: Vector3[];
  66746. path: Vector3[];
  66747. scaleFunction?: any;
  66748. rotationFunction?: any;
  66749. ribbonCloseArray?: boolean;
  66750. ribbonClosePath?: boolean;
  66751. cap?: number;
  66752. updatable?: boolean;
  66753. sideOrientation?: number;
  66754. frontUVs?: Vector4;
  66755. backUVs?: Vector4;
  66756. instance?: Mesh;
  66757. invertUV?: boolean;
  66758. }, scene?: Nullable<Scene>): Mesh;
  66759. /**
  66760. * Creates lathe mesh.
  66761. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66762. * * 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
  66763. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66764. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66765. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66766. * * 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
  66767. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66768. * * 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
  66769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66770. * * 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
  66771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66773. * @param name defines the name of the mesh
  66774. * @param options defines the options used to create the mesh
  66775. * @param scene defines the hosting scene
  66776. * @returns the lathe mesh
  66777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66778. */
  66779. static CreateLathe(name: string, options: {
  66780. shape: Vector3[];
  66781. radius?: number;
  66782. tessellation?: number;
  66783. clip?: number;
  66784. arc?: number;
  66785. closed?: boolean;
  66786. updatable?: boolean;
  66787. sideOrientation?: number;
  66788. frontUVs?: Vector4;
  66789. backUVs?: Vector4;
  66790. cap?: number;
  66791. invertUV?: boolean;
  66792. }, scene?: Nullable<Scene>): Mesh;
  66793. /**
  66794. * Creates a tiled plane mesh
  66795. * * You can set a limited pattern arrangement with the tiles
  66796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66797. * * 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
  66798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66799. * @param name defines the name of the mesh
  66800. * @param options defines the options used to create the mesh
  66801. * @param scene defines the hosting scene
  66802. * @returns the plane mesh
  66803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66804. */
  66805. static CreateTiledPlane(name: string, options: {
  66806. pattern?: number;
  66807. tileSize?: number;
  66808. tileWidth?: number;
  66809. tileHeight?: number;
  66810. size?: number;
  66811. width?: number;
  66812. height?: number;
  66813. alignHorizontal?: number;
  66814. alignVertical?: number;
  66815. sideOrientation?: number;
  66816. frontUVs?: Vector4;
  66817. backUVs?: Vector4;
  66818. updatable?: boolean;
  66819. }, scene?: Nullable<Scene>): Mesh;
  66820. /**
  66821. * Creates a plane mesh
  66822. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66823. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66824. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66826. * * 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
  66827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66828. * @param name defines the name of the mesh
  66829. * @param options defines the options used to create the mesh
  66830. * @param scene defines the hosting scene
  66831. * @returns the plane mesh
  66832. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66833. */
  66834. static CreatePlane(name: string, options: {
  66835. size?: number;
  66836. width?: number;
  66837. height?: number;
  66838. sideOrientation?: number;
  66839. frontUVs?: Vector4;
  66840. backUVs?: Vector4;
  66841. updatable?: boolean;
  66842. sourcePlane?: Plane;
  66843. }, scene?: Nullable<Scene>): Mesh;
  66844. /**
  66845. * Creates a ground mesh
  66846. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66847. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66849. * @param name defines the name of the mesh
  66850. * @param options defines the options used to create the mesh
  66851. * @param scene defines the hosting scene
  66852. * @returns the ground mesh
  66853. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66854. */
  66855. static CreateGround(name: string, options: {
  66856. width?: number;
  66857. height?: number;
  66858. subdivisions?: number;
  66859. subdivisionsX?: number;
  66860. subdivisionsY?: number;
  66861. updatable?: boolean;
  66862. }, scene?: Nullable<Scene>): Mesh;
  66863. /**
  66864. * Creates a tiled ground mesh
  66865. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66866. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66867. * * 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
  66868. * * 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
  66869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66870. * @param name defines the name of the mesh
  66871. * @param options defines the options used to create the mesh
  66872. * @param scene defines the hosting scene
  66873. * @returns the tiled ground mesh
  66874. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66875. */
  66876. static CreateTiledGround(name: string, options: {
  66877. xmin: number;
  66878. zmin: number;
  66879. xmax: number;
  66880. zmax: number;
  66881. subdivisions?: {
  66882. w: number;
  66883. h: number;
  66884. };
  66885. precision?: {
  66886. w: number;
  66887. h: number;
  66888. };
  66889. updatable?: boolean;
  66890. }, scene?: Nullable<Scene>): Mesh;
  66891. /**
  66892. * Creates a ground mesh from a height map
  66893. * * The parameter `url` sets the URL of the height map image resource.
  66894. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66895. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66896. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66897. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66898. * * 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.
  66899. * * 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).
  66900. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66902. * @param name defines the name of the mesh
  66903. * @param url defines the url to the height map
  66904. * @param options defines the options used to create the mesh
  66905. * @param scene defines the hosting scene
  66906. * @returns the ground mesh
  66907. * @see https://doc.babylonjs.com/babylon101/height_map
  66908. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66909. */
  66910. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66911. width?: number;
  66912. height?: number;
  66913. subdivisions?: number;
  66914. minHeight?: number;
  66915. maxHeight?: number;
  66916. colorFilter?: Color3;
  66917. alphaFilter?: number;
  66918. updatable?: boolean;
  66919. onReady?: (mesh: GroundMesh) => void;
  66920. }, scene?: Nullable<Scene>): GroundMesh;
  66921. /**
  66922. * Creates a polygon mesh
  66923. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66924. * * 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
  66925. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66927. * * 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)
  66928. * * Remember you can only change the shape positions, not their number when updating a polygon
  66929. * @param name defines the name of the mesh
  66930. * @param options defines the options used to create the mesh
  66931. * @param scene defines the hosting scene
  66932. * @param earcutInjection can be used to inject your own earcut reference
  66933. * @returns the polygon mesh
  66934. */
  66935. static CreatePolygon(name: string, options: {
  66936. shape: Vector3[];
  66937. holes?: Vector3[][];
  66938. depth?: number;
  66939. faceUV?: Vector4[];
  66940. faceColors?: Color4[];
  66941. updatable?: boolean;
  66942. sideOrientation?: number;
  66943. frontUVs?: Vector4;
  66944. backUVs?: Vector4;
  66945. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66946. /**
  66947. * Creates an extruded polygon mesh, with depth in the Y direction.
  66948. * * 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)
  66949. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66950. * @param name defines the name of the mesh
  66951. * @param options defines the options used to create the mesh
  66952. * @param scene defines the hosting scene
  66953. * @param earcutInjection can be used to inject your own earcut reference
  66954. * @returns the polygon mesh
  66955. */
  66956. static ExtrudePolygon(name: string, options: {
  66957. shape: Vector3[];
  66958. holes?: Vector3[][];
  66959. depth?: number;
  66960. faceUV?: Vector4[];
  66961. faceColors?: Color4[];
  66962. updatable?: boolean;
  66963. sideOrientation?: number;
  66964. frontUVs?: Vector4;
  66965. backUVs?: Vector4;
  66966. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66967. /**
  66968. * Creates a tube mesh.
  66969. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66970. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66971. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66972. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66973. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66974. * * 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)
  66975. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66976. * * 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
  66977. * * 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
  66978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66979. * * 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
  66980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66982. * @param name defines the name of the mesh
  66983. * @param options defines the options used to create the mesh
  66984. * @param scene defines the hosting scene
  66985. * @returns the tube mesh
  66986. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66987. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66988. */
  66989. static CreateTube(name: string, options: {
  66990. path: Vector3[];
  66991. radius?: number;
  66992. tessellation?: number;
  66993. radiusFunction?: {
  66994. (i: number, distance: number): number;
  66995. };
  66996. cap?: number;
  66997. arc?: number;
  66998. updatable?: boolean;
  66999. sideOrientation?: number;
  67000. frontUVs?: Vector4;
  67001. backUVs?: Vector4;
  67002. instance?: Mesh;
  67003. invertUV?: boolean;
  67004. }, scene?: Nullable<Scene>): Mesh;
  67005. /**
  67006. * Creates a polyhedron mesh
  67007. * * 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
  67008. * * The parameter `size` (positive float, default 1) sets the polygon size
  67009. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67010. * * 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`
  67011. * * 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
  67012. * * 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)`)
  67013. * * 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
  67014. * * 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
  67015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67016. * * 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
  67017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67018. * @param name defines the name of the mesh
  67019. * @param options defines the options used to create the mesh
  67020. * @param scene defines the hosting scene
  67021. * @returns the polyhedron mesh
  67022. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67023. */
  67024. static CreatePolyhedron(name: string, options: {
  67025. type?: number;
  67026. size?: number;
  67027. sizeX?: number;
  67028. sizeY?: number;
  67029. sizeZ?: number;
  67030. custom?: any;
  67031. faceUV?: Vector4[];
  67032. faceColors?: Color4[];
  67033. flat?: boolean;
  67034. updatable?: boolean;
  67035. sideOrientation?: number;
  67036. frontUVs?: Vector4;
  67037. backUVs?: Vector4;
  67038. }, scene?: Nullable<Scene>): Mesh;
  67039. /**
  67040. * Creates a decal mesh.
  67041. * 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
  67042. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67043. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67044. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67045. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67046. * @param name defines the name of the mesh
  67047. * @param sourceMesh defines the mesh where the decal must be applied
  67048. * @param options defines the options used to create the mesh
  67049. * @param scene defines the hosting scene
  67050. * @returns the decal mesh
  67051. * @see https://doc.babylonjs.com/how_to/decals
  67052. */
  67053. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67054. position?: Vector3;
  67055. normal?: Vector3;
  67056. size?: Vector3;
  67057. angle?: number;
  67058. }): Mesh;
  67059. }
  67060. }
  67061. declare module "babylonjs/Meshes/meshSimplification" {
  67062. import { Mesh } from "babylonjs/Meshes/mesh";
  67063. /**
  67064. * A simplifier interface for future simplification implementations
  67065. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67066. */
  67067. export interface ISimplifier {
  67068. /**
  67069. * Simplification of a given mesh according to the given settings.
  67070. * Since this requires computation, it is assumed that the function runs async.
  67071. * @param settings The settings of the simplification, including quality and distance
  67072. * @param successCallback A callback that will be called after the mesh was simplified.
  67073. * @param errorCallback in case of an error, this callback will be called. optional.
  67074. */
  67075. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67076. }
  67077. /**
  67078. * Expected simplification settings.
  67079. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67080. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67081. */
  67082. export interface ISimplificationSettings {
  67083. /**
  67084. * Gets or sets the expected quality
  67085. */
  67086. quality: number;
  67087. /**
  67088. * Gets or sets the distance when this optimized version should be used
  67089. */
  67090. distance: number;
  67091. /**
  67092. * Gets an already optimized mesh
  67093. */
  67094. optimizeMesh?: boolean;
  67095. }
  67096. /**
  67097. * Class used to specify simplification options
  67098. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67099. */
  67100. export class SimplificationSettings implements ISimplificationSettings {
  67101. /** expected quality */
  67102. quality: number;
  67103. /** distance when this optimized version should be used */
  67104. distance: number;
  67105. /** already optimized mesh */
  67106. optimizeMesh?: boolean | undefined;
  67107. /**
  67108. * Creates a SimplificationSettings
  67109. * @param quality expected quality
  67110. * @param distance distance when this optimized version should be used
  67111. * @param optimizeMesh already optimized mesh
  67112. */
  67113. constructor(
  67114. /** expected quality */
  67115. quality: number,
  67116. /** distance when this optimized version should be used */
  67117. distance: number,
  67118. /** already optimized mesh */
  67119. optimizeMesh?: boolean | undefined);
  67120. }
  67121. /**
  67122. * Interface used to define a simplification task
  67123. */
  67124. export interface ISimplificationTask {
  67125. /**
  67126. * Array of settings
  67127. */
  67128. settings: Array<ISimplificationSettings>;
  67129. /**
  67130. * Simplification type
  67131. */
  67132. simplificationType: SimplificationType;
  67133. /**
  67134. * Mesh to simplify
  67135. */
  67136. mesh: Mesh;
  67137. /**
  67138. * Callback called on success
  67139. */
  67140. successCallback?: () => void;
  67141. /**
  67142. * Defines if parallel processing can be used
  67143. */
  67144. parallelProcessing: boolean;
  67145. }
  67146. /**
  67147. * Queue used to order the simplification tasks
  67148. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67149. */
  67150. export class SimplificationQueue {
  67151. private _simplificationArray;
  67152. /**
  67153. * Gets a boolean indicating that the process is still running
  67154. */
  67155. running: boolean;
  67156. /**
  67157. * Creates a new queue
  67158. */
  67159. constructor();
  67160. /**
  67161. * Adds a new simplification task
  67162. * @param task defines a task to add
  67163. */
  67164. addTask(task: ISimplificationTask): void;
  67165. /**
  67166. * Execute next task
  67167. */
  67168. executeNext(): void;
  67169. /**
  67170. * Execute a simplification task
  67171. * @param task defines the task to run
  67172. */
  67173. runSimplification(task: ISimplificationTask): void;
  67174. private getSimplifier;
  67175. }
  67176. /**
  67177. * The implemented types of simplification
  67178. * At the moment only Quadratic Error Decimation is implemented
  67179. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67180. */
  67181. export enum SimplificationType {
  67182. /** Quadratic error decimation */
  67183. QUADRATIC = 0
  67184. }
  67185. /**
  67186. * An implementation of the Quadratic Error simplification algorithm.
  67187. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67188. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67189. * @author RaananW
  67190. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67191. */
  67192. export class QuadraticErrorSimplification implements ISimplifier {
  67193. private _mesh;
  67194. private triangles;
  67195. private vertices;
  67196. private references;
  67197. private _reconstructedMesh;
  67198. /** Gets or sets the number pf sync interations */
  67199. syncIterations: number;
  67200. /** Gets or sets the aggressiveness of the simplifier */
  67201. aggressiveness: number;
  67202. /** Gets or sets the number of allowed iterations for decimation */
  67203. decimationIterations: number;
  67204. /** Gets or sets the espilon to use for bounding box computation */
  67205. boundingBoxEpsilon: number;
  67206. /**
  67207. * Creates a new QuadraticErrorSimplification
  67208. * @param _mesh defines the target mesh
  67209. */
  67210. constructor(_mesh: Mesh);
  67211. /**
  67212. * Simplification of a given mesh according to the given settings.
  67213. * Since this requires computation, it is assumed that the function runs async.
  67214. * @param settings The settings of the simplification, including quality and distance
  67215. * @param successCallback A callback that will be called after the mesh was simplified.
  67216. */
  67217. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67218. private runDecimation;
  67219. private initWithMesh;
  67220. private init;
  67221. private reconstructMesh;
  67222. private initDecimatedMesh;
  67223. private isFlipped;
  67224. private updateTriangles;
  67225. private identifyBorder;
  67226. private updateMesh;
  67227. private vertexError;
  67228. private calculateError;
  67229. }
  67230. }
  67231. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  67232. import { Scene } from "babylonjs/scene";
  67233. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  67234. import { ISceneComponent } from "babylonjs/sceneComponent";
  67235. module "babylonjs/scene" {
  67236. interface Scene {
  67237. /** @hidden (Backing field) */
  67238. _simplificationQueue: SimplificationQueue;
  67239. /**
  67240. * Gets or sets the simplification queue attached to the scene
  67241. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67242. */
  67243. simplificationQueue: SimplificationQueue;
  67244. }
  67245. }
  67246. module "babylonjs/Meshes/mesh" {
  67247. interface Mesh {
  67248. /**
  67249. * Simplify the mesh according to the given array of settings.
  67250. * Function will return immediately and will simplify async
  67251. * @param settings a collection of simplification settings
  67252. * @param parallelProcessing should all levels calculate parallel or one after the other
  67253. * @param simplificationType the type of simplification to run
  67254. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67255. * @returns the current mesh
  67256. */
  67257. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67258. }
  67259. }
  67260. /**
  67261. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67262. * created in a scene
  67263. */
  67264. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67265. /**
  67266. * The component name helpfull to identify the component in the list of scene components.
  67267. */
  67268. readonly name: string;
  67269. /**
  67270. * The scene the component belongs to.
  67271. */
  67272. scene: Scene;
  67273. /**
  67274. * Creates a new instance of the component for the given scene
  67275. * @param scene Defines the scene to register the component in
  67276. */
  67277. constructor(scene: Scene);
  67278. /**
  67279. * Registers the component in a given scene
  67280. */
  67281. register(): void;
  67282. /**
  67283. * Rebuilds the elements related to this component in case of
  67284. * context lost for instance.
  67285. */
  67286. rebuild(): void;
  67287. /**
  67288. * Disposes the component and the associated ressources
  67289. */
  67290. dispose(): void;
  67291. private _beforeCameraUpdate;
  67292. }
  67293. }
  67294. declare module "babylonjs/Meshes/Builders/index" {
  67295. export * from "babylonjs/Meshes/Builders/boxBuilder";
  67296. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  67297. export * from "babylonjs/Meshes/Builders/discBuilder";
  67298. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  67299. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  67300. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  67301. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  67302. export * from "babylonjs/Meshes/Builders/torusBuilder";
  67303. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  67304. export * from "babylonjs/Meshes/Builders/linesBuilder";
  67305. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  67306. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  67307. export * from "babylonjs/Meshes/Builders/latheBuilder";
  67308. export * from "babylonjs/Meshes/Builders/planeBuilder";
  67309. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  67310. export * from "babylonjs/Meshes/Builders/groundBuilder";
  67311. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  67312. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  67313. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  67314. export * from "babylonjs/Meshes/Builders/decalBuilder";
  67315. }
  67316. declare module "babylonjs/Meshes/index" {
  67317. export * from "babylonjs/Meshes/abstractMesh";
  67318. export * from "babylonjs/Meshes/buffer";
  67319. export * from "babylonjs/Meshes/Compression/index";
  67320. export * from "babylonjs/Meshes/csg";
  67321. export * from "babylonjs/Meshes/geometry";
  67322. export * from "babylonjs/Meshes/groundMesh";
  67323. export * from "babylonjs/Meshes/trailMesh";
  67324. export * from "babylonjs/Meshes/instancedMesh";
  67325. export * from "babylonjs/Meshes/linesMesh";
  67326. export * from "babylonjs/Meshes/mesh";
  67327. export * from "babylonjs/Meshes/mesh.vertexData";
  67328. export * from "babylonjs/Meshes/meshBuilder";
  67329. export * from "babylonjs/Meshes/meshSimplification";
  67330. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  67331. export * from "babylonjs/Meshes/polygonMesh";
  67332. export * from "babylonjs/Meshes/subMesh";
  67333. export * from "babylonjs/Meshes/meshLODLevel";
  67334. export * from "babylonjs/Meshes/transformNode";
  67335. export * from "babylonjs/Meshes/Builders/index";
  67336. export * from "babylonjs/Meshes/dataBuffer";
  67337. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  67338. }
  67339. declare module "babylonjs/Morph/index" {
  67340. export * from "babylonjs/Morph/morphTarget";
  67341. export * from "babylonjs/Morph/morphTargetManager";
  67342. }
  67343. declare module "babylonjs/Navigation/INavigationEngine" {
  67344. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67345. import { Vector3 } from "babylonjs/Maths/math";
  67346. import { Mesh } from "babylonjs/Meshes/mesh";
  67347. import { Scene } from "babylonjs/scene";
  67348. /**
  67349. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67350. */
  67351. export interface INavigationEnginePlugin {
  67352. /**
  67353. * plugin name
  67354. */
  67355. name: string;
  67356. /**
  67357. * Creates a navigation mesh
  67358. * @param meshes array of all the geometry used to compute the navigatio mesh
  67359. * @param parameters bunch of parameters used to filter geometry
  67360. */
  67361. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67362. /**
  67363. * Create a navigation mesh debug mesh
  67364. * @param scene is where the mesh will be added
  67365. * @returns debug display mesh
  67366. */
  67367. createDebugNavMesh(scene: Scene): Mesh;
  67368. /**
  67369. * Get a navigation mesh constrained position, closest to the parameter position
  67370. * @param position world position
  67371. * @returns the closest point to position constrained by the navigation mesh
  67372. */
  67373. getClosestPoint(position: Vector3): Vector3;
  67374. /**
  67375. * Get a navigation mesh constrained position, closest to the parameter position
  67376. * @param position world position
  67377. * @param result output the closest point to position constrained by the navigation mesh
  67378. */
  67379. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67380. /**
  67381. * Get a navigation mesh constrained position, within a particular radius
  67382. * @param position world position
  67383. * @param maxRadius the maximum distance to the constrained world position
  67384. * @returns the closest point to position constrained by the navigation mesh
  67385. */
  67386. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67387. /**
  67388. * Get a navigation mesh constrained position, within a particular radius
  67389. * @param position world position
  67390. * @param maxRadius the maximum distance to the constrained world position
  67391. * @param result output the closest point to position constrained by the navigation mesh
  67392. */
  67393. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67394. /**
  67395. * Compute the final position from a segment made of destination-position
  67396. * @param position world position
  67397. * @param destination world position
  67398. * @returns the resulting point along the navmesh
  67399. */
  67400. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67401. /**
  67402. * Compute the final position from a segment made of destination-position
  67403. * @param position world position
  67404. * @param destination world position
  67405. * @param result output the resulting point along the navmesh
  67406. */
  67407. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67408. /**
  67409. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67410. * @param start world position
  67411. * @param end world position
  67412. * @returns array containing world position composing the path
  67413. */
  67414. computePath(start: Vector3, end: Vector3): Vector3[];
  67415. /**
  67416. * If this plugin is supported
  67417. * @returns true if plugin is supported
  67418. */
  67419. isSupported(): boolean;
  67420. /**
  67421. * Create a new Crowd so you can add agents
  67422. * @param maxAgents the maximum agent count in the crowd
  67423. * @param maxAgentRadius the maximum radius an agent can have
  67424. * @param scene to attach the crowd to
  67425. * @returns the crowd you can add agents to
  67426. */
  67427. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67428. /**
  67429. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67430. * The queries will try to find a solution within those bounds
  67431. * default is (1,1,1)
  67432. * @param extent x,y,z value that define the extent around the queries point of reference
  67433. */
  67434. setDefaultQueryExtent(extent: Vector3): void;
  67435. /**
  67436. * Get the Bounding box extent specified by setDefaultQueryExtent
  67437. * @returns the box extent values
  67438. */
  67439. getDefaultQueryExtent(): Vector3;
  67440. /**
  67441. * build the navmesh from a previously saved state using getNavmeshData
  67442. * @param data the Uint8Array returned by getNavmeshData
  67443. */
  67444. buildFromNavmeshData(data: Uint8Array): void;
  67445. /**
  67446. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67447. * @returns data the Uint8Array that can be saved and reused
  67448. */
  67449. getNavmeshData(): Uint8Array;
  67450. /**
  67451. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67452. * @param result output the box extent values
  67453. */
  67454. getDefaultQueryExtentToRef(result: Vector3): void;
  67455. /**
  67456. * Release all resources
  67457. */
  67458. dispose(): void;
  67459. }
  67460. /**
  67461. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67462. */
  67463. export interface ICrowd {
  67464. /**
  67465. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67466. * You can attach anything to that node. The node position is updated in the scene update tick.
  67467. * @param pos world position that will be constrained by the navigation mesh
  67468. * @param parameters agent parameters
  67469. * @param transform hooked to the agent that will be update by the scene
  67470. * @returns agent index
  67471. */
  67472. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67473. /**
  67474. * Returns the agent position in world space
  67475. * @param index agent index returned by addAgent
  67476. * @returns world space position
  67477. */
  67478. getAgentPosition(index: number): Vector3;
  67479. /**
  67480. * Gets the agent position result in world space
  67481. * @param index agent index returned by addAgent
  67482. * @param result output world space position
  67483. */
  67484. getAgentPositionToRef(index: number, result: Vector3): void;
  67485. /**
  67486. * Gets the agent velocity in world space
  67487. * @param index agent index returned by addAgent
  67488. * @returns world space velocity
  67489. */
  67490. getAgentVelocity(index: number): Vector3;
  67491. /**
  67492. * Gets the agent velocity result in world space
  67493. * @param index agent index returned by addAgent
  67494. * @param result output world space velocity
  67495. */
  67496. getAgentVelocityToRef(index: number, result: Vector3): void;
  67497. /**
  67498. * remove a particular agent previously created
  67499. * @param index agent index returned by addAgent
  67500. */
  67501. removeAgent(index: number): void;
  67502. /**
  67503. * get the list of all agents attached to this crowd
  67504. * @returns list of agent indices
  67505. */
  67506. getAgents(): number[];
  67507. /**
  67508. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67509. * @param deltaTime in seconds
  67510. */
  67511. update(deltaTime: number): void;
  67512. /**
  67513. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67514. * @param index agent index returned by addAgent
  67515. * @param destination targeted world position
  67516. */
  67517. agentGoto(index: number, destination: Vector3): void;
  67518. /**
  67519. * Teleport the agent to a new position
  67520. * @param index agent index returned by addAgent
  67521. * @param destination targeted world position
  67522. */
  67523. agentTeleport(index: number, destination: Vector3): void;
  67524. /**
  67525. * Update agent parameters
  67526. * @param index agent index returned by addAgent
  67527. * @param parameters agent parameters
  67528. */
  67529. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67530. /**
  67531. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67532. * The queries will try to find a solution within those bounds
  67533. * default is (1,1,1)
  67534. * @param extent x,y,z value that define the extent around the queries point of reference
  67535. */
  67536. setDefaultQueryExtent(extent: Vector3): void;
  67537. /**
  67538. * Get the Bounding box extent specified by setDefaultQueryExtent
  67539. * @returns the box extent values
  67540. */
  67541. getDefaultQueryExtent(): Vector3;
  67542. /**
  67543. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67544. * @param result output the box extent values
  67545. */
  67546. getDefaultQueryExtentToRef(result: Vector3): void;
  67547. /**
  67548. * Release all resources
  67549. */
  67550. dispose(): void;
  67551. }
  67552. /**
  67553. * Configures an agent
  67554. */
  67555. export interface IAgentParameters {
  67556. /**
  67557. * Agent radius. [Limit: >= 0]
  67558. */
  67559. radius: number;
  67560. /**
  67561. * Agent height. [Limit: > 0]
  67562. */
  67563. height: number;
  67564. /**
  67565. * Maximum allowed acceleration. [Limit: >= 0]
  67566. */
  67567. maxAcceleration: number;
  67568. /**
  67569. * Maximum allowed speed. [Limit: >= 0]
  67570. */
  67571. maxSpeed: number;
  67572. /**
  67573. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67574. */
  67575. collisionQueryRange: number;
  67576. /**
  67577. * The path visibility optimization range. [Limit: > 0]
  67578. */
  67579. pathOptimizationRange: number;
  67580. /**
  67581. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67582. */
  67583. separationWeight: number;
  67584. }
  67585. /**
  67586. * Configures the navigation mesh creation
  67587. */
  67588. export interface INavMeshParameters {
  67589. /**
  67590. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67591. */
  67592. cs: number;
  67593. /**
  67594. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67595. */
  67596. ch: number;
  67597. /**
  67598. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67599. */
  67600. walkableSlopeAngle: number;
  67601. /**
  67602. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67603. * be considered walkable. [Limit: >= 3] [Units: vx]
  67604. */
  67605. walkableHeight: number;
  67606. /**
  67607. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67608. */
  67609. walkableClimb: number;
  67610. /**
  67611. * The distance to erode/shrink the walkable area of the heightfield away from
  67612. * obstructions. [Limit: >=0] [Units: vx]
  67613. */
  67614. walkableRadius: number;
  67615. /**
  67616. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67617. */
  67618. maxEdgeLen: number;
  67619. /**
  67620. * The maximum distance a simplfied contour's border edges should deviate
  67621. * the original raw contour. [Limit: >=0] [Units: vx]
  67622. */
  67623. maxSimplificationError: number;
  67624. /**
  67625. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67626. */
  67627. minRegionArea: number;
  67628. /**
  67629. * Any regions with a span count smaller than this value will, if possible,
  67630. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67631. */
  67632. mergeRegionArea: number;
  67633. /**
  67634. * The maximum number of vertices allowed for polygons generated during the
  67635. * contour to polygon conversion process. [Limit: >= 3]
  67636. */
  67637. maxVertsPerPoly: number;
  67638. /**
  67639. * Sets the sampling distance to use when generating the detail mesh.
  67640. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67641. */
  67642. detailSampleDist: number;
  67643. /**
  67644. * The maximum distance the detail mesh surface should deviate from heightfield
  67645. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67646. */
  67647. detailSampleMaxError: number;
  67648. }
  67649. }
  67650. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  67651. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  67652. import { Mesh } from "babylonjs/Meshes/mesh";
  67653. import { Scene } from "babylonjs/scene";
  67654. import { Vector3 } from "babylonjs/Maths/math";
  67655. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67656. /**
  67657. * RecastJS navigation plugin
  67658. */
  67659. export class RecastJSPlugin implements INavigationEnginePlugin {
  67660. /**
  67661. * Reference to the Recast library
  67662. */
  67663. bjsRECAST: any;
  67664. /**
  67665. * plugin name
  67666. */
  67667. name: string;
  67668. /**
  67669. * the first navmesh created. We might extend this to support multiple navmeshes
  67670. */
  67671. navMesh: any;
  67672. /**
  67673. * Initializes the recastJS plugin
  67674. * @param recastInjection can be used to inject your own recast reference
  67675. */
  67676. constructor(recastInjection?: any);
  67677. /**
  67678. * Creates a navigation mesh
  67679. * @param meshes array of all the geometry used to compute the navigatio mesh
  67680. * @param parameters bunch of parameters used to filter geometry
  67681. */
  67682. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67683. /**
  67684. * Create a navigation mesh debug mesh
  67685. * @param scene is where the mesh will be added
  67686. * @returns debug display mesh
  67687. */
  67688. createDebugNavMesh(scene: Scene): Mesh;
  67689. /**
  67690. * Get a navigation mesh constrained position, closest to the parameter position
  67691. * @param position world position
  67692. * @returns the closest point to position constrained by the navigation mesh
  67693. */
  67694. getClosestPoint(position: Vector3): Vector3;
  67695. /**
  67696. * Get a navigation mesh constrained position, closest to the parameter position
  67697. * @param position world position
  67698. * @param result output the closest point to position constrained by the navigation mesh
  67699. */
  67700. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67701. /**
  67702. * Get a navigation mesh constrained position, within a particular radius
  67703. * @param position world position
  67704. * @param maxRadius the maximum distance to the constrained world position
  67705. * @returns the closest point to position constrained by the navigation mesh
  67706. */
  67707. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67708. /**
  67709. * Get a navigation mesh constrained position, within a particular radius
  67710. * @param position world position
  67711. * @param maxRadius the maximum distance to the constrained world position
  67712. * @param result output the closest point to position constrained by the navigation mesh
  67713. */
  67714. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67715. /**
  67716. * Compute the final position from a segment made of destination-position
  67717. * @param position world position
  67718. * @param destination world position
  67719. * @returns the resulting point along the navmesh
  67720. */
  67721. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67722. /**
  67723. * Compute the final position from a segment made of destination-position
  67724. * @param position world position
  67725. * @param destination world position
  67726. * @param result output the resulting point along the navmesh
  67727. */
  67728. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67729. /**
  67730. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67731. * @param start world position
  67732. * @param end world position
  67733. * @returns array containing world position composing the path
  67734. */
  67735. computePath(start: Vector3, end: Vector3): Vector3[];
  67736. /**
  67737. * Create a new Crowd so you can add agents
  67738. * @param maxAgents the maximum agent count in the crowd
  67739. * @param maxAgentRadius the maximum radius an agent can have
  67740. * @param scene to attach the crowd to
  67741. * @returns the crowd you can add agents to
  67742. */
  67743. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67744. /**
  67745. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67746. * The queries will try to find a solution within those bounds
  67747. * default is (1,1,1)
  67748. * @param extent x,y,z value that define the extent around the queries point of reference
  67749. */
  67750. setDefaultQueryExtent(extent: Vector3): void;
  67751. /**
  67752. * Get the Bounding box extent specified by setDefaultQueryExtent
  67753. * @returns the box extent values
  67754. */
  67755. getDefaultQueryExtent(): Vector3;
  67756. /**
  67757. * build the navmesh from a previously saved state using getNavmeshData
  67758. * @param data the Uint8Array returned by getNavmeshData
  67759. */
  67760. buildFromNavmeshData(data: Uint8Array): void;
  67761. /**
  67762. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67763. * @returns data the Uint8Array that can be saved and reused
  67764. */
  67765. getNavmeshData(): Uint8Array;
  67766. /**
  67767. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67768. * @param result output the box extent values
  67769. */
  67770. getDefaultQueryExtentToRef(result: Vector3): void;
  67771. /**
  67772. * Disposes
  67773. */
  67774. dispose(): void;
  67775. /**
  67776. * If this plugin is supported
  67777. * @returns true if plugin is supported
  67778. */
  67779. isSupported(): boolean;
  67780. }
  67781. /**
  67782. * Recast detour crowd implementation
  67783. */
  67784. export class RecastJSCrowd implements ICrowd {
  67785. /**
  67786. * Recast/detour plugin
  67787. */
  67788. bjsRECASTPlugin: RecastJSPlugin;
  67789. /**
  67790. * Link to the detour crowd
  67791. */
  67792. recastCrowd: any;
  67793. /**
  67794. * One transform per agent
  67795. */
  67796. transforms: TransformNode[];
  67797. /**
  67798. * All agents created
  67799. */
  67800. agents: number[];
  67801. /**
  67802. * Link to the scene is kept to unregister the crowd from the scene
  67803. */
  67804. private _scene;
  67805. /**
  67806. * Observer for crowd updates
  67807. */
  67808. private _onBeforeAnimationsObserver;
  67809. /**
  67810. * Constructor
  67811. * @param plugin recastJS plugin
  67812. * @param maxAgents the maximum agent count in the crowd
  67813. * @param maxAgentRadius the maximum radius an agent can have
  67814. * @param scene to attach the crowd to
  67815. * @returns the crowd you can add agents to
  67816. */
  67817. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67818. /**
  67819. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67820. * You can attach anything to that node. The node position is updated in the scene update tick.
  67821. * @param pos world position that will be constrained by the navigation mesh
  67822. * @param parameters agent parameters
  67823. * @param transform hooked to the agent that will be update by the scene
  67824. * @returns agent index
  67825. */
  67826. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67827. /**
  67828. * Returns the agent position in world space
  67829. * @param index agent index returned by addAgent
  67830. * @returns world space position
  67831. */
  67832. getAgentPosition(index: number): Vector3;
  67833. /**
  67834. * Returns the agent position result in world space
  67835. * @param index agent index returned by addAgent
  67836. * @param result output world space position
  67837. */
  67838. getAgentPositionToRef(index: number, result: Vector3): void;
  67839. /**
  67840. * Returns the agent velocity in world space
  67841. * @param index agent index returned by addAgent
  67842. * @returns world space velocity
  67843. */
  67844. getAgentVelocity(index: number): Vector3;
  67845. /**
  67846. * Returns the agent velocity result in world space
  67847. * @param index agent index returned by addAgent
  67848. * @param result output world space velocity
  67849. */
  67850. getAgentVelocityToRef(index: number, result: Vector3): void;
  67851. /**
  67852. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67853. * @param index agent index returned by addAgent
  67854. * @param destination targeted world position
  67855. */
  67856. agentGoto(index: number, destination: Vector3): void;
  67857. /**
  67858. * Teleport the agent to a new position
  67859. * @param index agent index returned by addAgent
  67860. * @param destination targeted world position
  67861. */
  67862. agentTeleport(index: number, destination: Vector3): void;
  67863. /**
  67864. * Update agent parameters
  67865. * @param index agent index returned by addAgent
  67866. * @param parameters agent parameters
  67867. */
  67868. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67869. /**
  67870. * remove a particular agent previously created
  67871. * @param index agent index returned by addAgent
  67872. */
  67873. removeAgent(index: number): void;
  67874. /**
  67875. * get the list of all agents attached to this crowd
  67876. * @returns list of agent indices
  67877. */
  67878. getAgents(): number[];
  67879. /**
  67880. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67881. * @param deltaTime in seconds
  67882. */
  67883. update(deltaTime: number): void;
  67884. /**
  67885. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67886. * The queries will try to find a solution within those bounds
  67887. * default is (1,1,1)
  67888. * @param extent x,y,z value that define the extent around the queries point of reference
  67889. */
  67890. setDefaultQueryExtent(extent: Vector3): void;
  67891. /**
  67892. * Get the Bounding box extent specified by setDefaultQueryExtent
  67893. * @returns the box extent values
  67894. */
  67895. getDefaultQueryExtent(): Vector3;
  67896. /**
  67897. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67898. * @param result output the box extent values
  67899. */
  67900. getDefaultQueryExtentToRef(result: Vector3): void;
  67901. /**
  67902. * Release all resources
  67903. */
  67904. dispose(): void;
  67905. }
  67906. }
  67907. declare module "babylonjs/Navigation/Plugins/index" {
  67908. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  67909. }
  67910. declare module "babylonjs/Navigation/index" {
  67911. export * from "babylonjs/Navigation/INavigationEngine";
  67912. export * from "babylonjs/Navigation/Plugins/index";
  67913. }
  67914. declare module "babylonjs/Offline/database" {
  67915. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  67916. /**
  67917. * Class used to enable access to IndexedDB
  67918. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67919. */
  67920. export class Database implements IOfflineProvider {
  67921. private _callbackManifestChecked;
  67922. private _currentSceneUrl;
  67923. private _db;
  67924. private _enableSceneOffline;
  67925. private _enableTexturesOffline;
  67926. private _manifestVersionFound;
  67927. private _mustUpdateRessources;
  67928. private _hasReachedQuota;
  67929. private _isSupported;
  67930. private _idbFactory;
  67931. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67932. private static IsUASupportingBlobStorage;
  67933. /**
  67934. * Gets a boolean indicating if Database storate is enabled (off by default)
  67935. */
  67936. static IDBStorageEnabled: boolean;
  67937. /**
  67938. * Gets a boolean indicating if scene must be saved in the database
  67939. */
  67940. get enableSceneOffline(): boolean;
  67941. /**
  67942. * Gets a boolean indicating if textures must be saved in the database
  67943. */
  67944. get enableTexturesOffline(): boolean;
  67945. /**
  67946. * Creates a new Database
  67947. * @param urlToScene defines the url to load the scene
  67948. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67949. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67950. */
  67951. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67952. private static _ParseURL;
  67953. private static _ReturnFullUrlLocation;
  67954. private _checkManifestFile;
  67955. /**
  67956. * Open the database and make it available
  67957. * @param successCallback defines the callback to call on success
  67958. * @param errorCallback defines the callback to call on error
  67959. */
  67960. open(successCallback: () => void, errorCallback: () => void): void;
  67961. /**
  67962. * Loads an image from the database
  67963. * @param url defines the url to load from
  67964. * @param image defines the target DOM image
  67965. */
  67966. loadImage(url: string, image: HTMLImageElement): void;
  67967. private _loadImageFromDBAsync;
  67968. private _saveImageIntoDBAsync;
  67969. private _checkVersionFromDB;
  67970. private _loadVersionFromDBAsync;
  67971. private _saveVersionIntoDBAsync;
  67972. /**
  67973. * Loads a file from database
  67974. * @param url defines the URL to load from
  67975. * @param sceneLoaded defines a callback to call on success
  67976. * @param progressCallBack defines a callback to call when progress changed
  67977. * @param errorCallback defines a callback to call on error
  67978. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67979. */
  67980. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67981. private _loadFileAsync;
  67982. private _saveFileAsync;
  67983. /**
  67984. * Validates if xhr data is correct
  67985. * @param xhr defines the request to validate
  67986. * @param dataType defines the expected data type
  67987. * @returns true if data is correct
  67988. */
  67989. private static _ValidateXHRData;
  67990. }
  67991. }
  67992. declare module "babylonjs/Offline/index" {
  67993. export * from "babylonjs/Offline/database";
  67994. export * from "babylonjs/Offline/IOfflineProvider";
  67995. }
  67996. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  67997. /** @hidden */
  67998. export var gpuUpdateParticlesPixelShader: {
  67999. name: string;
  68000. shader: string;
  68001. };
  68002. }
  68003. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  68004. /** @hidden */
  68005. export var gpuUpdateParticlesVertexShader: {
  68006. name: string;
  68007. shader: string;
  68008. };
  68009. }
  68010. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  68011. /** @hidden */
  68012. export var clipPlaneFragmentDeclaration2: {
  68013. name: string;
  68014. shader: string;
  68015. };
  68016. }
  68017. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  68018. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  68019. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  68020. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68021. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  68022. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  68023. /** @hidden */
  68024. export var gpuRenderParticlesPixelShader: {
  68025. name: string;
  68026. shader: string;
  68027. };
  68028. }
  68029. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  68030. /** @hidden */
  68031. export var clipPlaneVertexDeclaration2: {
  68032. name: string;
  68033. shader: string;
  68034. };
  68035. }
  68036. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  68037. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  68038. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  68039. /** @hidden */
  68040. export var gpuRenderParticlesVertexShader: {
  68041. name: string;
  68042. shader: string;
  68043. };
  68044. }
  68045. declare module "babylonjs/Particles/gpuParticleSystem" {
  68046. import { Nullable } from "babylonjs/types";
  68047. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  68048. import { Observable } from "babylonjs/Misc/observable";
  68049. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68050. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68051. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  68052. import { Scene, IDisposable } from "babylonjs/scene";
  68053. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68054. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68055. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  68056. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  68057. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  68058. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  68059. /**
  68060. * This represents a GPU particle system in Babylon
  68061. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68062. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68063. */
  68064. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68065. /**
  68066. * The layer mask we are rendering the particles through.
  68067. */
  68068. layerMask: number;
  68069. private _capacity;
  68070. private _activeCount;
  68071. private _currentActiveCount;
  68072. private _accumulatedCount;
  68073. private _renderEffect;
  68074. private _updateEffect;
  68075. private _buffer0;
  68076. private _buffer1;
  68077. private _spriteBuffer;
  68078. private _updateVAO;
  68079. private _renderVAO;
  68080. private _targetIndex;
  68081. private _sourceBuffer;
  68082. private _targetBuffer;
  68083. private _engine;
  68084. private _currentRenderId;
  68085. private _started;
  68086. private _stopped;
  68087. private _timeDelta;
  68088. private _randomTexture;
  68089. private _randomTexture2;
  68090. private _attributesStrideSize;
  68091. private _updateEffectOptions;
  68092. private _randomTextureSize;
  68093. private _actualFrame;
  68094. private readonly _rawTextureWidth;
  68095. /**
  68096. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68097. */
  68098. static get IsSupported(): boolean;
  68099. /**
  68100. * An event triggered when the system is disposed.
  68101. */
  68102. onDisposeObservable: Observable<GPUParticleSystem>;
  68103. /**
  68104. * Gets the maximum number of particles active at the same time.
  68105. * @returns The max number of active particles.
  68106. */
  68107. getCapacity(): number;
  68108. /**
  68109. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68110. * to override the particles.
  68111. */
  68112. forceDepthWrite: boolean;
  68113. /**
  68114. * Gets or set the number of active particles
  68115. */
  68116. get activeParticleCount(): number;
  68117. set activeParticleCount(value: number);
  68118. private _preWarmDone;
  68119. /**
  68120. * Specifies if the particles are updated in emitter local space or world space.
  68121. */
  68122. isLocal: boolean;
  68123. /**
  68124. * Is this system ready to be used/rendered
  68125. * @return true if the system is ready
  68126. */
  68127. isReady(): boolean;
  68128. /**
  68129. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68130. * @returns True if it has been started, otherwise false.
  68131. */
  68132. isStarted(): boolean;
  68133. /**
  68134. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68135. * @returns True if it has been stopped, otherwise false.
  68136. */
  68137. isStopped(): boolean;
  68138. /**
  68139. * Gets a boolean indicating that the system is stopping
  68140. * @returns true if the system is currently stopping
  68141. */
  68142. isStopping(): boolean;
  68143. /**
  68144. * Gets the number of particles active at the same time.
  68145. * @returns The number of active particles.
  68146. */
  68147. getActiveCount(): number;
  68148. /**
  68149. * Starts the particle system and begins to emit
  68150. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68151. */
  68152. start(delay?: number): void;
  68153. /**
  68154. * Stops the particle system.
  68155. */
  68156. stop(): void;
  68157. /**
  68158. * Remove all active particles
  68159. */
  68160. reset(): void;
  68161. /**
  68162. * Returns the string "GPUParticleSystem"
  68163. * @returns a string containing the class name
  68164. */
  68165. getClassName(): string;
  68166. private _colorGradientsTexture;
  68167. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68168. /**
  68169. * Adds a new color gradient
  68170. * @param gradient defines the gradient to use (between 0 and 1)
  68171. * @param color1 defines the color to affect to the specified gradient
  68172. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68173. * @returns the current particle system
  68174. */
  68175. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68176. private _refreshColorGradient;
  68177. /** Force the system to rebuild all gradients that need to be resync */
  68178. forceRefreshGradients(): void;
  68179. /**
  68180. * Remove a specific color gradient
  68181. * @param gradient defines the gradient to remove
  68182. * @returns the current particle system
  68183. */
  68184. removeColorGradient(gradient: number): GPUParticleSystem;
  68185. private _angularSpeedGradientsTexture;
  68186. private _sizeGradientsTexture;
  68187. private _velocityGradientsTexture;
  68188. private _limitVelocityGradientsTexture;
  68189. private _dragGradientsTexture;
  68190. private _addFactorGradient;
  68191. /**
  68192. * Adds a new size gradient
  68193. * @param gradient defines the gradient to use (between 0 and 1)
  68194. * @param factor defines the size factor to affect to the specified gradient
  68195. * @returns the current particle system
  68196. */
  68197. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68198. /**
  68199. * Remove a specific size gradient
  68200. * @param gradient defines the gradient to remove
  68201. * @returns the current particle system
  68202. */
  68203. removeSizeGradient(gradient: number): GPUParticleSystem;
  68204. private _refreshFactorGradient;
  68205. /**
  68206. * Adds a new angular speed gradient
  68207. * @param gradient defines the gradient to use (between 0 and 1)
  68208. * @param factor defines the angular speed to affect to the specified gradient
  68209. * @returns the current particle system
  68210. */
  68211. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68212. /**
  68213. * Remove a specific angular speed gradient
  68214. * @param gradient defines the gradient to remove
  68215. * @returns the current particle system
  68216. */
  68217. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68218. /**
  68219. * Adds a new velocity gradient
  68220. * @param gradient defines the gradient to use (between 0 and 1)
  68221. * @param factor defines the velocity to affect to the specified gradient
  68222. * @returns the current particle system
  68223. */
  68224. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68225. /**
  68226. * Remove a specific velocity gradient
  68227. * @param gradient defines the gradient to remove
  68228. * @returns the current particle system
  68229. */
  68230. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68231. /**
  68232. * Adds a new limit velocity gradient
  68233. * @param gradient defines the gradient to use (between 0 and 1)
  68234. * @param factor defines the limit velocity value to affect to the specified gradient
  68235. * @returns the current particle system
  68236. */
  68237. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68238. /**
  68239. * Remove a specific limit velocity gradient
  68240. * @param gradient defines the gradient to remove
  68241. * @returns the current particle system
  68242. */
  68243. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68244. /**
  68245. * Adds a new drag gradient
  68246. * @param gradient defines the gradient to use (between 0 and 1)
  68247. * @param factor defines the drag value to affect to the specified gradient
  68248. * @returns the current particle system
  68249. */
  68250. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68251. /**
  68252. * Remove a specific drag gradient
  68253. * @param gradient defines the gradient to remove
  68254. * @returns the current particle system
  68255. */
  68256. removeDragGradient(gradient: number): GPUParticleSystem;
  68257. /**
  68258. * Not supported by GPUParticleSystem
  68259. * @param gradient defines the gradient to use (between 0 and 1)
  68260. * @param factor defines the emit rate value to affect to the specified gradient
  68261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68262. * @returns the current particle system
  68263. */
  68264. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68265. /**
  68266. * Not supported by GPUParticleSystem
  68267. * @param gradient defines the gradient to remove
  68268. * @returns the current particle system
  68269. */
  68270. removeEmitRateGradient(gradient: number): IParticleSystem;
  68271. /**
  68272. * Not supported by GPUParticleSystem
  68273. * @param gradient defines the gradient to use (between 0 and 1)
  68274. * @param factor defines the start size value to affect to the specified gradient
  68275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68276. * @returns the current particle system
  68277. */
  68278. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68279. /**
  68280. * Not supported by GPUParticleSystem
  68281. * @param gradient defines the gradient to remove
  68282. * @returns the current particle system
  68283. */
  68284. removeStartSizeGradient(gradient: number): IParticleSystem;
  68285. /**
  68286. * Not supported by GPUParticleSystem
  68287. * @param gradient defines the gradient to use (between 0 and 1)
  68288. * @param min defines the color remap minimal range
  68289. * @param max defines the color remap maximal range
  68290. * @returns the current particle system
  68291. */
  68292. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68293. /**
  68294. * Not supported by GPUParticleSystem
  68295. * @param gradient defines the gradient to remove
  68296. * @returns the current particle system
  68297. */
  68298. removeColorRemapGradient(): IParticleSystem;
  68299. /**
  68300. * Not supported by GPUParticleSystem
  68301. * @param gradient defines the gradient to use (between 0 and 1)
  68302. * @param min defines the alpha remap minimal range
  68303. * @param max defines the alpha remap maximal range
  68304. * @returns the current particle system
  68305. */
  68306. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68307. /**
  68308. * Not supported by GPUParticleSystem
  68309. * @param gradient defines the gradient to remove
  68310. * @returns the current particle system
  68311. */
  68312. removeAlphaRemapGradient(): IParticleSystem;
  68313. /**
  68314. * Not supported by GPUParticleSystem
  68315. * @param gradient defines the gradient to use (between 0 and 1)
  68316. * @param color defines the color to affect to the specified gradient
  68317. * @returns the current particle system
  68318. */
  68319. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68320. /**
  68321. * Not supported by GPUParticleSystem
  68322. * @param gradient defines the gradient to remove
  68323. * @returns the current particle system
  68324. */
  68325. removeRampGradient(): IParticleSystem;
  68326. /**
  68327. * Not supported by GPUParticleSystem
  68328. * @returns the list of ramp gradients
  68329. */
  68330. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68331. /**
  68332. * Not supported by GPUParticleSystem
  68333. * Gets or sets a boolean indicating that ramp gradients must be used
  68334. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68335. */
  68336. get useRampGradients(): boolean;
  68337. set useRampGradients(value: boolean);
  68338. /**
  68339. * Not supported by GPUParticleSystem
  68340. * @param gradient defines the gradient to use (between 0 and 1)
  68341. * @param factor defines the life time factor to affect to the specified gradient
  68342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68343. * @returns the current particle system
  68344. */
  68345. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68346. /**
  68347. * Not supported by GPUParticleSystem
  68348. * @param gradient defines the gradient to remove
  68349. * @returns the current particle system
  68350. */
  68351. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68352. /**
  68353. * Instantiates a GPU particle system.
  68354. * 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.
  68355. * @param name The name of the particle system
  68356. * @param options The options used to create the system
  68357. * @param scene The scene the particle system belongs to
  68358. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68359. */
  68360. constructor(name: string, options: Partial<{
  68361. capacity: number;
  68362. randomTextureSize: number;
  68363. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  68364. protected _reset(): void;
  68365. private _createUpdateVAO;
  68366. private _createRenderVAO;
  68367. private _initialize;
  68368. /** @hidden */
  68369. _recreateUpdateEffect(): void;
  68370. /** @hidden */
  68371. _recreateRenderEffect(): void;
  68372. /**
  68373. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68374. * @param preWarm defines if we are in the pre-warmimg phase
  68375. */
  68376. animate(preWarm?: boolean): void;
  68377. private _createFactorGradientTexture;
  68378. private _createSizeGradientTexture;
  68379. private _createAngularSpeedGradientTexture;
  68380. private _createVelocityGradientTexture;
  68381. private _createLimitVelocityGradientTexture;
  68382. private _createDragGradientTexture;
  68383. private _createColorGradientTexture;
  68384. /**
  68385. * Renders the particle system in its current state
  68386. * @param preWarm defines if the system should only update the particles but not render them
  68387. * @returns the current number of particles
  68388. */
  68389. render(preWarm?: boolean): number;
  68390. /**
  68391. * Rebuilds the particle system
  68392. */
  68393. rebuild(): void;
  68394. private _releaseBuffers;
  68395. private _releaseVAOs;
  68396. /**
  68397. * Disposes the particle system and free the associated resources
  68398. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68399. */
  68400. dispose(disposeTexture?: boolean): void;
  68401. /**
  68402. * Clones the particle system.
  68403. * @param name The name of the cloned object
  68404. * @param newEmitter The new emitter to use
  68405. * @returns the cloned particle system
  68406. */
  68407. clone(name: string, newEmitter: any): GPUParticleSystem;
  68408. /**
  68409. * Serializes the particle system to a JSON object
  68410. * @param serializeTexture defines if the texture must be serialized as well
  68411. * @returns the JSON object
  68412. */
  68413. serialize(serializeTexture?: boolean): any;
  68414. /**
  68415. * Parses a JSON object to create a GPU particle system.
  68416. * @param parsedParticleSystem The JSON object to parse
  68417. * @param scene The scene to create the particle system in
  68418. * @param rootUrl The root url to use to load external dependencies like texture
  68419. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68420. * @returns the parsed GPU particle system
  68421. */
  68422. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68423. }
  68424. }
  68425. declare module "babylonjs/Particles/particleSystemSet" {
  68426. import { Nullable } from "babylonjs/types";
  68427. import { Color3 } from "babylonjs/Maths/math.color";
  68428. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68430. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68431. import { Scene, IDisposable } from "babylonjs/scene";
  68432. /**
  68433. * Represents a set of particle systems working together to create a specific effect
  68434. */
  68435. export class ParticleSystemSet implements IDisposable {
  68436. /**
  68437. * Gets or sets base Assets URL
  68438. */
  68439. static BaseAssetsUrl: string;
  68440. private _emitterCreationOptions;
  68441. private _emitterNode;
  68442. /**
  68443. * Gets the particle system list
  68444. */
  68445. systems: IParticleSystem[];
  68446. /**
  68447. * Gets the emitter node used with this set
  68448. */
  68449. get emitterNode(): Nullable<TransformNode>;
  68450. /**
  68451. * Creates a new emitter mesh as a sphere
  68452. * @param options defines the options used to create the sphere
  68453. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68454. * @param scene defines the hosting scene
  68455. */
  68456. setEmitterAsSphere(options: {
  68457. diameter: number;
  68458. segments: number;
  68459. color: Color3;
  68460. }, renderingGroupId: number, scene: Scene): void;
  68461. /**
  68462. * Starts all particle systems of the set
  68463. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68464. */
  68465. start(emitter?: AbstractMesh): void;
  68466. /**
  68467. * Release all associated resources
  68468. */
  68469. dispose(): void;
  68470. /**
  68471. * Serialize the set into a JSON compatible object
  68472. * @param serializeTexture defines if the texture must be serialized as well
  68473. * @returns a JSON compatible representation of the set
  68474. */
  68475. serialize(serializeTexture?: boolean): any;
  68476. /**
  68477. * Parse a new ParticleSystemSet from a serialized source
  68478. * @param data defines a JSON compatible representation of the set
  68479. * @param scene defines the hosting scene
  68480. * @param gpu defines if we want GPU particles or CPU particles
  68481. * @returns a new ParticleSystemSet
  68482. */
  68483. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68484. }
  68485. }
  68486. declare module "babylonjs/Particles/particleHelper" {
  68487. import { Nullable } from "babylonjs/types";
  68488. import { Scene } from "babylonjs/scene";
  68489. import { Vector3 } from "babylonjs/Maths/math.vector";
  68490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68491. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68492. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  68493. /**
  68494. * This class is made for on one-liner static method to help creating particle system set.
  68495. */
  68496. export class ParticleHelper {
  68497. /**
  68498. * Gets or sets base Assets URL
  68499. */
  68500. static BaseAssetsUrl: string;
  68501. /** Define the Url to load snippets */
  68502. static SnippetUrl: string;
  68503. /**
  68504. * Create a default particle system that you can tweak
  68505. * @param emitter defines the emitter to use
  68506. * @param capacity defines the system capacity (default is 500 particles)
  68507. * @param scene defines the hosting scene
  68508. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68509. * @returns the new Particle system
  68510. */
  68511. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68512. /**
  68513. * This is the main static method (one-liner) of this helper to create different particle systems
  68514. * @param type This string represents the type to the particle system to create
  68515. * @param scene The scene where the particle system should live
  68516. * @param gpu If the system will use gpu
  68517. * @returns the ParticleSystemSet created
  68518. */
  68519. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68520. /**
  68521. * Static function used to export a particle system to a ParticleSystemSet variable.
  68522. * Please note that the emitter shape is not exported
  68523. * @param systems defines the particle systems to export
  68524. * @returns the created particle system set
  68525. */
  68526. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68527. /**
  68528. * Creates a particle system from a snippet saved in a remote file
  68529. * @param name defines the name of the particle system to create
  68530. * @param url defines the url to load from
  68531. * @param scene defines the hosting scene
  68532. * @param gpu If the system will use gpu
  68533. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68534. * @returns a promise that will resolve to the new particle system
  68535. */
  68536. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68537. /**
  68538. * Creates a particle system from a snippet saved by the particle system editor
  68539. * @param snippetId defines the snippet to load
  68540. * @param scene defines the hosting scene
  68541. * @param gpu If the system will use gpu
  68542. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68543. * @returns a promise that will resolve to the new particle system
  68544. */
  68545. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68546. }
  68547. }
  68548. declare module "babylonjs/Particles/particleSystemComponent" {
  68549. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68550. import { Effect } from "babylonjs/Materials/effect";
  68551. import "babylonjs/Shaders/particles.vertex";
  68552. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  68553. module "babylonjs/Engines/engine" {
  68554. interface Engine {
  68555. /**
  68556. * Create an effect to use with particle systems.
  68557. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  68558. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68559. * @param uniformsNames defines a list of attribute names
  68560. * @param samplers defines an array of string used to represent textures
  68561. * @param defines defines the string containing the defines to use to compile the shaders
  68562. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68563. * @param onCompiled defines a function to call when the effect creation is successful
  68564. * @param onError defines a function to call when the effect creation has failed
  68565. * @returns the new Effect
  68566. */
  68567. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  68568. }
  68569. }
  68570. module "babylonjs/Meshes/mesh" {
  68571. interface Mesh {
  68572. /**
  68573. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68574. * @returns an array of IParticleSystem
  68575. */
  68576. getEmittedParticleSystems(): IParticleSystem[];
  68577. /**
  68578. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68579. * @returns an array of IParticleSystem
  68580. */
  68581. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68582. }
  68583. }
  68584. /**
  68585. * @hidden
  68586. */
  68587. export var _IDoNeedToBeInTheBuild: number;
  68588. }
  68589. declare module "babylonjs/Particles/pointsCloudSystem" {
  68590. import { Color4 } from "babylonjs/Maths/math";
  68591. import { Mesh } from "babylonjs/Meshes/mesh";
  68592. import { Scene, IDisposable } from "babylonjs/scene";
  68593. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  68594. /** Defines the 4 color options */
  68595. export enum PointColor {
  68596. /** color value */
  68597. Color = 2,
  68598. /** uv value */
  68599. UV = 1,
  68600. /** random value */
  68601. Random = 0,
  68602. /** stated value */
  68603. Stated = 3
  68604. }
  68605. /**
  68606. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68607. * 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.
  68608. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68609. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68610. *
  68611. * Full documentation here : TO BE ENTERED
  68612. */
  68613. export class PointsCloudSystem implements IDisposable {
  68614. /**
  68615. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68616. * Example : var p = SPS.particles[i];
  68617. */
  68618. particles: CloudPoint[];
  68619. /**
  68620. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68621. */
  68622. nbParticles: number;
  68623. /**
  68624. * This a counter for your own usage. It's not set by any SPS functions.
  68625. */
  68626. counter: number;
  68627. /**
  68628. * The PCS name. This name is also given to the underlying mesh.
  68629. */
  68630. name: string;
  68631. /**
  68632. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68633. */
  68634. mesh: Mesh;
  68635. /**
  68636. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68637. * Please read :
  68638. */
  68639. vars: any;
  68640. /**
  68641. * @hidden
  68642. */
  68643. _size: number;
  68644. private _scene;
  68645. private _promises;
  68646. private _positions;
  68647. private _indices;
  68648. private _normals;
  68649. private _colors;
  68650. private _uvs;
  68651. private _indices32;
  68652. private _positions32;
  68653. private _colors32;
  68654. private _uvs32;
  68655. private _updatable;
  68656. private _isVisibilityBoxLocked;
  68657. private _alwaysVisible;
  68658. private _groups;
  68659. private _groupCounter;
  68660. private _computeParticleColor;
  68661. private _computeParticleTexture;
  68662. private _computeParticleRotation;
  68663. private _computeBoundingBox;
  68664. private _isReady;
  68665. /**
  68666. * Creates a PCS (Points Cloud System) object
  68667. * @param name (String) is the PCS name, this will be the underlying mesh name
  68668. * @param pointSize (number) is the size for each point
  68669. * @param scene (Scene) is the scene in which the PCS is added
  68670. * @param options defines the options of the PCS e.g.
  68671. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68672. */
  68673. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68674. updatable?: boolean;
  68675. });
  68676. /**
  68677. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68678. * If no points were added to the PCS, the returned mesh is just a single point.
  68679. * @returns a promise for the created mesh
  68680. */
  68681. buildMeshAsync(): Promise<Mesh>;
  68682. /**
  68683. * @hidden
  68684. */
  68685. private _buildMesh;
  68686. private _addParticle;
  68687. private _randomUnitVector;
  68688. private _getColorIndicesForCoord;
  68689. private _setPointsColorOrUV;
  68690. private _colorFromTexture;
  68691. private _calculateDensity;
  68692. /**
  68693. * Adds points to the PCS in random positions within a unit sphere
  68694. * @param nb (positive integer) the number of particles to be created from this model
  68695. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68696. * @returns the number of groups in the system
  68697. */
  68698. addPoints(nb: number, pointFunction?: any): number;
  68699. /**
  68700. * Adds points to the PCS from the surface of the model shape
  68701. * @param mesh is any Mesh object that will be used as a surface model for the points
  68702. * @param nb (positive integer) the number of particles to be created from this model
  68703. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68704. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68705. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68706. * @returns the number of groups in the system
  68707. */
  68708. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68709. /**
  68710. * Adds points to the PCS inside the model shape
  68711. * @param mesh is any Mesh object that will be used as a surface model for the points
  68712. * @param nb (positive integer) the number of particles to be created from this model
  68713. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68714. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68715. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68716. * @returns the number of groups in the system
  68717. */
  68718. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68719. /**
  68720. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68721. * This method calls `updateParticle()` for each particle of the SPS.
  68722. * For an animated SPS, it is usually called within the render loop.
  68723. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68724. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68725. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68726. * @returns the PCS.
  68727. */
  68728. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68729. /**
  68730. * Disposes the PCS.
  68731. */
  68732. dispose(): void;
  68733. /**
  68734. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68735. * doc :
  68736. * @returns the PCS.
  68737. */
  68738. refreshVisibleSize(): PointsCloudSystem;
  68739. /**
  68740. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68741. * @param size the size (float) of the visibility box
  68742. * note : this doesn't lock the PCS mesh bounding box.
  68743. * doc :
  68744. */
  68745. setVisibilityBox(size: number): void;
  68746. /**
  68747. * Gets whether the PCS is always visible or not
  68748. * doc :
  68749. */
  68750. get isAlwaysVisible(): boolean;
  68751. /**
  68752. * Sets the PCS as always visible or not
  68753. * doc :
  68754. */
  68755. set isAlwaysVisible(val: boolean);
  68756. /**
  68757. * Tells to `setParticles()` to compute the particle rotations or not
  68758. * Default value : false. The PCS is faster when it's set to false
  68759. * Note : particle rotations are only applied to parent particles
  68760. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68761. */
  68762. set computeParticleRotation(val: boolean);
  68763. /**
  68764. * Tells to `setParticles()` to compute the particle colors or not.
  68765. * Default value : true. The PCS is faster when it's set to false.
  68766. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68767. */
  68768. set computeParticleColor(val: boolean);
  68769. set computeParticleTexture(val: boolean);
  68770. /**
  68771. * Gets if `setParticles()` computes the particle colors or not.
  68772. * Default value : false. The PCS is faster when it's set to false.
  68773. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68774. */
  68775. get computeParticleColor(): boolean;
  68776. /**
  68777. * Gets if `setParticles()` computes the particle textures or not.
  68778. * Default value : false. The PCS is faster when it's set to false.
  68779. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68780. */
  68781. get computeParticleTexture(): boolean;
  68782. /**
  68783. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68784. */
  68785. set computeBoundingBox(val: boolean);
  68786. /**
  68787. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68788. */
  68789. get computeBoundingBox(): boolean;
  68790. /**
  68791. * This function does nothing. It may be overwritten to set all the particle first values.
  68792. * The PCS doesn't call this function, you may have to call it by your own.
  68793. * doc :
  68794. */
  68795. initParticles(): void;
  68796. /**
  68797. * This function does nothing. It may be overwritten to recycle a particle
  68798. * The PCS doesn't call this function, you can to call it
  68799. * doc :
  68800. * @param particle The particle to recycle
  68801. * @returns the recycled particle
  68802. */
  68803. recycleParticle(particle: CloudPoint): CloudPoint;
  68804. /**
  68805. * Updates a particle : this function should be overwritten by the user.
  68806. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68807. * doc :
  68808. * @example : just set a particle position or velocity and recycle conditions
  68809. * @param particle The particle to update
  68810. * @returns the updated particle
  68811. */
  68812. updateParticle(particle: CloudPoint): CloudPoint;
  68813. /**
  68814. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68815. * This does nothing and may be overwritten by the user.
  68816. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68817. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68818. * @param update the boolean update value actually passed to setParticles()
  68819. */
  68820. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68821. /**
  68822. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68823. * This will be passed three parameters.
  68824. * This does nothing and may be overwritten by the user.
  68825. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68826. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68827. * @param update the boolean update value actually passed to setParticles()
  68828. */
  68829. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68830. }
  68831. }
  68832. declare module "babylonjs/Particles/cloudPoint" {
  68833. import { Nullable } from "babylonjs/types";
  68834. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  68835. import { Mesh } from "babylonjs/Meshes/mesh";
  68836. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  68837. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  68838. /**
  68839. * Represents one particle of a points cloud system.
  68840. */
  68841. export class CloudPoint {
  68842. /**
  68843. * particle global index
  68844. */
  68845. idx: number;
  68846. /**
  68847. * The color of the particle
  68848. */
  68849. color: Nullable<Color4>;
  68850. /**
  68851. * The world space position of the particle.
  68852. */
  68853. position: Vector3;
  68854. /**
  68855. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68856. */
  68857. rotation: Vector3;
  68858. /**
  68859. * The world space rotation quaternion of the particle.
  68860. */
  68861. rotationQuaternion: Nullable<Quaternion>;
  68862. /**
  68863. * The uv of the particle.
  68864. */
  68865. uv: Nullable<Vector2>;
  68866. /**
  68867. * The current speed of the particle.
  68868. */
  68869. velocity: Vector3;
  68870. /**
  68871. * The pivot point in the particle local space.
  68872. */
  68873. pivot: Vector3;
  68874. /**
  68875. * Must the particle be translated from its pivot point in its local space ?
  68876. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68877. * Default : false
  68878. */
  68879. translateFromPivot: boolean;
  68880. /**
  68881. * Index of this particle in the global "positions" array (Internal use)
  68882. * @hidden
  68883. */
  68884. _pos: number;
  68885. /**
  68886. * @hidden Index of this particle in the global "indices" array (Internal use)
  68887. */
  68888. _ind: number;
  68889. /**
  68890. * Group this particle belongs to
  68891. */
  68892. _group: PointsGroup;
  68893. /**
  68894. * Group id of this particle
  68895. */
  68896. groupId: number;
  68897. /**
  68898. * Index of the particle in its group id (Internal use)
  68899. */
  68900. idxInGroup: number;
  68901. /**
  68902. * @hidden Particle BoundingInfo object (Internal use)
  68903. */
  68904. _boundingInfo: BoundingInfo;
  68905. /**
  68906. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68907. */
  68908. _pcs: PointsCloudSystem;
  68909. /**
  68910. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68911. */
  68912. _stillInvisible: boolean;
  68913. /**
  68914. * @hidden Last computed particle rotation matrix
  68915. */
  68916. _rotationMatrix: number[];
  68917. /**
  68918. * Parent particle Id, if any.
  68919. * Default null.
  68920. */
  68921. parentId: Nullable<number>;
  68922. /**
  68923. * @hidden Internal global position in the PCS.
  68924. */
  68925. _globalPosition: Vector3;
  68926. /**
  68927. * Creates a Point Cloud object.
  68928. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68929. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68930. * @param group (PointsGroup) is the group the particle belongs to
  68931. * @param groupId (integer) is the group identifier in the PCS.
  68932. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68933. * @param pcs defines the PCS it is associated to
  68934. */
  68935. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68936. /**
  68937. * get point size
  68938. */
  68939. get size(): Vector3;
  68940. /**
  68941. * Set point size
  68942. */
  68943. set size(scale: Vector3);
  68944. /**
  68945. * Legacy support, changed quaternion to rotationQuaternion
  68946. */
  68947. get quaternion(): Nullable<Quaternion>;
  68948. /**
  68949. * Legacy support, changed quaternion to rotationQuaternion
  68950. */
  68951. set quaternion(q: Nullable<Quaternion>);
  68952. /**
  68953. * Returns a boolean. True if the particle intersects a mesh, else false
  68954. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68955. * @param target is the object (point or mesh) what the intersection is computed against
  68956. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68957. * @returns true if it intersects
  68958. */
  68959. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68960. /**
  68961. * get the rotation matrix of the particle
  68962. * @hidden
  68963. */
  68964. getRotationMatrix(m: Matrix): void;
  68965. }
  68966. /**
  68967. * Represents a group of points in a points cloud system
  68968. * * PCS internal tool, don't use it manually.
  68969. */
  68970. export class PointsGroup {
  68971. /**
  68972. * The group id
  68973. * @hidden
  68974. */
  68975. groupID: number;
  68976. /**
  68977. * image data for group (internal use)
  68978. * @hidden
  68979. */
  68980. _groupImageData: Nullable<ArrayBufferView>;
  68981. /**
  68982. * Image Width (internal use)
  68983. * @hidden
  68984. */
  68985. _groupImgWidth: number;
  68986. /**
  68987. * Image Height (internal use)
  68988. * @hidden
  68989. */
  68990. _groupImgHeight: number;
  68991. /**
  68992. * Custom position function (internal use)
  68993. * @hidden
  68994. */
  68995. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68996. /**
  68997. * density per facet for surface points
  68998. * @hidden
  68999. */
  69000. _groupDensity: number[];
  69001. /**
  69002. * Only when points are colored by texture carries pointer to texture list array
  69003. * @hidden
  69004. */
  69005. _textureNb: number;
  69006. /**
  69007. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69008. * PCS internal tool, don't use it manually.
  69009. * @hidden
  69010. */
  69011. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69012. }
  69013. }
  69014. declare module "babylonjs/Particles/index" {
  69015. export * from "babylonjs/Particles/baseParticleSystem";
  69016. export * from "babylonjs/Particles/EmitterTypes/index";
  69017. export * from "babylonjs/Particles/gpuParticleSystem";
  69018. export * from "babylonjs/Particles/IParticleSystem";
  69019. export * from "babylonjs/Particles/particle";
  69020. export * from "babylonjs/Particles/particleHelper";
  69021. export * from "babylonjs/Particles/particleSystem";
  69022. export * from "babylonjs/Particles/particleSystemComponent";
  69023. export * from "babylonjs/Particles/particleSystemSet";
  69024. export * from "babylonjs/Particles/solidParticle";
  69025. export * from "babylonjs/Particles/solidParticleSystem";
  69026. export * from "babylonjs/Particles/cloudPoint";
  69027. export * from "babylonjs/Particles/pointsCloudSystem";
  69028. export * from "babylonjs/Particles/subEmitter";
  69029. }
  69030. declare module "babylonjs/Physics/physicsEngineComponent" {
  69031. import { Nullable } from "babylonjs/types";
  69032. import { Observable, Observer } from "babylonjs/Misc/observable";
  69033. import { Vector3 } from "babylonjs/Maths/math.vector";
  69034. import { Mesh } from "babylonjs/Meshes/mesh";
  69035. import { ISceneComponent } from "babylonjs/sceneComponent";
  69036. import { Scene } from "babylonjs/scene";
  69037. import { Node } from "babylonjs/node";
  69038. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  69039. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69040. module "babylonjs/scene" {
  69041. interface Scene {
  69042. /** @hidden (Backing field) */
  69043. _physicsEngine: Nullable<IPhysicsEngine>;
  69044. /** @hidden */
  69045. _physicsTimeAccumulator: number;
  69046. /**
  69047. * Gets the current physics engine
  69048. * @returns a IPhysicsEngine or null if none attached
  69049. */
  69050. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69051. /**
  69052. * Enables physics to the current scene
  69053. * @param gravity defines the scene's gravity for the physics engine
  69054. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69055. * @return a boolean indicating if the physics engine was initialized
  69056. */
  69057. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69058. /**
  69059. * Disables and disposes the physics engine associated with the scene
  69060. */
  69061. disablePhysicsEngine(): void;
  69062. /**
  69063. * Gets a boolean indicating if there is an active physics engine
  69064. * @returns a boolean indicating if there is an active physics engine
  69065. */
  69066. isPhysicsEnabled(): boolean;
  69067. /**
  69068. * Deletes a physics compound impostor
  69069. * @param compound defines the compound to delete
  69070. */
  69071. deleteCompoundImpostor(compound: any): void;
  69072. /**
  69073. * An event triggered when physic simulation is about to be run
  69074. */
  69075. onBeforePhysicsObservable: Observable<Scene>;
  69076. /**
  69077. * An event triggered when physic simulation has been done
  69078. */
  69079. onAfterPhysicsObservable: Observable<Scene>;
  69080. }
  69081. }
  69082. module "babylonjs/Meshes/abstractMesh" {
  69083. interface AbstractMesh {
  69084. /** @hidden */
  69085. _physicsImpostor: Nullable<PhysicsImpostor>;
  69086. /**
  69087. * Gets or sets impostor used for physic simulation
  69088. * @see http://doc.babylonjs.com/features/physics_engine
  69089. */
  69090. physicsImpostor: Nullable<PhysicsImpostor>;
  69091. /**
  69092. * Gets the current physics impostor
  69093. * @see http://doc.babylonjs.com/features/physics_engine
  69094. * @returns a physics impostor or null
  69095. */
  69096. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69097. /** Apply a physic impulse to the mesh
  69098. * @param force defines the force to apply
  69099. * @param contactPoint defines where to apply the force
  69100. * @returns the current mesh
  69101. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  69102. */
  69103. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69104. /**
  69105. * Creates a physic joint between two meshes
  69106. * @param otherMesh defines the other mesh to use
  69107. * @param pivot1 defines the pivot to use on this mesh
  69108. * @param pivot2 defines the pivot to use on the other mesh
  69109. * @param options defines additional options (can be plugin dependent)
  69110. * @returns the current mesh
  69111. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69112. */
  69113. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69114. /** @hidden */
  69115. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69116. }
  69117. }
  69118. /**
  69119. * Defines the physics engine scene component responsible to manage a physics engine
  69120. */
  69121. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69122. /**
  69123. * The component name helpful to identify the component in the list of scene components.
  69124. */
  69125. readonly name: string;
  69126. /**
  69127. * The scene the component belongs to.
  69128. */
  69129. scene: Scene;
  69130. /**
  69131. * Creates a new instance of the component for the given scene
  69132. * @param scene Defines the scene to register the component in
  69133. */
  69134. constructor(scene: Scene);
  69135. /**
  69136. * Registers the component in a given scene
  69137. */
  69138. register(): void;
  69139. /**
  69140. * Rebuilds the elements related to this component in case of
  69141. * context lost for instance.
  69142. */
  69143. rebuild(): void;
  69144. /**
  69145. * Disposes the component and the associated ressources
  69146. */
  69147. dispose(): void;
  69148. }
  69149. }
  69150. declare module "babylonjs/Physics/physicsHelper" {
  69151. import { Nullable } from "babylonjs/types";
  69152. import { Vector3 } from "babylonjs/Maths/math.vector";
  69153. import { Mesh } from "babylonjs/Meshes/mesh";
  69154. import { Scene } from "babylonjs/scene";
  69155. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69156. /**
  69157. * A helper for physics simulations
  69158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69159. */
  69160. export class PhysicsHelper {
  69161. private _scene;
  69162. private _physicsEngine;
  69163. /**
  69164. * Initializes the Physics helper
  69165. * @param scene Babylon.js scene
  69166. */
  69167. constructor(scene: Scene);
  69168. /**
  69169. * Applies a radial explosion impulse
  69170. * @param origin the origin of the explosion
  69171. * @param radiusOrEventOptions the radius or the options of radial explosion
  69172. * @param strength the explosion strength
  69173. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69174. * @returns A physics radial explosion event, or null
  69175. */
  69176. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69177. /**
  69178. * Applies a radial explosion force
  69179. * @param origin the origin of the explosion
  69180. * @param radiusOrEventOptions the radius or the options of radial explosion
  69181. * @param strength the explosion strength
  69182. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69183. * @returns A physics radial explosion event, or null
  69184. */
  69185. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69186. /**
  69187. * Creates a gravitational field
  69188. * @param origin the origin of the explosion
  69189. * @param radiusOrEventOptions the radius or the options of radial explosion
  69190. * @param strength the explosion strength
  69191. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69192. * @returns A physics gravitational field event, or null
  69193. */
  69194. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69195. /**
  69196. * Creates a physics updraft event
  69197. * @param origin the origin of the updraft
  69198. * @param radiusOrEventOptions the radius or the options of the updraft
  69199. * @param strength the strength of the updraft
  69200. * @param height the height of the updraft
  69201. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69202. * @returns A physics updraft event, or null
  69203. */
  69204. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69205. /**
  69206. * Creates a physics vortex event
  69207. * @param origin the of the vortex
  69208. * @param radiusOrEventOptions the radius or the options of the vortex
  69209. * @param strength the strength of the vortex
  69210. * @param height the height of the vortex
  69211. * @returns a Physics vortex event, or null
  69212. * A physics vortex event or null
  69213. */
  69214. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69215. }
  69216. /**
  69217. * Represents a physics radial explosion event
  69218. */
  69219. class PhysicsRadialExplosionEvent {
  69220. private _scene;
  69221. private _options;
  69222. private _sphere;
  69223. private _dataFetched;
  69224. /**
  69225. * Initializes a radial explosioin event
  69226. * @param _scene BabylonJS scene
  69227. * @param _options The options for the vortex event
  69228. */
  69229. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69230. /**
  69231. * Returns the data related to the radial explosion event (sphere).
  69232. * @returns The radial explosion event data
  69233. */
  69234. getData(): PhysicsRadialExplosionEventData;
  69235. /**
  69236. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69237. * @param impostor A physics imposter
  69238. * @param origin the origin of the explosion
  69239. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69240. */
  69241. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69242. /**
  69243. * Triggers affecterd impostors callbacks
  69244. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69245. */
  69246. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69247. /**
  69248. * Disposes the sphere.
  69249. * @param force Specifies if the sphere should be disposed by force
  69250. */
  69251. dispose(force?: boolean): void;
  69252. /*** Helpers ***/
  69253. private _prepareSphere;
  69254. private _intersectsWithSphere;
  69255. }
  69256. /**
  69257. * Represents a gravitational field event
  69258. */
  69259. class PhysicsGravitationalFieldEvent {
  69260. private _physicsHelper;
  69261. private _scene;
  69262. private _origin;
  69263. private _options;
  69264. private _tickCallback;
  69265. private _sphere;
  69266. private _dataFetched;
  69267. /**
  69268. * Initializes the physics gravitational field event
  69269. * @param _physicsHelper A physics helper
  69270. * @param _scene BabylonJS scene
  69271. * @param _origin The origin position of the gravitational field event
  69272. * @param _options The options for the vortex event
  69273. */
  69274. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69275. /**
  69276. * Returns the data related to the gravitational field event (sphere).
  69277. * @returns A gravitational field event
  69278. */
  69279. getData(): PhysicsGravitationalFieldEventData;
  69280. /**
  69281. * Enables the gravitational field.
  69282. */
  69283. enable(): void;
  69284. /**
  69285. * Disables the gravitational field.
  69286. */
  69287. disable(): void;
  69288. /**
  69289. * Disposes the sphere.
  69290. * @param force The force to dispose from the gravitational field event
  69291. */
  69292. dispose(force?: boolean): void;
  69293. private _tick;
  69294. }
  69295. /**
  69296. * Represents a physics updraft event
  69297. */
  69298. class PhysicsUpdraftEvent {
  69299. private _scene;
  69300. private _origin;
  69301. private _options;
  69302. private _physicsEngine;
  69303. private _originTop;
  69304. private _originDirection;
  69305. private _tickCallback;
  69306. private _cylinder;
  69307. private _cylinderPosition;
  69308. private _dataFetched;
  69309. /**
  69310. * Initializes the physics updraft event
  69311. * @param _scene BabylonJS scene
  69312. * @param _origin The origin position of the updraft
  69313. * @param _options The options for the updraft event
  69314. */
  69315. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69316. /**
  69317. * Returns the data related to the updraft event (cylinder).
  69318. * @returns A physics updraft event
  69319. */
  69320. getData(): PhysicsUpdraftEventData;
  69321. /**
  69322. * Enables the updraft.
  69323. */
  69324. enable(): void;
  69325. /**
  69326. * Disables the updraft.
  69327. */
  69328. disable(): void;
  69329. /**
  69330. * Disposes the cylinder.
  69331. * @param force Specifies if the updraft should be disposed by force
  69332. */
  69333. dispose(force?: boolean): void;
  69334. private getImpostorHitData;
  69335. private _tick;
  69336. /*** Helpers ***/
  69337. private _prepareCylinder;
  69338. private _intersectsWithCylinder;
  69339. }
  69340. /**
  69341. * Represents a physics vortex event
  69342. */
  69343. class PhysicsVortexEvent {
  69344. private _scene;
  69345. private _origin;
  69346. private _options;
  69347. private _physicsEngine;
  69348. private _originTop;
  69349. private _tickCallback;
  69350. private _cylinder;
  69351. private _cylinderPosition;
  69352. private _dataFetched;
  69353. /**
  69354. * Initializes the physics vortex event
  69355. * @param _scene The BabylonJS scene
  69356. * @param _origin The origin position of the vortex
  69357. * @param _options The options for the vortex event
  69358. */
  69359. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69360. /**
  69361. * Returns the data related to the vortex event (cylinder).
  69362. * @returns The physics vortex event data
  69363. */
  69364. getData(): PhysicsVortexEventData;
  69365. /**
  69366. * Enables the vortex.
  69367. */
  69368. enable(): void;
  69369. /**
  69370. * Disables the cortex.
  69371. */
  69372. disable(): void;
  69373. /**
  69374. * Disposes the sphere.
  69375. * @param force
  69376. */
  69377. dispose(force?: boolean): void;
  69378. private getImpostorHitData;
  69379. private _tick;
  69380. /*** Helpers ***/
  69381. private _prepareCylinder;
  69382. private _intersectsWithCylinder;
  69383. }
  69384. /**
  69385. * Options fot the radial explosion event
  69386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69387. */
  69388. export class PhysicsRadialExplosionEventOptions {
  69389. /**
  69390. * The radius of the sphere for the radial explosion.
  69391. */
  69392. radius: number;
  69393. /**
  69394. * The strenth of the explosion.
  69395. */
  69396. strength: number;
  69397. /**
  69398. * The strenght of the force in correspondence to the distance of the affected object
  69399. */
  69400. falloff: PhysicsRadialImpulseFalloff;
  69401. /**
  69402. * Sphere options for the radial explosion.
  69403. */
  69404. sphere: {
  69405. segments: number;
  69406. diameter: number;
  69407. };
  69408. /**
  69409. * Sphere options for the radial explosion.
  69410. */
  69411. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69412. }
  69413. /**
  69414. * Options fot the updraft event
  69415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69416. */
  69417. export class PhysicsUpdraftEventOptions {
  69418. /**
  69419. * The radius of the cylinder for the vortex
  69420. */
  69421. radius: number;
  69422. /**
  69423. * The strenth of the updraft.
  69424. */
  69425. strength: number;
  69426. /**
  69427. * The height of the cylinder for the updraft.
  69428. */
  69429. height: number;
  69430. /**
  69431. * The mode for the the updraft.
  69432. */
  69433. updraftMode: PhysicsUpdraftMode;
  69434. }
  69435. /**
  69436. * Options fot the vortex event
  69437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69438. */
  69439. export class PhysicsVortexEventOptions {
  69440. /**
  69441. * The radius of the cylinder for the vortex
  69442. */
  69443. radius: number;
  69444. /**
  69445. * The strenth of the vortex.
  69446. */
  69447. strength: number;
  69448. /**
  69449. * The height of the cylinder for the vortex.
  69450. */
  69451. height: number;
  69452. /**
  69453. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69454. */
  69455. centripetalForceThreshold: number;
  69456. /**
  69457. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69458. */
  69459. centripetalForceMultiplier: number;
  69460. /**
  69461. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69462. */
  69463. centrifugalForceMultiplier: number;
  69464. /**
  69465. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69466. */
  69467. updraftForceMultiplier: number;
  69468. }
  69469. /**
  69470. * The strenght of the force in correspondence to the distance of the affected object
  69471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69472. */
  69473. export enum PhysicsRadialImpulseFalloff {
  69474. /** Defines that impulse is constant in strength across it's whole radius */
  69475. Constant = 0,
  69476. /** Defines that impulse gets weaker if it's further from the origin */
  69477. Linear = 1
  69478. }
  69479. /**
  69480. * The strength of the force in correspondence to the distance of the affected object
  69481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69482. */
  69483. export enum PhysicsUpdraftMode {
  69484. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69485. Center = 0,
  69486. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69487. Perpendicular = 1
  69488. }
  69489. /**
  69490. * Interface for a physics hit data
  69491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69492. */
  69493. export interface PhysicsHitData {
  69494. /**
  69495. * The force applied at the contact point
  69496. */
  69497. force: Vector3;
  69498. /**
  69499. * The contact point
  69500. */
  69501. contactPoint: Vector3;
  69502. /**
  69503. * The distance from the origin to the contact point
  69504. */
  69505. distanceFromOrigin: number;
  69506. }
  69507. /**
  69508. * Interface for radial explosion event data
  69509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69510. */
  69511. export interface PhysicsRadialExplosionEventData {
  69512. /**
  69513. * A sphere used for the radial explosion event
  69514. */
  69515. sphere: Mesh;
  69516. }
  69517. /**
  69518. * Interface for gravitational field event data
  69519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69520. */
  69521. export interface PhysicsGravitationalFieldEventData {
  69522. /**
  69523. * A sphere mesh used for the gravitational field event
  69524. */
  69525. sphere: Mesh;
  69526. }
  69527. /**
  69528. * Interface for updraft event data
  69529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69530. */
  69531. export interface PhysicsUpdraftEventData {
  69532. /**
  69533. * A cylinder used for the updraft event
  69534. */
  69535. cylinder: Mesh;
  69536. }
  69537. /**
  69538. * Interface for vortex event data
  69539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69540. */
  69541. export interface PhysicsVortexEventData {
  69542. /**
  69543. * A cylinder used for the vortex event
  69544. */
  69545. cylinder: Mesh;
  69546. }
  69547. /**
  69548. * Interface for an affected physics impostor
  69549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69550. */
  69551. export interface PhysicsAffectedImpostorWithData {
  69552. /**
  69553. * The impostor affected by the effect
  69554. */
  69555. impostor: PhysicsImpostor;
  69556. /**
  69557. * The data about the hit/horce from the explosion
  69558. */
  69559. hitData: PhysicsHitData;
  69560. }
  69561. }
  69562. declare module "babylonjs/Physics/Plugins/index" {
  69563. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  69564. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  69565. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  69566. }
  69567. declare module "babylonjs/Physics/index" {
  69568. export * from "babylonjs/Physics/IPhysicsEngine";
  69569. export * from "babylonjs/Physics/physicsEngine";
  69570. export * from "babylonjs/Physics/physicsEngineComponent";
  69571. export * from "babylonjs/Physics/physicsHelper";
  69572. export * from "babylonjs/Physics/physicsImpostor";
  69573. export * from "babylonjs/Physics/physicsJoint";
  69574. export * from "babylonjs/Physics/Plugins/index";
  69575. }
  69576. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  69577. /** @hidden */
  69578. export var blackAndWhitePixelShader: {
  69579. name: string;
  69580. shader: string;
  69581. };
  69582. }
  69583. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  69584. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69585. import { Camera } from "babylonjs/Cameras/camera";
  69586. import { Engine } from "babylonjs/Engines/engine";
  69587. import "babylonjs/Shaders/blackAndWhite.fragment";
  69588. /**
  69589. * Post process used to render in black and white
  69590. */
  69591. export class BlackAndWhitePostProcess extends PostProcess {
  69592. /**
  69593. * Linear about to convert he result to black and white (default: 1)
  69594. */
  69595. degree: number;
  69596. /**
  69597. * Creates a black and white post process
  69598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69599. * @param name The name of the effect.
  69600. * @param options The required width/height ratio to downsize to before computing the render pass.
  69601. * @param camera The camera to apply the render pass to.
  69602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69603. * @param engine The engine which the post process will be applied. (default: current engine)
  69604. * @param reusable If the post process can be reused on the same frame. (default: false)
  69605. */
  69606. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69607. }
  69608. }
  69609. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  69610. import { Nullable } from "babylonjs/types";
  69611. import { Camera } from "babylonjs/Cameras/camera";
  69612. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69613. import { Engine } from "babylonjs/Engines/engine";
  69614. /**
  69615. * This represents a set of one or more post processes in Babylon.
  69616. * A post process can be used to apply a shader to a texture after it is rendered.
  69617. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69618. */
  69619. export class PostProcessRenderEffect {
  69620. private _postProcesses;
  69621. private _getPostProcesses;
  69622. private _singleInstance;
  69623. private _cameras;
  69624. private _indicesForCamera;
  69625. /**
  69626. * Name of the effect
  69627. * @hidden
  69628. */
  69629. _name: string;
  69630. /**
  69631. * Instantiates a post process render effect.
  69632. * A post process can be used to apply a shader to a texture after it is rendered.
  69633. * @param engine The engine the effect is tied to
  69634. * @param name The name of the effect
  69635. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69636. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69637. */
  69638. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69639. /**
  69640. * Checks if all the post processes in the effect are supported.
  69641. */
  69642. get isSupported(): boolean;
  69643. /**
  69644. * Updates the current state of the effect
  69645. * @hidden
  69646. */
  69647. _update(): void;
  69648. /**
  69649. * Attaches the effect on cameras
  69650. * @param cameras The camera to attach to.
  69651. * @hidden
  69652. */
  69653. _attachCameras(cameras: Camera): void;
  69654. /**
  69655. * Attaches the effect on cameras
  69656. * @param cameras The camera to attach to.
  69657. * @hidden
  69658. */
  69659. _attachCameras(cameras: Camera[]): void;
  69660. /**
  69661. * Detaches the effect on cameras
  69662. * @param cameras The camera to detatch from.
  69663. * @hidden
  69664. */
  69665. _detachCameras(cameras: Camera): void;
  69666. /**
  69667. * Detatches the effect on cameras
  69668. * @param cameras The camera to detatch from.
  69669. * @hidden
  69670. */
  69671. _detachCameras(cameras: Camera[]): void;
  69672. /**
  69673. * Enables the effect on given cameras
  69674. * @param cameras The camera to enable.
  69675. * @hidden
  69676. */
  69677. _enable(cameras: Camera): void;
  69678. /**
  69679. * Enables the effect on given cameras
  69680. * @param cameras The camera to enable.
  69681. * @hidden
  69682. */
  69683. _enable(cameras: Nullable<Camera[]>): void;
  69684. /**
  69685. * Disables the effect on the given cameras
  69686. * @param cameras The camera to disable.
  69687. * @hidden
  69688. */
  69689. _disable(cameras: Camera): void;
  69690. /**
  69691. * Disables the effect on the given cameras
  69692. * @param cameras The camera to disable.
  69693. * @hidden
  69694. */
  69695. _disable(cameras: Nullable<Camera[]>): void;
  69696. /**
  69697. * Gets a list of the post processes contained in the effect.
  69698. * @param camera The camera to get the post processes on.
  69699. * @returns The list of the post processes in the effect.
  69700. */
  69701. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69702. }
  69703. }
  69704. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  69705. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69706. /** @hidden */
  69707. export var extractHighlightsPixelShader: {
  69708. name: string;
  69709. shader: string;
  69710. };
  69711. }
  69712. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  69713. import { Nullable } from "babylonjs/types";
  69714. import { Camera } from "babylonjs/Cameras/camera";
  69715. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69716. import { Engine } from "babylonjs/Engines/engine";
  69717. import "babylonjs/Shaders/extractHighlights.fragment";
  69718. /**
  69719. * 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.
  69720. */
  69721. export class ExtractHighlightsPostProcess extends PostProcess {
  69722. /**
  69723. * The luminance threshold, pixels below this value will be set to black.
  69724. */
  69725. threshold: number;
  69726. /** @hidden */
  69727. _exposure: number;
  69728. /**
  69729. * Post process which has the input texture to be used when performing highlight extraction
  69730. * @hidden
  69731. */
  69732. _inputPostProcess: Nullable<PostProcess>;
  69733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69734. }
  69735. }
  69736. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  69737. /** @hidden */
  69738. export var bloomMergePixelShader: {
  69739. name: string;
  69740. shader: string;
  69741. };
  69742. }
  69743. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  69744. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69745. import { Nullable } from "babylonjs/types";
  69746. import { Engine } from "babylonjs/Engines/engine";
  69747. import { Camera } from "babylonjs/Cameras/camera";
  69748. import "babylonjs/Shaders/bloomMerge.fragment";
  69749. /**
  69750. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69751. */
  69752. export class BloomMergePostProcess extends PostProcess {
  69753. /** Weight of the bloom to be added to the original input. */
  69754. weight: number;
  69755. /**
  69756. * Creates a new instance of @see BloomMergePostProcess
  69757. * @param name The name of the effect.
  69758. * @param originalFromInput Post process which's input will be used for the merge.
  69759. * @param blurred Blurred highlights post process which's output will be used.
  69760. * @param weight Weight of the bloom to be added to the original input.
  69761. * @param options The required width/height ratio to downsize to before computing the render pass.
  69762. * @param camera The camera to apply the render pass to.
  69763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69764. * @param engine The engine which the post process will be applied. (default: current engine)
  69765. * @param reusable If the post process can be reused on the same frame. (default: false)
  69766. * @param textureType Type of textures used when performing the post process. (default: 0)
  69767. * @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)
  69768. */
  69769. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69770. /** Weight of the bloom to be added to the original input. */
  69771. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69772. }
  69773. }
  69774. declare module "babylonjs/PostProcesses/bloomEffect" {
  69775. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69776. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69777. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69778. import { Camera } from "babylonjs/Cameras/camera";
  69779. import { Scene } from "babylonjs/scene";
  69780. /**
  69781. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69782. */
  69783. export class BloomEffect extends PostProcessRenderEffect {
  69784. private bloomScale;
  69785. /**
  69786. * @hidden Internal
  69787. */
  69788. _effects: Array<PostProcess>;
  69789. /**
  69790. * @hidden Internal
  69791. */
  69792. _downscale: ExtractHighlightsPostProcess;
  69793. private _blurX;
  69794. private _blurY;
  69795. private _merge;
  69796. /**
  69797. * The luminance threshold to find bright areas of the image to bloom.
  69798. */
  69799. get threshold(): number;
  69800. set threshold(value: number);
  69801. /**
  69802. * The strength of the bloom.
  69803. */
  69804. get weight(): number;
  69805. set weight(value: number);
  69806. /**
  69807. * Specifies the size of the bloom blur kernel, relative to the final output size
  69808. */
  69809. get kernel(): number;
  69810. set kernel(value: number);
  69811. /**
  69812. * Creates a new instance of @see BloomEffect
  69813. * @param scene The scene the effect belongs to.
  69814. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69815. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69816. * @param bloomWeight The the strength of bloom.
  69817. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69818. * @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)
  69819. */
  69820. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69821. /**
  69822. * Disposes each of the internal effects for a given camera.
  69823. * @param camera The camera to dispose the effect on.
  69824. */
  69825. disposeEffects(camera: Camera): void;
  69826. /**
  69827. * @hidden Internal
  69828. */
  69829. _updateEffects(): void;
  69830. /**
  69831. * Internal
  69832. * @returns if all the contained post processes are ready.
  69833. * @hidden
  69834. */
  69835. _isReady(): boolean;
  69836. }
  69837. }
  69838. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  69839. /** @hidden */
  69840. export var chromaticAberrationPixelShader: {
  69841. name: string;
  69842. shader: string;
  69843. };
  69844. }
  69845. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  69846. import { Vector2 } from "babylonjs/Maths/math.vector";
  69847. import { Nullable } from "babylonjs/types";
  69848. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69849. import { Camera } from "babylonjs/Cameras/camera";
  69850. import { Engine } from "babylonjs/Engines/engine";
  69851. import "babylonjs/Shaders/chromaticAberration.fragment";
  69852. /**
  69853. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69854. */
  69855. export class ChromaticAberrationPostProcess extends PostProcess {
  69856. /**
  69857. * The amount of seperation of rgb channels (default: 30)
  69858. */
  69859. aberrationAmount: number;
  69860. /**
  69861. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69862. */
  69863. radialIntensity: number;
  69864. /**
  69865. * 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))
  69866. */
  69867. direction: Vector2;
  69868. /**
  69869. * 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))
  69870. */
  69871. centerPosition: Vector2;
  69872. /**
  69873. * Creates a new instance ChromaticAberrationPostProcess
  69874. * @param name The name of the effect.
  69875. * @param screenWidth The width of the screen to apply the effect on.
  69876. * @param screenHeight The height of the screen to apply the effect on.
  69877. * @param options The required width/height ratio to downsize to before computing the render pass.
  69878. * @param camera The camera to apply the render pass to.
  69879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69880. * @param engine The engine which the post process will be applied. (default: current engine)
  69881. * @param reusable If the post process can be reused on the same frame. (default: false)
  69882. * @param textureType Type of textures used when performing the post process. (default: 0)
  69883. * @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)
  69884. */
  69885. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69886. }
  69887. }
  69888. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  69889. /** @hidden */
  69890. export var circleOfConfusionPixelShader: {
  69891. name: string;
  69892. shader: string;
  69893. };
  69894. }
  69895. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  69896. import { Nullable } from "babylonjs/types";
  69897. import { Engine } from "babylonjs/Engines/engine";
  69898. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69899. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69900. import { Camera } from "babylonjs/Cameras/camera";
  69901. import "babylonjs/Shaders/circleOfConfusion.fragment";
  69902. /**
  69903. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69904. */
  69905. export class CircleOfConfusionPostProcess extends PostProcess {
  69906. /**
  69907. * 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.
  69908. */
  69909. lensSize: number;
  69910. /**
  69911. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69912. */
  69913. fStop: number;
  69914. /**
  69915. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69916. */
  69917. focusDistance: number;
  69918. /**
  69919. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69920. */
  69921. focalLength: number;
  69922. private _depthTexture;
  69923. /**
  69924. * Creates a new instance CircleOfConfusionPostProcess
  69925. * @param name The name of the effect.
  69926. * @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.
  69927. * @param options The required width/height ratio to downsize to before computing the render pass.
  69928. * @param camera The camera to apply the render pass to.
  69929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69930. * @param engine The engine which the post process will be applied. (default: current engine)
  69931. * @param reusable If the post process can be reused on the same frame. (default: false)
  69932. * @param textureType Type of textures used when performing the post process. (default: 0)
  69933. * @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)
  69934. */
  69935. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69936. /**
  69937. * 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.
  69938. */
  69939. set depthTexture(value: RenderTargetTexture);
  69940. }
  69941. }
  69942. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  69943. /** @hidden */
  69944. export var colorCorrectionPixelShader: {
  69945. name: string;
  69946. shader: string;
  69947. };
  69948. }
  69949. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  69950. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69951. import { Engine } from "babylonjs/Engines/engine";
  69952. import { Camera } from "babylonjs/Cameras/camera";
  69953. import "babylonjs/Shaders/colorCorrection.fragment";
  69954. /**
  69955. *
  69956. * This post-process allows the modification of rendered colors by using
  69957. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69958. *
  69959. * The object needs to be provided an url to a texture containing the color
  69960. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69961. * Use an image editing software to tweak the LUT to match your needs.
  69962. *
  69963. * For an example of a color LUT, see here:
  69964. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69965. * For explanations on color grading, see here:
  69966. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69967. *
  69968. */
  69969. export class ColorCorrectionPostProcess extends PostProcess {
  69970. private _colorTableTexture;
  69971. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69972. }
  69973. }
  69974. declare module "babylonjs/Shaders/convolution.fragment" {
  69975. /** @hidden */
  69976. export var convolutionPixelShader: {
  69977. name: string;
  69978. shader: string;
  69979. };
  69980. }
  69981. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  69982. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69983. import { Nullable } from "babylonjs/types";
  69984. import { Camera } from "babylonjs/Cameras/camera";
  69985. import { Engine } from "babylonjs/Engines/engine";
  69986. import "babylonjs/Shaders/convolution.fragment";
  69987. /**
  69988. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69989. * input texture to perform effects such as edge detection or sharpening
  69990. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69991. */
  69992. export class ConvolutionPostProcess extends PostProcess {
  69993. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69994. kernel: number[];
  69995. /**
  69996. * Creates a new instance ConvolutionPostProcess
  69997. * @param name The name of the effect.
  69998. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69999. * @param options The required width/height ratio to downsize to before computing the render pass.
  70000. * @param camera The camera to apply the render pass to.
  70001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70002. * @param engine The engine which the post process will be applied. (default: current engine)
  70003. * @param reusable If the post process can be reused on the same frame. (default: false)
  70004. * @param textureType Type of textures used when performing the post process. (default: 0)
  70005. */
  70006. constructor(name: string,
  70007. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70008. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70009. /**
  70010. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70011. */
  70012. static EdgeDetect0Kernel: number[];
  70013. /**
  70014. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70015. */
  70016. static EdgeDetect1Kernel: number[];
  70017. /**
  70018. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70019. */
  70020. static EdgeDetect2Kernel: number[];
  70021. /**
  70022. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70023. */
  70024. static SharpenKernel: number[];
  70025. /**
  70026. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70027. */
  70028. static EmbossKernel: number[];
  70029. /**
  70030. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70031. */
  70032. static GaussianKernel: number[];
  70033. }
  70034. }
  70035. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  70036. import { Nullable } from "babylonjs/types";
  70037. import { Vector2 } from "babylonjs/Maths/math.vector";
  70038. import { Camera } from "babylonjs/Cameras/camera";
  70039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70040. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70041. import { Engine } from "babylonjs/Engines/engine";
  70042. import { Scene } from "babylonjs/scene";
  70043. /**
  70044. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70045. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70046. * based on samples that have a large difference in distance than the center pixel.
  70047. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70048. */
  70049. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70050. direction: Vector2;
  70051. /**
  70052. * Creates a new instance CircleOfConfusionPostProcess
  70053. * @param name The name of the effect.
  70054. * @param scene The scene the effect belongs to.
  70055. * @param direction The direction the blur should be applied.
  70056. * @param kernel The size of the kernel used to blur.
  70057. * @param options The required width/height ratio to downsize to before computing the render pass.
  70058. * @param camera The camera to apply the render pass to.
  70059. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70060. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70062. * @param engine The engine which the post process will be applied. (default: current engine)
  70063. * @param reusable If the post process can be reused on the same frame. (default: false)
  70064. * @param textureType Type of textures used when performing the post process. (default: 0)
  70065. * @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)
  70066. */
  70067. 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);
  70068. }
  70069. }
  70070. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  70071. /** @hidden */
  70072. export var depthOfFieldMergePixelShader: {
  70073. name: string;
  70074. shader: string;
  70075. };
  70076. }
  70077. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  70078. import { Nullable } from "babylonjs/types";
  70079. import { Camera } from "babylonjs/Cameras/camera";
  70080. import { Effect } from "babylonjs/Materials/effect";
  70081. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70082. import { Engine } from "babylonjs/Engines/engine";
  70083. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  70084. /**
  70085. * Options to be set when merging outputs from the default pipeline.
  70086. */
  70087. export class DepthOfFieldMergePostProcessOptions {
  70088. /**
  70089. * The original image to merge on top of
  70090. */
  70091. originalFromInput: PostProcess;
  70092. /**
  70093. * Parameters to perform the merge of the depth of field effect
  70094. */
  70095. depthOfField?: {
  70096. circleOfConfusion: PostProcess;
  70097. blurSteps: Array<PostProcess>;
  70098. };
  70099. /**
  70100. * Parameters to perform the merge of bloom effect
  70101. */
  70102. bloom?: {
  70103. blurred: PostProcess;
  70104. weight: number;
  70105. };
  70106. }
  70107. /**
  70108. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70109. */
  70110. export class DepthOfFieldMergePostProcess extends PostProcess {
  70111. private blurSteps;
  70112. /**
  70113. * Creates a new instance of DepthOfFieldMergePostProcess
  70114. * @param name The name of the effect.
  70115. * @param originalFromInput Post process which's input will be used for the merge.
  70116. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70117. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70118. * @param options The required width/height ratio to downsize to before computing the render pass.
  70119. * @param camera The camera to apply the render pass to.
  70120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70121. * @param engine The engine which the post process will be applied. (default: current engine)
  70122. * @param reusable If the post process can be reused on the same frame. (default: false)
  70123. * @param textureType Type of textures used when performing the post process. (default: 0)
  70124. * @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)
  70125. */
  70126. 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);
  70127. /**
  70128. * Updates the effect with the current post process compile time values and recompiles the shader.
  70129. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70130. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70131. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70132. * @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
  70133. * @param onCompiled Called when the shader has been compiled.
  70134. * @param onError Called if there is an error when compiling a shader.
  70135. */
  70136. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70137. }
  70138. }
  70139. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  70140. import { Nullable } from "babylonjs/types";
  70141. import { Camera } from "babylonjs/Cameras/camera";
  70142. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70143. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70144. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70145. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70146. import { Scene } from "babylonjs/scene";
  70147. /**
  70148. * Specifies the level of max blur that should be applied when using the depth of field effect
  70149. */
  70150. export enum DepthOfFieldEffectBlurLevel {
  70151. /**
  70152. * Subtle blur
  70153. */
  70154. Low = 0,
  70155. /**
  70156. * Medium blur
  70157. */
  70158. Medium = 1,
  70159. /**
  70160. * Large blur
  70161. */
  70162. High = 2
  70163. }
  70164. /**
  70165. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70166. */
  70167. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70168. private _circleOfConfusion;
  70169. /**
  70170. * @hidden Internal, blurs from high to low
  70171. */
  70172. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70173. private _depthOfFieldBlurY;
  70174. private _dofMerge;
  70175. /**
  70176. * @hidden Internal post processes in depth of field effect
  70177. */
  70178. _effects: Array<PostProcess>;
  70179. /**
  70180. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70181. */
  70182. set focalLength(value: number);
  70183. get focalLength(): number;
  70184. /**
  70185. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70186. */
  70187. set fStop(value: number);
  70188. get fStop(): number;
  70189. /**
  70190. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70191. */
  70192. set focusDistance(value: number);
  70193. get focusDistance(): number;
  70194. /**
  70195. * 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.
  70196. */
  70197. set lensSize(value: number);
  70198. get lensSize(): number;
  70199. /**
  70200. * Creates a new instance DepthOfFieldEffect
  70201. * @param scene The scene the effect belongs to.
  70202. * @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.
  70203. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70204. * @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)
  70205. */
  70206. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70207. /**
  70208. * Get the current class name of the current effet
  70209. * @returns "DepthOfFieldEffect"
  70210. */
  70211. getClassName(): string;
  70212. /**
  70213. * 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.
  70214. */
  70215. set depthTexture(value: RenderTargetTexture);
  70216. /**
  70217. * Disposes each of the internal effects for a given camera.
  70218. * @param camera The camera to dispose the effect on.
  70219. */
  70220. disposeEffects(camera: Camera): void;
  70221. /**
  70222. * @hidden Internal
  70223. */
  70224. _updateEffects(): void;
  70225. /**
  70226. * Internal
  70227. * @returns if all the contained post processes are ready.
  70228. * @hidden
  70229. */
  70230. _isReady(): boolean;
  70231. }
  70232. }
  70233. declare module "babylonjs/Shaders/displayPass.fragment" {
  70234. /** @hidden */
  70235. export var displayPassPixelShader: {
  70236. name: string;
  70237. shader: string;
  70238. };
  70239. }
  70240. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  70241. import { Nullable } from "babylonjs/types";
  70242. import { Camera } from "babylonjs/Cameras/camera";
  70243. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70244. import { Engine } from "babylonjs/Engines/engine";
  70245. import "babylonjs/Shaders/displayPass.fragment";
  70246. /**
  70247. * DisplayPassPostProcess which produces an output the same as it's input
  70248. */
  70249. export class DisplayPassPostProcess extends PostProcess {
  70250. /**
  70251. * Creates the DisplayPassPostProcess
  70252. * @param name The name of the effect.
  70253. * @param options The required width/height ratio to downsize to before computing the render pass.
  70254. * @param camera The camera to apply the render pass to.
  70255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70256. * @param engine The engine which the post process will be applied. (default: current engine)
  70257. * @param reusable If the post process can be reused on the same frame. (default: false)
  70258. */
  70259. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70260. }
  70261. }
  70262. declare module "babylonjs/Shaders/filter.fragment" {
  70263. /** @hidden */
  70264. export var filterPixelShader: {
  70265. name: string;
  70266. shader: string;
  70267. };
  70268. }
  70269. declare module "babylonjs/PostProcesses/filterPostProcess" {
  70270. import { Nullable } from "babylonjs/types";
  70271. import { Matrix } from "babylonjs/Maths/math.vector";
  70272. import { Camera } from "babylonjs/Cameras/camera";
  70273. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70274. import { Engine } from "babylonjs/Engines/engine";
  70275. import "babylonjs/Shaders/filter.fragment";
  70276. /**
  70277. * Applies a kernel filter to the image
  70278. */
  70279. export class FilterPostProcess extends PostProcess {
  70280. /** The matrix to be applied to the image */
  70281. kernelMatrix: Matrix;
  70282. /**
  70283. *
  70284. * @param name The name of the effect.
  70285. * @param kernelMatrix The matrix to be applied to the image
  70286. * @param options The required width/height ratio to downsize to before computing the render pass.
  70287. * @param camera The camera to apply the render pass to.
  70288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70289. * @param engine The engine which the post process will be applied. (default: current engine)
  70290. * @param reusable If the post process can be reused on the same frame. (default: false)
  70291. */
  70292. constructor(name: string,
  70293. /** The matrix to be applied to the image */
  70294. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70295. }
  70296. }
  70297. declare module "babylonjs/Shaders/fxaa.fragment" {
  70298. /** @hidden */
  70299. export var fxaaPixelShader: {
  70300. name: string;
  70301. shader: string;
  70302. };
  70303. }
  70304. declare module "babylonjs/Shaders/fxaa.vertex" {
  70305. /** @hidden */
  70306. export var fxaaVertexShader: {
  70307. name: string;
  70308. shader: string;
  70309. };
  70310. }
  70311. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  70312. import { Nullable } from "babylonjs/types";
  70313. import { Camera } from "babylonjs/Cameras/camera";
  70314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70315. import { Engine } from "babylonjs/Engines/engine";
  70316. import "babylonjs/Shaders/fxaa.fragment";
  70317. import "babylonjs/Shaders/fxaa.vertex";
  70318. /**
  70319. * Fxaa post process
  70320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70321. */
  70322. export class FxaaPostProcess extends PostProcess {
  70323. /** @hidden */
  70324. texelWidth: number;
  70325. /** @hidden */
  70326. texelHeight: number;
  70327. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70328. private _getDefines;
  70329. }
  70330. }
  70331. declare module "babylonjs/Shaders/grain.fragment" {
  70332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70333. /** @hidden */
  70334. export var grainPixelShader: {
  70335. name: string;
  70336. shader: string;
  70337. };
  70338. }
  70339. declare module "babylonjs/PostProcesses/grainPostProcess" {
  70340. import { Nullable } from "babylonjs/types";
  70341. import { Camera } from "babylonjs/Cameras/camera";
  70342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70343. import { Engine } from "babylonjs/Engines/engine";
  70344. import "babylonjs/Shaders/grain.fragment";
  70345. /**
  70346. * The GrainPostProcess adds noise to the image at mid luminance levels
  70347. */
  70348. export class GrainPostProcess extends PostProcess {
  70349. /**
  70350. * The intensity of the grain added (default: 30)
  70351. */
  70352. intensity: number;
  70353. /**
  70354. * If the grain should be randomized on every frame
  70355. */
  70356. animated: boolean;
  70357. /**
  70358. * Creates a new instance of @see GrainPostProcess
  70359. * @param name The name of the effect.
  70360. * @param options The required width/height ratio to downsize to before computing the render pass.
  70361. * @param camera The camera to apply the render pass to.
  70362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70363. * @param engine The engine which the post process will be applied. (default: current engine)
  70364. * @param reusable If the post process can be reused on the same frame. (default: false)
  70365. * @param textureType Type of textures used when performing the post process. (default: 0)
  70366. * @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)
  70367. */
  70368. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70369. }
  70370. }
  70371. declare module "babylonjs/Shaders/highlights.fragment" {
  70372. /** @hidden */
  70373. export var highlightsPixelShader: {
  70374. name: string;
  70375. shader: string;
  70376. };
  70377. }
  70378. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  70379. import { Nullable } from "babylonjs/types";
  70380. import { Camera } from "babylonjs/Cameras/camera";
  70381. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70382. import { Engine } from "babylonjs/Engines/engine";
  70383. import "babylonjs/Shaders/highlights.fragment";
  70384. /**
  70385. * Extracts highlights from the image
  70386. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70387. */
  70388. export class HighlightsPostProcess extends PostProcess {
  70389. /**
  70390. * Extracts highlights from the image
  70391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70392. * @param name The name of the effect.
  70393. * @param options The required width/height ratio to downsize to before computing the render pass.
  70394. * @param camera The camera to apply the render pass to.
  70395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70396. * @param engine The engine which the post process will be applied. (default: current engine)
  70397. * @param reusable If the post process can be reused on the same frame. (default: false)
  70398. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70399. */
  70400. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70401. }
  70402. }
  70403. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  70404. /** @hidden */
  70405. export var mrtFragmentDeclaration: {
  70406. name: string;
  70407. shader: string;
  70408. };
  70409. }
  70410. declare module "babylonjs/Shaders/geometry.fragment" {
  70411. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  70412. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70413. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70414. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70415. /** @hidden */
  70416. export var geometryPixelShader: {
  70417. name: string;
  70418. shader: string;
  70419. };
  70420. }
  70421. declare module "babylonjs/Shaders/geometry.vertex" {
  70422. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70423. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70424. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70425. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70427. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70428. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70429. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  70430. /** @hidden */
  70431. export var geometryVertexShader: {
  70432. name: string;
  70433. shader: string;
  70434. };
  70435. }
  70436. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  70437. import { Matrix } from "babylonjs/Maths/math.vector";
  70438. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70439. import { Mesh } from "babylonjs/Meshes/mesh";
  70440. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  70441. import { Effect } from "babylonjs/Materials/effect";
  70442. import { Scene } from "babylonjs/scene";
  70443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70444. import "babylonjs/Shaders/geometry.fragment";
  70445. import "babylonjs/Shaders/geometry.vertex";
  70446. /** @hidden */
  70447. interface ISavedTransformationMatrix {
  70448. world: Matrix;
  70449. viewProjection: Matrix;
  70450. }
  70451. /**
  70452. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  70453. */
  70454. export class GeometryBufferRenderer {
  70455. /**
  70456. * Constant used to retrieve the position texture index in the G-Buffer textures array
  70457. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  70458. */
  70459. static readonly POSITION_TEXTURE_TYPE: number;
  70460. /**
  70461. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  70462. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  70463. */
  70464. static readonly VELOCITY_TEXTURE_TYPE: number;
  70465. /**
  70466. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  70467. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  70468. */
  70469. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  70470. /**
  70471. * Dictionary used to store the previous transformation matrices of each rendered mesh
  70472. * in order to compute objects velocities when enableVelocity is set to "true"
  70473. * @hidden
  70474. */
  70475. _previousTransformationMatrices: {
  70476. [index: number]: ISavedTransformationMatrix;
  70477. };
  70478. /**
  70479. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  70480. * in order to compute objects velocities when enableVelocity is set to "true"
  70481. * @hidden
  70482. */
  70483. _previousBonesTransformationMatrices: {
  70484. [index: number]: Float32Array;
  70485. };
  70486. /**
  70487. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70488. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70489. */
  70490. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70491. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70492. renderTransparentMeshes: boolean;
  70493. private _scene;
  70494. private _multiRenderTarget;
  70495. private _ratio;
  70496. private _enablePosition;
  70497. private _enableVelocity;
  70498. private _enableReflectivity;
  70499. private _positionIndex;
  70500. private _velocityIndex;
  70501. private _reflectivityIndex;
  70502. protected _effect: Effect;
  70503. protected _cachedDefines: string;
  70504. /**
  70505. * Set the render list (meshes to be rendered) used in the G buffer.
  70506. */
  70507. set renderList(meshes: Mesh[]);
  70508. /**
  70509. * Gets wether or not G buffer are supported by the running hardware.
  70510. * This requires draw buffer supports
  70511. */
  70512. get isSupported(): boolean;
  70513. /**
  70514. * Returns the index of the given texture type in the G-Buffer textures array
  70515. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70516. * @returns the index of the given texture type in the G-Buffer textures array
  70517. */
  70518. getTextureIndex(textureType: number): number;
  70519. /**
  70520. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70521. */
  70522. get enablePosition(): boolean;
  70523. /**
  70524. * Sets whether or not objects positions are enabled for the G buffer.
  70525. */
  70526. set enablePosition(enable: boolean);
  70527. /**
  70528. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70529. */
  70530. get enableVelocity(): boolean;
  70531. /**
  70532. * Sets wether or not objects velocities are enabled for the G buffer.
  70533. */
  70534. set enableVelocity(enable: boolean);
  70535. /**
  70536. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70537. */
  70538. get enableReflectivity(): boolean;
  70539. /**
  70540. * Sets wether or not objects roughness are enabled for the G buffer.
  70541. */
  70542. set enableReflectivity(enable: boolean);
  70543. /**
  70544. * Gets the scene associated with the buffer.
  70545. */
  70546. get scene(): Scene;
  70547. /**
  70548. * Gets the ratio used by the buffer during its creation.
  70549. * How big is the buffer related to the main canvas.
  70550. */
  70551. get ratio(): number;
  70552. /** @hidden */
  70553. static _SceneComponentInitialization: (scene: Scene) => void;
  70554. /**
  70555. * Creates a new G Buffer for the scene
  70556. * @param scene The scene the buffer belongs to
  70557. * @param ratio How big is the buffer related to the main canvas.
  70558. */
  70559. constructor(scene: Scene, ratio?: number);
  70560. /**
  70561. * Checks wether everything is ready to render a submesh to the G buffer.
  70562. * @param subMesh the submesh to check readiness for
  70563. * @param useInstances is the mesh drawn using instance or not
  70564. * @returns true if ready otherwise false
  70565. */
  70566. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70567. /**
  70568. * Gets the current underlying G Buffer.
  70569. * @returns the buffer
  70570. */
  70571. getGBuffer(): MultiRenderTarget;
  70572. /**
  70573. * Gets the number of samples used to render the buffer (anti aliasing).
  70574. */
  70575. get samples(): number;
  70576. /**
  70577. * Sets the number of samples used to render the buffer (anti aliasing).
  70578. */
  70579. set samples(value: number);
  70580. /**
  70581. * Disposes the renderer and frees up associated resources.
  70582. */
  70583. dispose(): void;
  70584. protected _createRenderTargets(): void;
  70585. private _copyBonesTransformationMatrices;
  70586. }
  70587. }
  70588. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  70589. import { Nullable } from "babylonjs/types";
  70590. import { Scene } from "babylonjs/scene";
  70591. import { ISceneComponent } from "babylonjs/sceneComponent";
  70592. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  70593. module "babylonjs/scene" {
  70594. interface Scene {
  70595. /** @hidden (Backing field) */
  70596. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70597. /**
  70598. * Gets or Sets the current geometry buffer associated to the scene.
  70599. */
  70600. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70601. /**
  70602. * Enables a GeometryBufferRender and associates it with the scene
  70603. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70604. * @returns the GeometryBufferRenderer
  70605. */
  70606. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70607. /**
  70608. * Disables the GeometryBufferRender associated with the scene
  70609. */
  70610. disableGeometryBufferRenderer(): void;
  70611. }
  70612. }
  70613. /**
  70614. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70615. * in several rendering techniques.
  70616. */
  70617. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70618. /**
  70619. * The component name helpful to identify the component in the list of scene components.
  70620. */
  70621. readonly name: string;
  70622. /**
  70623. * The scene the component belongs to.
  70624. */
  70625. scene: Scene;
  70626. /**
  70627. * Creates a new instance of the component for the given scene
  70628. * @param scene Defines the scene to register the component in
  70629. */
  70630. constructor(scene: Scene);
  70631. /**
  70632. * Registers the component in a given scene
  70633. */
  70634. register(): void;
  70635. /**
  70636. * Rebuilds the elements related to this component in case of
  70637. * context lost for instance.
  70638. */
  70639. rebuild(): void;
  70640. /**
  70641. * Disposes the component and the associated ressources
  70642. */
  70643. dispose(): void;
  70644. private _gatherRenderTargets;
  70645. }
  70646. }
  70647. declare module "babylonjs/Shaders/motionBlur.fragment" {
  70648. /** @hidden */
  70649. export var motionBlurPixelShader: {
  70650. name: string;
  70651. shader: string;
  70652. };
  70653. }
  70654. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  70655. import { Nullable } from "babylonjs/types";
  70656. import { Camera } from "babylonjs/Cameras/camera";
  70657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70658. import { Scene } from "babylonjs/scene";
  70659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70660. import "babylonjs/Animations/animatable";
  70661. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70662. import "babylonjs/Shaders/motionBlur.fragment";
  70663. import { Engine } from "babylonjs/Engines/engine";
  70664. /**
  70665. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70666. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70667. * As an example, all you have to do is to create the post-process:
  70668. * var mb = new BABYLON.MotionBlurPostProcess(
  70669. * 'mb', // The name of the effect.
  70670. * scene, // The scene containing the objects to blur according to their velocity.
  70671. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70672. * camera // The camera to apply the render pass to.
  70673. * );
  70674. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70675. */
  70676. export class MotionBlurPostProcess extends PostProcess {
  70677. /**
  70678. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70679. */
  70680. motionStrength: number;
  70681. /**
  70682. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70683. */
  70684. get motionBlurSamples(): number;
  70685. /**
  70686. * Sets the number of iterations to be used for motion blur quality
  70687. */
  70688. set motionBlurSamples(samples: number);
  70689. private _motionBlurSamples;
  70690. private _geometryBufferRenderer;
  70691. /**
  70692. * Creates a new instance MotionBlurPostProcess
  70693. * @param name The name of the effect.
  70694. * @param scene The scene containing the objects to blur according to their velocity.
  70695. * @param options The required width/height ratio to downsize to before computing the render pass.
  70696. * @param camera The camera to apply the render pass to.
  70697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70698. * @param engine The engine which the post process will be applied. (default: current engine)
  70699. * @param reusable If the post process can be reused on the same frame. (default: false)
  70700. * @param textureType Type of textures used when performing the post process. (default: 0)
  70701. * @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)
  70702. */
  70703. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70704. /**
  70705. * Excludes the given skinned mesh from computing bones velocities.
  70706. * 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.
  70707. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70708. */
  70709. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70710. /**
  70711. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70712. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70713. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70714. */
  70715. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70716. /**
  70717. * Disposes the post process.
  70718. * @param camera The camera to dispose the post process on.
  70719. */
  70720. dispose(camera?: Camera): void;
  70721. }
  70722. }
  70723. declare module "babylonjs/Shaders/refraction.fragment" {
  70724. /** @hidden */
  70725. export var refractionPixelShader: {
  70726. name: string;
  70727. shader: string;
  70728. };
  70729. }
  70730. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  70731. import { Color3 } from "babylonjs/Maths/math.color";
  70732. import { Camera } from "babylonjs/Cameras/camera";
  70733. import { Texture } from "babylonjs/Materials/Textures/texture";
  70734. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70735. import { Engine } from "babylonjs/Engines/engine";
  70736. import "babylonjs/Shaders/refraction.fragment";
  70737. /**
  70738. * Post process which applies a refractin texture
  70739. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70740. */
  70741. export class RefractionPostProcess extends PostProcess {
  70742. /** the base color of the refraction (used to taint the rendering) */
  70743. color: Color3;
  70744. /** simulated refraction depth */
  70745. depth: number;
  70746. /** the coefficient of the base color (0 to remove base color tainting) */
  70747. colorLevel: number;
  70748. private _refTexture;
  70749. private _ownRefractionTexture;
  70750. /**
  70751. * Gets or sets the refraction texture
  70752. * Please note that you are responsible for disposing the texture if you set it manually
  70753. */
  70754. get refractionTexture(): Texture;
  70755. set refractionTexture(value: Texture);
  70756. /**
  70757. * Initializes the RefractionPostProcess
  70758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70759. * @param name The name of the effect.
  70760. * @param refractionTextureUrl Url of the refraction texture to use
  70761. * @param color the base color of the refraction (used to taint the rendering)
  70762. * @param depth simulated refraction depth
  70763. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70764. * @param camera The camera to apply the render pass to.
  70765. * @param options The required width/height ratio to downsize to before computing the render pass.
  70766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70767. * @param engine The engine which the post process will be applied. (default: current engine)
  70768. * @param reusable If the post process can be reused on the same frame. (default: false)
  70769. */
  70770. constructor(name: string, refractionTextureUrl: string,
  70771. /** the base color of the refraction (used to taint the rendering) */
  70772. color: Color3,
  70773. /** simulated refraction depth */
  70774. depth: number,
  70775. /** the coefficient of the base color (0 to remove base color tainting) */
  70776. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70777. /**
  70778. * Disposes of the post process
  70779. * @param camera Camera to dispose post process on
  70780. */
  70781. dispose(camera: Camera): void;
  70782. }
  70783. }
  70784. declare module "babylonjs/Shaders/sharpen.fragment" {
  70785. /** @hidden */
  70786. export var sharpenPixelShader: {
  70787. name: string;
  70788. shader: string;
  70789. };
  70790. }
  70791. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  70792. import { Nullable } from "babylonjs/types";
  70793. import { Camera } from "babylonjs/Cameras/camera";
  70794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70795. import "babylonjs/Shaders/sharpen.fragment";
  70796. import { Engine } from "babylonjs/Engines/engine";
  70797. /**
  70798. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70799. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70800. */
  70801. export class SharpenPostProcess extends PostProcess {
  70802. /**
  70803. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70804. */
  70805. colorAmount: number;
  70806. /**
  70807. * How much sharpness should be applied (default: 0.3)
  70808. */
  70809. edgeAmount: number;
  70810. /**
  70811. * Creates a new instance ConvolutionPostProcess
  70812. * @param name The name of the effect.
  70813. * @param options The required width/height ratio to downsize to before computing the render pass.
  70814. * @param camera The camera to apply the render pass to.
  70815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70816. * @param engine The engine which the post process will be applied. (default: current engine)
  70817. * @param reusable If the post process can be reused on the same frame. (default: false)
  70818. * @param textureType Type of textures used when performing the post process. (default: 0)
  70819. * @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)
  70820. */
  70821. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70822. }
  70823. }
  70824. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  70825. import { Nullable } from "babylonjs/types";
  70826. import { Camera } from "babylonjs/Cameras/camera";
  70827. import { Engine } from "babylonjs/Engines/engine";
  70828. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70829. import { IInspectable } from "babylonjs/Misc/iInspectable";
  70830. /**
  70831. * PostProcessRenderPipeline
  70832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70833. */
  70834. export class PostProcessRenderPipeline {
  70835. private engine;
  70836. private _renderEffects;
  70837. private _renderEffectsForIsolatedPass;
  70838. /**
  70839. * List of inspectable custom properties (used by the Inspector)
  70840. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70841. */
  70842. inspectableCustomProperties: IInspectable[];
  70843. /**
  70844. * @hidden
  70845. */
  70846. protected _cameras: Camera[];
  70847. /** @hidden */
  70848. _name: string;
  70849. /**
  70850. * Gets pipeline name
  70851. */
  70852. get name(): string;
  70853. /** Gets the list of attached cameras */
  70854. get cameras(): Camera[];
  70855. /**
  70856. * Initializes a PostProcessRenderPipeline
  70857. * @param engine engine to add the pipeline to
  70858. * @param name name of the pipeline
  70859. */
  70860. constructor(engine: Engine, name: string);
  70861. /**
  70862. * Gets the class name
  70863. * @returns "PostProcessRenderPipeline"
  70864. */
  70865. getClassName(): string;
  70866. /**
  70867. * If all the render effects in the pipeline are supported
  70868. */
  70869. get isSupported(): boolean;
  70870. /**
  70871. * Adds an effect to the pipeline
  70872. * @param renderEffect the effect to add
  70873. */
  70874. addEffect(renderEffect: PostProcessRenderEffect): void;
  70875. /** @hidden */
  70876. _rebuild(): void;
  70877. /** @hidden */
  70878. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70879. /** @hidden */
  70880. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70881. /** @hidden */
  70882. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70883. /** @hidden */
  70884. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70885. /** @hidden */
  70886. _attachCameras(cameras: Camera, unique: boolean): void;
  70887. /** @hidden */
  70888. _attachCameras(cameras: Camera[], unique: boolean): void;
  70889. /** @hidden */
  70890. _detachCameras(cameras: Camera): void;
  70891. /** @hidden */
  70892. _detachCameras(cameras: Nullable<Camera[]>): void;
  70893. /** @hidden */
  70894. _update(): void;
  70895. /** @hidden */
  70896. _reset(): void;
  70897. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70898. /**
  70899. * Disposes of the pipeline
  70900. */
  70901. dispose(): void;
  70902. }
  70903. }
  70904. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  70905. import { Camera } from "babylonjs/Cameras/camera";
  70906. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70907. /**
  70908. * PostProcessRenderPipelineManager class
  70909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70910. */
  70911. export class PostProcessRenderPipelineManager {
  70912. private _renderPipelines;
  70913. /**
  70914. * Initializes a PostProcessRenderPipelineManager
  70915. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70916. */
  70917. constructor();
  70918. /**
  70919. * Gets the list of supported render pipelines
  70920. */
  70921. get supportedPipelines(): PostProcessRenderPipeline[];
  70922. /**
  70923. * Adds a pipeline to the manager
  70924. * @param renderPipeline The pipeline to add
  70925. */
  70926. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70927. /**
  70928. * Attaches a camera to the pipeline
  70929. * @param renderPipelineName The name of the pipeline to attach to
  70930. * @param cameras the camera to attach
  70931. * @param unique if the camera can be attached multiple times to the pipeline
  70932. */
  70933. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70934. /**
  70935. * Detaches a camera from the pipeline
  70936. * @param renderPipelineName The name of the pipeline to detach from
  70937. * @param cameras the camera to detach
  70938. */
  70939. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70940. /**
  70941. * Enables an effect by name on a pipeline
  70942. * @param renderPipelineName the name of the pipeline to enable the effect in
  70943. * @param renderEffectName the name of the effect to enable
  70944. * @param cameras the cameras that the effect should be enabled on
  70945. */
  70946. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70947. /**
  70948. * Disables an effect by name on a pipeline
  70949. * @param renderPipelineName the name of the pipeline to disable the effect in
  70950. * @param renderEffectName the name of the effect to disable
  70951. * @param cameras the cameras that the effect should be disabled on
  70952. */
  70953. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70954. /**
  70955. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70956. */
  70957. update(): void;
  70958. /** @hidden */
  70959. _rebuild(): void;
  70960. /**
  70961. * Disposes of the manager and pipelines
  70962. */
  70963. dispose(): void;
  70964. }
  70965. }
  70966. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  70967. import { ISceneComponent } from "babylonjs/sceneComponent";
  70968. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70969. import { Scene } from "babylonjs/scene";
  70970. module "babylonjs/scene" {
  70971. interface Scene {
  70972. /** @hidden (Backing field) */
  70973. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70974. /**
  70975. * Gets the postprocess render pipeline manager
  70976. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70977. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70978. */
  70979. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70980. }
  70981. }
  70982. /**
  70983. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70984. */
  70985. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70986. /**
  70987. * The component name helpfull to identify the component in the list of scene components.
  70988. */
  70989. readonly name: string;
  70990. /**
  70991. * The scene the component belongs to.
  70992. */
  70993. scene: Scene;
  70994. /**
  70995. * Creates a new instance of the component for the given scene
  70996. * @param scene Defines the scene to register the component in
  70997. */
  70998. constructor(scene: Scene);
  70999. /**
  71000. * Registers the component in a given scene
  71001. */
  71002. register(): void;
  71003. /**
  71004. * Rebuilds the elements related to this component in case of
  71005. * context lost for instance.
  71006. */
  71007. rebuild(): void;
  71008. /**
  71009. * Disposes the component and the associated ressources
  71010. */
  71011. dispose(): void;
  71012. private _gatherRenderTargets;
  71013. }
  71014. }
  71015. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  71016. import { Nullable } from "babylonjs/types";
  71017. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71018. import { Camera } from "babylonjs/Cameras/camera";
  71019. import { IDisposable } from "babylonjs/scene";
  71020. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  71021. import { Scene } from "babylonjs/scene";
  71022. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  71023. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  71024. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  71025. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  71026. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71027. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71028. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  71029. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71030. import { Animation } from "babylonjs/Animations/animation";
  71031. /**
  71032. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71033. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71034. */
  71035. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71036. private _scene;
  71037. private _camerasToBeAttached;
  71038. /**
  71039. * ID of the sharpen post process,
  71040. */
  71041. private readonly SharpenPostProcessId;
  71042. /**
  71043. * @ignore
  71044. * ID of the image processing post process;
  71045. */
  71046. readonly ImageProcessingPostProcessId: string;
  71047. /**
  71048. * @ignore
  71049. * ID of the Fast Approximate Anti-Aliasing post process;
  71050. */
  71051. readonly FxaaPostProcessId: string;
  71052. /**
  71053. * ID of the chromatic aberration post process,
  71054. */
  71055. private readonly ChromaticAberrationPostProcessId;
  71056. /**
  71057. * ID of the grain post process
  71058. */
  71059. private readonly GrainPostProcessId;
  71060. /**
  71061. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71062. */
  71063. sharpen: SharpenPostProcess;
  71064. private _sharpenEffect;
  71065. private bloom;
  71066. /**
  71067. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71068. */
  71069. depthOfField: DepthOfFieldEffect;
  71070. /**
  71071. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71072. */
  71073. fxaa: FxaaPostProcess;
  71074. /**
  71075. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71076. */
  71077. imageProcessing: ImageProcessingPostProcess;
  71078. /**
  71079. * Chromatic aberration post process which will shift rgb colors in the image
  71080. */
  71081. chromaticAberration: ChromaticAberrationPostProcess;
  71082. private _chromaticAberrationEffect;
  71083. /**
  71084. * Grain post process which add noise to the image
  71085. */
  71086. grain: GrainPostProcess;
  71087. private _grainEffect;
  71088. /**
  71089. * Glow post process which adds a glow to emissive areas of the image
  71090. */
  71091. private _glowLayer;
  71092. /**
  71093. * Animations which can be used to tweak settings over a period of time
  71094. */
  71095. animations: Animation[];
  71096. private _imageProcessingConfigurationObserver;
  71097. private _sharpenEnabled;
  71098. private _bloomEnabled;
  71099. private _depthOfFieldEnabled;
  71100. private _depthOfFieldBlurLevel;
  71101. private _fxaaEnabled;
  71102. private _imageProcessingEnabled;
  71103. private _defaultPipelineTextureType;
  71104. private _bloomScale;
  71105. private _chromaticAberrationEnabled;
  71106. private _grainEnabled;
  71107. private _buildAllowed;
  71108. /**
  71109. * Gets active scene
  71110. */
  71111. get scene(): Scene;
  71112. /**
  71113. * Enable or disable the sharpen process from the pipeline
  71114. */
  71115. set sharpenEnabled(enabled: boolean);
  71116. get sharpenEnabled(): boolean;
  71117. private _resizeObserver;
  71118. private _hardwareScaleLevel;
  71119. private _bloomKernel;
  71120. /**
  71121. * Specifies the size of the bloom blur kernel, relative to the final output size
  71122. */
  71123. get bloomKernel(): number;
  71124. set bloomKernel(value: number);
  71125. /**
  71126. * Specifies the weight of the bloom in the final rendering
  71127. */
  71128. private _bloomWeight;
  71129. /**
  71130. * Specifies the luma threshold for the area that will be blurred by the bloom
  71131. */
  71132. private _bloomThreshold;
  71133. private _hdr;
  71134. /**
  71135. * The strength of the bloom.
  71136. */
  71137. set bloomWeight(value: number);
  71138. get bloomWeight(): number;
  71139. /**
  71140. * The strength of the bloom.
  71141. */
  71142. set bloomThreshold(value: number);
  71143. get bloomThreshold(): number;
  71144. /**
  71145. * The scale of the bloom, lower value will provide better performance.
  71146. */
  71147. set bloomScale(value: number);
  71148. get bloomScale(): number;
  71149. /**
  71150. * Enable or disable the bloom from the pipeline
  71151. */
  71152. set bloomEnabled(enabled: boolean);
  71153. get bloomEnabled(): boolean;
  71154. private _rebuildBloom;
  71155. /**
  71156. * If the depth of field is enabled.
  71157. */
  71158. get depthOfFieldEnabled(): boolean;
  71159. set depthOfFieldEnabled(enabled: boolean);
  71160. /**
  71161. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71162. */
  71163. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71164. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71165. /**
  71166. * If the anti aliasing is enabled.
  71167. */
  71168. set fxaaEnabled(enabled: boolean);
  71169. get fxaaEnabled(): boolean;
  71170. private _samples;
  71171. /**
  71172. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71173. */
  71174. set samples(sampleCount: number);
  71175. get samples(): number;
  71176. /**
  71177. * If image processing is enabled.
  71178. */
  71179. set imageProcessingEnabled(enabled: boolean);
  71180. get imageProcessingEnabled(): boolean;
  71181. /**
  71182. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71183. */
  71184. set glowLayerEnabled(enabled: boolean);
  71185. get glowLayerEnabled(): boolean;
  71186. /**
  71187. * Gets the glow layer (or null if not defined)
  71188. */
  71189. get glowLayer(): Nullable<GlowLayer>;
  71190. /**
  71191. * Enable or disable the chromaticAberration process from the pipeline
  71192. */
  71193. set chromaticAberrationEnabled(enabled: boolean);
  71194. get chromaticAberrationEnabled(): boolean;
  71195. /**
  71196. * Enable or disable the grain process from the pipeline
  71197. */
  71198. set grainEnabled(enabled: boolean);
  71199. get grainEnabled(): boolean;
  71200. /**
  71201. * @constructor
  71202. * @param name - The rendering pipeline name (default: "")
  71203. * @param hdr - If high dynamic range textures should be used (default: true)
  71204. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71205. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71206. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71207. */
  71208. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71209. /**
  71210. * Get the class name
  71211. * @returns "DefaultRenderingPipeline"
  71212. */
  71213. getClassName(): string;
  71214. /**
  71215. * Force the compilation of the entire pipeline.
  71216. */
  71217. prepare(): void;
  71218. private _hasCleared;
  71219. private _prevPostProcess;
  71220. private _prevPrevPostProcess;
  71221. private _setAutoClearAndTextureSharing;
  71222. private _depthOfFieldSceneObserver;
  71223. private _buildPipeline;
  71224. private _disposePostProcesses;
  71225. /**
  71226. * Adds a camera to the pipeline
  71227. * @param camera the camera to be added
  71228. */
  71229. addCamera(camera: Camera): void;
  71230. /**
  71231. * Removes a camera from the pipeline
  71232. * @param camera the camera to remove
  71233. */
  71234. removeCamera(camera: Camera): void;
  71235. /**
  71236. * Dispose of the pipeline and stop all post processes
  71237. */
  71238. dispose(): void;
  71239. /**
  71240. * Serialize the rendering pipeline (Used when exporting)
  71241. * @returns the serialized object
  71242. */
  71243. serialize(): any;
  71244. /**
  71245. * Parse the serialized pipeline
  71246. * @param source Source pipeline.
  71247. * @param scene The scene to load the pipeline to.
  71248. * @param rootUrl The URL of the serialized pipeline.
  71249. * @returns An instantiated pipeline from the serialized object.
  71250. */
  71251. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71252. }
  71253. }
  71254. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  71255. /** @hidden */
  71256. export var lensHighlightsPixelShader: {
  71257. name: string;
  71258. shader: string;
  71259. };
  71260. }
  71261. declare module "babylonjs/Shaders/depthOfField.fragment" {
  71262. /** @hidden */
  71263. export var depthOfFieldPixelShader: {
  71264. name: string;
  71265. shader: string;
  71266. };
  71267. }
  71268. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  71269. import { Camera } from "babylonjs/Cameras/camera";
  71270. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71271. import { Scene } from "babylonjs/scene";
  71272. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71273. import "babylonjs/Shaders/chromaticAberration.fragment";
  71274. import "babylonjs/Shaders/lensHighlights.fragment";
  71275. import "babylonjs/Shaders/depthOfField.fragment";
  71276. /**
  71277. * BABYLON.JS Chromatic Aberration GLSL Shader
  71278. * Author: Olivier Guyot
  71279. * Separates very slightly R, G and B colors on the edges of the screen
  71280. * Inspired by Francois Tarlier & Martins Upitis
  71281. */
  71282. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71283. /**
  71284. * @ignore
  71285. * The chromatic aberration PostProcess id in the pipeline
  71286. */
  71287. LensChromaticAberrationEffect: string;
  71288. /**
  71289. * @ignore
  71290. * The highlights enhancing PostProcess id in the pipeline
  71291. */
  71292. HighlightsEnhancingEffect: string;
  71293. /**
  71294. * @ignore
  71295. * The depth-of-field PostProcess id in the pipeline
  71296. */
  71297. LensDepthOfFieldEffect: string;
  71298. private _scene;
  71299. private _depthTexture;
  71300. private _grainTexture;
  71301. private _chromaticAberrationPostProcess;
  71302. private _highlightsPostProcess;
  71303. private _depthOfFieldPostProcess;
  71304. private _edgeBlur;
  71305. private _grainAmount;
  71306. private _chromaticAberration;
  71307. private _distortion;
  71308. private _highlightsGain;
  71309. private _highlightsThreshold;
  71310. private _dofDistance;
  71311. private _dofAperture;
  71312. private _dofDarken;
  71313. private _dofPentagon;
  71314. private _blurNoise;
  71315. /**
  71316. * @constructor
  71317. *
  71318. * Effect parameters are as follow:
  71319. * {
  71320. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71321. * edge_blur: number; // from 0 to x (1 for realism)
  71322. * distortion: number; // from 0 to x (1 for realism)
  71323. * grain_amount: number; // from 0 to 1
  71324. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71325. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71326. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71327. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71328. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71329. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71330. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71331. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71332. * }
  71333. * Note: if an effect parameter is unset, effect is disabled
  71334. *
  71335. * @param name The rendering pipeline name
  71336. * @param parameters - An object containing all parameters (see above)
  71337. * @param scene The scene linked to this pipeline
  71338. * @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)
  71339. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71340. */
  71341. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71342. /**
  71343. * Get the class name
  71344. * @returns "LensRenderingPipeline"
  71345. */
  71346. getClassName(): string;
  71347. /**
  71348. * Gets associated scene
  71349. */
  71350. get scene(): Scene;
  71351. /**
  71352. * Gets or sets the edge blur
  71353. */
  71354. get edgeBlur(): number;
  71355. set edgeBlur(value: number);
  71356. /**
  71357. * Gets or sets the grain amount
  71358. */
  71359. get grainAmount(): number;
  71360. set grainAmount(value: number);
  71361. /**
  71362. * Gets or sets the chromatic aberration amount
  71363. */
  71364. get chromaticAberration(): number;
  71365. set chromaticAberration(value: number);
  71366. /**
  71367. * Gets or sets the depth of field aperture
  71368. */
  71369. get dofAperture(): number;
  71370. set dofAperture(value: number);
  71371. /**
  71372. * Gets or sets the edge distortion
  71373. */
  71374. get edgeDistortion(): number;
  71375. set edgeDistortion(value: number);
  71376. /**
  71377. * Gets or sets the depth of field distortion
  71378. */
  71379. get dofDistortion(): number;
  71380. set dofDistortion(value: number);
  71381. /**
  71382. * Gets or sets the darken out of focus amount
  71383. */
  71384. get darkenOutOfFocus(): number;
  71385. set darkenOutOfFocus(value: number);
  71386. /**
  71387. * Gets or sets a boolean indicating if blur noise is enabled
  71388. */
  71389. get blurNoise(): boolean;
  71390. set blurNoise(value: boolean);
  71391. /**
  71392. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71393. */
  71394. get pentagonBokeh(): boolean;
  71395. set pentagonBokeh(value: boolean);
  71396. /**
  71397. * Gets or sets the highlight grain amount
  71398. */
  71399. get highlightsGain(): number;
  71400. set highlightsGain(value: number);
  71401. /**
  71402. * Gets or sets the highlight threshold
  71403. */
  71404. get highlightsThreshold(): number;
  71405. set highlightsThreshold(value: number);
  71406. /**
  71407. * Sets the amount of blur at the edges
  71408. * @param amount blur amount
  71409. */
  71410. setEdgeBlur(amount: number): void;
  71411. /**
  71412. * Sets edge blur to 0
  71413. */
  71414. disableEdgeBlur(): void;
  71415. /**
  71416. * Sets the amout of grain
  71417. * @param amount Amount of grain
  71418. */
  71419. setGrainAmount(amount: number): void;
  71420. /**
  71421. * Set grain amount to 0
  71422. */
  71423. disableGrain(): void;
  71424. /**
  71425. * Sets the chromatic aberration amount
  71426. * @param amount amount of chromatic aberration
  71427. */
  71428. setChromaticAberration(amount: number): void;
  71429. /**
  71430. * Sets chromatic aberration amount to 0
  71431. */
  71432. disableChromaticAberration(): void;
  71433. /**
  71434. * Sets the EdgeDistortion amount
  71435. * @param amount amount of EdgeDistortion
  71436. */
  71437. setEdgeDistortion(amount: number): void;
  71438. /**
  71439. * Sets edge distortion to 0
  71440. */
  71441. disableEdgeDistortion(): void;
  71442. /**
  71443. * Sets the FocusDistance amount
  71444. * @param amount amount of FocusDistance
  71445. */
  71446. setFocusDistance(amount: number): void;
  71447. /**
  71448. * Disables depth of field
  71449. */
  71450. disableDepthOfField(): void;
  71451. /**
  71452. * Sets the Aperture amount
  71453. * @param amount amount of Aperture
  71454. */
  71455. setAperture(amount: number): void;
  71456. /**
  71457. * Sets the DarkenOutOfFocus amount
  71458. * @param amount amount of DarkenOutOfFocus
  71459. */
  71460. setDarkenOutOfFocus(amount: number): void;
  71461. private _pentagonBokehIsEnabled;
  71462. /**
  71463. * Creates a pentagon bokeh effect
  71464. */
  71465. enablePentagonBokeh(): void;
  71466. /**
  71467. * Disables the pentagon bokeh effect
  71468. */
  71469. disablePentagonBokeh(): void;
  71470. /**
  71471. * Enables noise blur
  71472. */
  71473. enableNoiseBlur(): void;
  71474. /**
  71475. * Disables noise blur
  71476. */
  71477. disableNoiseBlur(): void;
  71478. /**
  71479. * Sets the HighlightsGain amount
  71480. * @param amount amount of HighlightsGain
  71481. */
  71482. setHighlightsGain(amount: number): void;
  71483. /**
  71484. * Sets the HighlightsThreshold amount
  71485. * @param amount amount of HighlightsThreshold
  71486. */
  71487. setHighlightsThreshold(amount: number): void;
  71488. /**
  71489. * Disables highlights
  71490. */
  71491. disableHighlights(): void;
  71492. /**
  71493. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71494. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71495. */
  71496. dispose(disableDepthRender?: boolean): void;
  71497. private _createChromaticAberrationPostProcess;
  71498. private _createHighlightsPostProcess;
  71499. private _createDepthOfFieldPostProcess;
  71500. private _createGrainTexture;
  71501. }
  71502. }
  71503. declare module "babylonjs/Shaders/ssao2.fragment" {
  71504. /** @hidden */
  71505. export var ssao2PixelShader: {
  71506. name: string;
  71507. shader: string;
  71508. };
  71509. }
  71510. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  71511. /** @hidden */
  71512. export var ssaoCombinePixelShader: {
  71513. name: string;
  71514. shader: string;
  71515. };
  71516. }
  71517. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  71518. import { Camera } from "babylonjs/Cameras/camera";
  71519. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71520. import { Scene } from "babylonjs/scene";
  71521. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71522. import "babylonjs/Shaders/ssao2.fragment";
  71523. import "babylonjs/Shaders/ssaoCombine.fragment";
  71524. /**
  71525. * Render pipeline to produce ssao effect
  71526. */
  71527. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71528. /**
  71529. * @ignore
  71530. * The PassPostProcess id in the pipeline that contains the original scene color
  71531. */
  71532. SSAOOriginalSceneColorEffect: string;
  71533. /**
  71534. * @ignore
  71535. * The SSAO PostProcess id in the pipeline
  71536. */
  71537. SSAORenderEffect: string;
  71538. /**
  71539. * @ignore
  71540. * The horizontal blur PostProcess id in the pipeline
  71541. */
  71542. SSAOBlurHRenderEffect: string;
  71543. /**
  71544. * @ignore
  71545. * The vertical blur PostProcess id in the pipeline
  71546. */
  71547. SSAOBlurVRenderEffect: string;
  71548. /**
  71549. * @ignore
  71550. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71551. */
  71552. SSAOCombineRenderEffect: string;
  71553. /**
  71554. * The output strength of the SSAO post-process. Default value is 1.0.
  71555. */
  71556. totalStrength: number;
  71557. /**
  71558. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71559. */
  71560. maxZ: number;
  71561. /**
  71562. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71563. */
  71564. minZAspect: number;
  71565. private _samples;
  71566. /**
  71567. * Number of samples used for the SSAO calculations. Default value is 8
  71568. */
  71569. set samples(n: number);
  71570. get samples(): number;
  71571. private _textureSamples;
  71572. /**
  71573. * Number of samples to use for antialiasing
  71574. */
  71575. set textureSamples(n: number);
  71576. get textureSamples(): number;
  71577. /**
  71578. * Ratio object used for SSAO ratio and blur ratio
  71579. */
  71580. private _ratio;
  71581. /**
  71582. * Dynamically generated sphere sampler.
  71583. */
  71584. private _sampleSphere;
  71585. /**
  71586. * Blur filter offsets
  71587. */
  71588. private _samplerOffsets;
  71589. private _expensiveBlur;
  71590. /**
  71591. * If bilateral blur should be used
  71592. */
  71593. set expensiveBlur(b: boolean);
  71594. get expensiveBlur(): boolean;
  71595. /**
  71596. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71597. */
  71598. radius: number;
  71599. /**
  71600. * The base color of the SSAO post-process
  71601. * The final result is "base + ssao" between [0, 1]
  71602. */
  71603. base: number;
  71604. /**
  71605. * Support test.
  71606. */
  71607. static get IsSupported(): boolean;
  71608. private _scene;
  71609. private _depthTexture;
  71610. private _normalTexture;
  71611. private _randomTexture;
  71612. private _originalColorPostProcess;
  71613. private _ssaoPostProcess;
  71614. private _blurHPostProcess;
  71615. private _blurVPostProcess;
  71616. private _ssaoCombinePostProcess;
  71617. /**
  71618. * Gets active scene
  71619. */
  71620. get scene(): Scene;
  71621. /**
  71622. * @constructor
  71623. * @param name The rendering pipeline name
  71624. * @param scene The scene linked to this pipeline
  71625. * @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 }
  71626. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71627. */
  71628. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71629. /**
  71630. * Get the class name
  71631. * @returns "SSAO2RenderingPipeline"
  71632. */
  71633. getClassName(): string;
  71634. /**
  71635. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71636. */
  71637. dispose(disableGeometryBufferRenderer?: boolean): void;
  71638. private _createBlurPostProcess;
  71639. /** @hidden */
  71640. _rebuild(): void;
  71641. private _bits;
  71642. private _radicalInverse_VdC;
  71643. private _hammersley;
  71644. private _hemisphereSample_uniform;
  71645. private _generateHemisphere;
  71646. private _createSSAOPostProcess;
  71647. private _createSSAOCombinePostProcess;
  71648. private _createRandomTexture;
  71649. /**
  71650. * Serialize the rendering pipeline (Used when exporting)
  71651. * @returns the serialized object
  71652. */
  71653. serialize(): any;
  71654. /**
  71655. * Parse the serialized pipeline
  71656. * @param source Source pipeline.
  71657. * @param scene The scene to load the pipeline to.
  71658. * @param rootUrl The URL of the serialized pipeline.
  71659. * @returns An instantiated pipeline from the serialized object.
  71660. */
  71661. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71662. }
  71663. }
  71664. declare module "babylonjs/Shaders/ssao.fragment" {
  71665. /** @hidden */
  71666. export var ssaoPixelShader: {
  71667. name: string;
  71668. shader: string;
  71669. };
  71670. }
  71671. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  71672. import { Camera } from "babylonjs/Cameras/camera";
  71673. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71674. import { Scene } from "babylonjs/scene";
  71675. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71676. import "babylonjs/Shaders/ssao.fragment";
  71677. import "babylonjs/Shaders/ssaoCombine.fragment";
  71678. /**
  71679. * Render pipeline to produce ssao effect
  71680. */
  71681. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71682. /**
  71683. * @ignore
  71684. * The PassPostProcess id in the pipeline that contains the original scene color
  71685. */
  71686. SSAOOriginalSceneColorEffect: string;
  71687. /**
  71688. * @ignore
  71689. * The SSAO PostProcess id in the pipeline
  71690. */
  71691. SSAORenderEffect: string;
  71692. /**
  71693. * @ignore
  71694. * The horizontal blur PostProcess id in the pipeline
  71695. */
  71696. SSAOBlurHRenderEffect: string;
  71697. /**
  71698. * @ignore
  71699. * The vertical blur PostProcess id in the pipeline
  71700. */
  71701. SSAOBlurVRenderEffect: string;
  71702. /**
  71703. * @ignore
  71704. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71705. */
  71706. SSAOCombineRenderEffect: string;
  71707. /**
  71708. * The output strength of the SSAO post-process. Default value is 1.0.
  71709. */
  71710. totalStrength: number;
  71711. /**
  71712. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71713. */
  71714. radius: number;
  71715. /**
  71716. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71717. * Must not be equal to fallOff and superior to fallOff.
  71718. * Default value is 0.0075
  71719. */
  71720. area: number;
  71721. /**
  71722. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71723. * Must not be equal to area and inferior to area.
  71724. * Default value is 0.000001
  71725. */
  71726. fallOff: number;
  71727. /**
  71728. * The base color of the SSAO post-process
  71729. * The final result is "base + ssao" between [0, 1]
  71730. */
  71731. base: number;
  71732. private _scene;
  71733. private _depthTexture;
  71734. private _randomTexture;
  71735. private _originalColorPostProcess;
  71736. private _ssaoPostProcess;
  71737. private _blurHPostProcess;
  71738. private _blurVPostProcess;
  71739. private _ssaoCombinePostProcess;
  71740. private _firstUpdate;
  71741. /**
  71742. * Gets active scene
  71743. */
  71744. get scene(): Scene;
  71745. /**
  71746. * @constructor
  71747. * @param name - The rendering pipeline name
  71748. * @param scene - The scene linked to this pipeline
  71749. * @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 }
  71750. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71751. */
  71752. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71753. /**
  71754. * Get the class name
  71755. * @returns "SSAORenderingPipeline"
  71756. */
  71757. getClassName(): string;
  71758. /**
  71759. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71760. */
  71761. dispose(disableDepthRender?: boolean): void;
  71762. private _createBlurPostProcess;
  71763. /** @hidden */
  71764. _rebuild(): void;
  71765. private _createSSAOPostProcess;
  71766. private _createSSAOCombinePostProcess;
  71767. private _createRandomTexture;
  71768. }
  71769. }
  71770. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  71771. /** @hidden */
  71772. export var screenSpaceReflectionPixelShader: {
  71773. name: string;
  71774. shader: string;
  71775. };
  71776. }
  71777. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  71778. import { Nullable } from "babylonjs/types";
  71779. import { Camera } from "babylonjs/Cameras/camera";
  71780. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71781. import { Scene } from "babylonjs/scene";
  71782. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  71783. import { Engine } from "babylonjs/Engines/engine";
  71784. /**
  71785. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71786. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71787. */
  71788. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71789. /**
  71790. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71791. */
  71792. threshold: number;
  71793. /**
  71794. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71795. */
  71796. strength: number;
  71797. /**
  71798. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71799. */
  71800. reflectionSpecularFalloffExponent: number;
  71801. /**
  71802. * 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]
  71803. */
  71804. step: number;
  71805. /**
  71806. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71807. */
  71808. roughnessFactor: number;
  71809. private _geometryBufferRenderer;
  71810. private _enableSmoothReflections;
  71811. private _reflectionSamples;
  71812. private _smoothSteps;
  71813. /**
  71814. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71815. * @param name The name of the effect.
  71816. * @param scene The scene containing the objects to calculate reflections.
  71817. * @param options The required width/height ratio to downsize to before computing the render pass.
  71818. * @param camera The camera to apply the render pass to.
  71819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71820. * @param engine The engine which the post process will be applied. (default: current engine)
  71821. * @param reusable If the post process can be reused on the same frame. (default: false)
  71822. * @param textureType Type of textures used when performing the post process. (default: 0)
  71823. * @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)
  71824. */
  71825. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71826. /**
  71827. * Gets wether or not smoothing reflections is enabled.
  71828. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71829. */
  71830. get enableSmoothReflections(): boolean;
  71831. /**
  71832. * Sets wether or not smoothing reflections is enabled.
  71833. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71834. */
  71835. set enableSmoothReflections(enabled: boolean);
  71836. /**
  71837. * Gets the number of samples taken while computing reflections. More samples count is high,
  71838. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71839. */
  71840. get reflectionSamples(): number;
  71841. /**
  71842. * Sets the number of samples taken while computing reflections. More samples count is high,
  71843. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71844. */
  71845. set reflectionSamples(samples: number);
  71846. /**
  71847. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71848. * more the post-process will require GPU power and can generate a drop in FPS.
  71849. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71850. */
  71851. get smoothSteps(): number;
  71852. set smoothSteps(steps: number);
  71853. private _updateEffectDefines;
  71854. }
  71855. }
  71856. declare module "babylonjs/Shaders/standard.fragment" {
  71857. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  71858. /** @hidden */
  71859. export var standardPixelShader: {
  71860. name: string;
  71861. shader: string;
  71862. };
  71863. }
  71864. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  71865. import { Nullable } from "babylonjs/types";
  71866. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71867. import { Camera } from "babylonjs/Cameras/camera";
  71868. import { Texture } from "babylonjs/Materials/Textures/texture";
  71869. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71870. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71871. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71872. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71873. import { IDisposable } from "babylonjs/scene";
  71874. import { SpotLight } from "babylonjs/Lights/spotLight";
  71875. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  71876. import { Scene } from "babylonjs/scene";
  71877. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71878. import { Animation } from "babylonjs/Animations/animation";
  71879. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71880. import "babylonjs/Shaders/standard.fragment";
  71881. /**
  71882. * Standard rendering pipeline
  71883. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71884. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71885. */
  71886. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71887. /**
  71888. * Public members
  71889. */
  71890. /**
  71891. * Post-process which contains the original scene color before the pipeline applies all the effects
  71892. */
  71893. originalPostProcess: Nullable<PostProcess>;
  71894. /**
  71895. * Post-process used to down scale an image x4
  71896. */
  71897. downSampleX4PostProcess: Nullable<PostProcess>;
  71898. /**
  71899. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71900. */
  71901. brightPassPostProcess: Nullable<PostProcess>;
  71902. /**
  71903. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71904. */
  71905. blurHPostProcesses: PostProcess[];
  71906. /**
  71907. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71908. */
  71909. blurVPostProcesses: PostProcess[];
  71910. /**
  71911. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71912. */
  71913. textureAdderPostProcess: Nullable<PostProcess>;
  71914. /**
  71915. * Post-process used to create volumetric lighting effect
  71916. */
  71917. volumetricLightPostProcess: Nullable<PostProcess>;
  71918. /**
  71919. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71920. */
  71921. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71922. /**
  71923. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71924. */
  71925. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71926. /**
  71927. * Post-process used to merge the volumetric light effect and the real scene color
  71928. */
  71929. volumetricLightMergePostProces: Nullable<PostProcess>;
  71930. /**
  71931. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71932. */
  71933. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71934. /**
  71935. * Base post-process used to calculate the average luminance of the final image for HDR
  71936. */
  71937. luminancePostProcess: Nullable<PostProcess>;
  71938. /**
  71939. * Post-processes used to create down sample post-processes in order to get
  71940. * the average luminance of the final image for HDR
  71941. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71942. */
  71943. luminanceDownSamplePostProcesses: PostProcess[];
  71944. /**
  71945. * Post-process used to create a HDR effect (light adaptation)
  71946. */
  71947. hdrPostProcess: Nullable<PostProcess>;
  71948. /**
  71949. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71950. */
  71951. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71952. /**
  71953. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71954. */
  71955. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71956. /**
  71957. * Post-process used to merge the final HDR post-process and the real scene color
  71958. */
  71959. hdrFinalPostProcess: Nullable<PostProcess>;
  71960. /**
  71961. * Post-process used to create a lens flare effect
  71962. */
  71963. lensFlarePostProcess: Nullable<PostProcess>;
  71964. /**
  71965. * Post-process that merges the result of the lens flare post-process and the real scene color
  71966. */
  71967. lensFlareComposePostProcess: Nullable<PostProcess>;
  71968. /**
  71969. * Post-process used to create a motion blur effect
  71970. */
  71971. motionBlurPostProcess: Nullable<PostProcess>;
  71972. /**
  71973. * Post-process used to create a depth of field effect
  71974. */
  71975. depthOfFieldPostProcess: Nullable<PostProcess>;
  71976. /**
  71977. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71978. */
  71979. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71980. /**
  71981. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71982. */
  71983. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71984. /**
  71985. * Represents the brightness threshold in order to configure the illuminated surfaces
  71986. */
  71987. brightThreshold: number;
  71988. /**
  71989. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71990. */
  71991. blurWidth: number;
  71992. /**
  71993. * Sets if the blur for highlighted surfaces must be only horizontal
  71994. */
  71995. horizontalBlur: boolean;
  71996. /**
  71997. * Gets the overall exposure used by the pipeline
  71998. */
  71999. get exposure(): number;
  72000. /**
  72001. * Sets the overall exposure used by the pipeline
  72002. */
  72003. set exposure(value: number);
  72004. /**
  72005. * Texture used typically to simulate "dirty" on camera lens
  72006. */
  72007. lensTexture: Nullable<Texture>;
  72008. /**
  72009. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72010. */
  72011. volumetricLightCoefficient: number;
  72012. /**
  72013. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72014. */
  72015. volumetricLightPower: number;
  72016. /**
  72017. * Used the set the blur intensity to smooth the volumetric lights
  72018. */
  72019. volumetricLightBlurScale: number;
  72020. /**
  72021. * Light (spot or directional) used to generate the volumetric lights rays
  72022. * The source light must have a shadow generate so the pipeline can get its
  72023. * depth map
  72024. */
  72025. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72026. /**
  72027. * For eye adaptation, represents the minimum luminance the eye can see
  72028. */
  72029. hdrMinimumLuminance: number;
  72030. /**
  72031. * For eye adaptation, represents the decrease luminance speed
  72032. */
  72033. hdrDecreaseRate: number;
  72034. /**
  72035. * For eye adaptation, represents the increase luminance speed
  72036. */
  72037. hdrIncreaseRate: number;
  72038. /**
  72039. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72040. */
  72041. get hdrAutoExposure(): boolean;
  72042. /**
  72043. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72044. */
  72045. set hdrAutoExposure(value: boolean);
  72046. /**
  72047. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72048. */
  72049. lensColorTexture: Nullable<Texture>;
  72050. /**
  72051. * The overall strengh for the lens flare effect
  72052. */
  72053. lensFlareStrength: number;
  72054. /**
  72055. * Dispersion coefficient for lens flare ghosts
  72056. */
  72057. lensFlareGhostDispersal: number;
  72058. /**
  72059. * Main lens flare halo width
  72060. */
  72061. lensFlareHaloWidth: number;
  72062. /**
  72063. * Based on the lens distortion effect, defines how much the lens flare result
  72064. * is distorted
  72065. */
  72066. lensFlareDistortionStrength: number;
  72067. /**
  72068. * Configures the blur intensity used for for lens flare (halo)
  72069. */
  72070. lensFlareBlurWidth: number;
  72071. /**
  72072. * Lens star texture must be used to simulate rays on the flares and is available
  72073. * in the documentation
  72074. */
  72075. lensStarTexture: Nullable<Texture>;
  72076. /**
  72077. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72078. * flare effect by taking account of the dirt texture
  72079. */
  72080. lensFlareDirtTexture: Nullable<Texture>;
  72081. /**
  72082. * Represents the focal length for the depth of field effect
  72083. */
  72084. depthOfFieldDistance: number;
  72085. /**
  72086. * Represents the blur intensity for the blurred part of the depth of field effect
  72087. */
  72088. depthOfFieldBlurWidth: number;
  72089. /**
  72090. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72091. */
  72092. get motionStrength(): number;
  72093. /**
  72094. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72095. */
  72096. set motionStrength(strength: number);
  72097. /**
  72098. * Gets wether or not the motion blur post-process is object based or screen based.
  72099. */
  72100. get objectBasedMotionBlur(): boolean;
  72101. /**
  72102. * Sets wether or not the motion blur post-process should be object based or screen based
  72103. */
  72104. set objectBasedMotionBlur(value: boolean);
  72105. /**
  72106. * List of animations for the pipeline (IAnimatable implementation)
  72107. */
  72108. animations: Animation[];
  72109. /**
  72110. * Private members
  72111. */
  72112. private _scene;
  72113. private _currentDepthOfFieldSource;
  72114. private _basePostProcess;
  72115. private _fixedExposure;
  72116. private _currentExposure;
  72117. private _hdrAutoExposure;
  72118. private _hdrCurrentLuminance;
  72119. private _motionStrength;
  72120. private _isObjectBasedMotionBlur;
  72121. private _floatTextureType;
  72122. private _camerasToBeAttached;
  72123. private _ratio;
  72124. private _bloomEnabled;
  72125. private _depthOfFieldEnabled;
  72126. private _vlsEnabled;
  72127. private _lensFlareEnabled;
  72128. private _hdrEnabled;
  72129. private _motionBlurEnabled;
  72130. private _fxaaEnabled;
  72131. private _screenSpaceReflectionsEnabled;
  72132. private _motionBlurSamples;
  72133. private _volumetricLightStepsCount;
  72134. private _samples;
  72135. /**
  72136. * @ignore
  72137. * Specifies if the bloom pipeline is enabled
  72138. */
  72139. get BloomEnabled(): boolean;
  72140. set BloomEnabled(enabled: boolean);
  72141. /**
  72142. * @ignore
  72143. * Specifies if the depth of field pipeline is enabed
  72144. */
  72145. get DepthOfFieldEnabled(): boolean;
  72146. set DepthOfFieldEnabled(enabled: boolean);
  72147. /**
  72148. * @ignore
  72149. * Specifies if the lens flare pipeline is enabed
  72150. */
  72151. get LensFlareEnabled(): boolean;
  72152. set LensFlareEnabled(enabled: boolean);
  72153. /**
  72154. * @ignore
  72155. * Specifies if the HDR pipeline is enabled
  72156. */
  72157. get HDREnabled(): boolean;
  72158. set HDREnabled(enabled: boolean);
  72159. /**
  72160. * @ignore
  72161. * Specifies if the volumetric lights scattering effect is enabled
  72162. */
  72163. get VLSEnabled(): boolean;
  72164. set VLSEnabled(enabled: boolean);
  72165. /**
  72166. * @ignore
  72167. * Specifies if the motion blur effect is enabled
  72168. */
  72169. get MotionBlurEnabled(): boolean;
  72170. set MotionBlurEnabled(enabled: boolean);
  72171. /**
  72172. * Specifies if anti-aliasing is enabled
  72173. */
  72174. get fxaaEnabled(): boolean;
  72175. set fxaaEnabled(enabled: boolean);
  72176. /**
  72177. * Specifies if screen space reflections are enabled.
  72178. */
  72179. get screenSpaceReflectionsEnabled(): boolean;
  72180. set screenSpaceReflectionsEnabled(enabled: boolean);
  72181. /**
  72182. * Specifies the number of steps used to calculate the volumetric lights
  72183. * Typically in interval [50, 200]
  72184. */
  72185. get volumetricLightStepsCount(): number;
  72186. set volumetricLightStepsCount(count: number);
  72187. /**
  72188. * Specifies the number of samples used for the motion blur effect
  72189. * Typically in interval [16, 64]
  72190. */
  72191. get motionBlurSamples(): number;
  72192. set motionBlurSamples(samples: number);
  72193. /**
  72194. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72195. */
  72196. get samples(): number;
  72197. set samples(sampleCount: number);
  72198. /**
  72199. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72200. * @constructor
  72201. * @param name The rendering pipeline name
  72202. * @param scene The scene linked to this pipeline
  72203. * @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)
  72204. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72205. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72206. */
  72207. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72208. private _buildPipeline;
  72209. private _createDownSampleX4PostProcess;
  72210. private _createBrightPassPostProcess;
  72211. private _createBlurPostProcesses;
  72212. private _createTextureAdderPostProcess;
  72213. private _createVolumetricLightPostProcess;
  72214. private _createLuminancePostProcesses;
  72215. private _createHdrPostProcess;
  72216. private _createLensFlarePostProcess;
  72217. private _createDepthOfFieldPostProcess;
  72218. private _createMotionBlurPostProcess;
  72219. private _getDepthTexture;
  72220. private _disposePostProcesses;
  72221. /**
  72222. * Dispose of the pipeline and stop all post processes
  72223. */
  72224. dispose(): void;
  72225. /**
  72226. * Serialize the rendering pipeline (Used when exporting)
  72227. * @returns the serialized object
  72228. */
  72229. serialize(): any;
  72230. /**
  72231. * Parse the serialized pipeline
  72232. * @param source Source pipeline.
  72233. * @param scene The scene to load the pipeline to.
  72234. * @param rootUrl The URL of the serialized pipeline.
  72235. * @returns An instantiated pipeline from the serialized object.
  72236. */
  72237. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72238. /**
  72239. * Luminance steps
  72240. */
  72241. static LuminanceSteps: number;
  72242. }
  72243. }
  72244. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  72245. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  72246. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  72247. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  72248. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  72249. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  72250. }
  72251. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  72252. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  72253. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72254. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72255. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72256. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72257. }
  72258. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  72259. /** @hidden */
  72260. export var stereoscopicInterlacePixelShader: {
  72261. name: string;
  72262. shader: string;
  72263. };
  72264. }
  72265. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  72266. import { Camera } from "babylonjs/Cameras/camera";
  72267. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72268. import { Engine } from "babylonjs/Engines/engine";
  72269. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  72270. /**
  72271. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72272. */
  72273. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72274. private _stepSize;
  72275. private _passedProcess;
  72276. /**
  72277. * Initializes a StereoscopicInterlacePostProcessI
  72278. * @param name The name of the effect.
  72279. * @param rigCameras The rig cameras to be appled to the post process
  72280. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72281. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72283. * @param engine The engine which the post process will be applied. (default: current engine)
  72284. * @param reusable If the post process can be reused on the same frame. (default: false)
  72285. */
  72286. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72287. }
  72288. /**
  72289. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72290. */
  72291. export class StereoscopicInterlacePostProcess extends PostProcess {
  72292. private _stepSize;
  72293. private _passedProcess;
  72294. /**
  72295. * Initializes a StereoscopicInterlacePostProcess
  72296. * @param name The name of the effect.
  72297. * @param rigCameras The rig cameras to be appled to the post process
  72298. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72300. * @param engine The engine which the post process will be applied. (default: current engine)
  72301. * @param reusable If the post process can be reused on the same frame. (default: false)
  72302. */
  72303. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72304. }
  72305. }
  72306. declare module "babylonjs/Shaders/tonemap.fragment" {
  72307. /** @hidden */
  72308. export var tonemapPixelShader: {
  72309. name: string;
  72310. shader: string;
  72311. };
  72312. }
  72313. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  72314. import { Camera } from "babylonjs/Cameras/camera";
  72315. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72316. import "babylonjs/Shaders/tonemap.fragment";
  72317. import { Engine } from "babylonjs/Engines/engine";
  72318. /** Defines operator used for tonemapping */
  72319. export enum TonemappingOperator {
  72320. /** Hable */
  72321. Hable = 0,
  72322. /** Reinhard */
  72323. Reinhard = 1,
  72324. /** HejiDawson */
  72325. HejiDawson = 2,
  72326. /** Photographic */
  72327. Photographic = 3
  72328. }
  72329. /**
  72330. * Defines a post process to apply tone mapping
  72331. */
  72332. export class TonemapPostProcess extends PostProcess {
  72333. private _operator;
  72334. /** Defines the required exposure adjustement */
  72335. exposureAdjustment: number;
  72336. /**
  72337. * Creates a new TonemapPostProcess
  72338. * @param name defines the name of the postprocess
  72339. * @param _operator defines the operator to use
  72340. * @param exposureAdjustment defines the required exposure adjustement
  72341. * @param camera defines the camera to use (can be null)
  72342. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72343. * @param engine defines the hosting engine (can be ignore if camera is set)
  72344. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72345. */
  72346. constructor(name: string, _operator: TonemappingOperator,
  72347. /** Defines the required exposure adjustement */
  72348. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72349. }
  72350. }
  72351. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  72352. /** @hidden */
  72353. export var volumetricLightScatteringPixelShader: {
  72354. name: string;
  72355. shader: string;
  72356. };
  72357. }
  72358. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  72359. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72360. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72361. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72362. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72363. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72364. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72365. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72366. /** @hidden */
  72367. export var volumetricLightScatteringPassVertexShader: {
  72368. name: string;
  72369. shader: string;
  72370. };
  72371. }
  72372. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  72373. /** @hidden */
  72374. export var volumetricLightScatteringPassPixelShader: {
  72375. name: string;
  72376. shader: string;
  72377. };
  72378. }
  72379. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  72380. import { Vector3 } from "babylonjs/Maths/math.vector";
  72381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72382. import { Mesh } from "babylonjs/Meshes/mesh";
  72383. import { Camera } from "babylonjs/Cameras/camera";
  72384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72385. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72386. import { Scene } from "babylonjs/scene";
  72387. import "babylonjs/Meshes/Builders/planeBuilder";
  72388. import "babylonjs/Shaders/depth.vertex";
  72389. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  72390. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  72391. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  72392. import { Engine } from "babylonjs/Engines/engine";
  72393. /**
  72394. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72395. */
  72396. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72397. private _volumetricLightScatteringPass;
  72398. private _volumetricLightScatteringRTT;
  72399. private _viewPort;
  72400. private _screenCoordinates;
  72401. private _cachedDefines;
  72402. /**
  72403. * If not undefined, the mesh position is computed from the attached node position
  72404. */
  72405. attachedNode: {
  72406. position: Vector3;
  72407. };
  72408. /**
  72409. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72410. */
  72411. customMeshPosition: Vector3;
  72412. /**
  72413. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72414. */
  72415. useCustomMeshPosition: boolean;
  72416. /**
  72417. * If the post-process should inverse the light scattering direction
  72418. */
  72419. invert: boolean;
  72420. /**
  72421. * The internal mesh used by the post-process
  72422. */
  72423. mesh: Mesh;
  72424. /**
  72425. * @hidden
  72426. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72427. */
  72428. get useDiffuseColor(): boolean;
  72429. set useDiffuseColor(useDiffuseColor: boolean);
  72430. /**
  72431. * Array containing the excluded meshes not rendered in the internal pass
  72432. */
  72433. excludedMeshes: AbstractMesh[];
  72434. /**
  72435. * Controls the overall intensity of the post-process
  72436. */
  72437. exposure: number;
  72438. /**
  72439. * Dissipates each sample's contribution in range [0, 1]
  72440. */
  72441. decay: number;
  72442. /**
  72443. * Controls the overall intensity of each sample
  72444. */
  72445. weight: number;
  72446. /**
  72447. * Controls the density of each sample
  72448. */
  72449. density: number;
  72450. /**
  72451. * @constructor
  72452. * @param name The post-process name
  72453. * @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)
  72454. * @param camera The camera that the post-process will be attached to
  72455. * @param mesh The mesh used to create the light scattering
  72456. * @param samples The post-process quality, default 100
  72457. * @param samplingModeThe post-process filtering mode
  72458. * @param engine The babylon engine
  72459. * @param reusable If the post-process is reusable
  72460. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72461. */
  72462. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72463. /**
  72464. * Returns the string "VolumetricLightScatteringPostProcess"
  72465. * @returns "VolumetricLightScatteringPostProcess"
  72466. */
  72467. getClassName(): string;
  72468. private _isReady;
  72469. /**
  72470. * Sets the new light position for light scattering effect
  72471. * @param position The new custom light position
  72472. */
  72473. setCustomMeshPosition(position: Vector3): void;
  72474. /**
  72475. * Returns the light position for light scattering effect
  72476. * @return Vector3 The custom light position
  72477. */
  72478. getCustomMeshPosition(): Vector3;
  72479. /**
  72480. * Disposes the internal assets and detaches the post-process from the camera
  72481. */
  72482. dispose(camera: Camera): void;
  72483. /**
  72484. * Returns the render target texture used by the post-process
  72485. * @return the render target texture used by the post-process
  72486. */
  72487. getPass(): RenderTargetTexture;
  72488. private _meshExcluded;
  72489. private _createPass;
  72490. private _updateMeshScreenCoordinates;
  72491. /**
  72492. * Creates a default mesh for the Volumeric Light Scattering post-process
  72493. * @param name The mesh name
  72494. * @param scene The scene where to create the mesh
  72495. * @return the default mesh
  72496. */
  72497. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72498. }
  72499. }
  72500. declare module "babylonjs/PostProcesses/index" {
  72501. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  72502. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  72503. export * from "babylonjs/PostProcesses/bloomEffect";
  72504. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  72505. export * from "babylonjs/PostProcesses/blurPostProcess";
  72506. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72507. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  72508. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  72509. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  72510. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72511. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  72512. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  72513. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  72514. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72515. export * from "babylonjs/PostProcesses/filterPostProcess";
  72516. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  72517. export * from "babylonjs/PostProcesses/grainPostProcess";
  72518. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  72519. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72520. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  72521. export * from "babylonjs/PostProcesses/passPostProcess";
  72522. export * from "babylonjs/PostProcesses/postProcess";
  72523. export * from "babylonjs/PostProcesses/postProcessManager";
  72524. export * from "babylonjs/PostProcesses/refractionPostProcess";
  72525. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  72526. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  72527. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  72528. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  72529. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  72530. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  72531. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  72532. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72533. }
  72534. declare module "babylonjs/Probes/index" {
  72535. export * from "babylonjs/Probes/reflectionProbe";
  72536. }
  72537. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  72538. import { Scene } from "babylonjs/scene";
  72539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72540. import { SmartArray } from "babylonjs/Misc/smartArray";
  72541. import { ISceneComponent } from "babylonjs/sceneComponent";
  72542. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  72543. import "babylonjs/Meshes/Builders/boxBuilder";
  72544. import "babylonjs/Shaders/color.fragment";
  72545. import "babylonjs/Shaders/color.vertex";
  72546. import { Color3 } from "babylonjs/Maths/math.color";
  72547. module "babylonjs/scene" {
  72548. interface Scene {
  72549. /** @hidden (Backing field) */
  72550. _boundingBoxRenderer: BoundingBoxRenderer;
  72551. /** @hidden (Backing field) */
  72552. _forceShowBoundingBoxes: boolean;
  72553. /**
  72554. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72555. */
  72556. forceShowBoundingBoxes: boolean;
  72557. /**
  72558. * Gets the bounding box renderer associated with the scene
  72559. * @returns a BoundingBoxRenderer
  72560. */
  72561. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72562. }
  72563. }
  72564. module "babylonjs/Meshes/abstractMesh" {
  72565. interface AbstractMesh {
  72566. /** @hidden (Backing field) */
  72567. _showBoundingBox: boolean;
  72568. /**
  72569. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72570. */
  72571. showBoundingBox: boolean;
  72572. }
  72573. }
  72574. /**
  72575. * Component responsible of rendering the bounding box of the meshes in a scene.
  72576. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72577. */
  72578. export class BoundingBoxRenderer implements ISceneComponent {
  72579. /**
  72580. * The component name helpfull to identify the component in the list of scene components.
  72581. */
  72582. readonly name: string;
  72583. /**
  72584. * The scene the component belongs to.
  72585. */
  72586. scene: Scene;
  72587. /**
  72588. * Color of the bounding box lines placed in front of an object
  72589. */
  72590. frontColor: Color3;
  72591. /**
  72592. * Color of the bounding box lines placed behind an object
  72593. */
  72594. backColor: Color3;
  72595. /**
  72596. * Defines if the renderer should show the back lines or not
  72597. */
  72598. showBackLines: boolean;
  72599. /**
  72600. * @hidden
  72601. */
  72602. renderList: SmartArray<BoundingBox>;
  72603. private _colorShader;
  72604. private _vertexBuffers;
  72605. private _indexBuffer;
  72606. private _fillIndexBuffer;
  72607. private _fillIndexData;
  72608. /**
  72609. * Instantiates a new bounding box renderer in a scene.
  72610. * @param scene the scene the renderer renders in
  72611. */
  72612. constructor(scene: Scene);
  72613. /**
  72614. * Registers the component in a given scene
  72615. */
  72616. register(): void;
  72617. private _evaluateSubMesh;
  72618. private _activeMesh;
  72619. private _prepareRessources;
  72620. private _createIndexBuffer;
  72621. /**
  72622. * Rebuilds the elements related to this component in case of
  72623. * context lost for instance.
  72624. */
  72625. rebuild(): void;
  72626. /**
  72627. * @hidden
  72628. */
  72629. reset(): void;
  72630. /**
  72631. * Render the bounding boxes of a specific rendering group
  72632. * @param renderingGroupId defines the rendering group to render
  72633. */
  72634. render(renderingGroupId: number): void;
  72635. /**
  72636. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72637. * @param mesh Define the mesh to render the occlusion bounding box for
  72638. */
  72639. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72640. /**
  72641. * Dispose and release the resources attached to this renderer.
  72642. */
  72643. dispose(): void;
  72644. }
  72645. }
  72646. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  72647. import { Nullable } from "babylonjs/types";
  72648. import { Scene } from "babylonjs/scene";
  72649. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  72650. import { Camera } from "babylonjs/Cameras/camera";
  72651. import { ISceneComponent } from "babylonjs/sceneComponent";
  72652. module "babylonjs/scene" {
  72653. interface Scene {
  72654. /** @hidden (Backing field) */
  72655. _depthRenderer: {
  72656. [id: string]: DepthRenderer;
  72657. };
  72658. /**
  72659. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72660. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72661. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72662. * @returns the created depth renderer
  72663. */
  72664. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72665. /**
  72666. * Disables a depth renderer for a given camera
  72667. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72668. */
  72669. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72670. }
  72671. }
  72672. /**
  72673. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72674. * in several rendering techniques.
  72675. */
  72676. export class DepthRendererSceneComponent implements ISceneComponent {
  72677. /**
  72678. * The component name helpfull to identify the component in the list of scene components.
  72679. */
  72680. readonly name: string;
  72681. /**
  72682. * The scene the component belongs to.
  72683. */
  72684. scene: Scene;
  72685. /**
  72686. * Creates a new instance of the component for the given scene
  72687. * @param scene Defines the scene to register the component in
  72688. */
  72689. constructor(scene: Scene);
  72690. /**
  72691. * Registers the component in a given scene
  72692. */
  72693. register(): void;
  72694. /**
  72695. * Rebuilds the elements related to this component in case of
  72696. * context lost for instance.
  72697. */
  72698. rebuild(): void;
  72699. /**
  72700. * Disposes the component and the associated ressources
  72701. */
  72702. dispose(): void;
  72703. private _gatherRenderTargets;
  72704. private _gatherActiveCameraRenderTargets;
  72705. }
  72706. }
  72707. declare module "babylonjs/Shaders/outline.fragment" {
  72708. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72709. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  72710. /** @hidden */
  72711. export var outlinePixelShader: {
  72712. name: string;
  72713. shader: string;
  72714. };
  72715. }
  72716. declare module "babylonjs/Shaders/outline.vertex" {
  72717. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72718. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72719. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72720. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72721. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72722. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72723. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72724. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72725. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  72726. /** @hidden */
  72727. export var outlineVertexShader: {
  72728. name: string;
  72729. shader: string;
  72730. };
  72731. }
  72732. declare module "babylonjs/Rendering/outlineRenderer" {
  72733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72734. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  72735. import { Scene } from "babylonjs/scene";
  72736. import { ISceneComponent } from "babylonjs/sceneComponent";
  72737. import "babylonjs/Shaders/outline.fragment";
  72738. import "babylonjs/Shaders/outline.vertex";
  72739. module "babylonjs/scene" {
  72740. interface Scene {
  72741. /** @hidden */
  72742. _outlineRenderer: OutlineRenderer;
  72743. /**
  72744. * Gets the outline renderer associated with the scene
  72745. * @returns a OutlineRenderer
  72746. */
  72747. getOutlineRenderer(): OutlineRenderer;
  72748. }
  72749. }
  72750. module "babylonjs/Meshes/abstractMesh" {
  72751. interface AbstractMesh {
  72752. /** @hidden (Backing field) */
  72753. _renderOutline: boolean;
  72754. /**
  72755. * Gets or sets a boolean indicating if the outline must be rendered as well
  72756. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72757. */
  72758. renderOutline: boolean;
  72759. /** @hidden (Backing field) */
  72760. _renderOverlay: boolean;
  72761. /**
  72762. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72763. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72764. */
  72765. renderOverlay: boolean;
  72766. }
  72767. }
  72768. /**
  72769. * This class is responsible to draw bothe outline/overlay of meshes.
  72770. * It should not be used directly but through the available method on mesh.
  72771. */
  72772. export class OutlineRenderer implements ISceneComponent {
  72773. /**
  72774. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72775. */
  72776. private static _StencilReference;
  72777. /**
  72778. * The name of the component. Each component must have a unique name.
  72779. */
  72780. name: string;
  72781. /**
  72782. * The scene the component belongs to.
  72783. */
  72784. scene: Scene;
  72785. /**
  72786. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72787. */
  72788. zOffset: number;
  72789. private _engine;
  72790. private _effect;
  72791. private _cachedDefines;
  72792. private _savedDepthWrite;
  72793. /**
  72794. * Instantiates a new outline renderer. (There could be only one per scene).
  72795. * @param scene Defines the scene it belongs to
  72796. */
  72797. constructor(scene: Scene);
  72798. /**
  72799. * Register the component to one instance of a scene.
  72800. */
  72801. register(): void;
  72802. /**
  72803. * Rebuilds the elements related to this component in case of
  72804. * context lost for instance.
  72805. */
  72806. rebuild(): void;
  72807. /**
  72808. * Disposes the component and the associated ressources.
  72809. */
  72810. dispose(): void;
  72811. /**
  72812. * Renders the outline in the canvas.
  72813. * @param subMesh Defines the sumesh to render
  72814. * @param batch Defines the batch of meshes in case of instances
  72815. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72816. */
  72817. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72818. /**
  72819. * Returns whether or not the outline renderer is ready for a given submesh.
  72820. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72821. * @param subMesh Defines the submesh to check readyness for
  72822. * @param useInstances Defines wheter wee are trying to render instances or not
  72823. * @returns true if ready otherwise false
  72824. */
  72825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72826. private _beforeRenderingMesh;
  72827. private _afterRenderingMesh;
  72828. }
  72829. }
  72830. declare module "babylonjs/Rendering/index" {
  72831. export * from "babylonjs/Rendering/boundingBoxRenderer";
  72832. export * from "babylonjs/Rendering/depthRenderer";
  72833. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  72834. export * from "babylonjs/Rendering/edgesRenderer";
  72835. export * from "babylonjs/Rendering/geometryBufferRenderer";
  72836. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72837. export * from "babylonjs/Rendering/outlineRenderer";
  72838. export * from "babylonjs/Rendering/renderingGroup";
  72839. export * from "babylonjs/Rendering/renderingManager";
  72840. export * from "babylonjs/Rendering/utilityLayerRenderer";
  72841. }
  72842. declare module "babylonjs/Sprites/ISprites" {
  72843. /**
  72844. * Defines the basic options interface of a Sprite Frame Source Size.
  72845. */
  72846. export interface ISpriteJSONSpriteSourceSize {
  72847. /**
  72848. * number of the original width of the Frame
  72849. */
  72850. w: number;
  72851. /**
  72852. * number of the original height of the Frame
  72853. */
  72854. h: number;
  72855. }
  72856. /**
  72857. * Defines the basic options interface of a Sprite Frame Data.
  72858. */
  72859. export interface ISpriteJSONSpriteFrameData {
  72860. /**
  72861. * number of the x offset of the Frame
  72862. */
  72863. x: number;
  72864. /**
  72865. * number of the y offset of the Frame
  72866. */
  72867. y: number;
  72868. /**
  72869. * number of the width of the Frame
  72870. */
  72871. w: number;
  72872. /**
  72873. * number of the height of the Frame
  72874. */
  72875. h: number;
  72876. }
  72877. /**
  72878. * Defines the basic options interface of a JSON Sprite.
  72879. */
  72880. export interface ISpriteJSONSprite {
  72881. /**
  72882. * string name of the Frame
  72883. */
  72884. filename: string;
  72885. /**
  72886. * ISpriteJSONSpriteFrame basic object of the frame data
  72887. */
  72888. frame: ISpriteJSONSpriteFrameData;
  72889. /**
  72890. * boolean to flag is the frame was rotated.
  72891. */
  72892. rotated: boolean;
  72893. /**
  72894. * boolean to flag is the frame was trimmed.
  72895. */
  72896. trimmed: boolean;
  72897. /**
  72898. * ISpriteJSONSpriteFrame basic object of the source data
  72899. */
  72900. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72901. /**
  72902. * ISpriteJSONSpriteFrame basic object of the source data
  72903. */
  72904. sourceSize: ISpriteJSONSpriteSourceSize;
  72905. }
  72906. /**
  72907. * Defines the basic options interface of a JSON atlas.
  72908. */
  72909. export interface ISpriteJSONAtlas {
  72910. /**
  72911. * Array of objects that contain the frame data.
  72912. */
  72913. frames: Array<ISpriteJSONSprite>;
  72914. /**
  72915. * object basic object containing the sprite meta data.
  72916. */
  72917. meta?: object;
  72918. }
  72919. }
  72920. declare module "babylonjs/Shaders/spriteMap.fragment" {
  72921. /** @hidden */
  72922. export var spriteMapPixelShader: {
  72923. name: string;
  72924. shader: string;
  72925. };
  72926. }
  72927. declare module "babylonjs/Shaders/spriteMap.vertex" {
  72928. /** @hidden */
  72929. export var spriteMapVertexShader: {
  72930. name: string;
  72931. shader: string;
  72932. };
  72933. }
  72934. declare module "babylonjs/Sprites/spriteMap" {
  72935. import { IDisposable, Scene } from "babylonjs/scene";
  72936. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  72937. import { Texture } from "babylonjs/Materials/Textures/texture";
  72938. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72939. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  72940. import "babylonjs/Meshes/Builders/planeBuilder";
  72941. import "babylonjs/Shaders/spriteMap.fragment";
  72942. import "babylonjs/Shaders/spriteMap.vertex";
  72943. /**
  72944. * Defines the basic options interface of a SpriteMap
  72945. */
  72946. export interface ISpriteMapOptions {
  72947. /**
  72948. * Vector2 of the number of cells in the grid.
  72949. */
  72950. stageSize?: Vector2;
  72951. /**
  72952. * Vector2 of the size of the output plane in World Units.
  72953. */
  72954. outputSize?: Vector2;
  72955. /**
  72956. * Vector3 of the position of the output plane in World Units.
  72957. */
  72958. outputPosition?: Vector3;
  72959. /**
  72960. * Vector3 of the rotation of the output plane.
  72961. */
  72962. outputRotation?: Vector3;
  72963. /**
  72964. * number of layers that the system will reserve in resources.
  72965. */
  72966. layerCount?: number;
  72967. /**
  72968. * number of max animation frames a single cell will reserve in resources.
  72969. */
  72970. maxAnimationFrames?: number;
  72971. /**
  72972. * number cell index of the base tile when the system compiles.
  72973. */
  72974. baseTile?: number;
  72975. /**
  72976. * boolean flip the sprite after its been repositioned by the framing data.
  72977. */
  72978. flipU?: boolean;
  72979. /**
  72980. * Vector3 scalar of the global RGB values of the SpriteMap.
  72981. */
  72982. colorMultiply?: Vector3;
  72983. }
  72984. /**
  72985. * Defines the IDisposable interface in order to be cleanable from resources.
  72986. */
  72987. export interface ISpriteMap extends IDisposable {
  72988. /**
  72989. * String name of the SpriteMap.
  72990. */
  72991. name: string;
  72992. /**
  72993. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72994. */
  72995. atlasJSON: ISpriteJSONAtlas;
  72996. /**
  72997. * Texture of the SpriteMap.
  72998. */
  72999. spriteSheet: Texture;
  73000. /**
  73001. * The parameters to initialize the SpriteMap with.
  73002. */
  73003. options: ISpriteMapOptions;
  73004. }
  73005. /**
  73006. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73007. */
  73008. export class SpriteMap implements ISpriteMap {
  73009. /** The Name of the spriteMap */
  73010. name: string;
  73011. /** The JSON file with the frame and meta data */
  73012. atlasJSON: ISpriteJSONAtlas;
  73013. /** The systems Sprite Sheet Texture */
  73014. spriteSheet: Texture;
  73015. /** Arguments passed with the Constructor */
  73016. options: ISpriteMapOptions;
  73017. /** Public Sprite Storage array, parsed from atlasJSON */
  73018. sprites: Array<ISpriteJSONSprite>;
  73019. /** Returns the Number of Sprites in the System */
  73020. get spriteCount(): number;
  73021. /** Returns the Position of Output Plane*/
  73022. get position(): Vector3;
  73023. /** Returns the Position of Output Plane*/
  73024. set position(v: Vector3);
  73025. /** Returns the Rotation of Output Plane*/
  73026. get rotation(): Vector3;
  73027. /** Returns the Rotation of Output Plane*/
  73028. set rotation(v: Vector3);
  73029. /** Sets the AnimationMap*/
  73030. get animationMap(): RawTexture;
  73031. /** Sets the AnimationMap*/
  73032. set animationMap(v: RawTexture);
  73033. /** Scene that the SpriteMap was created in */
  73034. private _scene;
  73035. /** Texture Buffer of Float32 that holds tile frame data*/
  73036. private _frameMap;
  73037. /** Texture Buffers of Float32 that holds tileMap data*/
  73038. private _tileMaps;
  73039. /** Texture Buffer of Float32 that holds Animation Data*/
  73040. private _animationMap;
  73041. /** Custom ShaderMaterial Central to the System*/
  73042. private _material;
  73043. /** Custom ShaderMaterial Central to the System*/
  73044. private _output;
  73045. /** Systems Time Ticker*/
  73046. private _time;
  73047. /**
  73048. * Creates a new SpriteMap
  73049. * @param name defines the SpriteMaps Name
  73050. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73051. * @param spriteSheet is the Texture that the Sprites are on.
  73052. * @param options a basic deployment configuration
  73053. * @param scene The Scene that the map is deployed on
  73054. */
  73055. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73056. /**
  73057. * Returns tileID location
  73058. * @returns Vector2 the cell position ID
  73059. */
  73060. getTileID(): Vector2;
  73061. /**
  73062. * Gets the UV location of the mouse over the SpriteMap.
  73063. * @returns Vector2 the UV position of the mouse interaction
  73064. */
  73065. getMousePosition(): Vector2;
  73066. /**
  73067. * Creates the "frame" texture Buffer
  73068. * -------------------------------------
  73069. * Structure of frames
  73070. * "filename": "Falling-Water-2.png",
  73071. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73072. * "rotated": true,
  73073. * "trimmed": true,
  73074. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73075. * "sourceSize": {"w":32,"h":32}
  73076. * @returns RawTexture of the frameMap
  73077. */
  73078. private _createFrameBuffer;
  73079. /**
  73080. * Creates the tileMap texture Buffer
  73081. * @param buffer normally and array of numbers, or a false to generate from scratch
  73082. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73083. * @returns RawTexture of the tileMap
  73084. */
  73085. private _createTileBuffer;
  73086. /**
  73087. * Modifies the data of the tileMaps
  73088. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73089. * @param pos is the iVector2 Coordinates of the Tile
  73090. * @param tile The SpriteIndex of the new Tile
  73091. */
  73092. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73093. /**
  73094. * Creates the animationMap texture Buffer
  73095. * @param buffer normally and array of numbers, or a false to generate from scratch
  73096. * @returns RawTexture of the animationMap
  73097. */
  73098. private _createTileAnimationBuffer;
  73099. /**
  73100. * Modifies the data of the animationMap
  73101. * @param cellID is the Index of the Sprite
  73102. * @param _frame is the target Animation frame
  73103. * @param toCell is the Target Index of the next frame of the animation
  73104. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73105. * @param speed is a global scalar of the time variable on the map.
  73106. */
  73107. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73108. /**
  73109. * Exports the .tilemaps file
  73110. */
  73111. saveTileMaps(): void;
  73112. /**
  73113. * Imports the .tilemaps file
  73114. * @param url of the .tilemaps file
  73115. */
  73116. loadTileMaps(url: string): void;
  73117. /**
  73118. * Release associated resources
  73119. */
  73120. dispose(): void;
  73121. }
  73122. }
  73123. declare module "babylonjs/Sprites/spritePackedManager" {
  73124. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  73125. import { Scene } from "babylonjs/scene";
  73126. /**
  73127. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73128. * @see http://doc.babylonjs.com/babylon101/sprites
  73129. */
  73130. export class SpritePackedManager extends SpriteManager {
  73131. /** defines the packed manager's name */
  73132. name: string;
  73133. /**
  73134. * Creates a new sprite manager from a packed sprite sheet
  73135. * @param name defines the manager's name
  73136. * @param imgUrl defines the sprite sheet url
  73137. * @param capacity defines the maximum allowed number of sprites
  73138. * @param scene defines the hosting scene
  73139. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73140. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73141. * @param samplingMode defines the smapling mode to use with spritesheet
  73142. * @param fromPacked set to true; do not alter
  73143. */
  73144. constructor(
  73145. /** defines the packed manager's name */
  73146. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73147. }
  73148. }
  73149. declare module "babylonjs/Sprites/index" {
  73150. export * from "babylonjs/Sprites/sprite";
  73151. export * from "babylonjs/Sprites/ISprites";
  73152. export * from "babylonjs/Sprites/spriteManager";
  73153. export * from "babylonjs/Sprites/spriteMap";
  73154. export * from "babylonjs/Sprites/spritePackedManager";
  73155. export * from "babylonjs/Sprites/spriteSceneComponent";
  73156. }
  73157. declare module "babylonjs/States/index" {
  73158. export * from "babylonjs/States/alphaCullingState";
  73159. export * from "babylonjs/States/depthCullingState";
  73160. export * from "babylonjs/States/stencilState";
  73161. }
  73162. declare module "babylonjs/Misc/assetsManager" {
  73163. import { Scene } from "babylonjs/scene";
  73164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73165. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73166. import { Skeleton } from "babylonjs/Bones/skeleton";
  73167. import { Observable } from "babylonjs/Misc/observable";
  73168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  73169. import { Texture } from "babylonjs/Materials/Textures/texture";
  73170. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  73171. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  73172. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  73173. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  73174. /**
  73175. * Defines the list of states available for a task inside a AssetsManager
  73176. */
  73177. export enum AssetTaskState {
  73178. /**
  73179. * Initialization
  73180. */
  73181. INIT = 0,
  73182. /**
  73183. * Running
  73184. */
  73185. RUNNING = 1,
  73186. /**
  73187. * Done
  73188. */
  73189. DONE = 2,
  73190. /**
  73191. * Error
  73192. */
  73193. ERROR = 3
  73194. }
  73195. /**
  73196. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73197. */
  73198. export abstract class AbstractAssetTask {
  73199. /**
  73200. * Task name
  73201. */ name: string;
  73202. /**
  73203. * Callback called when the task is successful
  73204. */
  73205. onSuccess: (task: any) => void;
  73206. /**
  73207. * Callback called when the task is not successful
  73208. */
  73209. onError: (task: any, message?: string, exception?: any) => void;
  73210. /**
  73211. * Creates a new AssetsManager
  73212. * @param name defines the name of the task
  73213. */
  73214. constructor(
  73215. /**
  73216. * Task name
  73217. */ name: string);
  73218. private _isCompleted;
  73219. private _taskState;
  73220. private _errorObject;
  73221. /**
  73222. * Get if the task is completed
  73223. */
  73224. get isCompleted(): boolean;
  73225. /**
  73226. * Gets the current state of the task
  73227. */
  73228. get taskState(): AssetTaskState;
  73229. /**
  73230. * Gets the current error object (if task is in error)
  73231. */
  73232. get errorObject(): {
  73233. message?: string;
  73234. exception?: any;
  73235. };
  73236. /**
  73237. * Internal only
  73238. * @hidden
  73239. */
  73240. _setErrorObject(message?: string, exception?: any): void;
  73241. /**
  73242. * Execute the current task
  73243. * @param scene defines the scene where you want your assets to be loaded
  73244. * @param onSuccess is a callback called when the task is successfully executed
  73245. * @param onError is a callback called if an error occurs
  73246. */
  73247. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73248. /**
  73249. * Execute the current task
  73250. * @param scene defines the scene where you want your assets to be loaded
  73251. * @param onSuccess is a callback called when the task is successfully executed
  73252. * @param onError is a callback called if an error occurs
  73253. */
  73254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73255. /**
  73256. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73257. * This can be used with failed tasks that have the reason for failure fixed.
  73258. */
  73259. reset(): void;
  73260. private onErrorCallback;
  73261. private onDoneCallback;
  73262. }
  73263. /**
  73264. * Define the interface used by progress events raised during assets loading
  73265. */
  73266. export interface IAssetsProgressEvent {
  73267. /**
  73268. * Defines the number of remaining tasks to process
  73269. */
  73270. remainingCount: number;
  73271. /**
  73272. * Defines the total number of tasks
  73273. */
  73274. totalCount: number;
  73275. /**
  73276. * Defines the task that was just processed
  73277. */
  73278. task: AbstractAssetTask;
  73279. }
  73280. /**
  73281. * Class used to share progress information about assets loading
  73282. */
  73283. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73284. /**
  73285. * Defines the number of remaining tasks to process
  73286. */
  73287. remainingCount: number;
  73288. /**
  73289. * Defines the total number of tasks
  73290. */
  73291. totalCount: number;
  73292. /**
  73293. * Defines the task that was just processed
  73294. */
  73295. task: AbstractAssetTask;
  73296. /**
  73297. * Creates a AssetsProgressEvent
  73298. * @param remainingCount defines the number of remaining tasks to process
  73299. * @param totalCount defines the total number of tasks
  73300. * @param task defines the task that was just processed
  73301. */
  73302. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73303. }
  73304. /**
  73305. * Define a task used by AssetsManager to load meshes
  73306. */
  73307. export class MeshAssetTask extends AbstractAssetTask {
  73308. /**
  73309. * Defines the name of the task
  73310. */
  73311. name: string;
  73312. /**
  73313. * Defines the list of mesh's names you want to load
  73314. */
  73315. meshesNames: any;
  73316. /**
  73317. * Defines the root url to use as a base to load your meshes and associated resources
  73318. */
  73319. rootUrl: string;
  73320. /**
  73321. * Defines the filename or File of the scene to load from
  73322. */
  73323. sceneFilename: string | File;
  73324. /**
  73325. * Gets the list of loaded meshes
  73326. */
  73327. loadedMeshes: Array<AbstractMesh>;
  73328. /**
  73329. * Gets the list of loaded particle systems
  73330. */
  73331. loadedParticleSystems: Array<IParticleSystem>;
  73332. /**
  73333. * Gets the list of loaded skeletons
  73334. */
  73335. loadedSkeletons: Array<Skeleton>;
  73336. /**
  73337. * Gets the list of loaded animation groups
  73338. */
  73339. loadedAnimationGroups: Array<AnimationGroup>;
  73340. /**
  73341. * Callback called when the task is successful
  73342. */
  73343. onSuccess: (task: MeshAssetTask) => void;
  73344. /**
  73345. * Callback called when the task is successful
  73346. */
  73347. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73348. /**
  73349. * Creates a new MeshAssetTask
  73350. * @param name defines the name of the task
  73351. * @param meshesNames defines the list of mesh's names you want to load
  73352. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73353. * @param sceneFilename defines the filename or File of the scene to load from
  73354. */
  73355. constructor(
  73356. /**
  73357. * Defines the name of the task
  73358. */
  73359. name: string,
  73360. /**
  73361. * Defines the list of mesh's names you want to load
  73362. */
  73363. meshesNames: any,
  73364. /**
  73365. * Defines the root url to use as a base to load your meshes and associated resources
  73366. */
  73367. rootUrl: string,
  73368. /**
  73369. * Defines the filename or File of the scene to load from
  73370. */
  73371. sceneFilename: string | File);
  73372. /**
  73373. * Execute the current task
  73374. * @param scene defines the scene where you want your assets to be loaded
  73375. * @param onSuccess is a callback called when the task is successfully executed
  73376. * @param onError is a callback called if an error occurs
  73377. */
  73378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73379. }
  73380. /**
  73381. * Define a task used by AssetsManager to load text content
  73382. */
  73383. export class TextFileAssetTask extends AbstractAssetTask {
  73384. /**
  73385. * Defines the name of the task
  73386. */
  73387. name: string;
  73388. /**
  73389. * Defines the location of the file to load
  73390. */
  73391. url: string;
  73392. /**
  73393. * Gets the loaded text string
  73394. */
  73395. text: string;
  73396. /**
  73397. * Callback called when the task is successful
  73398. */
  73399. onSuccess: (task: TextFileAssetTask) => void;
  73400. /**
  73401. * Callback called when the task is successful
  73402. */
  73403. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73404. /**
  73405. * Creates a new TextFileAssetTask object
  73406. * @param name defines the name of the task
  73407. * @param url defines the location of the file to load
  73408. */
  73409. constructor(
  73410. /**
  73411. * Defines the name of the task
  73412. */
  73413. name: string,
  73414. /**
  73415. * Defines the location of the file to load
  73416. */
  73417. url: string);
  73418. /**
  73419. * Execute the current task
  73420. * @param scene defines the scene where you want your assets to be loaded
  73421. * @param onSuccess is a callback called when the task is successfully executed
  73422. * @param onError is a callback called if an error occurs
  73423. */
  73424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73425. }
  73426. /**
  73427. * Define a task used by AssetsManager to load binary data
  73428. */
  73429. export class BinaryFileAssetTask extends AbstractAssetTask {
  73430. /**
  73431. * Defines the name of the task
  73432. */
  73433. name: string;
  73434. /**
  73435. * Defines the location of the file to load
  73436. */
  73437. url: string;
  73438. /**
  73439. * Gets the lodaded data (as an array buffer)
  73440. */
  73441. data: ArrayBuffer;
  73442. /**
  73443. * Callback called when the task is successful
  73444. */
  73445. onSuccess: (task: BinaryFileAssetTask) => void;
  73446. /**
  73447. * Callback called when the task is successful
  73448. */
  73449. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73450. /**
  73451. * Creates a new BinaryFileAssetTask object
  73452. * @param name defines the name of the new task
  73453. * @param url defines the location of the file to load
  73454. */
  73455. constructor(
  73456. /**
  73457. * Defines the name of the task
  73458. */
  73459. name: string,
  73460. /**
  73461. * Defines the location of the file to load
  73462. */
  73463. url: string);
  73464. /**
  73465. * Execute the current task
  73466. * @param scene defines the scene where you want your assets to be loaded
  73467. * @param onSuccess is a callback called when the task is successfully executed
  73468. * @param onError is a callback called if an error occurs
  73469. */
  73470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73471. }
  73472. /**
  73473. * Define a task used by AssetsManager to load images
  73474. */
  73475. export class ImageAssetTask extends AbstractAssetTask {
  73476. /**
  73477. * Defines the name of the task
  73478. */
  73479. name: string;
  73480. /**
  73481. * Defines the location of the image to load
  73482. */
  73483. url: string;
  73484. /**
  73485. * Gets the loaded images
  73486. */
  73487. image: HTMLImageElement;
  73488. /**
  73489. * Callback called when the task is successful
  73490. */
  73491. onSuccess: (task: ImageAssetTask) => void;
  73492. /**
  73493. * Callback called when the task is successful
  73494. */
  73495. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73496. /**
  73497. * Creates a new ImageAssetTask
  73498. * @param name defines the name of the task
  73499. * @param url defines the location of the image to load
  73500. */
  73501. constructor(
  73502. /**
  73503. * Defines the name of the task
  73504. */
  73505. name: string,
  73506. /**
  73507. * Defines the location of the image to load
  73508. */
  73509. url: string);
  73510. /**
  73511. * Execute the current task
  73512. * @param scene defines the scene where you want your assets to be loaded
  73513. * @param onSuccess is a callback called when the task is successfully executed
  73514. * @param onError is a callback called if an error occurs
  73515. */
  73516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73517. }
  73518. /**
  73519. * Defines the interface used by texture loading tasks
  73520. */
  73521. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73522. /**
  73523. * Gets the loaded texture
  73524. */
  73525. texture: TEX;
  73526. }
  73527. /**
  73528. * Define a task used by AssetsManager to load 2D textures
  73529. */
  73530. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73531. /**
  73532. * Defines the name of the task
  73533. */
  73534. name: string;
  73535. /**
  73536. * Defines the location of the file to load
  73537. */
  73538. url: string;
  73539. /**
  73540. * Defines if mipmap should not be generated (default is false)
  73541. */
  73542. noMipmap?: boolean | undefined;
  73543. /**
  73544. * Defines if texture must be inverted on Y axis (default is true)
  73545. */
  73546. invertY: boolean;
  73547. /**
  73548. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73549. */
  73550. samplingMode: number;
  73551. /**
  73552. * Gets the loaded texture
  73553. */
  73554. texture: Texture;
  73555. /**
  73556. * Callback called when the task is successful
  73557. */
  73558. onSuccess: (task: TextureAssetTask) => void;
  73559. /**
  73560. * Callback called when the task is successful
  73561. */
  73562. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73563. /**
  73564. * Creates a new TextureAssetTask object
  73565. * @param name defines the name of the task
  73566. * @param url defines the location of the file to load
  73567. * @param noMipmap defines if mipmap should not be generated (default is false)
  73568. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73569. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73570. */
  73571. constructor(
  73572. /**
  73573. * Defines the name of the task
  73574. */
  73575. name: string,
  73576. /**
  73577. * Defines the location of the file to load
  73578. */
  73579. url: string,
  73580. /**
  73581. * Defines if mipmap should not be generated (default is false)
  73582. */
  73583. noMipmap?: boolean | undefined,
  73584. /**
  73585. * Defines if texture must be inverted on Y axis (default is true)
  73586. */
  73587. invertY?: boolean,
  73588. /**
  73589. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73590. */
  73591. samplingMode?: number);
  73592. /**
  73593. * Execute the current task
  73594. * @param scene defines the scene where you want your assets to be loaded
  73595. * @param onSuccess is a callback called when the task is successfully executed
  73596. * @param onError is a callback called if an error occurs
  73597. */
  73598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73599. }
  73600. /**
  73601. * Define a task used by AssetsManager to load cube textures
  73602. */
  73603. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73604. /**
  73605. * Defines the name of the task
  73606. */
  73607. name: string;
  73608. /**
  73609. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73610. */
  73611. url: string;
  73612. /**
  73613. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73614. */
  73615. extensions?: string[] | undefined;
  73616. /**
  73617. * Defines if mipmaps should not be generated (default is false)
  73618. */
  73619. noMipmap?: boolean | undefined;
  73620. /**
  73621. * Defines the explicit list of files (undefined by default)
  73622. */
  73623. files?: string[] | undefined;
  73624. /**
  73625. * Gets the loaded texture
  73626. */
  73627. texture: CubeTexture;
  73628. /**
  73629. * Callback called when the task is successful
  73630. */
  73631. onSuccess: (task: CubeTextureAssetTask) => void;
  73632. /**
  73633. * Callback called when the task is successful
  73634. */
  73635. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73636. /**
  73637. * Creates a new CubeTextureAssetTask
  73638. * @param name defines the name of the task
  73639. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73640. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73641. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73642. * @param files defines the explicit list of files (undefined by default)
  73643. */
  73644. constructor(
  73645. /**
  73646. * Defines the name of the task
  73647. */
  73648. name: string,
  73649. /**
  73650. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73651. */
  73652. url: string,
  73653. /**
  73654. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73655. */
  73656. extensions?: string[] | undefined,
  73657. /**
  73658. * Defines if mipmaps should not be generated (default is false)
  73659. */
  73660. noMipmap?: boolean | undefined,
  73661. /**
  73662. * Defines the explicit list of files (undefined by default)
  73663. */
  73664. files?: string[] | undefined);
  73665. /**
  73666. * Execute the current task
  73667. * @param scene defines the scene where you want your assets to be loaded
  73668. * @param onSuccess is a callback called when the task is successfully executed
  73669. * @param onError is a callback called if an error occurs
  73670. */
  73671. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73672. }
  73673. /**
  73674. * Define a task used by AssetsManager to load HDR cube textures
  73675. */
  73676. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73677. /**
  73678. * Defines the name of the task
  73679. */
  73680. name: string;
  73681. /**
  73682. * Defines the location of the file to load
  73683. */
  73684. url: string;
  73685. /**
  73686. * Defines the desired size (the more it increases the longer the generation will be)
  73687. */
  73688. size: number;
  73689. /**
  73690. * Defines if mipmaps should not be generated (default is false)
  73691. */
  73692. noMipmap: boolean;
  73693. /**
  73694. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73695. */
  73696. generateHarmonics: boolean;
  73697. /**
  73698. * 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)
  73699. */
  73700. gammaSpace: boolean;
  73701. /**
  73702. * Internal Use Only
  73703. */
  73704. reserved: boolean;
  73705. /**
  73706. * Gets the loaded texture
  73707. */
  73708. texture: HDRCubeTexture;
  73709. /**
  73710. * Callback called when the task is successful
  73711. */
  73712. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73713. /**
  73714. * Callback called when the task is successful
  73715. */
  73716. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73717. /**
  73718. * Creates a new HDRCubeTextureAssetTask object
  73719. * @param name defines the name of the task
  73720. * @param url defines the location of the file to load
  73721. * @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.
  73722. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73723. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73724. * @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)
  73725. * @param reserved Internal use only
  73726. */
  73727. constructor(
  73728. /**
  73729. * Defines the name of the task
  73730. */
  73731. name: string,
  73732. /**
  73733. * Defines the location of the file to load
  73734. */
  73735. url: string,
  73736. /**
  73737. * Defines the desired size (the more it increases the longer the generation will be)
  73738. */
  73739. size: number,
  73740. /**
  73741. * Defines if mipmaps should not be generated (default is false)
  73742. */
  73743. noMipmap?: boolean,
  73744. /**
  73745. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73746. */
  73747. generateHarmonics?: boolean,
  73748. /**
  73749. * 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)
  73750. */
  73751. gammaSpace?: boolean,
  73752. /**
  73753. * Internal Use Only
  73754. */
  73755. reserved?: boolean);
  73756. /**
  73757. * Execute the current task
  73758. * @param scene defines the scene where you want your assets to be loaded
  73759. * @param onSuccess is a callback called when the task is successfully executed
  73760. * @param onError is a callback called if an error occurs
  73761. */
  73762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73763. }
  73764. /**
  73765. * Define a task used by AssetsManager to load Equirectangular cube textures
  73766. */
  73767. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73768. /**
  73769. * Defines the name of the task
  73770. */
  73771. name: string;
  73772. /**
  73773. * Defines the location of the file to load
  73774. */
  73775. url: string;
  73776. /**
  73777. * Defines the desired size (the more it increases the longer the generation will be)
  73778. */
  73779. size: number;
  73780. /**
  73781. * Defines if mipmaps should not be generated (default is false)
  73782. */
  73783. noMipmap: boolean;
  73784. /**
  73785. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73786. * but the standard material would require them in Gamma space) (default is true)
  73787. */
  73788. gammaSpace: boolean;
  73789. /**
  73790. * Gets the loaded texture
  73791. */
  73792. texture: EquiRectangularCubeTexture;
  73793. /**
  73794. * Callback called when the task is successful
  73795. */
  73796. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73797. /**
  73798. * Callback called when the task is successful
  73799. */
  73800. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73801. /**
  73802. * Creates a new EquiRectangularCubeTextureAssetTask object
  73803. * @param name defines the name of the task
  73804. * @param url defines the location of the file to load
  73805. * @param size defines the desired size (the more it increases the longer the generation will be)
  73806. * If the size is omitted this implies you are using a preprocessed cubemap.
  73807. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73808. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73809. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73810. * (default is true)
  73811. */
  73812. constructor(
  73813. /**
  73814. * Defines the name of the task
  73815. */
  73816. name: string,
  73817. /**
  73818. * Defines the location of the file to load
  73819. */
  73820. url: string,
  73821. /**
  73822. * Defines the desired size (the more it increases the longer the generation will be)
  73823. */
  73824. size: number,
  73825. /**
  73826. * Defines if mipmaps should not be generated (default is false)
  73827. */
  73828. noMipmap?: boolean,
  73829. /**
  73830. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73831. * but the standard material would require them in Gamma space) (default is true)
  73832. */
  73833. gammaSpace?: boolean);
  73834. /**
  73835. * Execute the current task
  73836. * @param scene defines the scene where you want your assets to be loaded
  73837. * @param onSuccess is a callback called when the task is successfully executed
  73838. * @param onError is a callback called if an error occurs
  73839. */
  73840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73841. }
  73842. /**
  73843. * This class can be used to easily import assets into a scene
  73844. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73845. */
  73846. export class AssetsManager {
  73847. private _scene;
  73848. private _isLoading;
  73849. protected _tasks: AbstractAssetTask[];
  73850. protected _waitingTasksCount: number;
  73851. protected _totalTasksCount: number;
  73852. /**
  73853. * Callback called when all tasks are processed
  73854. */
  73855. onFinish: (tasks: AbstractAssetTask[]) => void;
  73856. /**
  73857. * Callback called when a task is successful
  73858. */
  73859. onTaskSuccess: (task: AbstractAssetTask) => void;
  73860. /**
  73861. * Callback called when a task had an error
  73862. */
  73863. onTaskError: (task: AbstractAssetTask) => void;
  73864. /**
  73865. * Callback called when a task is done (whatever the result is)
  73866. */
  73867. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73868. /**
  73869. * Observable called when all tasks are processed
  73870. */
  73871. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73872. /**
  73873. * Observable called when a task had an error
  73874. */
  73875. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73876. /**
  73877. * Observable called when all tasks were executed
  73878. */
  73879. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73880. /**
  73881. * Observable called when a task is done (whatever the result is)
  73882. */
  73883. onProgressObservable: Observable<IAssetsProgressEvent>;
  73884. /**
  73885. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73886. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73887. */
  73888. useDefaultLoadingScreen: boolean;
  73889. /**
  73890. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73891. * when all assets have been downloaded.
  73892. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73893. */
  73894. autoHideLoadingUI: boolean;
  73895. /**
  73896. * Creates a new AssetsManager
  73897. * @param scene defines the scene to work on
  73898. */
  73899. constructor(scene: Scene);
  73900. /**
  73901. * Add a MeshAssetTask to the list of active tasks
  73902. * @param taskName defines the name of the new task
  73903. * @param meshesNames defines the name of meshes to load
  73904. * @param rootUrl defines the root url to use to locate files
  73905. * @param sceneFilename defines the filename of the scene file
  73906. * @returns a new MeshAssetTask object
  73907. */
  73908. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73909. /**
  73910. * Add a TextFileAssetTask to the list of active tasks
  73911. * @param taskName defines the name of the new task
  73912. * @param url defines the url of the file to load
  73913. * @returns a new TextFileAssetTask object
  73914. */
  73915. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73916. /**
  73917. * Add a BinaryFileAssetTask to the list of active tasks
  73918. * @param taskName defines the name of the new task
  73919. * @param url defines the url of the file to load
  73920. * @returns a new BinaryFileAssetTask object
  73921. */
  73922. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73923. /**
  73924. * Add a ImageAssetTask to the list of active tasks
  73925. * @param taskName defines the name of the new task
  73926. * @param url defines the url of the file to load
  73927. * @returns a new ImageAssetTask object
  73928. */
  73929. addImageTask(taskName: string, url: string): ImageAssetTask;
  73930. /**
  73931. * Add a TextureAssetTask to the list of active tasks
  73932. * @param taskName defines the name of the new task
  73933. * @param url defines the url of the file to load
  73934. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73935. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73936. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73937. * @returns a new TextureAssetTask object
  73938. */
  73939. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73940. /**
  73941. * Add a CubeTextureAssetTask to the list of active tasks
  73942. * @param taskName defines the name of the new task
  73943. * @param url defines the url of the file to load
  73944. * @param extensions defines the extension to use to load the cube map (can be null)
  73945. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73946. * @param files defines the list of files to load (can be null)
  73947. * @returns a new CubeTextureAssetTask object
  73948. */
  73949. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73950. /**
  73951. *
  73952. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73953. * @param taskName defines the name of the new task
  73954. * @param url defines the url of the file to load
  73955. * @param size defines the size you want for the cubemap (can be null)
  73956. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73957. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73958. * @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)
  73959. * @param reserved Internal use only
  73960. * @returns a new HDRCubeTextureAssetTask object
  73961. */
  73962. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73963. /**
  73964. *
  73965. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73966. * @param taskName defines the name of the new task
  73967. * @param url defines the url of the file to load
  73968. * @param size defines the size you want for the cubemap (can be null)
  73969. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73970. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73971. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73972. * @returns a new EquiRectangularCubeTextureAssetTask object
  73973. */
  73974. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73975. /**
  73976. * Remove a task from the assets manager.
  73977. * @param task the task to remove
  73978. */
  73979. removeTask(task: AbstractAssetTask): void;
  73980. private _decreaseWaitingTasksCount;
  73981. private _runTask;
  73982. /**
  73983. * Reset the AssetsManager and remove all tasks
  73984. * @return the current instance of the AssetsManager
  73985. */
  73986. reset(): AssetsManager;
  73987. /**
  73988. * Start the loading process
  73989. * @return the current instance of the AssetsManager
  73990. */
  73991. load(): AssetsManager;
  73992. /**
  73993. * Start the loading process as an async operation
  73994. * @return a promise returning the list of failed tasks
  73995. */
  73996. loadAsync(): Promise<void>;
  73997. }
  73998. }
  73999. declare module "babylonjs/Misc/deferred" {
  74000. /**
  74001. * Wrapper class for promise with external resolve and reject.
  74002. */
  74003. export class Deferred<T> {
  74004. /**
  74005. * The promise associated with this deferred object.
  74006. */
  74007. readonly promise: Promise<T>;
  74008. private _resolve;
  74009. private _reject;
  74010. /**
  74011. * The resolve method of the promise associated with this deferred object.
  74012. */
  74013. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74014. /**
  74015. * The reject method of the promise associated with this deferred object.
  74016. */
  74017. get reject(): (reason?: any) => void;
  74018. /**
  74019. * Constructor for this deferred object.
  74020. */
  74021. constructor();
  74022. }
  74023. }
  74024. declare module "babylonjs/Misc/meshExploder" {
  74025. import { Mesh } from "babylonjs/Meshes/mesh";
  74026. /**
  74027. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74028. */
  74029. export class MeshExploder {
  74030. private _centerMesh;
  74031. private _meshes;
  74032. private _meshesOrigins;
  74033. private _toCenterVectors;
  74034. private _scaledDirection;
  74035. private _newPosition;
  74036. private _centerPosition;
  74037. /**
  74038. * Explodes meshes from a center mesh.
  74039. * @param meshes The meshes to explode.
  74040. * @param centerMesh The mesh to be center of explosion.
  74041. */
  74042. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74043. private _setCenterMesh;
  74044. /**
  74045. * Get class name
  74046. * @returns "MeshExploder"
  74047. */
  74048. getClassName(): string;
  74049. /**
  74050. * "Exploded meshes"
  74051. * @returns Array of meshes with the centerMesh at index 0.
  74052. */
  74053. getMeshes(): Array<Mesh>;
  74054. /**
  74055. * Explodes meshes giving a specific direction
  74056. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74057. */
  74058. explode(direction?: number): void;
  74059. }
  74060. }
  74061. declare module "babylonjs/Misc/filesInput" {
  74062. import { Engine } from "babylonjs/Engines/engine";
  74063. import { Scene } from "babylonjs/scene";
  74064. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  74065. /**
  74066. * Class used to help managing file picking and drag'n'drop
  74067. */
  74068. export class FilesInput {
  74069. /**
  74070. * List of files ready to be loaded
  74071. */
  74072. static get FilesToLoad(): {
  74073. [key: string]: File;
  74074. };
  74075. /**
  74076. * Callback called when a file is processed
  74077. */
  74078. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  74079. private _engine;
  74080. private _currentScene;
  74081. private _sceneLoadedCallback;
  74082. private _progressCallback;
  74083. private _additionalRenderLoopLogicCallback;
  74084. private _textureLoadingCallback;
  74085. private _startingProcessingFilesCallback;
  74086. private _onReloadCallback;
  74087. private _errorCallback;
  74088. private _elementToMonitor;
  74089. private _sceneFileToLoad;
  74090. private _filesToLoad;
  74091. /**
  74092. * Creates a new FilesInput
  74093. * @param engine defines the rendering engine
  74094. * @param scene defines the hosting scene
  74095. * @param sceneLoadedCallback callback called when scene is loaded
  74096. * @param progressCallback callback called to track progress
  74097. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74098. * @param textureLoadingCallback callback called when a texture is loading
  74099. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74100. * @param onReloadCallback callback called when a reload is requested
  74101. * @param errorCallback callback call if an error occurs
  74102. */
  74103. 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);
  74104. private _dragEnterHandler;
  74105. private _dragOverHandler;
  74106. private _dropHandler;
  74107. /**
  74108. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74109. * @param elementToMonitor defines the DOM element to track
  74110. */
  74111. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74112. /**
  74113. * Release all associated resources
  74114. */
  74115. dispose(): void;
  74116. private renderFunction;
  74117. private drag;
  74118. private drop;
  74119. private _traverseFolder;
  74120. private _processFiles;
  74121. /**
  74122. * Load files from a drop event
  74123. * @param event defines the drop event to use as source
  74124. */
  74125. loadFiles(event: any): void;
  74126. private _processReload;
  74127. /**
  74128. * Reload the current scene from the loaded files
  74129. */
  74130. reload(): void;
  74131. }
  74132. }
  74133. declare module "babylonjs/Misc/HighDynamicRange/index" {
  74134. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  74135. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  74136. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  74137. }
  74138. declare module "babylonjs/Misc/sceneOptimizer" {
  74139. import { Scene, IDisposable } from "babylonjs/scene";
  74140. import { Observable } from "babylonjs/Misc/observable";
  74141. /**
  74142. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74144. */
  74145. export class SceneOptimization {
  74146. /**
  74147. * Defines the priority of this optimization (0 by default which means first in the list)
  74148. */
  74149. priority: number;
  74150. /**
  74151. * Gets a string describing the action executed by the current optimization
  74152. * @returns description string
  74153. */
  74154. getDescription(): string;
  74155. /**
  74156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74157. * @param scene defines the current scene where to apply this optimization
  74158. * @param optimizer defines the current optimizer
  74159. * @returns true if everything that can be done was applied
  74160. */
  74161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74162. /**
  74163. * Creates the SceneOptimization object
  74164. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74165. * @param desc defines the description associated with the optimization
  74166. */
  74167. constructor(
  74168. /**
  74169. * Defines the priority of this optimization (0 by default which means first in the list)
  74170. */
  74171. priority?: number);
  74172. }
  74173. /**
  74174. * Defines an optimization used to reduce the size of render target textures
  74175. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74176. */
  74177. export class TextureOptimization extends SceneOptimization {
  74178. /**
  74179. * Defines the priority of this optimization (0 by default which means first in the list)
  74180. */
  74181. priority: number;
  74182. /**
  74183. * 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
  74184. */
  74185. maximumSize: number;
  74186. /**
  74187. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74188. */
  74189. step: number;
  74190. /**
  74191. * Gets a string describing the action executed by the current optimization
  74192. * @returns description string
  74193. */
  74194. getDescription(): string;
  74195. /**
  74196. * Creates the TextureOptimization object
  74197. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74198. * @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
  74199. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74200. */
  74201. constructor(
  74202. /**
  74203. * Defines the priority of this optimization (0 by default which means first in the list)
  74204. */
  74205. priority?: number,
  74206. /**
  74207. * 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
  74208. */
  74209. maximumSize?: number,
  74210. /**
  74211. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74212. */
  74213. step?: number);
  74214. /**
  74215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74216. * @param scene defines the current scene where to apply this optimization
  74217. * @param optimizer defines the current optimizer
  74218. * @returns true if everything that can be done was applied
  74219. */
  74220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74221. }
  74222. /**
  74223. * Defines an optimization used to increase or decrease the rendering resolution
  74224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74225. */
  74226. export class HardwareScalingOptimization extends SceneOptimization {
  74227. /**
  74228. * Defines the priority of this optimization (0 by default which means first in the list)
  74229. */
  74230. priority: number;
  74231. /**
  74232. * Defines the maximum scale to use (2 by default)
  74233. */
  74234. maximumScale: number;
  74235. /**
  74236. * Defines the step to use between two passes (0.5 by default)
  74237. */
  74238. step: number;
  74239. private _currentScale;
  74240. private _directionOffset;
  74241. /**
  74242. * Gets a string describing the action executed by the current optimization
  74243. * @return description string
  74244. */
  74245. getDescription(): string;
  74246. /**
  74247. * Creates the HardwareScalingOptimization object
  74248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74249. * @param maximumScale defines the maximum scale to use (2 by default)
  74250. * @param step defines the step to use between two passes (0.5 by default)
  74251. */
  74252. constructor(
  74253. /**
  74254. * Defines the priority of this optimization (0 by default which means first in the list)
  74255. */
  74256. priority?: number,
  74257. /**
  74258. * Defines the maximum scale to use (2 by default)
  74259. */
  74260. maximumScale?: number,
  74261. /**
  74262. * Defines the step to use between two passes (0.5 by default)
  74263. */
  74264. step?: number);
  74265. /**
  74266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74267. * @param scene defines the current scene where to apply this optimization
  74268. * @param optimizer defines the current optimizer
  74269. * @returns true if everything that can be done was applied
  74270. */
  74271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74272. }
  74273. /**
  74274. * Defines an optimization used to remove shadows
  74275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74276. */
  74277. export class ShadowsOptimization extends SceneOptimization {
  74278. /**
  74279. * Gets a string describing the action executed by the current optimization
  74280. * @return description string
  74281. */
  74282. getDescription(): string;
  74283. /**
  74284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74285. * @param scene defines the current scene where to apply this optimization
  74286. * @param optimizer defines the current optimizer
  74287. * @returns true if everything that can be done was applied
  74288. */
  74289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74290. }
  74291. /**
  74292. * Defines an optimization used to turn post-processes off
  74293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74294. */
  74295. export class PostProcessesOptimization extends SceneOptimization {
  74296. /**
  74297. * Gets a string describing the action executed by the current optimization
  74298. * @return description string
  74299. */
  74300. getDescription(): string;
  74301. /**
  74302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74303. * @param scene defines the current scene where to apply this optimization
  74304. * @param optimizer defines the current optimizer
  74305. * @returns true if everything that can be done was applied
  74306. */
  74307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74308. }
  74309. /**
  74310. * Defines an optimization used to turn lens flares off
  74311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74312. */
  74313. export class LensFlaresOptimization extends SceneOptimization {
  74314. /**
  74315. * Gets a string describing the action executed by the current optimization
  74316. * @return description string
  74317. */
  74318. getDescription(): string;
  74319. /**
  74320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74321. * @param scene defines the current scene where to apply this optimization
  74322. * @param optimizer defines the current optimizer
  74323. * @returns true if everything that can be done was applied
  74324. */
  74325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74326. }
  74327. /**
  74328. * Defines an optimization based on user defined callback.
  74329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74330. */
  74331. export class CustomOptimization extends SceneOptimization {
  74332. /**
  74333. * Callback called to apply the custom optimization.
  74334. */
  74335. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74336. /**
  74337. * Callback called to get custom description
  74338. */
  74339. onGetDescription: () => string;
  74340. /**
  74341. * Gets a string describing the action executed by the current optimization
  74342. * @returns description string
  74343. */
  74344. getDescription(): string;
  74345. /**
  74346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74347. * @param scene defines the current scene where to apply this optimization
  74348. * @param optimizer defines the current optimizer
  74349. * @returns true if everything that can be done was applied
  74350. */
  74351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74352. }
  74353. /**
  74354. * Defines an optimization used to turn particles off
  74355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74356. */
  74357. export class ParticlesOptimization extends SceneOptimization {
  74358. /**
  74359. * Gets a string describing the action executed by the current optimization
  74360. * @return description string
  74361. */
  74362. getDescription(): string;
  74363. /**
  74364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74365. * @param scene defines the current scene where to apply this optimization
  74366. * @param optimizer defines the current optimizer
  74367. * @returns true if everything that can be done was applied
  74368. */
  74369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74370. }
  74371. /**
  74372. * Defines an optimization used to turn render targets off
  74373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74374. */
  74375. export class RenderTargetsOptimization extends SceneOptimization {
  74376. /**
  74377. * Gets a string describing the action executed by the current optimization
  74378. * @return description string
  74379. */
  74380. getDescription(): string;
  74381. /**
  74382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74383. * @param scene defines the current scene where to apply this optimization
  74384. * @param optimizer defines the current optimizer
  74385. * @returns true if everything that can be done was applied
  74386. */
  74387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74388. }
  74389. /**
  74390. * Defines an optimization used to merge meshes with compatible materials
  74391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74392. */
  74393. export class MergeMeshesOptimization extends SceneOptimization {
  74394. private static _UpdateSelectionTree;
  74395. /**
  74396. * Gets or sets a boolean which defines if optimization octree has to be updated
  74397. */
  74398. static get UpdateSelectionTree(): boolean;
  74399. /**
  74400. * Gets or sets a boolean which defines if optimization octree has to be updated
  74401. */
  74402. static set UpdateSelectionTree(value: boolean);
  74403. /**
  74404. * Gets a string describing the action executed by the current optimization
  74405. * @return description string
  74406. */
  74407. getDescription(): string;
  74408. private _canBeMerged;
  74409. /**
  74410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74411. * @param scene defines the current scene where to apply this optimization
  74412. * @param optimizer defines the current optimizer
  74413. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74414. * @returns true if everything that can be done was applied
  74415. */
  74416. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74417. }
  74418. /**
  74419. * Defines a list of options used by SceneOptimizer
  74420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74421. */
  74422. export class SceneOptimizerOptions {
  74423. /**
  74424. * Defines the target frame rate to reach (60 by default)
  74425. */
  74426. targetFrameRate: number;
  74427. /**
  74428. * Defines the interval between two checkes (2000ms by default)
  74429. */
  74430. trackerDuration: number;
  74431. /**
  74432. * Gets the list of optimizations to apply
  74433. */
  74434. optimizations: SceneOptimization[];
  74435. /**
  74436. * Creates a new list of options used by SceneOptimizer
  74437. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74438. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74439. */
  74440. constructor(
  74441. /**
  74442. * Defines the target frame rate to reach (60 by default)
  74443. */
  74444. targetFrameRate?: number,
  74445. /**
  74446. * Defines the interval between two checkes (2000ms by default)
  74447. */
  74448. trackerDuration?: number);
  74449. /**
  74450. * Add a new optimization
  74451. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74452. * @returns the current SceneOptimizerOptions
  74453. */
  74454. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74455. /**
  74456. * Add a new custom optimization
  74457. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74458. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74459. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74460. * @returns the current SceneOptimizerOptions
  74461. */
  74462. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74463. /**
  74464. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74465. * @param targetFrameRate defines the target frame rate (60 by default)
  74466. * @returns a SceneOptimizerOptions object
  74467. */
  74468. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74469. /**
  74470. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74471. * @param targetFrameRate defines the target frame rate (60 by default)
  74472. * @returns a SceneOptimizerOptions object
  74473. */
  74474. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74475. /**
  74476. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74477. * @param targetFrameRate defines the target frame rate (60 by default)
  74478. * @returns a SceneOptimizerOptions object
  74479. */
  74480. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74481. }
  74482. /**
  74483. * Class used to run optimizations in order to reach a target frame rate
  74484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74485. */
  74486. export class SceneOptimizer implements IDisposable {
  74487. private _isRunning;
  74488. private _options;
  74489. private _scene;
  74490. private _currentPriorityLevel;
  74491. private _targetFrameRate;
  74492. private _trackerDuration;
  74493. private _currentFrameRate;
  74494. private _sceneDisposeObserver;
  74495. private _improvementMode;
  74496. /**
  74497. * Defines an observable called when the optimizer reaches the target frame rate
  74498. */
  74499. onSuccessObservable: Observable<SceneOptimizer>;
  74500. /**
  74501. * Defines an observable called when the optimizer enables an optimization
  74502. */
  74503. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74504. /**
  74505. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74506. */
  74507. onFailureObservable: Observable<SceneOptimizer>;
  74508. /**
  74509. * Gets a boolean indicating if the optimizer is in improvement mode
  74510. */
  74511. get isInImprovementMode(): boolean;
  74512. /**
  74513. * Gets the current priority level (0 at start)
  74514. */
  74515. get currentPriorityLevel(): number;
  74516. /**
  74517. * Gets the current frame rate checked by the SceneOptimizer
  74518. */
  74519. get currentFrameRate(): number;
  74520. /**
  74521. * Gets or sets the current target frame rate (60 by default)
  74522. */
  74523. get targetFrameRate(): number;
  74524. /**
  74525. * Gets or sets the current target frame rate (60 by default)
  74526. */
  74527. set targetFrameRate(value: number);
  74528. /**
  74529. * Gets or sets the current interval between two checks (every 2000ms by default)
  74530. */
  74531. get trackerDuration(): number;
  74532. /**
  74533. * Gets or sets the current interval between two checks (every 2000ms by default)
  74534. */
  74535. set trackerDuration(value: number);
  74536. /**
  74537. * Gets the list of active optimizations
  74538. */
  74539. get optimizations(): SceneOptimization[];
  74540. /**
  74541. * Creates a new SceneOptimizer
  74542. * @param scene defines the scene to work on
  74543. * @param options defines the options to use with the SceneOptimizer
  74544. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74545. * @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)
  74546. */
  74547. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74548. /**
  74549. * Stops the current optimizer
  74550. */
  74551. stop(): void;
  74552. /**
  74553. * Reset the optimizer to initial step (current priority level = 0)
  74554. */
  74555. reset(): void;
  74556. /**
  74557. * Start the optimizer. By default it will try to reach a specific framerate
  74558. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74559. */
  74560. start(): void;
  74561. private _checkCurrentState;
  74562. /**
  74563. * Release all resources
  74564. */
  74565. dispose(): void;
  74566. /**
  74567. * Helper function to create a SceneOptimizer with one single line of code
  74568. * @param scene defines the scene to work on
  74569. * @param options defines the options to use with the SceneOptimizer
  74570. * @param onSuccess defines a callback to call on success
  74571. * @param onFailure defines a callback to call on failure
  74572. * @returns the new SceneOptimizer object
  74573. */
  74574. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74575. }
  74576. }
  74577. declare module "babylonjs/Misc/sceneSerializer" {
  74578. import { Scene } from "babylonjs/scene";
  74579. /**
  74580. * Class used to serialize a scene into a string
  74581. */
  74582. export class SceneSerializer {
  74583. /**
  74584. * Clear cache used by a previous serialization
  74585. */
  74586. static ClearCache(): void;
  74587. /**
  74588. * Serialize a scene into a JSON compatible object
  74589. * @param scene defines the scene to serialize
  74590. * @returns a JSON compatible object
  74591. */
  74592. static Serialize(scene: Scene): any;
  74593. /**
  74594. * Serialize a mesh into a JSON compatible object
  74595. * @param toSerialize defines the mesh to serialize
  74596. * @param withParents defines if parents must be serialized as well
  74597. * @param withChildren defines if children must be serialized as well
  74598. * @returns a JSON compatible object
  74599. */
  74600. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74601. }
  74602. }
  74603. declare module "babylonjs/Misc/textureTools" {
  74604. import { Texture } from "babylonjs/Materials/Textures/texture";
  74605. /**
  74606. * Class used to host texture specific utilities
  74607. */
  74608. export class TextureTools {
  74609. /**
  74610. * Uses the GPU to create a copy texture rescaled at a given size
  74611. * @param texture Texture to copy from
  74612. * @param width defines the desired width
  74613. * @param height defines the desired height
  74614. * @param useBilinearMode defines if bilinear mode has to be used
  74615. * @return the generated texture
  74616. */
  74617. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74618. }
  74619. }
  74620. declare module "babylonjs/Misc/videoRecorder" {
  74621. import { Nullable } from "babylonjs/types";
  74622. import { Engine } from "babylonjs/Engines/engine";
  74623. /**
  74624. * This represents the different options available for the video capture.
  74625. */
  74626. export interface VideoRecorderOptions {
  74627. /** Defines the mime type of the video. */
  74628. mimeType: string;
  74629. /** Defines the FPS the video should be recorded at. */
  74630. fps: number;
  74631. /** Defines the chunk size for the recording data. */
  74632. recordChunckSize: number;
  74633. /** The audio tracks to attach to the recording. */
  74634. audioTracks?: MediaStreamTrack[];
  74635. }
  74636. /**
  74637. * This can help with recording videos from BabylonJS.
  74638. * This is based on the available WebRTC functionalities of the browser.
  74639. *
  74640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  74641. */
  74642. export class VideoRecorder {
  74643. private static readonly _defaultOptions;
  74644. /**
  74645. * Returns whether or not the VideoRecorder is available in your browser.
  74646. * @param engine Defines the Babylon Engine.
  74647. * @returns true if supported otherwise false.
  74648. */
  74649. static IsSupported(engine: Engine): boolean;
  74650. private readonly _options;
  74651. private _canvas;
  74652. private _mediaRecorder;
  74653. private _recordedChunks;
  74654. private _fileName;
  74655. private _resolve;
  74656. private _reject;
  74657. /**
  74658. * True when a recording is already in progress.
  74659. */
  74660. get isRecording(): boolean;
  74661. /**
  74662. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74663. * @param engine Defines the BabylonJS Engine you wish to record.
  74664. * @param options Defines options that can be used to customize the capture.
  74665. */
  74666. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74667. /**
  74668. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74669. */
  74670. stopRecording(): void;
  74671. /**
  74672. * Starts recording the canvas for a max duration specified in parameters.
  74673. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74674. * If null no automatic download will start and you can rely on the promise to get the data back.
  74675. * @param maxDuration Defines the maximum recording time in seconds.
  74676. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74677. * @return A promise callback at the end of the recording with the video data in Blob.
  74678. */
  74679. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74680. /**
  74681. * Releases internal resources used during the recording.
  74682. */
  74683. dispose(): void;
  74684. private _handleDataAvailable;
  74685. private _handleError;
  74686. private _handleStop;
  74687. }
  74688. }
  74689. declare module "babylonjs/Misc/screenshotTools" {
  74690. import { Camera } from "babylonjs/Cameras/camera";
  74691. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  74692. import { Engine } from "babylonjs/Engines/engine";
  74693. /**
  74694. * Class containing a set of static utilities functions for screenshots
  74695. */
  74696. export class ScreenshotTools {
  74697. /**
  74698. * Captures a screenshot of the current rendering
  74699. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74700. * @param engine defines the rendering engine
  74701. * @param camera defines the source camera
  74702. * @param size This parameter can be set to a single number or to an object with the
  74703. * following (optional) properties: precision, width, height. If a single number is passed,
  74704. * it will be used for both width and height. If an object is passed, the screenshot size
  74705. * will be derived from the parameters. The precision property is a multiplier allowing
  74706. * rendering at a higher or lower resolution
  74707. * @param successCallback defines the callback receives a single parameter which contains the
  74708. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74709. * src parameter of an <img> to display it
  74710. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74711. * Check your browser for supported MIME types
  74712. */
  74713. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74714. /**
  74715. * Captures a screenshot of the current rendering
  74716. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74717. * @param engine defines the rendering engine
  74718. * @param camera defines the source camera
  74719. * @param size This parameter can be set to a single number or to an object with the
  74720. * following (optional) properties: precision, width, height. If a single number is passed,
  74721. * it will be used for both width and height. If an object is passed, the screenshot size
  74722. * will be derived from the parameters. The precision property is a multiplier allowing
  74723. * rendering at a higher or lower resolution
  74724. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74725. * Check your browser for supported MIME types
  74726. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74727. * to the src parameter of an <img> to display it
  74728. */
  74729. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74730. /**
  74731. * Generates an image screenshot from the specified camera.
  74732. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74733. * @param engine The engine to use for rendering
  74734. * @param camera The camera to use for rendering
  74735. * @param size This parameter can be set to a single number or to an object with the
  74736. * following (optional) properties: precision, width, height. If a single number is passed,
  74737. * it will be used for both width and height. If an object is passed, the screenshot size
  74738. * will be derived from the parameters. The precision property is a multiplier allowing
  74739. * rendering at a higher or lower resolution
  74740. * @param successCallback The callback receives a single parameter which contains the
  74741. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74742. * src parameter of an <img> to display it
  74743. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74744. * Check your browser for supported MIME types
  74745. * @param samples Texture samples (default: 1)
  74746. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74747. * @param fileName A name for for the downloaded file.
  74748. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74749. */
  74750. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  74751. /**
  74752. * Generates an image screenshot from the specified camera.
  74753. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74754. * @param engine The engine to use for rendering
  74755. * @param camera The camera to use for rendering
  74756. * @param size This parameter can be set to a single number or to an object with the
  74757. * following (optional) properties: precision, width, height. If a single number is passed,
  74758. * it will be used for both width and height. If an object is passed, the screenshot size
  74759. * will be derived from the parameters. The precision property is a multiplier allowing
  74760. * rendering at a higher or lower resolution
  74761. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74762. * Check your browser for supported MIME types
  74763. * @param samples Texture samples (default: 1)
  74764. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74765. * @param fileName A name for for the downloaded file.
  74766. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74767. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74768. * to the src parameter of an <img> to display it
  74769. */
  74770. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74771. /**
  74772. * Gets height and width for screenshot size
  74773. * @private
  74774. */
  74775. private static _getScreenshotSize;
  74776. }
  74777. }
  74778. declare module "babylonjs/Misc/dataReader" {
  74779. /**
  74780. * Interface for a data buffer
  74781. */
  74782. export interface IDataBuffer {
  74783. /**
  74784. * Reads bytes from the data buffer.
  74785. * @param byteOffset The byte offset to read
  74786. * @param byteLength The byte length to read
  74787. * @returns A promise that resolves when the bytes are read
  74788. */
  74789. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74790. /**
  74791. * The byte length of the buffer.
  74792. */
  74793. readonly byteLength: number;
  74794. }
  74795. /**
  74796. * Utility class for reading from a data buffer
  74797. */
  74798. export class DataReader {
  74799. /**
  74800. * The data buffer associated with this data reader.
  74801. */
  74802. readonly buffer: IDataBuffer;
  74803. /**
  74804. * The current byte offset from the beginning of the data buffer.
  74805. */
  74806. byteOffset: number;
  74807. private _dataView;
  74808. private _dataByteOffset;
  74809. /**
  74810. * Constructor
  74811. * @param buffer The buffer to read
  74812. */
  74813. constructor(buffer: IDataBuffer);
  74814. /**
  74815. * Loads the given byte length.
  74816. * @param byteLength The byte length to load
  74817. * @returns A promise that resolves when the load is complete
  74818. */
  74819. loadAsync(byteLength: number): Promise<void>;
  74820. /**
  74821. * Read a unsigned 32-bit integer from the currently loaded data range.
  74822. * @returns The 32-bit integer read
  74823. */
  74824. readUint32(): number;
  74825. /**
  74826. * Read a byte array from the currently loaded data range.
  74827. * @param byteLength The byte length to read
  74828. * @returns The byte array read
  74829. */
  74830. readUint8Array(byteLength: number): Uint8Array;
  74831. /**
  74832. * Read a string from the currently loaded data range.
  74833. * @param byteLength The byte length to read
  74834. * @returns The string read
  74835. */
  74836. readString(byteLength: number): string;
  74837. /**
  74838. * Skips the given byte length the currently loaded data range.
  74839. * @param byteLength The byte length to skip
  74840. */
  74841. skipBytes(byteLength: number): void;
  74842. }
  74843. }
  74844. declare module "babylonjs/Misc/dataStorage" {
  74845. /**
  74846. * Class for storing data to local storage if available or in-memory storage otherwise
  74847. */
  74848. export class DataStorage {
  74849. private static _Storage;
  74850. private static _GetStorage;
  74851. /**
  74852. * Reads a string from the data storage
  74853. * @param key The key to read
  74854. * @param defaultValue The value if the key doesn't exist
  74855. * @returns The string value
  74856. */
  74857. static ReadString(key: string, defaultValue: string): string;
  74858. /**
  74859. * Writes a string to the data storage
  74860. * @param key The key to write
  74861. * @param value The value to write
  74862. */
  74863. static WriteString(key: string, value: string): void;
  74864. /**
  74865. * Reads a boolean from the data storage
  74866. * @param key The key to read
  74867. * @param defaultValue The value if the key doesn't exist
  74868. * @returns The boolean value
  74869. */
  74870. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74871. /**
  74872. * Writes a boolean to the data storage
  74873. * @param key The key to write
  74874. * @param value The value to write
  74875. */
  74876. static WriteBoolean(key: string, value: boolean): void;
  74877. /**
  74878. * Reads a number from the data storage
  74879. * @param key The key to read
  74880. * @param defaultValue The value if the key doesn't exist
  74881. * @returns The number value
  74882. */
  74883. static ReadNumber(key: string, defaultValue: number): number;
  74884. /**
  74885. * Writes a number to the data storage
  74886. * @param key The key to write
  74887. * @param value The value to write
  74888. */
  74889. static WriteNumber(key: string, value: number): void;
  74890. }
  74891. }
  74892. declare module "babylonjs/Misc/index" {
  74893. export * from "babylonjs/Misc/andOrNotEvaluator";
  74894. export * from "babylonjs/Misc/assetsManager";
  74895. export * from "babylonjs/Misc/basis";
  74896. export * from "babylonjs/Misc/dds";
  74897. export * from "babylonjs/Misc/decorators";
  74898. export * from "babylonjs/Misc/deferred";
  74899. export * from "babylonjs/Misc/environmentTextureTools";
  74900. export * from "babylonjs/Misc/meshExploder";
  74901. export * from "babylonjs/Misc/filesInput";
  74902. export * from "babylonjs/Misc/HighDynamicRange/index";
  74903. export * from "babylonjs/Misc/khronosTextureContainer";
  74904. export * from "babylonjs/Misc/observable";
  74905. export * from "babylonjs/Misc/performanceMonitor";
  74906. export * from "babylonjs/Misc/promise";
  74907. export * from "babylonjs/Misc/sceneOptimizer";
  74908. export * from "babylonjs/Misc/sceneSerializer";
  74909. export * from "babylonjs/Misc/smartArray";
  74910. export * from "babylonjs/Misc/stringDictionary";
  74911. export * from "babylonjs/Misc/tags";
  74912. export * from "babylonjs/Misc/textureTools";
  74913. export * from "babylonjs/Misc/tga";
  74914. export * from "babylonjs/Misc/tools";
  74915. export * from "babylonjs/Misc/videoRecorder";
  74916. export * from "babylonjs/Misc/virtualJoystick";
  74917. export * from "babylonjs/Misc/workerPool";
  74918. export * from "babylonjs/Misc/logger";
  74919. export * from "babylonjs/Misc/typeStore";
  74920. export * from "babylonjs/Misc/filesInputStore";
  74921. export * from "babylonjs/Misc/deepCopier";
  74922. export * from "babylonjs/Misc/pivotTools";
  74923. export * from "babylonjs/Misc/precisionDate";
  74924. export * from "babylonjs/Misc/screenshotTools";
  74925. export * from "babylonjs/Misc/typeStore";
  74926. export * from "babylonjs/Misc/webRequest";
  74927. export * from "babylonjs/Misc/iInspectable";
  74928. export * from "babylonjs/Misc/brdfTextureTools";
  74929. export * from "babylonjs/Misc/rgbdTextureTools";
  74930. export * from "babylonjs/Misc/gradients";
  74931. export * from "babylonjs/Misc/perfCounter";
  74932. export * from "babylonjs/Misc/fileRequest";
  74933. export * from "babylonjs/Misc/customAnimationFrameRequester";
  74934. export * from "babylonjs/Misc/retryStrategy";
  74935. export * from "babylonjs/Misc/interfaces/screenshotSize";
  74936. export * from "babylonjs/Misc/canvasGenerator";
  74937. export * from "babylonjs/Misc/fileTools";
  74938. export * from "babylonjs/Misc/stringTools";
  74939. export * from "babylonjs/Misc/dataReader";
  74940. export * from "babylonjs/Misc/minMaxReducer";
  74941. export * from "babylonjs/Misc/depthReducer";
  74942. export * from "babylonjs/Misc/dataStorage";
  74943. }
  74944. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  74945. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74946. import { Observable } from "babylonjs/Misc/observable";
  74947. import { Matrix } from "babylonjs/Maths/math.vector";
  74948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74949. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74950. /**
  74951. * Options used for hit testing
  74952. */
  74953. export interface IWebXRLegacyHitTestOptions {
  74954. /**
  74955. * Only test when user interacted with the scene. Default - hit test every frame
  74956. */
  74957. testOnPointerDownOnly?: boolean;
  74958. /**
  74959. * The node to use to transform the local results to world coordinates
  74960. */
  74961. worldParentNode?: TransformNode;
  74962. }
  74963. /**
  74964. * Interface defining the babylon result of raycasting/hit-test
  74965. */
  74966. export interface IWebXRLegacyHitResult {
  74967. /**
  74968. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74969. */
  74970. transformationMatrix: Matrix;
  74971. /**
  74972. * The native hit test result
  74973. */
  74974. xrHitResult: XRHitResult | XRHitTestResult;
  74975. }
  74976. /**
  74977. * The currently-working hit-test module.
  74978. * Hit test (or Ray-casting) is used to interact with the real world.
  74979. * For further information read here - https://github.com/immersive-web/hit-test
  74980. */
  74981. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  74982. /**
  74983. * options to use when constructing this feature
  74984. */
  74985. readonly options: IWebXRLegacyHitTestOptions;
  74986. private _direction;
  74987. private _mat;
  74988. private _onSelectEnabled;
  74989. private _origin;
  74990. /**
  74991. * The module's name
  74992. */
  74993. static readonly Name: string;
  74994. /**
  74995. * The (Babylon) version of this module.
  74996. * This is an integer representing the implementation version.
  74997. * This number does not correspond to the WebXR specs version
  74998. */
  74999. static readonly Version: number;
  75000. /**
  75001. * Populated with the last native XR Hit Results
  75002. */
  75003. lastNativeXRHitResults: XRHitResult[];
  75004. /**
  75005. * Triggered when new babylon (transformed) hit test results are available
  75006. */
  75007. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75008. /**
  75009. * Creates a new instance of the (legacy version) hit test feature
  75010. * @param _xrSessionManager an instance of WebXRSessionManager
  75011. * @param options options to use when constructing this feature
  75012. */
  75013. constructor(_xrSessionManager: WebXRSessionManager,
  75014. /**
  75015. * options to use when constructing this feature
  75016. */
  75017. options?: IWebXRLegacyHitTestOptions);
  75018. /**
  75019. * execute a hit test with an XR Ray
  75020. *
  75021. * @param xrSession a native xrSession that will execute this hit test
  75022. * @param xrRay the ray (position and direction) to use for ray-casting
  75023. * @param referenceSpace native XR reference space to use for the hit-test
  75024. * @param filter filter function that will filter the results
  75025. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75026. */
  75027. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75028. /**
  75029. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75030. * @param event the (select) event to use to select with
  75031. * @param referenceSpace the reference space to use for this hit test
  75032. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75033. */
  75034. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75035. /**
  75036. * attach this feature
  75037. * Will usually be called by the features manager
  75038. *
  75039. * @returns true if successful.
  75040. */
  75041. attach(): boolean;
  75042. /**
  75043. * detach this feature.
  75044. * Will usually be called by the features manager
  75045. *
  75046. * @returns true if successful.
  75047. */
  75048. detach(): boolean;
  75049. /**
  75050. * Dispose this feature and all of the resources attached
  75051. */
  75052. dispose(): void;
  75053. protected _onXRFrame(frame: XRFrame): void;
  75054. private _onHitTestResults;
  75055. private _onSelect;
  75056. }
  75057. }
  75058. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  75059. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75060. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75061. import { Observable } from "babylonjs/Misc/observable";
  75062. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  75063. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75064. /**
  75065. * Options used in the plane detector module
  75066. */
  75067. export interface IWebXRPlaneDetectorOptions {
  75068. /**
  75069. * The node to use to transform the local results to world coordinates
  75070. */
  75071. worldParentNode?: TransformNode;
  75072. }
  75073. /**
  75074. * A babylon interface for a WebXR plane.
  75075. * A Plane is actually a polygon, built from N points in space
  75076. *
  75077. * Supported in chrome 79, not supported in canary 81 ATM
  75078. */
  75079. export interface IWebXRPlane {
  75080. /**
  75081. * a babylon-assigned ID for this polygon
  75082. */
  75083. id: number;
  75084. /**
  75085. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75086. */
  75087. polygonDefinition: Array<Vector3>;
  75088. /**
  75089. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75090. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75091. */
  75092. transformationMatrix: Matrix;
  75093. /**
  75094. * the native xr-plane object
  75095. */
  75096. xrPlane: XRPlane;
  75097. }
  75098. /**
  75099. * The plane detector is used to detect planes in the real world when in AR
  75100. * For more information see https://github.com/immersive-web/real-world-geometry/
  75101. */
  75102. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75103. private _options;
  75104. private _detectedPlanes;
  75105. private _enabled;
  75106. private _lastFrameDetected;
  75107. /**
  75108. * The module's name
  75109. */
  75110. static readonly Name: string;
  75111. /**
  75112. * The (Babylon) version of this module.
  75113. * This is an integer representing the implementation version.
  75114. * This number does not correspond to the WebXR specs version
  75115. */
  75116. static readonly Version: number;
  75117. /**
  75118. * Observers registered here will be executed when a new plane was added to the session
  75119. */
  75120. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75121. /**
  75122. * Observers registered here will be executed when a plane is no longer detected in the session
  75123. */
  75124. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75125. /**
  75126. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75127. * This can execute N times every frame
  75128. */
  75129. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75130. /**
  75131. * construct a new Plane Detector
  75132. * @param _xrSessionManager an instance of xr Session manager
  75133. * @param _options configuration to use when constructing this feature
  75134. */
  75135. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75136. /**
  75137. * Dispose this feature and all of the resources attached
  75138. */
  75139. dispose(): void;
  75140. protected _onXRFrame(frame: XRFrame): void;
  75141. private _init;
  75142. private _updatePlaneWithXRPlane;
  75143. /**
  75144. * avoiding using Array.find for global support.
  75145. * @param xrPlane the plane to find in the array
  75146. */
  75147. private findIndexInPlaneArray;
  75148. }
  75149. }
  75150. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  75151. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75152. import { Observable } from "babylonjs/Misc/observable";
  75153. import { Matrix } from "babylonjs/Maths/math.vector";
  75154. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75155. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  75156. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75157. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75158. /**
  75159. * Configuration options of the anchor system
  75160. */
  75161. export interface IWebXRAnchorSystemOptions {
  75162. /**
  75163. * Should a new anchor be added every time a select event is triggered
  75164. */
  75165. addAnchorOnSelect?: boolean;
  75166. /**
  75167. * should the anchor system use plane detection.
  75168. * If set to true, the plane-detection feature should be set using setPlaneDetector
  75169. */
  75170. usePlaneDetection?: boolean;
  75171. /**
  75172. * a node that will be used to convert local to world coordinates
  75173. */
  75174. worldParentNode?: TransformNode;
  75175. }
  75176. /**
  75177. * A babylon container for an XR Anchor
  75178. */
  75179. export interface IWebXRAnchor {
  75180. /**
  75181. * A babylon-assigned ID for this anchor
  75182. */
  75183. id: number;
  75184. /**
  75185. * Transformation matrix to apply to an object attached to this anchor
  75186. */
  75187. transformationMatrix: Matrix;
  75188. /**
  75189. * The native anchor object
  75190. */
  75191. xrAnchor: XRAnchor;
  75192. }
  75193. /**
  75194. * An implementation of the anchor system of WebXR.
  75195. * Note that the current documented implementation is not available in any browser. Future implementations
  75196. * will use the frame to create an anchor and not the session or a detected plane
  75197. * For further information see https://github.com/immersive-web/anchors/
  75198. */
  75199. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75200. private _options;
  75201. private _enabled;
  75202. private _hitTestModule;
  75203. private _lastFrameDetected;
  75204. private _onSelect;
  75205. private _planeDetector;
  75206. private _trackedAnchors;
  75207. /**
  75208. * The module's name
  75209. */
  75210. static readonly Name: string;
  75211. /**
  75212. * The (Babylon) version of this module.
  75213. * This is an integer representing the implementation version.
  75214. * This number does not correspond to the WebXR specs version
  75215. */
  75216. static readonly Version: number;
  75217. /**
  75218. * Observers registered here will be executed when a new anchor was added to the session
  75219. */
  75220. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75221. /**
  75222. * Observers registered here will be executed when an anchor was removed from the session
  75223. */
  75224. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75225. /**
  75226. * Observers registered here will be executed when an existing anchor updates
  75227. * This can execute N times every frame
  75228. */
  75229. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75230. /**
  75231. * constructs a new anchor system
  75232. * @param _xrSessionManager an instance of WebXRSessionManager
  75233. * @param _options configuration object for this feature
  75234. */
  75235. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75236. /**
  75237. * Add anchor at a specific XR point.
  75238. *
  75239. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  75240. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  75241. * @returns a promise the fulfills when the anchor was created
  75242. */
  75243. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  75244. /**
  75245. * attach this feature
  75246. * Will usually be called by the features manager
  75247. *
  75248. * @returns true if successful.
  75249. */
  75250. attach(): boolean;
  75251. /**
  75252. * detach this feature.
  75253. * Will usually be called by the features manager
  75254. *
  75255. * @returns true if successful.
  75256. */
  75257. detach(): boolean;
  75258. /**
  75259. * Dispose this feature and all of the resources attached
  75260. */
  75261. dispose(): void;
  75262. /**
  75263. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  75264. * @param hitTestModule the hit-test module to use.
  75265. */
  75266. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  75267. /**
  75268. * set the plane detector to use in order to create anchors from frames
  75269. * @param planeDetector the plane-detector module to use
  75270. * @param enable enable plane-anchors. default is true
  75271. */
  75272. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  75273. protected _onXRFrame(frame: XRFrame): void;
  75274. /**
  75275. * avoiding using Array.find for global support.
  75276. * @param xrAnchor the plane to find in the array
  75277. */
  75278. private _findIndexInAnchorArray;
  75279. private _updateAnchorWithXRFrame;
  75280. }
  75281. }
  75282. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  75283. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75285. import { Observable } from "babylonjs/Misc/observable";
  75286. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75287. /**
  75288. * Options interface for the background remover plugin
  75289. */
  75290. export interface IWebXRBackgroundRemoverOptions {
  75291. /**
  75292. * Further background meshes to disable when entering AR
  75293. */
  75294. backgroundMeshes?: AbstractMesh[];
  75295. /**
  75296. * flags to configure the removal of the environment helper.
  75297. * If not set, the entire background will be removed. If set, flags should be set as well.
  75298. */
  75299. environmentHelperRemovalFlags?: {
  75300. /**
  75301. * Should the skybox be removed (default false)
  75302. */
  75303. skyBox?: boolean;
  75304. /**
  75305. * Should the ground be removed (default false)
  75306. */
  75307. ground?: boolean;
  75308. };
  75309. /**
  75310. * don't disable the environment helper
  75311. */
  75312. ignoreEnvironmentHelper?: boolean;
  75313. }
  75314. /**
  75315. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75316. */
  75317. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75318. /**
  75319. * read-only options to be used in this module
  75320. */
  75321. readonly options: IWebXRBackgroundRemoverOptions;
  75322. /**
  75323. * The module's name
  75324. */
  75325. static readonly Name: string;
  75326. /**
  75327. * The (Babylon) version of this module.
  75328. * This is an integer representing the implementation version.
  75329. * This number does not correspond to the WebXR specs version
  75330. */
  75331. static readonly Version: number;
  75332. /**
  75333. * registered observers will be triggered when the background state changes
  75334. */
  75335. onBackgroundStateChangedObservable: Observable<boolean>;
  75336. /**
  75337. * constructs a new background remover module
  75338. * @param _xrSessionManager the session manager for this module
  75339. * @param options read-only options to be used in this module
  75340. */
  75341. constructor(_xrSessionManager: WebXRSessionManager,
  75342. /**
  75343. * read-only options to be used in this module
  75344. */
  75345. options?: IWebXRBackgroundRemoverOptions);
  75346. /**
  75347. * attach this feature
  75348. * Will usually be called by the features manager
  75349. *
  75350. * @returns true if successful.
  75351. */
  75352. attach(): boolean;
  75353. /**
  75354. * detach this feature.
  75355. * Will usually be called by the features manager
  75356. *
  75357. * @returns true if successful.
  75358. */
  75359. detach(): boolean;
  75360. /**
  75361. * Dispose this feature and all of the resources attached
  75362. */
  75363. dispose(): void;
  75364. protected _onXRFrame(_xrFrame: XRFrame): void;
  75365. private _setBackgroundState;
  75366. }
  75367. }
  75368. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  75369. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75370. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  75371. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  75372. import { WebXRInput } from "babylonjs/XR/webXRInput";
  75373. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75374. import { Nullable } from "babylonjs/types";
  75375. /**
  75376. * Options for the controller physics feature
  75377. */
  75378. export class IWebXRControllerPhysicsOptions {
  75379. /**
  75380. * Should the headset get its own impostor
  75381. */
  75382. enableHeadsetImpostor?: boolean;
  75383. /**
  75384. * Optional parameters for the headset impostor
  75385. */
  75386. headsetImpostorParams?: {
  75387. /**
  75388. * The type of impostor to create. Default is sphere
  75389. */
  75390. impostorType: number;
  75391. /**
  75392. * the size of the impostor. Defaults to 10cm
  75393. */
  75394. impostorSize?: number | {
  75395. width: number;
  75396. height: number;
  75397. depth: number;
  75398. };
  75399. /**
  75400. * Friction definitions
  75401. */
  75402. friction?: number;
  75403. /**
  75404. * Restitution
  75405. */
  75406. restitution?: number;
  75407. };
  75408. /**
  75409. * The physics properties of the future impostors
  75410. */
  75411. physicsProperties?: {
  75412. /**
  75413. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75414. * Note that this requires a physics engine that supports mesh impostors!
  75415. */
  75416. useControllerMesh?: boolean;
  75417. /**
  75418. * The type of impostor to create. Default is sphere
  75419. */
  75420. impostorType?: number;
  75421. /**
  75422. * the size of the impostor. Defaults to 10cm
  75423. */
  75424. impostorSize?: number | {
  75425. width: number;
  75426. height: number;
  75427. depth: number;
  75428. };
  75429. /**
  75430. * Friction definitions
  75431. */
  75432. friction?: number;
  75433. /**
  75434. * Restitution
  75435. */
  75436. restitution?: number;
  75437. };
  75438. /**
  75439. * the xr input to use with this pointer selection
  75440. */
  75441. xrInput: WebXRInput;
  75442. }
  75443. /**
  75444. * Add physics impostor to your webxr controllers,
  75445. * including naive calculation of their linear and angular velocity
  75446. */
  75447. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75448. private readonly _options;
  75449. private _attachController;
  75450. private _controllers;
  75451. private _debugMode;
  75452. private _delta;
  75453. private _headsetImpostor?;
  75454. private _headsetMesh?;
  75455. private _lastTimestamp;
  75456. private _tmpQuaternion;
  75457. private _tmpVector;
  75458. /**
  75459. * The module's name
  75460. */
  75461. static readonly Name: string;
  75462. /**
  75463. * The (Babylon) version of this module.
  75464. * This is an integer representing the implementation version.
  75465. * This number does not correspond to the webxr specs version
  75466. */
  75467. static readonly Version: number;
  75468. /**
  75469. * Construct a new Controller Physics Feature
  75470. * @param _xrSessionManager the corresponding xr session manager
  75471. * @param _options options to create this feature with
  75472. */
  75473. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75474. /**
  75475. * @hidden
  75476. * enable debugging - will show console outputs and the impostor mesh
  75477. */
  75478. _enablePhysicsDebug(): void;
  75479. /**
  75480. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75481. * @param xrController the controller to add
  75482. */
  75483. addController(xrController: WebXRInputSource): void;
  75484. /**
  75485. * attach this feature
  75486. * Will usually be called by the features manager
  75487. *
  75488. * @returns true if successful.
  75489. */
  75490. attach(): boolean;
  75491. /**
  75492. * detach this feature.
  75493. * Will usually be called by the features manager
  75494. *
  75495. * @returns true if successful.
  75496. */
  75497. detach(): boolean;
  75498. /**
  75499. * Get the headset impostor, if enabled
  75500. * @returns the impostor
  75501. */
  75502. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75503. /**
  75504. * Get the physics impostor of a specific controller.
  75505. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75506. * @param controller the controller or the controller id of which to get the impostor
  75507. * @returns the impostor or null
  75508. */
  75509. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75510. /**
  75511. * Update the physics properties provided in the constructor
  75512. * @param newProperties the new properties object
  75513. */
  75514. setPhysicsProperties(newProperties: {
  75515. impostorType?: number;
  75516. impostorSize?: number | {
  75517. width: number;
  75518. height: number;
  75519. depth: number;
  75520. };
  75521. friction?: number;
  75522. restitution?: number;
  75523. }): void;
  75524. protected _onXRFrame(_xrFrame: any): void;
  75525. private _detachController;
  75526. }
  75527. }
  75528. declare module "babylonjs/XR/features/WebXRHitTest" {
  75529. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75530. import { Observable } from "babylonjs/Misc/observable";
  75531. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  75532. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75533. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75534. /**
  75535. * Options used for hit testing (version 2)
  75536. */
  75537. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75538. /**
  75539. * Do not create a permanent hit test. Will usually be used when only
  75540. * transient inputs are needed.
  75541. */
  75542. disablePermanentHitTest?: boolean;
  75543. /**
  75544. * Enable transient (for example touch-based) hit test inspections
  75545. */
  75546. enableTransientHitTest?: boolean;
  75547. /**
  75548. * Offset ray for the permanent hit test
  75549. */
  75550. offsetRay?: Vector3;
  75551. /**
  75552. * Offset ray for the transient hit test
  75553. */
  75554. transientOffsetRay?: Vector3;
  75555. /**
  75556. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75557. */
  75558. useReferenceSpace?: boolean;
  75559. }
  75560. /**
  75561. * Interface defining the babylon result of hit-test
  75562. */
  75563. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75564. /**
  75565. * The input source that generated this hit test (if transient)
  75566. */
  75567. inputSource?: XRInputSource;
  75568. /**
  75569. * Is this a transient hit test
  75570. */
  75571. isTransient?: boolean;
  75572. /**
  75573. * Position of the hit test result
  75574. */
  75575. position: Vector3;
  75576. /**
  75577. * Rotation of the hit test result
  75578. */
  75579. rotationQuaternion: Quaternion;
  75580. }
  75581. /**
  75582. * The currently-working hit-test module.
  75583. * Hit test (or Ray-casting) is used to interact with the real world.
  75584. * For further information read here - https://github.com/immersive-web/hit-test
  75585. *
  75586. * Tested on chrome (mobile) 80.
  75587. */
  75588. export class WebXRHitTest extends WebXRAbstractFeature {
  75589. /**
  75590. * options to use when constructing this feature
  75591. */
  75592. readonly options: IWebXRHitTestOptions;
  75593. private _tmpMat;
  75594. private _tmpPos;
  75595. private _tmpQuat;
  75596. private _transientXrHitTestSource;
  75597. private _xrHitTestSource;
  75598. private initHitTestSource;
  75599. /**
  75600. * The module's name
  75601. */
  75602. static readonly Name: string;
  75603. /**
  75604. * The (Babylon) version of this module.
  75605. * This is an integer representing the implementation version.
  75606. * This number does not correspond to the WebXR specs version
  75607. */
  75608. static readonly Version: number;
  75609. /**
  75610. * When set to true, each hit test will have its own position/rotation objects
  75611. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75612. * the developers will clone them or copy them as they see fit.
  75613. */
  75614. autoCloneTransformation: boolean;
  75615. /**
  75616. * Populated with the last native XR Hit Results
  75617. */
  75618. lastNativeXRHitResults: XRHitResult[];
  75619. /**
  75620. * Triggered when new babylon (transformed) hit test results are available
  75621. */
  75622. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75623. /**
  75624. * Use this to temporarily pause hit test checks.
  75625. */
  75626. paused: boolean;
  75627. /**
  75628. * Creates a new instance of the hit test feature
  75629. * @param _xrSessionManager an instance of WebXRSessionManager
  75630. * @param options options to use when constructing this feature
  75631. */
  75632. constructor(_xrSessionManager: WebXRSessionManager,
  75633. /**
  75634. * options to use when constructing this feature
  75635. */
  75636. options?: IWebXRHitTestOptions);
  75637. /**
  75638. * attach this feature
  75639. * Will usually be called by the features manager
  75640. *
  75641. * @returns true if successful.
  75642. */
  75643. attach(): boolean;
  75644. /**
  75645. * detach this feature.
  75646. * Will usually be called by the features manager
  75647. *
  75648. * @returns true if successful.
  75649. */
  75650. detach(): boolean;
  75651. /**
  75652. * Dispose this feature and all of the resources attached
  75653. */
  75654. dispose(): void;
  75655. protected _onXRFrame(frame: XRFrame): void;
  75656. private _processWebXRHitTestResult;
  75657. }
  75658. }
  75659. declare module "babylonjs/XR/features/index" {
  75660. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  75661. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  75662. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  75663. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  75664. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  75665. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  75666. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  75667. export * from "babylonjs/XR/features/WebXRHitTest";
  75668. }
  75669. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  75670. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75672. import { Scene } from "babylonjs/scene";
  75673. /**
  75674. * The motion controller class for all microsoft mixed reality controllers
  75675. */
  75676. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75677. protected readonly _mapping: {
  75678. defaultButton: {
  75679. valueNodeName: string;
  75680. unpressedNodeName: string;
  75681. pressedNodeName: string;
  75682. };
  75683. defaultAxis: {
  75684. valueNodeName: string;
  75685. minNodeName: string;
  75686. maxNodeName: string;
  75687. };
  75688. buttons: {
  75689. "xr-standard-trigger": {
  75690. rootNodeName: string;
  75691. componentProperty: string;
  75692. states: string[];
  75693. };
  75694. "xr-standard-squeeze": {
  75695. rootNodeName: string;
  75696. componentProperty: string;
  75697. states: string[];
  75698. };
  75699. "xr-standard-touchpad": {
  75700. rootNodeName: string;
  75701. labelAnchorNodeName: string;
  75702. touchPointNodeName: string;
  75703. };
  75704. "xr-standard-thumbstick": {
  75705. rootNodeName: string;
  75706. componentProperty: string;
  75707. states: string[];
  75708. };
  75709. };
  75710. axes: {
  75711. "xr-standard-touchpad": {
  75712. "x-axis": {
  75713. rootNodeName: string;
  75714. };
  75715. "y-axis": {
  75716. rootNodeName: string;
  75717. };
  75718. };
  75719. "xr-standard-thumbstick": {
  75720. "x-axis": {
  75721. rootNodeName: string;
  75722. };
  75723. "y-axis": {
  75724. rootNodeName: string;
  75725. };
  75726. };
  75727. };
  75728. };
  75729. /**
  75730. * The base url used to load the left and right controller models
  75731. */
  75732. static MODEL_BASE_URL: string;
  75733. /**
  75734. * The name of the left controller model file
  75735. */
  75736. static MODEL_LEFT_FILENAME: string;
  75737. /**
  75738. * The name of the right controller model file
  75739. */
  75740. static MODEL_RIGHT_FILENAME: string;
  75741. profileId: string;
  75742. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75743. protected _getFilenameAndPath(): {
  75744. filename: string;
  75745. path: string;
  75746. };
  75747. protected _getModelLoadingConstraints(): boolean;
  75748. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75749. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75750. protected _updateModel(): void;
  75751. }
  75752. }
  75753. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  75754. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75756. import { Scene } from "babylonjs/scene";
  75757. /**
  75758. * The motion controller class for oculus touch (quest, rift).
  75759. * This class supports legacy mapping as well the standard xr mapping
  75760. */
  75761. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75762. private _forceLegacyControllers;
  75763. private _modelRootNode;
  75764. /**
  75765. * The base url used to load the left and right controller models
  75766. */
  75767. static MODEL_BASE_URL: string;
  75768. /**
  75769. * The name of the left controller model file
  75770. */
  75771. static MODEL_LEFT_FILENAME: string;
  75772. /**
  75773. * The name of the right controller model file
  75774. */
  75775. static MODEL_RIGHT_FILENAME: string;
  75776. /**
  75777. * Base Url for the Quest controller model.
  75778. */
  75779. static QUEST_MODEL_BASE_URL: string;
  75780. profileId: string;
  75781. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75782. protected _getFilenameAndPath(): {
  75783. filename: string;
  75784. path: string;
  75785. };
  75786. protected _getModelLoadingConstraints(): boolean;
  75787. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75788. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75789. protected _updateModel(): void;
  75790. /**
  75791. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75792. * between the touch and touch 2.
  75793. */
  75794. private _isQuest;
  75795. }
  75796. }
  75797. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  75798. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75799. import { Scene } from "babylonjs/scene";
  75800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75801. /**
  75802. * The motion controller class for the standard HTC-Vive controllers
  75803. */
  75804. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75805. private _modelRootNode;
  75806. /**
  75807. * The base url used to load the left and right controller models
  75808. */
  75809. static MODEL_BASE_URL: string;
  75810. /**
  75811. * File name for the controller model.
  75812. */
  75813. static MODEL_FILENAME: string;
  75814. profileId: string;
  75815. /**
  75816. * Create a new Vive motion controller object
  75817. * @param scene the scene to use to create this controller
  75818. * @param gamepadObject the corresponding gamepad object
  75819. * @param handedness the handedness of the controller
  75820. */
  75821. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75822. protected _getFilenameAndPath(): {
  75823. filename: string;
  75824. path: string;
  75825. };
  75826. protected _getModelLoadingConstraints(): boolean;
  75827. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75828. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75829. protected _updateModel(): void;
  75830. }
  75831. }
  75832. declare module "babylonjs/XR/motionController/index" {
  75833. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75834. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  75835. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  75836. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  75837. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  75838. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  75839. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  75840. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  75841. }
  75842. declare module "babylonjs/XR/index" {
  75843. export * from "babylonjs/XR/webXRCamera";
  75844. export * from "babylonjs/XR/webXREnterExitUI";
  75845. export * from "babylonjs/XR/webXRExperienceHelper";
  75846. export * from "babylonjs/XR/webXRInput";
  75847. export * from "babylonjs/XR/webXRInputSource";
  75848. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  75849. export * from "babylonjs/XR/webXRTypes";
  75850. export * from "babylonjs/XR/webXRSessionManager";
  75851. export * from "babylonjs/XR/webXRDefaultExperience";
  75852. export * from "babylonjs/XR/webXRFeaturesManager";
  75853. export * from "babylonjs/XR/features/index";
  75854. export * from "babylonjs/XR/motionController/index";
  75855. }
  75856. declare module "babylonjs/index" {
  75857. export * from "babylonjs/abstractScene";
  75858. export * from "babylonjs/Actions/index";
  75859. export * from "babylonjs/Animations/index";
  75860. export * from "babylonjs/assetContainer";
  75861. export * from "babylonjs/Audio/index";
  75862. export * from "babylonjs/Behaviors/index";
  75863. export * from "babylonjs/Bones/index";
  75864. export * from "babylonjs/Cameras/index";
  75865. export * from "babylonjs/Collisions/index";
  75866. export * from "babylonjs/Culling/index";
  75867. export * from "babylonjs/Debug/index";
  75868. export * from "babylonjs/DeviceInput/index";
  75869. export * from "babylonjs/Engines/index";
  75870. export * from "babylonjs/Events/index";
  75871. export * from "babylonjs/Gamepads/index";
  75872. export * from "babylonjs/Gizmos/index";
  75873. export * from "babylonjs/Helpers/index";
  75874. export * from "babylonjs/Instrumentation/index";
  75875. export * from "babylonjs/Layers/index";
  75876. export * from "babylonjs/LensFlares/index";
  75877. export * from "babylonjs/Lights/index";
  75878. export * from "babylonjs/Loading/index";
  75879. export * from "babylonjs/Materials/index";
  75880. export * from "babylonjs/Maths/index";
  75881. export * from "babylonjs/Meshes/index";
  75882. export * from "babylonjs/Morph/index";
  75883. export * from "babylonjs/Navigation/index";
  75884. export * from "babylonjs/node";
  75885. export * from "babylonjs/Offline/index";
  75886. export * from "babylonjs/Particles/index";
  75887. export * from "babylonjs/Physics/index";
  75888. export * from "babylonjs/PostProcesses/index";
  75889. export * from "babylonjs/Probes/index";
  75890. export * from "babylonjs/Rendering/index";
  75891. export * from "babylonjs/scene";
  75892. export * from "babylonjs/sceneComponent";
  75893. export * from "babylonjs/Sprites/index";
  75894. export * from "babylonjs/States/index";
  75895. export * from "babylonjs/Misc/index";
  75896. export * from "babylonjs/XR/index";
  75897. export * from "babylonjs/types";
  75898. }
  75899. declare module "babylonjs/Animations/pathCursor" {
  75900. import { Vector3 } from "babylonjs/Maths/math.vector";
  75901. import { Path2 } from "babylonjs/Maths/math.path";
  75902. /**
  75903. * A cursor which tracks a point on a path
  75904. */
  75905. export class PathCursor {
  75906. private path;
  75907. /**
  75908. * Stores path cursor callbacks for when an onchange event is triggered
  75909. */
  75910. private _onchange;
  75911. /**
  75912. * The value of the path cursor
  75913. */
  75914. value: number;
  75915. /**
  75916. * The animation array of the path cursor
  75917. */
  75918. animations: Animation[];
  75919. /**
  75920. * Initializes the path cursor
  75921. * @param path The path to track
  75922. */
  75923. constructor(path: Path2);
  75924. /**
  75925. * Gets the cursor point on the path
  75926. * @returns A point on the path cursor at the cursor location
  75927. */
  75928. getPoint(): Vector3;
  75929. /**
  75930. * Moves the cursor ahead by the step amount
  75931. * @param step The amount to move the cursor forward
  75932. * @returns This path cursor
  75933. */
  75934. moveAhead(step?: number): PathCursor;
  75935. /**
  75936. * Moves the cursor behind by the step amount
  75937. * @param step The amount to move the cursor back
  75938. * @returns This path cursor
  75939. */
  75940. moveBack(step?: number): PathCursor;
  75941. /**
  75942. * Moves the cursor by the step amount
  75943. * If the step amount is greater than one, an exception is thrown
  75944. * @param step The amount to move the cursor
  75945. * @returns This path cursor
  75946. */
  75947. move(step: number): PathCursor;
  75948. /**
  75949. * Ensures that the value is limited between zero and one
  75950. * @returns This path cursor
  75951. */
  75952. private ensureLimits;
  75953. /**
  75954. * Runs onchange callbacks on change (used by the animation engine)
  75955. * @returns This path cursor
  75956. */
  75957. private raiseOnChange;
  75958. /**
  75959. * Executes a function on change
  75960. * @param f A path cursor onchange callback
  75961. * @returns This path cursor
  75962. */
  75963. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75964. }
  75965. }
  75966. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  75967. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  75968. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  75969. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  75970. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  75971. }
  75972. declare module "babylonjs/Engines/Processors/Expressions/index" {
  75973. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  75974. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  75975. }
  75976. declare module "babylonjs/Engines/Processors/index" {
  75977. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  75978. export * from "babylonjs/Engines/Processors/Expressions/index";
  75979. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  75980. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  75981. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  75982. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  75983. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  75984. export * from "babylonjs/Engines/Processors/shaderProcessor";
  75985. }
  75986. declare module "babylonjs/Legacy/legacy" {
  75987. import * as Babylon from "babylonjs/index";
  75988. export * from "babylonjs/index";
  75989. }
  75990. declare module "babylonjs/Shaders/blur.fragment" {
  75991. /** @hidden */
  75992. export var blurPixelShader: {
  75993. name: string;
  75994. shader: string;
  75995. };
  75996. }
  75997. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  75998. /** @hidden */
  75999. export var pointCloudVertexDeclaration: {
  76000. name: string;
  76001. shader: string;
  76002. };
  76003. }
  76004. declare module "babylonjs" {
  76005. export * from "babylonjs/Legacy/legacy";
  76006. }
  76007. declare module BABYLON {
  76008. /** Alias type for value that can be null */
  76009. export type Nullable<T> = T | null;
  76010. /**
  76011. * Alias type for number that are floats
  76012. * @ignorenaming
  76013. */
  76014. export type float = number;
  76015. /**
  76016. * Alias type for number that are doubles.
  76017. * @ignorenaming
  76018. */
  76019. export type double = number;
  76020. /**
  76021. * Alias type for number that are integer
  76022. * @ignorenaming
  76023. */
  76024. export type int = number;
  76025. /** Alias type for number array or Float32Array */
  76026. export type FloatArray = number[] | Float32Array;
  76027. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  76028. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  76029. /**
  76030. * Alias for types that can be used by a Buffer or VertexBuffer.
  76031. */
  76032. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  76033. /**
  76034. * Alias type for primitive types
  76035. * @ignorenaming
  76036. */
  76037. type Primitive = undefined | null | boolean | string | number | Function;
  76038. /**
  76039. * Type modifier to make all the properties of an object Readonly
  76040. */
  76041. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  76042. /**
  76043. * Type modifier to make all the properties of an object Readonly recursively
  76044. */
  76045. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  76046. /**
  76047. * Type modifier to make object properties readonly.
  76048. */
  76049. export type DeepImmutableObject<T> = {
  76050. readonly [K in keyof T]: DeepImmutable<T[K]>;
  76051. };
  76052. /** @hidden */
  76053. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  76054. }
  76055. }
  76056. declare module BABYLON {
  76057. /**
  76058. * A class serves as a medium between the observable and its observers
  76059. */
  76060. export class EventState {
  76061. /**
  76062. * Create a new EventState
  76063. * @param mask defines the mask associated with this state
  76064. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76065. * @param target defines the original target of the state
  76066. * @param currentTarget defines the current target of the state
  76067. */
  76068. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  76069. /**
  76070. * Initialize the current event state
  76071. * @param mask defines the mask associated with this state
  76072. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76073. * @param target defines the original target of the state
  76074. * @param currentTarget defines the current target of the state
  76075. * @returns the current event state
  76076. */
  76077. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  76078. /**
  76079. * An Observer can set this property to true to prevent subsequent observers of being notified
  76080. */
  76081. skipNextObservers: boolean;
  76082. /**
  76083. * Get the mask value that were used to trigger the event corresponding to this EventState object
  76084. */
  76085. mask: number;
  76086. /**
  76087. * The object that originally notified the event
  76088. */
  76089. target?: any;
  76090. /**
  76091. * The current object in the bubbling phase
  76092. */
  76093. currentTarget?: any;
  76094. /**
  76095. * This will be populated with the return value of the last function that was executed.
  76096. * If it is the first function in the callback chain it will be the event data.
  76097. */
  76098. lastReturnValue?: any;
  76099. }
  76100. /**
  76101. * Represent an Observer registered to a given Observable object.
  76102. */
  76103. export class Observer<T> {
  76104. /**
  76105. * Defines the callback to call when the observer is notified
  76106. */
  76107. callback: (eventData: T, eventState: EventState) => void;
  76108. /**
  76109. * Defines the mask of the observer (used to filter notifications)
  76110. */
  76111. mask: number;
  76112. /**
  76113. * Defines the current scope used to restore the JS context
  76114. */
  76115. scope: any;
  76116. /** @hidden */
  76117. _willBeUnregistered: boolean;
  76118. /**
  76119. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  76120. */
  76121. unregisterOnNextCall: boolean;
  76122. /**
  76123. * Creates a new observer
  76124. * @param callback defines the callback to call when the observer is notified
  76125. * @param mask defines the mask of the observer (used to filter notifications)
  76126. * @param scope defines the current scope used to restore the JS context
  76127. */
  76128. constructor(
  76129. /**
  76130. * Defines the callback to call when the observer is notified
  76131. */
  76132. callback: (eventData: T, eventState: EventState) => void,
  76133. /**
  76134. * Defines the mask of the observer (used to filter notifications)
  76135. */
  76136. mask: number,
  76137. /**
  76138. * Defines the current scope used to restore the JS context
  76139. */
  76140. scope?: any);
  76141. }
  76142. /**
  76143. * Represent a list of observers registered to multiple Observables object.
  76144. */
  76145. export class MultiObserver<T> {
  76146. private _observers;
  76147. private _observables;
  76148. /**
  76149. * Release associated resources
  76150. */
  76151. dispose(): void;
  76152. /**
  76153. * Raise a callback when one of the observable will notify
  76154. * @param observables defines a list of observables to watch
  76155. * @param callback defines the callback to call on notification
  76156. * @param mask defines the mask used to filter notifications
  76157. * @param scope defines the current scope used to restore the JS context
  76158. * @returns the new MultiObserver
  76159. */
  76160. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  76161. }
  76162. /**
  76163. * The Observable class is a simple implementation of the Observable pattern.
  76164. *
  76165. * 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.
  76166. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  76167. * 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).
  76168. * 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.
  76169. */
  76170. export class Observable<T> {
  76171. private _observers;
  76172. private _eventState;
  76173. private _onObserverAdded;
  76174. /**
  76175. * Gets the list of observers
  76176. */
  76177. get observers(): Array<Observer<T>>;
  76178. /**
  76179. * Creates a new observable
  76180. * @param onObserverAdded defines a callback to call when a new observer is added
  76181. */
  76182. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  76183. /**
  76184. * Create a new Observer with the specified callback
  76185. * @param callback the callback that will be executed for that Observer
  76186. * @param mask the mask used to filter observers
  76187. * @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.
  76188. * @param scope optional scope for the callback to be called from
  76189. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  76190. * @returns the new observer created for the callback
  76191. */
  76192. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  76193. /**
  76194. * Create a new Observer with the specified callback and unregisters after the next notification
  76195. * @param callback the callback that will be executed for that Observer
  76196. * @returns the new observer created for the callback
  76197. */
  76198. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  76199. /**
  76200. * Remove an Observer from the Observable object
  76201. * @param observer the instance of the Observer to remove
  76202. * @returns false if it doesn't belong to this Observable
  76203. */
  76204. remove(observer: Nullable<Observer<T>>): boolean;
  76205. /**
  76206. * Remove a callback from the Observable object
  76207. * @param callback the callback to remove
  76208. * @param scope optional scope. If used only the callbacks with this scope will be removed
  76209. * @returns false if it doesn't belong to this Observable
  76210. */
  76211. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  76212. private _deferUnregister;
  76213. private _remove;
  76214. /**
  76215. * Moves the observable to the top of the observer list making it get called first when notified
  76216. * @param observer the observer to move
  76217. */
  76218. makeObserverTopPriority(observer: Observer<T>): void;
  76219. /**
  76220. * Moves the observable to the bottom of the observer list making it get called last when notified
  76221. * @param observer the observer to move
  76222. */
  76223. makeObserverBottomPriority(observer: Observer<T>): void;
  76224. /**
  76225. * Notify all Observers by calling their respective callback with the given data
  76226. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  76227. * @param eventData defines the data to send to all observers
  76228. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  76229. * @param target defines the original target of the state
  76230. * @param currentTarget defines the current target of the state
  76231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  76232. */
  76233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  76234. /**
  76235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  76236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  76237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  76238. * and it is crucial that all callbacks will be executed.
  76239. * The order of the callbacks is kept, callbacks are not executed parallel.
  76240. *
  76241. * @param eventData The data to be sent to each callback
  76242. * @param mask is used to filter observers defaults to -1
  76243. * @param target defines the callback target (see EventState)
  76244. * @param currentTarget defines he current object in the bubbling phase
  76245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  76246. */
  76247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  76248. /**
  76249. * Notify a specific observer
  76250. * @param observer defines the observer to notify
  76251. * @param eventData defines the data to be sent to each callback
  76252. * @param mask is used to filter observers defaults to -1
  76253. */
  76254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  76255. /**
  76256. * Gets a boolean indicating if the observable has at least one observer
  76257. * @returns true is the Observable has at least one Observer registered
  76258. */
  76259. hasObservers(): boolean;
  76260. /**
  76261. * Clear the list of observers
  76262. */
  76263. clear(): void;
  76264. /**
  76265. * Clone the current observable
  76266. * @returns a new observable
  76267. */
  76268. clone(): Observable<T>;
  76269. /**
  76270. * Does this observable handles observer registered with a given mask
  76271. * @param mask defines the mask to be tested
  76272. * @return whether or not one observer registered with the given mask is handeled
  76273. **/
  76274. hasSpecificMask(mask?: number): boolean;
  76275. }
  76276. }
  76277. declare module BABYLON {
  76278. /**
  76279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  76280. * Babylon.js
  76281. */
  76282. export class DomManagement {
  76283. /**
  76284. * Checks if the window object exists
  76285. * @returns true if the window object exists
  76286. */
  76287. static IsWindowObjectExist(): boolean;
  76288. /**
  76289. * Checks if the navigator object exists
  76290. * @returns true if the navigator object exists
  76291. */
  76292. static IsNavigatorAvailable(): boolean;
  76293. /**
  76294. * Check if the document object exists
  76295. * @returns true if the document object exists
  76296. */
  76297. static IsDocumentAvailable(): boolean;
  76298. /**
  76299. * Extracts text content from a DOM element hierarchy
  76300. * @param element defines the root element
  76301. * @returns a string
  76302. */
  76303. static GetDOMTextContent(element: HTMLElement): string;
  76304. }
  76305. }
  76306. declare module BABYLON {
  76307. /**
  76308. * Logger used througouht the application to allow configuration of
  76309. * the log level required for the messages.
  76310. */
  76311. export class Logger {
  76312. /**
  76313. * No log
  76314. */
  76315. static readonly NoneLogLevel: number;
  76316. /**
  76317. * Only message logs
  76318. */
  76319. static readonly MessageLogLevel: number;
  76320. /**
  76321. * Only warning logs
  76322. */
  76323. static readonly WarningLogLevel: number;
  76324. /**
  76325. * Only error logs
  76326. */
  76327. static readonly ErrorLogLevel: number;
  76328. /**
  76329. * All logs
  76330. */
  76331. static readonly AllLogLevel: number;
  76332. private static _LogCache;
  76333. /**
  76334. * Gets a value indicating the number of loading errors
  76335. * @ignorenaming
  76336. */
  76337. static errorsCount: number;
  76338. /**
  76339. * Callback called when a new log is added
  76340. */
  76341. static OnNewCacheEntry: (entry: string) => void;
  76342. private static _AddLogEntry;
  76343. private static _FormatMessage;
  76344. private static _LogDisabled;
  76345. private static _LogEnabled;
  76346. private static _WarnDisabled;
  76347. private static _WarnEnabled;
  76348. private static _ErrorDisabled;
  76349. private static _ErrorEnabled;
  76350. /**
  76351. * Log a message to the console
  76352. */
  76353. static Log: (message: string) => void;
  76354. /**
  76355. * Write a warning message to the console
  76356. */
  76357. static Warn: (message: string) => void;
  76358. /**
  76359. * Write an error message to the console
  76360. */
  76361. static Error: (message: string) => void;
  76362. /**
  76363. * Gets current log cache (list of logs)
  76364. */
  76365. static get LogCache(): string;
  76366. /**
  76367. * Clears the log cache
  76368. */
  76369. static ClearLogCache(): void;
  76370. /**
  76371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  76372. */
  76373. static set LogLevels(level: number);
  76374. }
  76375. }
  76376. declare module BABYLON {
  76377. /** @hidden */
  76378. export class _TypeStore {
  76379. /** @hidden */
  76380. static RegisteredTypes: {
  76381. [key: string]: Object;
  76382. };
  76383. /** @hidden */
  76384. static GetClass(fqdn: string): any;
  76385. }
  76386. }
  76387. declare module BABYLON {
  76388. /**
  76389. * Helper to manipulate strings
  76390. */
  76391. export class StringTools {
  76392. /**
  76393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  76394. * @param str Source string
  76395. * @param suffix Suffix to search for in the source string
  76396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76397. */
  76398. static EndsWith(str: string, suffix: string): boolean;
  76399. /**
  76400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  76401. * @param str Source string
  76402. * @param suffix Suffix to search for in the source string
  76403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76404. */
  76405. static StartsWith(str: string, suffix: string): boolean;
  76406. /**
  76407. * Decodes a buffer into a string
  76408. * @param buffer The buffer to decode
  76409. * @returns The decoded string
  76410. */
  76411. static Decode(buffer: Uint8Array | Uint16Array): string;
  76412. /**
  76413. * Encode a buffer to a base64 string
  76414. * @param buffer defines the buffer to encode
  76415. * @returns the encoded string
  76416. */
  76417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  76418. /**
  76419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  76420. * @param num the number to convert and pad
  76421. * @param length the expected length of the string
  76422. * @returns the padded string
  76423. */
  76424. static PadNumber(num: number, length: number): string;
  76425. }
  76426. }
  76427. declare module BABYLON {
  76428. /**
  76429. * Class containing a set of static utilities functions for deep copy.
  76430. */
  76431. export class DeepCopier {
  76432. /**
  76433. * Tries to copy an object by duplicating every property
  76434. * @param source defines the source object
  76435. * @param destination defines the target object
  76436. * @param doNotCopyList defines a list of properties to avoid
  76437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  76438. */
  76439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  76440. }
  76441. }
  76442. declare module BABYLON {
  76443. /**
  76444. * Class containing a set of static utilities functions for precision date
  76445. */
  76446. export class PrecisionDate {
  76447. /**
  76448. * Gets either window.performance.now() if supported or Date.now() else
  76449. */
  76450. static get Now(): number;
  76451. }
  76452. }
  76453. declare module BABYLON {
  76454. /** @hidden */
  76455. export class _DevTools {
  76456. static WarnImport(name: string): string;
  76457. }
  76458. }
  76459. declare module BABYLON {
  76460. /**
  76461. * Interface used to define the mechanism to get data from the network
  76462. */
  76463. export interface IWebRequest {
  76464. /**
  76465. * Returns client's response url
  76466. */
  76467. responseURL: string;
  76468. /**
  76469. * Returns client's status
  76470. */
  76471. status: number;
  76472. /**
  76473. * Returns client's status as a text
  76474. */
  76475. statusText: string;
  76476. }
  76477. }
  76478. declare module BABYLON {
  76479. /**
  76480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  76481. */
  76482. export class WebRequest implements IWebRequest {
  76483. private _xhr;
  76484. /**
  76485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  76486. * i.e. when loading files, where the server/service expects an Authorization header
  76487. */
  76488. static CustomRequestHeaders: {
  76489. [key: string]: string;
  76490. };
  76491. /**
  76492. * Add callback functions in this array to update all the requests before they get sent to the network
  76493. */
  76494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  76495. private _injectCustomRequestHeaders;
  76496. /**
  76497. * Gets or sets a function to be called when loading progress changes
  76498. */
  76499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  76500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  76501. /**
  76502. * Returns client's state
  76503. */
  76504. get readyState(): number;
  76505. /**
  76506. * Returns client's status
  76507. */
  76508. get status(): number;
  76509. /**
  76510. * Returns client's status as a text
  76511. */
  76512. get statusText(): string;
  76513. /**
  76514. * Returns client's response
  76515. */
  76516. get response(): any;
  76517. /**
  76518. * Returns client's response url
  76519. */
  76520. get responseURL(): string;
  76521. /**
  76522. * Returns client's response as text
  76523. */
  76524. get responseText(): string;
  76525. /**
  76526. * Gets or sets the expected response type
  76527. */
  76528. get responseType(): XMLHttpRequestResponseType;
  76529. set responseType(value: XMLHttpRequestResponseType);
  76530. /** @hidden */
  76531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  76532. /** @hidden */
  76533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  76534. /**
  76535. * Cancels any network activity
  76536. */
  76537. abort(): void;
  76538. /**
  76539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  76540. * @param body defines an optional request body
  76541. */
  76542. send(body?: Document | BodyInit | null): void;
  76543. /**
  76544. * Sets the request method, request URL
  76545. * @param method defines the method to use (GET, POST, etc..)
  76546. * @param url defines the url to connect with
  76547. */
  76548. open(method: string, url: string): void;
  76549. /**
  76550. * Sets the value of a request header.
  76551. * @param name The name of the header whose value is to be set
  76552. * @param value The value to set as the body of the header
  76553. */
  76554. setRequestHeader(name: string, value: string): void;
  76555. /**
  76556. * Get the string containing the text of a particular header's value.
  76557. * @param name The name of the header
  76558. * @returns The string containing the text of the given header name
  76559. */
  76560. getResponseHeader(name: string): Nullable<string>;
  76561. }
  76562. }
  76563. declare module BABYLON {
  76564. /**
  76565. * File request interface
  76566. */
  76567. export interface IFileRequest {
  76568. /**
  76569. * Raised when the request is complete (success or error).
  76570. */
  76571. onCompleteObservable: Observable<IFileRequest>;
  76572. /**
  76573. * Aborts the request for a file.
  76574. */
  76575. abort: () => void;
  76576. }
  76577. }
  76578. declare module BABYLON {
  76579. /**
  76580. * Define options used to create a render target texture
  76581. */
  76582. export class RenderTargetCreationOptions {
  76583. /**
  76584. * Specifies is mipmaps must be generated
  76585. */
  76586. generateMipMaps?: boolean;
  76587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  76588. generateDepthBuffer?: boolean;
  76589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  76590. generateStencilBuffer?: boolean;
  76591. /** Defines texture type (int by default) */
  76592. type?: number;
  76593. /** Defines sampling mode (trilinear by default) */
  76594. samplingMode?: number;
  76595. /** Defines format (RGBA by default) */
  76596. format?: number;
  76597. }
  76598. }
  76599. declare module BABYLON {
  76600. /** Defines the cross module used constants to avoid circular dependncies */
  76601. export class Constants {
  76602. /** Defines that alpha blending is disabled */
  76603. static readonly ALPHA_DISABLE: number;
  76604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  76605. static readonly ALPHA_ADD: number;
  76606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  76607. static readonly ALPHA_COMBINE: number;
  76608. /** Defines that alpha blending is DEST - SRC * DEST */
  76609. static readonly ALPHA_SUBTRACT: number;
  76610. /** Defines that alpha blending is SRC * DEST */
  76611. static readonly ALPHA_MULTIPLY: number;
  76612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  76613. static readonly ALPHA_MAXIMIZED: number;
  76614. /** Defines that alpha blending is SRC + DEST */
  76615. static readonly ALPHA_ONEONE: number;
  76616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  76617. static readonly ALPHA_PREMULTIPLIED: number;
  76618. /**
  76619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  76620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  76621. */
  76622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  76623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  76624. static readonly ALPHA_INTERPOLATE: number;
  76625. /**
  76626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  76627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  76628. */
  76629. static readonly ALPHA_SCREENMODE: number;
  76630. /**
  76631. * Defines that alpha blending is SRC + DST
  76632. * Alpha will be set to SRC ALPHA + DST ALPHA
  76633. */
  76634. static readonly ALPHA_ONEONE_ONEONE: number;
  76635. /**
  76636. * Defines that alpha blending is SRC * DST ALPHA + DST
  76637. * Alpha will be set to 0
  76638. */
  76639. static readonly ALPHA_ALPHATOCOLOR: number;
  76640. /**
  76641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76642. */
  76643. static readonly ALPHA_REVERSEONEMINUS: number;
  76644. /**
  76645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  76646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  76647. */
  76648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  76649. /**
  76650. * Defines that alpha blending is SRC + DST
  76651. * Alpha will be set to SRC ALPHA
  76652. */
  76653. static readonly ALPHA_ONEONE_ONEZERO: number;
  76654. /**
  76655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76656. * Alpha will be set to DST ALPHA
  76657. */
  76658. static readonly ALPHA_EXCLUSION: number;
  76659. /** Defines that alpha blending equation a SUM */
  76660. static readonly ALPHA_EQUATION_ADD: number;
  76661. /** Defines that alpha blending equation a SUBSTRACTION */
  76662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  76663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  76664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  76665. /** Defines that alpha blending equation a MAX operation */
  76666. static readonly ALPHA_EQUATION_MAX: number;
  76667. /** Defines that alpha blending equation a MIN operation */
  76668. static readonly ALPHA_EQUATION_MIN: number;
  76669. /**
  76670. * Defines that alpha blending equation a DARKEN operation:
  76671. * It takes the min of the src and sums the alpha channels.
  76672. */
  76673. static readonly ALPHA_EQUATION_DARKEN: number;
  76674. /** Defines that the ressource is not delayed*/
  76675. static readonly DELAYLOADSTATE_NONE: number;
  76676. /** Defines that the ressource was successfully delay loaded */
  76677. static readonly DELAYLOADSTATE_LOADED: number;
  76678. /** Defines that the ressource is currently delay loading */
  76679. static readonly DELAYLOADSTATE_LOADING: number;
  76680. /** Defines that the ressource is delayed and has not started loading */
  76681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  76682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  76683. static readonly NEVER: number;
  76684. /** 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 */
  76685. static readonly ALWAYS: number;
  76686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  76687. static readonly LESS: number;
  76688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  76689. static readonly EQUAL: number;
  76690. /** 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 */
  76691. static readonly LEQUAL: number;
  76692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  76693. static readonly GREATER: number;
  76694. /** 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 */
  76695. static readonly GEQUAL: number;
  76696. /** 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 */
  76697. static readonly NOTEQUAL: number;
  76698. /** Passed to stencilOperation to specify that stencil value must be kept */
  76699. static readonly KEEP: number;
  76700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  76701. static readonly REPLACE: number;
  76702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  76703. static readonly INCR: number;
  76704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  76705. static readonly DECR: number;
  76706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  76707. static readonly INVERT: number;
  76708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  76709. static readonly INCR_WRAP: number;
  76710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  76711. static readonly DECR_WRAP: number;
  76712. /** Texture is not repeating outside of 0..1 UVs */
  76713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  76714. /** Texture is repeating outside of 0..1 UVs */
  76715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  76716. /** Texture is repeating and mirrored */
  76717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  76718. /** ALPHA */
  76719. static readonly TEXTUREFORMAT_ALPHA: number;
  76720. /** LUMINANCE */
  76721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  76722. /** LUMINANCE_ALPHA */
  76723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  76724. /** RGB */
  76725. static readonly TEXTUREFORMAT_RGB: number;
  76726. /** RGBA */
  76727. static readonly TEXTUREFORMAT_RGBA: number;
  76728. /** RED */
  76729. static readonly TEXTUREFORMAT_RED: number;
  76730. /** RED (2nd reference) */
  76731. static readonly TEXTUREFORMAT_R: number;
  76732. /** RG */
  76733. static readonly TEXTUREFORMAT_RG: number;
  76734. /** RED_INTEGER */
  76735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  76736. /** RED_INTEGER (2nd reference) */
  76737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  76738. /** RG_INTEGER */
  76739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  76740. /** RGB_INTEGER */
  76741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  76742. /** RGBA_INTEGER */
  76743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  76744. /** UNSIGNED_BYTE */
  76745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  76746. /** UNSIGNED_BYTE (2nd reference) */
  76747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  76748. /** FLOAT */
  76749. static readonly TEXTURETYPE_FLOAT: number;
  76750. /** HALF_FLOAT */
  76751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  76752. /** BYTE */
  76753. static readonly TEXTURETYPE_BYTE: number;
  76754. /** SHORT */
  76755. static readonly TEXTURETYPE_SHORT: number;
  76756. /** UNSIGNED_SHORT */
  76757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  76758. /** INT */
  76759. static readonly TEXTURETYPE_INT: number;
  76760. /** UNSIGNED_INT */
  76761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  76762. /** UNSIGNED_SHORT_4_4_4_4 */
  76763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  76764. /** UNSIGNED_SHORT_5_5_5_1 */
  76765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  76766. /** UNSIGNED_SHORT_5_6_5 */
  76767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  76768. /** UNSIGNED_INT_2_10_10_10_REV */
  76769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  76770. /** UNSIGNED_INT_24_8 */
  76771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  76772. /** UNSIGNED_INT_10F_11F_11F_REV */
  76773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  76774. /** UNSIGNED_INT_5_9_9_9_REV */
  76775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  76776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  76777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76778. /** nearest is mag = nearest and min = nearest and no mip */
  76779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  76780. /** mag = nearest and min = nearest and mip = none */
  76781. static readonly TEXTURE_NEAREST_NEAREST: number;
  76782. /** Bilinear is mag = linear and min = linear and no mip */
  76783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  76784. /** mag = linear and min = linear and mip = none */
  76785. static readonly TEXTURE_LINEAR_LINEAR: number;
  76786. /** Trilinear is mag = linear and min = linear and mip = linear */
  76787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  76788. /** Trilinear is mag = linear and min = linear and mip = linear */
  76789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  76790. /** mag = nearest and min = nearest and mip = nearest */
  76791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  76792. /** mag = nearest and min = linear and mip = nearest */
  76793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  76794. /** mag = nearest and min = linear and mip = linear */
  76795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  76796. /** mag = nearest and min = linear and mip = none */
  76797. static readonly TEXTURE_NEAREST_LINEAR: number;
  76798. /** nearest is mag = nearest and min = nearest and mip = linear */
  76799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  76800. /** mag = linear and min = nearest and mip = nearest */
  76801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  76802. /** mag = linear and min = nearest and mip = linear */
  76803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  76804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  76806. /** mag = linear and min = nearest and mip = none */
  76807. static readonly TEXTURE_LINEAR_NEAREST: number;
  76808. /** Explicit coordinates mode */
  76809. static readonly TEXTURE_EXPLICIT_MODE: number;
  76810. /** Spherical coordinates mode */
  76811. static readonly TEXTURE_SPHERICAL_MODE: number;
  76812. /** Planar coordinates mode */
  76813. static readonly TEXTURE_PLANAR_MODE: number;
  76814. /** Cubic coordinates mode */
  76815. static readonly TEXTURE_CUBIC_MODE: number;
  76816. /** Projection coordinates mode */
  76817. static readonly TEXTURE_PROJECTION_MODE: number;
  76818. /** Skybox coordinates mode */
  76819. static readonly TEXTURE_SKYBOX_MODE: number;
  76820. /** Inverse Cubic coordinates mode */
  76821. static readonly TEXTURE_INVCUBIC_MODE: number;
  76822. /** Equirectangular coordinates mode */
  76823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  76824. /** Equirectangular Fixed coordinates mode */
  76825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  76826. /** Equirectangular Fixed Mirrored coordinates mode */
  76827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76828. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  76829. static readonly SCALEMODE_FLOOR: number;
  76830. /** Defines that texture rescaling will look for the nearest power of 2 size */
  76831. static readonly SCALEMODE_NEAREST: number;
  76832. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  76833. static readonly SCALEMODE_CEILING: number;
  76834. /**
  76835. * The dirty texture flag value
  76836. */
  76837. static readonly MATERIAL_TextureDirtyFlag: number;
  76838. /**
  76839. * The dirty light flag value
  76840. */
  76841. static readonly MATERIAL_LightDirtyFlag: number;
  76842. /**
  76843. * The dirty fresnel flag value
  76844. */
  76845. static readonly MATERIAL_FresnelDirtyFlag: number;
  76846. /**
  76847. * The dirty attribute flag value
  76848. */
  76849. static readonly MATERIAL_AttributesDirtyFlag: number;
  76850. /**
  76851. * The dirty misc flag value
  76852. */
  76853. static readonly MATERIAL_MiscDirtyFlag: number;
  76854. /**
  76855. * The all dirty flag value
  76856. */
  76857. static readonly MATERIAL_AllDirtyFlag: number;
  76858. /**
  76859. * Returns the triangle fill mode
  76860. */
  76861. static readonly MATERIAL_TriangleFillMode: number;
  76862. /**
  76863. * Returns the wireframe mode
  76864. */
  76865. static readonly MATERIAL_WireFrameFillMode: number;
  76866. /**
  76867. * Returns the point fill mode
  76868. */
  76869. static readonly MATERIAL_PointFillMode: number;
  76870. /**
  76871. * Returns the point list draw mode
  76872. */
  76873. static readonly MATERIAL_PointListDrawMode: number;
  76874. /**
  76875. * Returns the line list draw mode
  76876. */
  76877. static readonly MATERIAL_LineListDrawMode: number;
  76878. /**
  76879. * Returns the line loop draw mode
  76880. */
  76881. static readonly MATERIAL_LineLoopDrawMode: number;
  76882. /**
  76883. * Returns the line strip draw mode
  76884. */
  76885. static readonly MATERIAL_LineStripDrawMode: number;
  76886. /**
  76887. * Returns the triangle strip draw mode
  76888. */
  76889. static readonly MATERIAL_TriangleStripDrawMode: number;
  76890. /**
  76891. * Returns the triangle fan draw mode
  76892. */
  76893. static readonly MATERIAL_TriangleFanDrawMode: number;
  76894. /**
  76895. * Stores the clock-wise side orientation
  76896. */
  76897. static readonly MATERIAL_ClockWiseSideOrientation: number;
  76898. /**
  76899. * Stores the counter clock-wise side orientation
  76900. */
  76901. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  76902. /**
  76903. * Nothing
  76904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76905. */
  76906. static readonly ACTION_NothingTrigger: number;
  76907. /**
  76908. * On pick
  76909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76910. */
  76911. static readonly ACTION_OnPickTrigger: number;
  76912. /**
  76913. * On left pick
  76914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76915. */
  76916. static readonly ACTION_OnLeftPickTrigger: number;
  76917. /**
  76918. * On right pick
  76919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76920. */
  76921. static readonly ACTION_OnRightPickTrigger: number;
  76922. /**
  76923. * On center pick
  76924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76925. */
  76926. static readonly ACTION_OnCenterPickTrigger: number;
  76927. /**
  76928. * On pick down
  76929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76930. */
  76931. static readonly ACTION_OnPickDownTrigger: number;
  76932. /**
  76933. * On double pick
  76934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76935. */
  76936. static readonly ACTION_OnDoublePickTrigger: number;
  76937. /**
  76938. * On pick up
  76939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76940. */
  76941. static readonly ACTION_OnPickUpTrigger: number;
  76942. /**
  76943. * On pick out.
  76944. * This trigger will only be raised if you also declared a OnPickDown
  76945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76946. */
  76947. static readonly ACTION_OnPickOutTrigger: number;
  76948. /**
  76949. * On long press
  76950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76951. */
  76952. static readonly ACTION_OnLongPressTrigger: number;
  76953. /**
  76954. * On pointer over
  76955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76956. */
  76957. static readonly ACTION_OnPointerOverTrigger: number;
  76958. /**
  76959. * On pointer out
  76960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76961. */
  76962. static readonly ACTION_OnPointerOutTrigger: number;
  76963. /**
  76964. * On every frame
  76965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76966. */
  76967. static readonly ACTION_OnEveryFrameTrigger: number;
  76968. /**
  76969. * On intersection enter
  76970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76971. */
  76972. static readonly ACTION_OnIntersectionEnterTrigger: number;
  76973. /**
  76974. * On intersection exit
  76975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76976. */
  76977. static readonly ACTION_OnIntersectionExitTrigger: number;
  76978. /**
  76979. * On key down
  76980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76981. */
  76982. static readonly ACTION_OnKeyDownTrigger: number;
  76983. /**
  76984. * On key up
  76985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76986. */
  76987. static readonly ACTION_OnKeyUpTrigger: number;
  76988. /**
  76989. * Billboard mode will only apply to Y axis
  76990. */
  76991. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  76992. /**
  76993. * Billboard mode will apply to all axes
  76994. */
  76995. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  76996. /**
  76997. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  76998. */
  76999. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  77000. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  77001. * Test order :
  77002. * Is the bounding sphere outside the frustum ?
  77003. * If not, are the bounding box vertices outside the frustum ?
  77004. * It not, then the cullable object is in the frustum.
  77005. */
  77006. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  77007. /** Culling strategy : Bounding Sphere Only.
  77008. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  77009. * It's also less accurate than the standard because some not visible objects can still be selected.
  77010. * Test : is the bounding sphere outside the frustum ?
  77011. * If not, then the cullable object is in the frustum.
  77012. */
  77013. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  77014. /** Culling strategy : Optimistic Inclusion.
  77015. * This in an inclusion test first, then the standard exclusion test.
  77016. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  77017. * 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.
  77018. * Anyway, it's as accurate as the standard strategy.
  77019. * Test :
  77020. * Is the cullable object bounding sphere center in the frustum ?
  77021. * If not, apply the default culling strategy.
  77022. */
  77023. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  77024. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  77025. * This in an inclusion test first, then the bounding sphere only exclusion test.
  77026. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  77027. * 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.
  77028. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  77029. * Test :
  77030. * Is the cullable object bounding sphere center in the frustum ?
  77031. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  77032. */
  77033. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  77034. /**
  77035. * No logging while loading
  77036. */
  77037. static readonly SCENELOADER_NO_LOGGING: number;
  77038. /**
  77039. * Minimal logging while loading
  77040. */
  77041. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  77042. /**
  77043. * Summary logging while loading
  77044. */
  77045. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  77046. /**
  77047. * Detailled logging while loading
  77048. */
  77049. static readonly SCENELOADER_DETAILED_LOGGING: number;
  77050. }
  77051. }
  77052. declare module BABYLON {
  77053. /**
  77054. * This represents the required contract to create a new type of texture loader.
  77055. */
  77056. export interface IInternalTextureLoader {
  77057. /**
  77058. * Defines wether the loader supports cascade loading the different faces.
  77059. */
  77060. supportCascades: boolean;
  77061. /**
  77062. * This returns if the loader support the current file information.
  77063. * @param extension defines the file extension of the file being loaded
  77064. * @returns true if the loader can load the specified file
  77065. */
  77066. canLoad(extension: string): boolean;
  77067. /**
  77068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  77069. * @param data contains the texture data
  77070. * @param texture defines the BabylonJS internal texture
  77071. * @param createPolynomials will be true if polynomials have been requested
  77072. * @param onLoad defines the callback to trigger once the texture is ready
  77073. * @param onError defines the callback to trigger in case of error
  77074. */
  77075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  77076. /**
  77077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  77078. * @param data contains the texture data
  77079. * @param texture defines the BabylonJS internal texture
  77080. * @param callback defines the method to call once ready to upload
  77081. */
  77082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  77083. }
  77084. }
  77085. declare module BABYLON {
  77086. /**
  77087. * Class used to store and describe the pipeline context associated with an effect
  77088. */
  77089. export interface IPipelineContext {
  77090. /**
  77091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  77092. */
  77093. isAsync: boolean;
  77094. /**
  77095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  77096. */
  77097. isReady: boolean;
  77098. /** @hidden */
  77099. _getVertexShaderCode(): string | null;
  77100. /** @hidden */
  77101. _getFragmentShaderCode(): string | null;
  77102. /** @hidden */
  77103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  77104. }
  77105. }
  77106. declare module BABYLON {
  77107. /**
  77108. * Class used to store gfx data (like WebGLBuffer)
  77109. */
  77110. export class DataBuffer {
  77111. /**
  77112. * Gets or sets the number of objects referencing this buffer
  77113. */
  77114. references: number;
  77115. /** Gets or sets the size of the underlying buffer */
  77116. capacity: number;
  77117. /**
  77118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  77119. */
  77120. is32Bits: boolean;
  77121. /**
  77122. * Gets the underlying buffer
  77123. */
  77124. get underlyingResource(): any;
  77125. }
  77126. }
  77127. declare module BABYLON {
  77128. /** @hidden */
  77129. export interface IShaderProcessor {
  77130. attributeProcessor?: (attribute: string) => string;
  77131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  77132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  77133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  77134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  77135. lineProcessor?: (line: string, isFragment: boolean) => string;
  77136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  77137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  77138. }
  77139. }
  77140. declare module BABYLON {
  77141. /** @hidden */
  77142. export interface ProcessingOptions {
  77143. defines: string[];
  77144. indexParameters: any;
  77145. isFragment: boolean;
  77146. shouldUseHighPrecisionShader: boolean;
  77147. supportsUniformBuffers: boolean;
  77148. shadersRepository: string;
  77149. includesShadersStore: {
  77150. [key: string]: string;
  77151. };
  77152. processor?: IShaderProcessor;
  77153. version: string;
  77154. platformName: string;
  77155. lookForClosingBracketForUniformBuffer?: boolean;
  77156. }
  77157. }
  77158. declare module BABYLON {
  77159. /** @hidden */
  77160. export class ShaderCodeNode {
  77161. line: string;
  77162. children: ShaderCodeNode[];
  77163. additionalDefineKey?: string;
  77164. additionalDefineValue?: string;
  77165. isValid(preprocessors: {
  77166. [key: string]: string;
  77167. }): boolean;
  77168. process(preprocessors: {
  77169. [key: string]: string;
  77170. }, options: ProcessingOptions): string;
  77171. }
  77172. }
  77173. declare module BABYLON {
  77174. /** @hidden */
  77175. export class ShaderCodeCursor {
  77176. private _lines;
  77177. lineIndex: number;
  77178. get currentLine(): string;
  77179. get canRead(): boolean;
  77180. set lines(value: string[]);
  77181. }
  77182. }
  77183. declare module BABYLON {
  77184. /** @hidden */
  77185. export class ShaderCodeConditionNode extends ShaderCodeNode {
  77186. process(preprocessors: {
  77187. [key: string]: string;
  77188. }, options: ProcessingOptions): string;
  77189. }
  77190. }
  77191. declare module BABYLON {
  77192. /** @hidden */
  77193. export class ShaderDefineExpression {
  77194. isTrue(preprocessors: {
  77195. [key: string]: string;
  77196. }): boolean;
  77197. private static _OperatorPriority;
  77198. private static _Stack;
  77199. static postfixToInfix(postfix: string[]): string;
  77200. static infixToPostfix(infix: string): string[];
  77201. }
  77202. }
  77203. declare module BABYLON {
  77204. /** @hidden */
  77205. export class ShaderCodeTestNode extends ShaderCodeNode {
  77206. testExpression: ShaderDefineExpression;
  77207. isValid(preprocessors: {
  77208. [key: string]: string;
  77209. }): boolean;
  77210. }
  77211. }
  77212. declare module BABYLON {
  77213. /** @hidden */
  77214. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  77215. define: string;
  77216. not: boolean;
  77217. constructor(define: string, not?: boolean);
  77218. isTrue(preprocessors: {
  77219. [key: string]: string;
  77220. }): boolean;
  77221. }
  77222. }
  77223. declare module BABYLON {
  77224. /** @hidden */
  77225. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  77226. leftOperand: ShaderDefineExpression;
  77227. rightOperand: ShaderDefineExpression;
  77228. isTrue(preprocessors: {
  77229. [key: string]: string;
  77230. }): boolean;
  77231. }
  77232. }
  77233. declare module BABYLON {
  77234. /** @hidden */
  77235. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  77236. leftOperand: ShaderDefineExpression;
  77237. rightOperand: ShaderDefineExpression;
  77238. isTrue(preprocessors: {
  77239. [key: string]: string;
  77240. }): boolean;
  77241. }
  77242. }
  77243. declare module BABYLON {
  77244. /** @hidden */
  77245. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  77246. define: string;
  77247. operand: string;
  77248. testValue: string;
  77249. constructor(define: string, operand: string, testValue: string);
  77250. isTrue(preprocessors: {
  77251. [key: string]: string;
  77252. }): boolean;
  77253. }
  77254. }
  77255. declare module BABYLON {
  77256. /**
  77257. * Class used to enable access to offline support
  77258. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  77259. */
  77260. export interface IOfflineProvider {
  77261. /**
  77262. * Gets a boolean indicating if scene must be saved in the database
  77263. */
  77264. enableSceneOffline: boolean;
  77265. /**
  77266. * Gets a boolean indicating if textures must be saved in the database
  77267. */
  77268. enableTexturesOffline: boolean;
  77269. /**
  77270. * Open the offline support and make it available
  77271. * @param successCallback defines the callback to call on success
  77272. * @param errorCallback defines the callback to call on error
  77273. */
  77274. open(successCallback: () => void, errorCallback: () => void): void;
  77275. /**
  77276. * Loads an image from the offline support
  77277. * @param url defines the url to load from
  77278. * @param image defines the target DOM image
  77279. */
  77280. loadImage(url: string, image: HTMLImageElement): void;
  77281. /**
  77282. * Loads a file from offline support
  77283. * @param url defines the URL to load from
  77284. * @param sceneLoaded defines a callback to call on success
  77285. * @param progressCallBack defines a callback to call when progress changed
  77286. * @param errorCallback defines a callback to call on error
  77287. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  77288. */
  77289. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  77290. }
  77291. }
  77292. declare module BABYLON {
  77293. /**
  77294. * Class used to help managing file picking and drag'n'drop
  77295. * File Storage
  77296. */
  77297. export class FilesInputStore {
  77298. /**
  77299. * List of files ready to be loaded
  77300. */
  77301. static FilesToLoad: {
  77302. [key: string]: File;
  77303. };
  77304. }
  77305. }
  77306. declare module BABYLON {
  77307. /**
  77308. * Class used to define a retry strategy when error happens while loading assets
  77309. */
  77310. export class RetryStrategy {
  77311. /**
  77312. * Function used to defines an exponential back off strategy
  77313. * @param maxRetries defines the maximum number of retries (3 by default)
  77314. * @param baseInterval defines the interval between retries
  77315. * @returns the strategy function to use
  77316. */
  77317. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  77318. }
  77319. }
  77320. declare module BABYLON {
  77321. /**
  77322. * @ignore
  77323. * Application error to support additional information when loading a file
  77324. */
  77325. export abstract class BaseError extends Error {
  77326. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  77327. }
  77328. }
  77329. declare module BABYLON {
  77330. /** @ignore */
  77331. export class LoadFileError extends BaseError {
  77332. request?: WebRequest;
  77333. file?: File;
  77334. /**
  77335. * Creates a new LoadFileError
  77336. * @param message defines the message of the error
  77337. * @param request defines the optional web request
  77338. * @param file defines the optional file
  77339. */
  77340. constructor(message: string, object?: WebRequest | File);
  77341. }
  77342. /** @ignore */
  77343. export class RequestFileError extends BaseError {
  77344. request: WebRequest;
  77345. /**
  77346. * Creates a new LoadFileError
  77347. * @param message defines the message of the error
  77348. * @param request defines the optional web request
  77349. */
  77350. constructor(message: string, request: WebRequest);
  77351. }
  77352. /** @ignore */
  77353. export class ReadFileError extends BaseError {
  77354. file: File;
  77355. /**
  77356. * Creates a new ReadFileError
  77357. * @param message defines the message of the error
  77358. * @param file defines the optional file
  77359. */
  77360. constructor(message: string, file: File);
  77361. }
  77362. /**
  77363. * @hidden
  77364. */
  77365. export class FileTools {
  77366. /**
  77367. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  77368. */
  77369. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  77370. /**
  77371. * Gets or sets the base URL to use to load assets
  77372. */
  77373. static BaseUrl: string;
  77374. /**
  77375. * Default behaviour for cors in the application.
  77376. * It can be a string if the expected behavior is identical in the entire app.
  77377. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  77378. */
  77379. static CorsBehavior: string | ((url: string | string[]) => string);
  77380. /**
  77381. * Gets or sets a function used to pre-process url before using them to load assets
  77382. */
  77383. static PreprocessUrl: (url: string) => string;
  77384. /**
  77385. * Removes unwanted characters from an url
  77386. * @param url defines the url to clean
  77387. * @returns the cleaned url
  77388. */
  77389. private static _CleanUrl;
  77390. /**
  77391. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  77392. * @param url define the url we are trying
  77393. * @param element define the dom element where to configure the cors policy
  77394. */
  77395. static SetCorsBehavior(url: string | string[], element: {
  77396. crossOrigin: string | null;
  77397. }): void;
  77398. /**
  77399. * Loads an image as an HTMLImageElement.
  77400. * @param input url string, ArrayBuffer, or Blob to load
  77401. * @param onLoad callback called when the image successfully loads
  77402. * @param onError callback called when the image fails to load
  77403. * @param offlineProvider offline provider for caching
  77404. * @param mimeType optional mime type
  77405. * @returns the HTMLImageElement of the loaded image
  77406. */
  77407. 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>;
  77408. /**
  77409. * Reads a file from a File object
  77410. * @param file defines the file to load
  77411. * @param onSuccess defines the callback to call when data is loaded
  77412. * @param onProgress defines the callback to call during loading process
  77413. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  77414. * @param onError defines the callback to call when an error occurs
  77415. * @returns a file request object
  77416. */
  77417. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  77418. /**
  77419. * Loads a file from a url
  77420. * @param url url to load
  77421. * @param onSuccess callback called when the file successfully loads
  77422. * @param onProgress callback called while file is loading (if the server supports this mode)
  77423. * @param offlineProvider defines the offline provider for caching
  77424. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77425. * @param onError callback called when the file fails to load
  77426. * @returns a file request object
  77427. */
  77428. 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;
  77429. /**
  77430. * Loads a file
  77431. * @param url url to load
  77432. * @param onSuccess callback called when the file successfully loads
  77433. * @param onProgress callback called while file is loading (if the server supports this mode)
  77434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77435. * @param onError callback called when the file fails to load
  77436. * @param onOpened callback called when the web request is opened
  77437. * @returns a file request object
  77438. */
  77439. 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;
  77440. /**
  77441. * Checks if the loaded document was accessed via `file:`-Protocol.
  77442. * @returns boolean
  77443. */
  77444. static IsFileURL(): boolean;
  77445. }
  77446. }
  77447. declare module BABYLON {
  77448. /** @hidden */
  77449. export class ShaderProcessor {
  77450. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  77451. private static _ProcessPrecision;
  77452. private static _ExtractOperation;
  77453. private static _BuildSubExpression;
  77454. private static _BuildExpression;
  77455. private static _MoveCursorWithinIf;
  77456. private static _MoveCursor;
  77457. private static _EvaluatePreProcessors;
  77458. private static _PreparePreProcessors;
  77459. private static _ProcessShaderConversion;
  77460. private static _ProcessIncludes;
  77461. /**
  77462. * Loads a file from a url
  77463. * @param url url to load
  77464. * @param onSuccess callback called when the file successfully loads
  77465. * @param onProgress callback called while file is loading (if the server supports this mode)
  77466. * @param offlineProvider defines the offline provider for caching
  77467. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77468. * @param onError callback called when the file fails to load
  77469. * @returns a file request object
  77470. * @hidden
  77471. */
  77472. 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;
  77473. }
  77474. }
  77475. declare module BABYLON {
  77476. /**
  77477. * @hidden
  77478. */
  77479. export interface IColor4Like {
  77480. r: float;
  77481. g: float;
  77482. b: float;
  77483. a: float;
  77484. }
  77485. /**
  77486. * @hidden
  77487. */
  77488. export interface IColor3Like {
  77489. r: float;
  77490. g: float;
  77491. b: float;
  77492. }
  77493. /**
  77494. * @hidden
  77495. */
  77496. export interface IVector4Like {
  77497. x: float;
  77498. y: float;
  77499. z: float;
  77500. w: float;
  77501. }
  77502. /**
  77503. * @hidden
  77504. */
  77505. export interface IVector3Like {
  77506. x: float;
  77507. y: float;
  77508. z: float;
  77509. }
  77510. /**
  77511. * @hidden
  77512. */
  77513. export interface IVector2Like {
  77514. x: float;
  77515. y: float;
  77516. }
  77517. /**
  77518. * @hidden
  77519. */
  77520. export interface IMatrixLike {
  77521. toArray(): DeepImmutable<Float32Array>;
  77522. updateFlag: int;
  77523. }
  77524. /**
  77525. * @hidden
  77526. */
  77527. export interface IViewportLike {
  77528. x: float;
  77529. y: float;
  77530. width: float;
  77531. height: float;
  77532. }
  77533. /**
  77534. * @hidden
  77535. */
  77536. export interface IPlaneLike {
  77537. normal: IVector3Like;
  77538. d: float;
  77539. normalize(): void;
  77540. }
  77541. }
  77542. declare module BABYLON {
  77543. /**
  77544. * Interface used to define common properties for effect fallbacks
  77545. */
  77546. export interface IEffectFallbacks {
  77547. /**
  77548. * Removes the defines that should be removed when falling back.
  77549. * @param currentDefines defines the current define statements for the shader.
  77550. * @param effect defines the current effect we try to compile
  77551. * @returns The resulting defines with defines of the current rank removed.
  77552. */
  77553. reduce(currentDefines: string, effect: Effect): string;
  77554. /**
  77555. * Removes the fallback from the bound mesh.
  77556. */
  77557. unBindMesh(): void;
  77558. /**
  77559. * Checks to see if more fallbacks are still availible.
  77560. */
  77561. hasMoreFallbacks: boolean;
  77562. }
  77563. }
  77564. declare module BABYLON {
  77565. /**
  77566. * Class used to evalaute queries containing `and` and `or` operators
  77567. */
  77568. export class AndOrNotEvaluator {
  77569. /**
  77570. * Evaluate a query
  77571. * @param query defines the query to evaluate
  77572. * @param evaluateCallback defines the callback used to filter result
  77573. * @returns true if the query matches
  77574. */
  77575. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  77576. private static _HandleParenthesisContent;
  77577. private static _SimplifyNegation;
  77578. }
  77579. }
  77580. declare module BABYLON {
  77581. /**
  77582. * Class used to store custom tags
  77583. */
  77584. export class Tags {
  77585. /**
  77586. * Adds support for tags on the given object
  77587. * @param obj defines the object to use
  77588. */
  77589. static EnableFor(obj: any): void;
  77590. /**
  77591. * Removes tags support
  77592. * @param obj defines the object to use
  77593. */
  77594. static DisableFor(obj: any): void;
  77595. /**
  77596. * Gets a boolean indicating if the given object has tags
  77597. * @param obj defines the object to use
  77598. * @returns a boolean
  77599. */
  77600. static HasTags(obj: any): boolean;
  77601. /**
  77602. * Gets the tags available on a given object
  77603. * @param obj defines the object to use
  77604. * @param asString defines if the tags must be returned as a string instead of an array of strings
  77605. * @returns the tags
  77606. */
  77607. static GetTags(obj: any, asString?: boolean): any;
  77608. /**
  77609. * Adds tags to an object
  77610. * @param obj defines the object to use
  77611. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  77612. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  77613. */
  77614. static AddTagsTo(obj: any, tagsString: string): void;
  77615. /**
  77616. * @hidden
  77617. */
  77618. static _AddTagTo(obj: any, tag: string): void;
  77619. /**
  77620. * Removes specific tags from a specific object
  77621. * @param obj defines the object to use
  77622. * @param tagsString defines the tags to remove
  77623. */
  77624. static RemoveTagsFrom(obj: any, tagsString: string): void;
  77625. /**
  77626. * @hidden
  77627. */
  77628. static _RemoveTagFrom(obj: any, tag: string): void;
  77629. /**
  77630. * Defines if tags hosted on an object match a given query
  77631. * @param obj defines the object to use
  77632. * @param tagsQuery defines the tag query
  77633. * @returns a boolean
  77634. */
  77635. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  77636. }
  77637. }
  77638. declare module BABYLON {
  77639. /**
  77640. * Scalar computation library
  77641. */
  77642. export class Scalar {
  77643. /**
  77644. * Two pi constants convenient for computation.
  77645. */
  77646. static TwoPi: number;
  77647. /**
  77648. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77649. * @param a number
  77650. * @param b number
  77651. * @param epsilon (default = 1.401298E-45)
  77652. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77653. */
  77654. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  77655. /**
  77656. * Returns a string : the upper case translation of the number i to hexadecimal.
  77657. * @param i number
  77658. * @returns the upper case translation of the number i to hexadecimal.
  77659. */
  77660. static ToHex(i: number): string;
  77661. /**
  77662. * Returns -1 if value is negative and +1 is value is positive.
  77663. * @param value the value
  77664. * @returns the value itself if it's equal to zero.
  77665. */
  77666. static Sign(value: number): number;
  77667. /**
  77668. * Returns the value itself if it's between min and max.
  77669. * Returns min if the value is lower than min.
  77670. * Returns max if the value is greater than max.
  77671. * @param value the value to clmap
  77672. * @param min the min value to clamp to (default: 0)
  77673. * @param max the max value to clamp to (default: 1)
  77674. * @returns the clamped value
  77675. */
  77676. static Clamp(value: number, min?: number, max?: number): number;
  77677. /**
  77678. * the log2 of value.
  77679. * @param value the value to compute log2 of
  77680. * @returns the log2 of value.
  77681. */
  77682. static Log2(value: number): number;
  77683. /**
  77684. * Loops the value, so that it is never larger than length and never smaller than 0.
  77685. *
  77686. * This is similar to the modulo operator but it works with floating point numbers.
  77687. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  77688. * With t = 5 and length = 2.5, the result would be 0.0.
  77689. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  77690. * @param value the value
  77691. * @param length the length
  77692. * @returns the looped value
  77693. */
  77694. static Repeat(value: number, length: number): number;
  77695. /**
  77696. * Normalize the value between 0.0 and 1.0 using min and max values
  77697. * @param value value to normalize
  77698. * @param min max to normalize between
  77699. * @param max min to normalize between
  77700. * @returns the normalized value
  77701. */
  77702. static Normalize(value: number, min: number, max: number): number;
  77703. /**
  77704. * Denormalize the value from 0.0 and 1.0 using min and max values
  77705. * @param normalized value to denormalize
  77706. * @param min max to denormalize between
  77707. * @param max min to denormalize between
  77708. * @returns the denormalized value
  77709. */
  77710. static Denormalize(normalized: number, min: number, max: number): number;
  77711. /**
  77712. * Calculates the shortest difference between two given angles given in degrees.
  77713. * @param current current angle in degrees
  77714. * @param target target angle in degrees
  77715. * @returns the delta
  77716. */
  77717. static DeltaAngle(current: number, target: number): number;
  77718. /**
  77719. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  77720. * @param tx value
  77721. * @param length length
  77722. * @returns The returned value will move back and forth between 0 and length
  77723. */
  77724. static PingPong(tx: number, length: number): number;
  77725. /**
  77726. * Interpolates between min and max with smoothing at the limits.
  77727. *
  77728. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  77729. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  77730. * @param from from
  77731. * @param to to
  77732. * @param tx value
  77733. * @returns the smooth stepped value
  77734. */
  77735. static SmoothStep(from: number, to: number, tx: number): number;
  77736. /**
  77737. * Moves a value current towards target.
  77738. *
  77739. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  77740. * Negative values of maxDelta pushes the value away from target.
  77741. * @param current current value
  77742. * @param target target value
  77743. * @param maxDelta max distance to move
  77744. * @returns resulting value
  77745. */
  77746. static MoveTowards(current: number, target: number, maxDelta: number): number;
  77747. /**
  77748. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77749. *
  77750. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  77751. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  77752. * @param current current value
  77753. * @param target target value
  77754. * @param maxDelta max distance to move
  77755. * @returns resulting angle
  77756. */
  77757. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  77758. /**
  77759. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  77760. * @param start start value
  77761. * @param end target value
  77762. * @param amount amount to lerp between
  77763. * @returns the lerped value
  77764. */
  77765. static Lerp(start: number, end: number, amount: number): number;
  77766. /**
  77767. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77768. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  77769. * @param start start value
  77770. * @param end target value
  77771. * @param amount amount to lerp between
  77772. * @returns the lerped value
  77773. */
  77774. static LerpAngle(start: number, end: number, amount: number): number;
  77775. /**
  77776. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  77777. * @param a start value
  77778. * @param b target value
  77779. * @param value value between a and b
  77780. * @returns the inverseLerp value
  77781. */
  77782. static InverseLerp(a: number, b: number, value: number): number;
  77783. /**
  77784. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  77785. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  77786. * @param value1 spline value
  77787. * @param tangent1 spline value
  77788. * @param value2 spline value
  77789. * @param tangent2 spline value
  77790. * @param amount input value
  77791. * @returns hermite result
  77792. */
  77793. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  77794. /**
  77795. * Returns a random float number between and min and max values
  77796. * @param min min value of random
  77797. * @param max max value of random
  77798. * @returns random value
  77799. */
  77800. static RandomRange(min: number, max: number): number;
  77801. /**
  77802. * This function returns percentage of a number in a given range.
  77803. *
  77804. * RangeToPercent(40,20,60) will return 0.5 (50%)
  77805. * RangeToPercent(34,0,100) will return 0.34 (34%)
  77806. * @param number to convert to percentage
  77807. * @param min min range
  77808. * @param max max range
  77809. * @returns the percentage
  77810. */
  77811. static RangeToPercent(number: number, min: number, max: number): number;
  77812. /**
  77813. * This function returns number that corresponds to the percentage in a given range.
  77814. *
  77815. * PercentToRange(0.34,0,100) will return 34.
  77816. * @param percent to convert to number
  77817. * @param min min range
  77818. * @param max max range
  77819. * @returns the number
  77820. */
  77821. static PercentToRange(percent: number, min: number, max: number): number;
  77822. /**
  77823. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  77824. * @param angle The angle to normalize in radian.
  77825. * @return The converted angle.
  77826. */
  77827. static NormalizeRadians(angle: number): number;
  77828. }
  77829. }
  77830. declare module BABYLON {
  77831. /**
  77832. * Constant used to convert a value to gamma space
  77833. * @ignorenaming
  77834. */
  77835. export const ToGammaSpace: number;
  77836. /**
  77837. * Constant used to convert a value to linear space
  77838. * @ignorenaming
  77839. */
  77840. export const ToLinearSpace = 2.2;
  77841. /**
  77842. * Constant used to define the minimal number value in Babylon.js
  77843. * @ignorenaming
  77844. */
  77845. let Epsilon: number;
  77846. }
  77847. declare module BABYLON {
  77848. /**
  77849. * Class used to represent a viewport on screen
  77850. */
  77851. export class Viewport {
  77852. /** viewport left coordinate */
  77853. x: number;
  77854. /** viewport top coordinate */
  77855. y: number;
  77856. /**viewport width */
  77857. width: number;
  77858. /** viewport height */
  77859. height: number;
  77860. /**
  77861. * Creates a Viewport object located at (x, y) and sized (width, height)
  77862. * @param x defines viewport left coordinate
  77863. * @param y defines viewport top coordinate
  77864. * @param width defines the viewport width
  77865. * @param height defines the viewport height
  77866. */
  77867. constructor(
  77868. /** viewport left coordinate */
  77869. x: number,
  77870. /** viewport top coordinate */
  77871. y: number,
  77872. /**viewport width */
  77873. width: number,
  77874. /** viewport height */
  77875. height: number);
  77876. /**
  77877. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  77878. * @param renderWidth defines the rendering width
  77879. * @param renderHeight defines the rendering height
  77880. * @returns a new Viewport
  77881. */
  77882. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  77883. /**
  77884. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  77885. * @param renderWidth defines the rendering width
  77886. * @param renderHeight defines the rendering height
  77887. * @param ref defines the target viewport
  77888. * @returns the current viewport
  77889. */
  77890. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  77891. /**
  77892. * Returns a new Viewport copied from the current one
  77893. * @returns a new Viewport
  77894. */
  77895. clone(): Viewport;
  77896. }
  77897. }
  77898. declare module BABYLON {
  77899. /**
  77900. * Class containing a set of static utilities functions for arrays.
  77901. */
  77902. export class ArrayTools {
  77903. /**
  77904. * Returns an array of the given size filled with element built from the given constructor and the paramters
  77905. * @param size the number of element to construct and put in the array
  77906. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  77907. * @returns a new array filled with new objects
  77908. */
  77909. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  77910. }
  77911. }
  77912. declare module BABYLON {
  77913. /**
  77914. * Represens a plane by the equation ax + by + cz + d = 0
  77915. */
  77916. export class Plane {
  77917. private static _TmpMatrix;
  77918. /**
  77919. * Normal of the plane (a,b,c)
  77920. */
  77921. normal: Vector3;
  77922. /**
  77923. * d component of the plane
  77924. */
  77925. d: number;
  77926. /**
  77927. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77928. * @param a a component of the plane
  77929. * @param b b component of the plane
  77930. * @param c c component of the plane
  77931. * @param d d component of the plane
  77932. */
  77933. constructor(a: number, b: number, c: number, d: number);
  77934. /**
  77935. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77936. */
  77937. asArray(): number[];
  77938. /**
  77939. * @returns a new plane copied from the current Plane.
  77940. */
  77941. clone(): Plane;
  77942. /**
  77943. * @returns the string "Plane".
  77944. */
  77945. getClassName(): string;
  77946. /**
  77947. * @returns the Plane hash code.
  77948. */
  77949. getHashCode(): number;
  77950. /**
  77951. * Normalize the current Plane in place.
  77952. * @returns the updated Plane.
  77953. */
  77954. normalize(): Plane;
  77955. /**
  77956. * Applies a transformation the plane and returns the result
  77957. * @param transformation the transformation matrix to be applied to the plane
  77958. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77959. */
  77960. transform(transformation: DeepImmutable<Matrix>): Plane;
  77961. /**
  77962. * Compute the dot product between the point and the plane normal
  77963. * @param point point to calculate the dot product with
  77964. * @returns the dot product (float) of the point coordinates and the plane normal.
  77965. */
  77966. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77967. /**
  77968. * Updates the current Plane from the plane defined by the three given points.
  77969. * @param point1 one of the points used to contruct the plane
  77970. * @param point2 one of the points used to contruct the plane
  77971. * @param point3 one of the points used to contruct the plane
  77972. * @returns the updated Plane.
  77973. */
  77974. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77975. /**
  77976. * Checks if the plane is facing a given direction
  77977. * @param direction the direction to check if the plane is facing
  77978. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77979. * @returns True is the vector "direction" is the same side than the plane normal.
  77980. */
  77981. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77982. /**
  77983. * Calculates the distance to a point
  77984. * @param point point to calculate distance to
  77985. * @returns the signed distance (float) from the given point to the Plane.
  77986. */
  77987. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77988. /**
  77989. * Creates a plane from an array
  77990. * @param array the array to create a plane from
  77991. * @returns a new Plane from the given array.
  77992. */
  77993. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77994. /**
  77995. * Creates a plane from three points
  77996. * @param point1 point used to create the plane
  77997. * @param point2 point used to create the plane
  77998. * @param point3 point used to create the plane
  77999. * @returns a new Plane defined by the three given points.
  78000. */
  78001. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78002. /**
  78003. * Creates a plane from an origin point and a normal
  78004. * @param origin origin of the plane to be constructed
  78005. * @param normal normal of the plane to be constructed
  78006. * @returns a new Plane the normal vector to this plane at the given origin point.
  78007. * Note : the vector "normal" is updated because normalized.
  78008. */
  78009. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  78010. /**
  78011. * Calculates the distance from a plane and a point
  78012. * @param origin origin of the plane to be constructed
  78013. * @param normal normal of the plane to be constructed
  78014. * @param point point to calculate distance to
  78015. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  78016. */
  78017. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  78018. }
  78019. }
  78020. declare module BABYLON {
  78021. /**
  78022. * Class representing a vector containing 2 coordinates
  78023. */
  78024. export class Vector2 {
  78025. /** defines the first coordinate */
  78026. x: number;
  78027. /** defines the second coordinate */
  78028. y: number;
  78029. /**
  78030. * Creates a new Vector2 from the given x and y coordinates
  78031. * @param x defines the first coordinate
  78032. * @param y defines the second coordinate
  78033. */
  78034. constructor(
  78035. /** defines the first coordinate */
  78036. x?: number,
  78037. /** defines the second coordinate */
  78038. y?: number);
  78039. /**
  78040. * Gets a string with the Vector2 coordinates
  78041. * @returns a string with the Vector2 coordinates
  78042. */
  78043. toString(): string;
  78044. /**
  78045. * Gets class name
  78046. * @returns the string "Vector2"
  78047. */
  78048. getClassName(): string;
  78049. /**
  78050. * Gets current vector hash code
  78051. * @returns the Vector2 hash code as a number
  78052. */
  78053. getHashCode(): number;
  78054. /**
  78055. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  78056. * @param array defines the source array
  78057. * @param index defines the offset in source array
  78058. * @returns the current Vector2
  78059. */
  78060. toArray(array: FloatArray, index?: number): Vector2;
  78061. /**
  78062. * Copy the current vector to an array
  78063. * @returns a new array with 2 elements: the Vector2 coordinates.
  78064. */
  78065. asArray(): number[];
  78066. /**
  78067. * Sets the Vector2 coordinates with the given Vector2 coordinates
  78068. * @param source defines the source Vector2
  78069. * @returns the current updated Vector2
  78070. */
  78071. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  78072. /**
  78073. * Sets the Vector2 coordinates with the given floats
  78074. * @param x defines the first coordinate
  78075. * @param y defines the second coordinate
  78076. * @returns the current updated Vector2
  78077. */
  78078. copyFromFloats(x: number, y: number): Vector2;
  78079. /**
  78080. * Sets the Vector2 coordinates with the given floats
  78081. * @param x defines the first coordinate
  78082. * @param y defines the second coordinate
  78083. * @returns the current updated Vector2
  78084. */
  78085. set(x: number, y: number): Vector2;
  78086. /**
  78087. * Add another vector with the current one
  78088. * @param otherVector defines the other vector
  78089. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  78090. */
  78091. add(otherVector: DeepImmutable<Vector2>): Vector2;
  78092. /**
  78093. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  78094. * @param otherVector defines the other vector
  78095. * @param result defines the target vector
  78096. * @returns the unmodified current Vector2
  78097. */
  78098. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78099. /**
  78100. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  78101. * @param otherVector defines the other vector
  78102. * @returns the current updated Vector2
  78103. */
  78104. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78105. /**
  78106. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  78107. * @param otherVector defines the other vector
  78108. * @returns a new Vector2
  78109. */
  78110. addVector3(otherVector: Vector3): Vector2;
  78111. /**
  78112. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  78113. * @param otherVector defines the other vector
  78114. * @returns a new Vector2
  78115. */
  78116. subtract(otherVector: Vector2): Vector2;
  78117. /**
  78118. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  78119. * @param otherVector defines the other vector
  78120. * @param result defines the target vector
  78121. * @returns the unmodified current Vector2
  78122. */
  78123. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78124. /**
  78125. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  78126. * @param otherVector defines the other vector
  78127. * @returns the current updated Vector2
  78128. */
  78129. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78130. /**
  78131. * Multiplies in place the current Vector2 coordinates by the given ones
  78132. * @param otherVector defines the other vector
  78133. * @returns the current updated Vector2
  78134. */
  78135. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78136. /**
  78137. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  78138. * @param otherVector defines the other vector
  78139. * @returns a new Vector2
  78140. */
  78141. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  78142. /**
  78143. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  78144. * @param otherVector defines the other vector
  78145. * @param result defines the target vector
  78146. * @returns the unmodified current Vector2
  78147. */
  78148. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78149. /**
  78150. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  78151. * @param x defines the first coordinate
  78152. * @param y defines the second coordinate
  78153. * @returns a new Vector2
  78154. */
  78155. multiplyByFloats(x: number, y: number): Vector2;
  78156. /**
  78157. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  78158. * @param otherVector defines the other vector
  78159. * @returns a new Vector2
  78160. */
  78161. divide(otherVector: Vector2): Vector2;
  78162. /**
  78163. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  78164. * @param otherVector defines the other vector
  78165. * @param result defines the target vector
  78166. * @returns the unmodified current Vector2
  78167. */
  78168. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78169. /**
  78170. * Divides the current Vector2 coordinates by the given ones
  78171. * @param otherVector defines the other vector
  78172. * @returns the current updated Vector2
  78173. */
  78174. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78175. /**
  78176. * Gets a new Vector2 with current Vector2 negated coordinates
  78177. * @returns a new Vector2
  78178. */
  78179. negate(): Vector2;
  78180. /**
  78181. * Negate this vector in place
  78182. * @returns this
  78183. */
  78184. negateInPlace(): Vector2;
  78185. /**
  78186. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  78187. * @param result defines the Vector3 object where to store the result
  78188. * @returns the current Vector2
  78189. */
  78190. negateToRef(result: Vector2): Vector2;
  78191. /**
  78192. * Multiply the Vector2 coordinates by scale
  78193. * @param scale defines the scaling factor
  78194. * @returns the current updated Vector2
  78195. */
  78196. scaleInPlace(scale: number): Vector2;
  78197. /**
  78198. * Returns a new Vector2 scaled by "scale" from the current Vector2
  78199. * @param scale defines the scaling factor
  78200. * @returns a new Vector2
  78201. */
  78202. scale(scale: number): Vector2;
  78203. /**
  78204. * Scale the current Vector2 values by a factor to a given Vector2
  78205. * @param scale defines the scale factor
  78206. * @param result defines the Vector2 object where to store the result
  78207. * @returns the unmodified current Vector2
  78208. */
  78209. scaleToRef(scale: number, result: Vector2): Vector2;
  78210. /**
  78211. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  78212. * @param scale defines the scale factor
  78213. * @param result defines the Vector2 object where to store the result
  78214. * @returns the unmodified current Vector2
  78215. */
  78216. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  78217. /**
  78218. * Gets a boolean if two vectors are equals
  78219. * @param otherVector defines the other vector
  78220. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  78221. */
  78222. equals(otherVector: DeepImmutable<Vector2>): boolean;
  78223. /**
  78224. * Gets a boolean if two vectors are equals (using an epsilon value)
  78225. * @param otherVector defines the other vector
  78226. * @param epsilon defines the minimal distance to consider equality
  78227. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  78228. */
  78229. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  78230. /**
  78231. * Gets a new Vector2 from current Vector2 floored values
  78232. * @returns a new Vector2
  78233. */
  78234. floor(): Vector2;
  78235. /**
  78236. * Gets a new Vector2 from current Vector2 floored values
  78237. * @returns a new Vector2
  78238. */
  78239. fract(): Vector2;
  78240. /**
  78241. * Gets the length of the vector
  78242. * @returns the vector length (float)
  78243. */
  78244. length(): number;
  78245. /**
  78246. * Gets the vector squared length
  78247. * @returns the vector squared length (float)
  78248. */
  78249. lengthSquared(): number;
  78250. /**
  78251. * Normalize the vector
  78252. * @returns the current updated Vector2
  78253. */
  78254. normalize(): Vector2;
  78255. /**
  78256. * Gets a new Vector2 copied from the Vector2
  78257. * @returns a new Vector2
  78258. */
  78259. clone(): Vector2;
  78260. /**
  78261. * Gets a new Vector2(0, 0)
  78262. * @returns a new Vector2
  78263. */
  78264. static Zero(): Vector2;
  78265. /**
  78266. * Gets a new Vector2(1, 1)
  78267. * @returns a new Vector2
  78268. */
  78269. static One(): Vector2;
  78270. /**
  78271. * Gets a new Vector2 set from the given index element of the given array
  78272. * @param array defines the data source
  78273. * @param offset defines the offset in the data source
  78274. * @returns a new Vector2
  78275. */
  78276. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  78277. /**
  78278. * Sets "result" from the given index element of the given array
  78279. * @param array defines the data source
  78280. * @param offset defines the offset in the data source
  78281. * @param result defines the target vector
  78282. */
  78283. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  78284. /**
  78285. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  78286. * @param value1 defines 1st point of control
  78287. * @param value2 defines 2nd point of control
  78288. * @param value3 defines 3rd point of control
  78289. * @param value4 defines 4th point of control
  78290. * @param amount defines the interpolation factor
  78291. * @returns a new Vector2
  78292. */
  78293. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  78294. /**
  78295. * 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".
  78296. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  78297. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  78298. * @param value defines the value to clamp
  78299. * @param min defines the lower limit
  78300. * @param max defines the upper limit
  78301. * @returns a new Vector2
  78302. */
  78303. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  78304. /**
  78305. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  78306. * @param value1 defines the 1st control point
  78307. * @param tangent1 defines the outgoing tangent
  78308. * @param value2 defines the 2nd control point
  78309. * @param tangent2 defines the incoming tangent
  78310. * @param amount defines the interpolation factor
  78311. * @returns a new Vector2
  78312. */
  78313. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  78314. /**
  78315. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  78316. * @param start defines the start vector
  78317. * @param end defines the end vector
  78318. * @param amount defines the interpolation factor
  78319. * @returns a new Vector2
  78320. */
  78321. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  78322. /**
  78323. * Gets the dot product of the vector "left" and the vector "right"
  78324. * @param left defines first vector
  78325. * @param right defines second vector
  78326. * @returns the dot product (float)
  78327. */
  78328. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  78329. /**
  78330. * Returns a new Vector2 equal to the normalized given vector
  78331. * @param vector defines the vector to normalize
  78332. * @returns a new Vector2
  78333. */
  78334. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  78335. /**
  78336. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  78337. * @param left defines 1st vector
  78338. * @param right defines 2nd vector
  78339. * @returns a new Vector2
  78340. */
  78341. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78342. /**
  78343. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  78344. * @param left defines 1st vector
  78345. * @param right defines 2nd vector
  78346. * @returns a new Vector2
  78347. */
  78348. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78349. /**
  78350. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  78351. * @param vector defines the vector to transform
  78352. * @param transformation defines the matrix to apply
  78353. * @returns a new Vector2
  78354. */
  78355. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  78356. /**
  78357. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  78358. * @param vector defines the vector to transform
  78359. * @param transformation defines the matrix to apply
  78360. * @param result defines the target vector
  78361. */
  78362. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  78363. /**
  78364. * Determines if a given vector is included in a triangle
  78365. * @param p defines the vector to test
  78366. * @param p0 defines 1st triangle point
  78367. * @param p1 defines 2nd triangle point
  78368. * @param p2 defines 3rd triangle point
  78369. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  78370. */
  78371. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  78372. /**
  78373. * Gets the distance between the vectors "value1" and "value2"
  78374. * @param value1 defines first vector
  78375. * @param value2 defines second vector
  78376. * @returns the distance between vectors
  78377. */
  78378. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78379. /**
  78380. * Returns the squared distance between the vectors "value1" and "value2"
  78381. * @param value1 defines first vector
  78382. * @param value2 defines second vector
  78383. * @returns the squared distance between vectors
  78384. */
  78385. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78386. /**
  78387. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  78388. * @param value1 defines first vector
  78389. * @param value2 defines second vector
  78390. * @returns a new Vector2
  78391. */
  78392. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  78393. /**
  78394. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  78395. * @param p defines the middle point
  78396. * @param segA defines one point of the segment
  78397. * @param segB defines the other point of the segment
  78398. * @returns the shortest distance
  78399. */
  78400. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  78401. }
  78402. /**
  78403. * Class used to store (x,y,z) vector representation
  78404. * A Vector3 is the main object used in 3D geometry
  78405. * It can represent etiher the coordinates of a point the space, either a direction
  78406. * Reminder: js uses a left handed forward facing system
  78407. */
  78408. export class Vector3 {
  78409. /**
  78410. * Defines the first coordinates (on X axis)
  78411. */
  78412. x: number;
  78413. /**
  78414. * Defines the second coordinates (on Y axis)
  78415. */
  78416. y: number;
  78417. /**
  78418. * Defines the third coordinates (on Z axis)
  78419. */
  78420. z: number;
  78421. private static _UpReadOnly;
  78422. private static _ZeroReadOnly;
  78423. /**
  78424. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  78425. * @param x defines the first coordinates (on X axis)
  78426. * @param y defines the second coordinates (on Y axis)
  78427. * @param z defines the third coordinates (on Z axis)
  78428. */
  78429. constructor(
  78430. /**
  78431. * Defines the first coordinates (on X axis)
  78432. */
  78433. x?: number,
  78434. /**
  78435. * Defines the second coordinates (on Y axis)
  78436. */
  78437. y?: number,
  78438. /**
  78439. * Defines the third coordinates (on Z axis)
  78440. */
  78441. z?: number);
  78442. /**
  78443. * Creates a string representation of the Vector3
  78444. * @returns a string with the Vector3 coordinates.
  78445. */
  78446. toString(): string;
  78447. /**
  78448. * Gets the class name
  78449. * @returns the string "Vector3"
  78450. */
  78451. getClassName(): string;
  78452. /**
  78453. * Creates the Vector3 hash code
  78454. * @returns a number which tends to be unique between Vector3 instances
  78455. */
  78456. getHashCode(): number;
  78457. /**
  78458. * Creates an array containing three elements : the coordinates of the Vector3
  78459. * @returns a new array of numbers
  78460. */
  78461. asArray(): number[];
  78462. /**
  78463. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  78464. * @param array defines the destination array
  78465. * @param index defines the offset in the destination array
  78466. * @returns the current Vector3
  78467. */
  78468. toArray(array: FloatArray, index?: number): Vector3;
  78469. /**
  78470. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  78471. * @returns a new Quaternion object, computed from the Vector3 coordinates
  78472. */
  78473. toQuaternion(): Quaternion;
  78474. /**
  78475. * Adds the given vector to the current Vector3
  78476. * @param otherVector defines the second operand
  78477. * @returns the current updated Vector3
  78478. */
  78479. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78480. /**
  78481. * Adds the given coordinates to the current Vector3
  78482. * @param x defines the x coordinate of the operand
  78483. * @param y defines the y coordinate of the operand
  78484. * @param z defines the z coordinate of the operand
  78485. * @returns the current updated Vector3
  78486. */
  78487. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78488. /**
  78489. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  78490. * @param otherVector defines the second operand
  78491. * @returns the resulting Vector3
  78492. */
  78493. add(otherVector: DeepImmutable<Vector3>): Vector3;
  78494. /**
  78495. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  78496. * @param otherVector defines the second operand
  78497. * @param result defines the Vector3 object where to store the result
  78498. * @returns the current Vector3
  78499. */
  78500. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78501. /**
  78502. * Subtract the given vector from the current Vector3
  78503. * @param otherVector defines the second operand
  78504. * @returns the current updated Vector3
  78505. */
  78506. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78507. /**
  78508. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  78509. * @param otherVector defines the second operand
  78510. * @returns the resulting Vector3
  78511. */
  78512. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  78513. /**
  78514. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  78515. * @param otherVector defines the second operand
  78516. * @param result defines the Vector3 object where to store the result
  78517. * @returns the current Vector3
  78518. */
  78519. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78520. /**
  78521. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  78522. * @param x defines the x coordinate of the operand
  78523. * @param y defines the y coordinate of the operand
  78524. * @param z defines the z coordinate of the operand
  78525. * @returns the resulting Vector3
  78526. */
  78527. subtractFromFloats(x: number, y: number, z: number): Vector3;
  78528. /**
  78529. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  78530. * @param x defines the x coordinate of the operand
  78531. * @param y defines the y coordinate of the operand
  78532. * @param z defines the z coordinate of the operand
  78533. * @param result defines the Vector3 object where to store the result
  78534. * @returns the current Vector3
  78535. */
  78536. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  78537. /**
  78538. * Gets a new Vector3 set with the current Vector3 negated coordinates
  78539. * @returns a new Vector3
  78540. */
  78541. negate(): Vector3;
  78542. /**
  78543. * Negate this vector in place
  78544. * @returns this
  78545. */
  78546. negateInPlace(): Vector3;
  78547. /**
  78548. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  78549. * @param result defines the Vector3 object where to store the result
  78550. * @returns the current Vector3
  78551. */
  78552. negateToRef(result: Vector3): Vector3;
  78553. /**
  78554. * Multiplies the Vector3 coordinates by the float "scale"
  78555. * @param scale defines the multiplier factor
  78556. * @returns the current updated Vector3
  78557. */
  78558. scaleInPlace(scale: number): Vector3;
  78559. /**
  78560. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  78561. * @param scale defines the multiplier factor
  78562. * @returns a new Vector3
  78563. */
  78564. scale(scale: number): Vector3;
  78565. /**
  78566. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  78567. * @param scale defines the multiplier factor
  78568. * @param result defines the Vector3 object where to store the result
  78569. * @returns the current Vector3
  78570. */
  78571. scaleToRef(scale: number, result: Vector3): Vector3;
  78572. /**
  78573. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  78574. * @param scale defines the scale factor
  78575. * @param result defines the Vector3 object where to store the result
  78576. * @returns the unmodified current Vector3
  78577. */
  78578. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  78579. /**
  78580. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78581. * @param origin defines the origin of the projection ray
  78582. * @param plane defines the plane to project to
  78583. * @returns the projected vector3
  78584. */
  78585. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  78586. /**
  78587. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78588. * @param origin defines the origin of the projection ray
  78589. * @param plane defines the plane to project to
  78590. * @param result defines the Vector3 where to store the result
  78591. */
  78592. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  78593. /**
  78594. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  78595. * @param otherVector defines the second operand
  78596. * @returns true if both vectors are equals
  78597. */
  78598. equals(otherVector: DeepImmutable<Vector3>): boolean;
  78599. /**
  78600. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  78601. * @param otherVector defines the second operand
  78602. * @param epsilon defines the minimal distance to define values as equals
  78603. * @returns true if both vectors are distant less than epsilon
  78604. */
  78605. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  78606. /**
  78607. * Returns true if the current Vector3 coordinates equals the given floats
  78608. * @param x defines the x coordinate of the operand
  78609. * @param y defines the y coordinate of the operand
  78610. * @param z defines the z coordinate of the operand
  78611. * @returns true if both vectors are equals
  78612. */
  78613. equalsToFloats(x: number, y: number, z: number): boolean;
  78614. /**
  78615. * Multiplies the current Vector3 coordinates by the given ones
  78616. * @param otherVector defines the second operand
  78617. * @returns the current updated Vector3
  78618. */
  78619. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78620. /**
  78621. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  78622. * @param otherVector defines the second operand
  78623. * @returns the new Vector3
  78624. */
  78625. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  78626. /**
  78627. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  78628. * @param otherVector defines the second operand
  78629. * @param result defines the Vector3 object where to store the result
  78630. * @returns the current Vector3
  78631. */
  78632. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78633. /**
  78634. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  78635. * @param x defines the x coordinate of the operand
  78636. * @param y defines the y coordinate of the operand
  78637. * @param z defines the z coordinate of the operand
  78638. * @returns the new Vector3
  78639. */
  78640. multiplyByFloats(x: number, y: number, z: number): Vector3;
  78641. /**
  78642. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  78643. * @param otherVector defines the second operand
  78644. * @returns the new Vector3
  78645. */
  78646. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  78647. /**
  78648. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  78649. * @param otherVector defines the second operand
  78650. * @param result defines the Vector3 object where to store the result
  78651. * @returns the current Vector3
  78652. */
  78653. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78654. /**
  78655. * Divides the current Vector3 coordinates by the given ones.
  78656. * @param otherVector defines the second operand
  78657. * @returns the current updated Vector3
  78658. */
  78659. divideInPlace(otherVector: Vector3): Vector3;
  78660. /**
  78661. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  78662. * @param other defines the second operand
  78663. * @returns the current updated Vector3
  78664. */
  78665. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78666. /**
  78667. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  78668. * @param other defines the second operand
  78669. * @returns the current updated Vector3
  78670. */
  78671. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78672. /**
  78673. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  78674. * @param x defines the x coordinate of the operand
  78675. * @param y defines the y coordinate of the operand
  78676. * @param z defines the z coordinate of the operand
  78677. * @returns the current updated Vector3
  78678. */
  78679. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78680. /**
  78681. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  78682. * @param x defines the x coordinate of the operand
  78683. * @param y defines the y coordinate of the operand
  78684. * @param z defines the z coordinate of the operand
  78685. * @returns the current updated Vector3
  78686. */
  78687. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78688. /**
  78689. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  78690. * Check if is non uniform within a certain amount of decimal places to account for this
  78691. * @param epsilon the amount the values can differ
  78692. * @returns if the the vector is non uniform to a certain number of decimal places
  78693. */
  78694. isNonUniformWithinEpsilon(epsilon: number): boolean;
  78695. /**
  78696. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  78697. */
  78698. get isNonUniform(): boolean;
  78699. /**
  78700. * Gets a new Vector3 from current Vector3 floored values
  78701. * @returns a new Vector3
  78702. */
  78703. floor(): Vector3;
  78704. /**
  78705. * Gets a new Vector3 from current Vector3 floored values
  78706. * @returns a new Vector3
  78707. */
  78708. fract(): Vector3;
  78709. /**
  78710. * Gets the length of the Vector3
  78711. * @returns the length of the Vector3
  78712. */
  78713. length(): number;
  78714. /**
  78715. * Gets the squared length of the Vector3
  78716. * @returns squared length of the Vector3
  78717. */
  78718. lengthSquared(): number;
  78719. /**
  78720. * Normalize the current Vector3.
  78721. * Please note that this is an in place operation.
  78722. * @returns the current updated Vector3
  78723. */
  78724. normalize(): Vector3;
  78725. /**
  78726. * Reorders the x y z properties of the vector in place
  78727. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  78728. * @returns the current updated vector
  78729. */
  78730. reorderInPlace(order: string): this;
  78731. /**
  78732. * Rotates the vector around 0,0,0 by a quaternion
  78733. * @param quaternion the rotation quaternion
  78734. * @param result vector to store the result
  78735. * @returns the resulting vector
  78736. */
  78737. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  78738. /**
  78739. * Rotates a vector around a given point
  78740. * @param quaternion the rotation quaternion
  78741. * @param point the point to rotate around
  78742. * @param result vector to store the result
  78743. * @returns the resulting vector
  78744. */
  78745. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  78746. /**
  78747. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  78748. * The cross product is then orthogonal to both current and "other"
  78749. * @param other defines the right operand
  78750. * @returns the cross product
  78751. */
  78752. cross(other: Vector3): Vector3;
  78753. /**
  78754. * Normalize the current Vector3 with the given input length.
  78755. * Please note that this is an in place operation.
  78756. * @param len the length of the vector
  78757. * @returns the current updated Vector3
  78758. */
  78759. normalizeFromLength(len: number): Vector3;
  78760. /**
  78761. * Normalize the current Vector3 to a new vector
  78762. * @returns the new Vector3
  78763. */
  78764. normalizeToNew(): Vector3;
  78765. /**
  78766. * Normalize the current Vector3 to the reference
  78767. * @param reference define the Vector3 to update
  78768. * @returns the updated Vector3
  78769. */
  78770. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  78771. /**
  78772. * Creates a new Vector3 copied from the current Vector3
  78773. * @returns the new Vector3
  78774. */
  78775. clone(): Vector3;
  78776. /**
  78777. * Copies the given vector coordinates to the current Vector3 ones
  78778. * @param source defines the source Vector3
  78779. * @returns the current updated Vector3
  78780. */
  78781. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  78782. /**
  78783. * Copies the given floats to the current Vector3 coordinates
  78784. * @param x defines the x coordinate of the operand
  78785. * @param y defines the y coordinate of the operand
  78786. * @param z defines the z coordinate of the operand
  78787. * @returns the current updated Vector3
  78788. */
  78789. copyFromFloats(x: number, y: number, z: number): Vector3;
  78790. /**
  78791. * Copies the given floats to the current Vector3 coordinates
  78792. * @param x defines the x coordinate of the operand
  78793. * @param y defines the y coordinate of the operand
  78794. * @param z defines the z coordinate of the operand
  78795. * @returns the current updated Vector3
  78796. */
  78797. set(x: number, y: number, z: number): Vector3;
  78798. /**
  78799. * Copies the given float to the current Vector3 coordinates
  78800. * @param v defines the x, y and z coordinates of the operand
  78801. * @returns the current updated Vector3
  78802. */
  78803. setAll(v: number): Vector3;
  78804. /**
  78805. * Get the clip factor between two vectors
  78806. * @param vector0 defines the first operand
  78807. * @param vector1 defines the second operand
  78808. * @param axis defines the axis to use
  78809. * @param size defines the size along the axis
  78810. * @returns the clip factor
  78811. */
  78812. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  78813. /**
  78814. * Get angle between two vectors
  78815. * @param vector0 angle between vector0 and vector1
  78816. * @param vector1 angle between vector0 and vector1
  78817. * @param normal direction of the normal
  78818. * @return the angle between vector0 and vector1
  78819. */
  78820. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  78821. /**
  78822. * Returns a new Vector3 set from the index "offset" of the given array
  78823. * @param array defines the source array
  78824. * @param offset defines the offset in the source array
  78825. * @returns the new Vector3
  78826. */
  78827. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  78828. /**
  78829. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  78830. * @param array defines the source array
  78831. * @param offset defines the offset in the source array
  78832. * @returns the new Vector3
  78833. * @deprecated Please use FromArray instead.
  78834. */
  78835. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  78836. /**
  78837. * Sets the given vector "result" with the element values from the index "offset" of the given array
  78838. * @param array defines the source array
  78839. * @param offset defines the offset in the source array
  78840. * @param result defines the Vector3 where to store the result
  78841. */
  78842. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  78843. /**
  78844. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  78845. * @param array defines the source array
  78846. * @param offset defines the offset in the source array
  78847. * @param result defines the Vector3 where to store the result
  78848. * @deprecated Please use FromArrayToRef instead.
  78849. */
  78850. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  78851. /**
  78852. * Sets the given vector "result" with the given floats.
  78853. * @param x defines the x coordinate of the source
  78854. * @param y defines the y coordinate of the source
  78855. * @param z defines the z coordinate of the source
  78856. * @param result defines the Vector3 where to store the result
  78857. */
  78858. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  78859. /**
  78860. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  78861. * @returns a new empty Vector3
  78862. */
  78863. static Zero(): Vector3;
  78864. /**
  78865. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  78866. * @returns a new unit Vector3
  78867. */
  78868. static One(): Vector3;
  78869. /**
  78870. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  78871. * @returns a new up Vector3
  78872. */
  78873. static Up(): Vector3;
  78874. /**
  78875. * Gets a up Vector3 that must not be updated
  78876. */
  78877. static get UpReadOnly(): DeepImmutable<Vector3>;
  78878. /**
  78879. * Gets a zero Vector3 that must not be updated
  78880. */
  78881. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  78882. /**
  78883. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  78884. * @returns a new down Vector3
  78885. */
  78886. static Down(): Vector3;
  78887. /**
  78888. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  78889. * @param rightHandedSystem is the scene right-handed (negative z)
  78890. * @returns a new forward Vector3
  78891. */
  78892. static Forward(rightHandedSystem?: boolean): Vector3;
  78893. /**
  78894. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  78895. * @param rightHandedSystem is the scene right-handed (negative-z)
  78896. * @returns a new forward Vector3
  78897. */
  78898. static Backward(rightHandedSystem?: boolean): Vector3;
  78899. /**
  78900. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  78901. * @returns a new right Vector3
  78902. */
  78903. static Right(): Vector3;
  78904. /**
  78905. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  78906. * @returns a new left Vector3
  78907. */
  78908. static Left(): Vector3;
  78909. /**
  78910. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  78911. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78912. * @param vector defines the Vector3 to transform
  78913. * @param transformation defines the transformation matrix
  78914. * @returns the transformed Vector3
  78915. */
  78916. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78917. /**
  78918. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  78919. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78920. * @param vector defines the Vector3 to transform
  78921. * @param transformation defines the transformation matrix
  78922. * @param result defines the Vector3 where to store the result
  78923. */
  78924. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78925. /**
  78926. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  78927. * This method computes tranformed coordinates only, not transformed direction vectors
  78928. * @param x define the x coordinate of the source vector
  78929. * @param y define the y coordinate of the source vector
  78930. * @param z define the z coordinate of the source vector
  78931. * @param transformation defines the transformation matrix
  78932. * @param result defines the Vector3 where to store the result
  78933. */
  78934. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78935. /**
  78936. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  78937. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78938. * @param vector defines the Vector3 to transform
  78939. * @param transformation defines the transformation matrix
  78940. * @returns the new Vector3
  78941. */
  78942. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78943. /**
  78944. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  78945. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78946. * @param vector defines the Vector3 to transform
  78947. * @param transformation defines the transformation matrix
  78948. * @param result defines the Vector3 where to store the result
  78949. */
  78950. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78951. /**
  78952. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  78953. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78954. * @param x define the x coordinate of the source vector
  78955. * @param y define the y coordinate of the source vector
  78956. * @param z define the z coordinate of the source vector
  78957. * @param transformation defines the transformation matrix
  78958. * @param result defines the Vector3 where to store the result
  78959. */
  78960. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78961. /**
  78962. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  78963. * @param value1 defines the first control point
  78964. * @param value2 defines the second control point
  78965. * @param value3 defines the third control point
  78966. * @param value4 defines the fourth control point
  78967. * @param amount defines the amount on the spline to use
  78968. * @returns the new Vector3
  78969. */
  78970. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  78971. /**
  78972. * 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"
  78973. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78974. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78975. * @param value defines the current value
  78976. * @param min defines the lower range value
  78977. * @param max defines the upper range value
  78978. * @returns the new Vector3
  78979. */
  78980. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  78981. /**
  78982. * 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"
  78983. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78984. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78985. * @param value defines the current value
  78986. * @param min defines the lower range value
  78987. * @param max defines the upper range value
  78988. * @param result defines the Vector3 where to store the result
  78989. */
  78990. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  78991. /**
  78992. * Checks if a given vector is inside a specific range
  78993. * @param v defines the vector to test
  78994. * @param min defines the minimum range
  78995. * @param max defines the maximum range
  78996. */
  78997. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  78998. /**
  78999. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  79000. * @param value1 defines the first control point
  79001. * @param tangent1 defines the first tangent vector
  79002. * @param value2 defines the second control point
  79003. * @param tangent2 defines the second tangent vector
  79004. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  79005. * @returns the new Vector3
  79006. */
  79007. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  79008. /**
  79009. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  79010. * @param start defines the start value
  79011. * @param end defines the end value
  79012. * @param amount max defines amount between both (between 0 and 1)
  79013. * @returns the new Vector3
  79014. */
  79015. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  79016. /**
  79017. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  79018. * @param start defines the start value
  79019. * @param end defines the end value
  79020. * @param amount max defines amount between both (between 0 and 1)
  79021. * @param result defines the Vector3 where to store the result
  79022. */
  79023. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  79024. /**
  79025. * Returns the dot product (float) between the vectors "left" and "right"
  79026. * @param left defines the left operand
  79027. * @param right defines the right operand
  79028. * @returns the dot product
  79029. */
  79030. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  79031. /**
  79032. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  79033. * The cross product is then orthogonal to both "left" and "right"
  79034. * @param left defines the left operand
  79035. * @param right defines the right operand
  79036. * @returns the cross product
  79037. */
  79038. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79039. /**
  79040. * Sets the given vector "result" with the cross product of "left" and "right"
  79041. * The cross product is then orthogonal to both "left" and "right"
  79042. * @param left defines the left operand
  79043. * @param right defines the right operand
  79044. * @param result defines the Vector3 where to store the result
  79045. */
  79046. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  79047. /**
  79048. * Returns a new Vector3 as the normalization of the given vector
  79049. * @param vector defines the Vector3 to normalize
  79050. * @returns the new Vector3
  79051. */
  79052. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  79053. /**
  79054. * Sets the given vector "result" with the normalization of the given first vector
  79055. * @param vector defines the Vector3 to normalize
  79056. * @param result defines the Vector3 where to store the result
  79057. */
  79058. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  79059. /**
  79060. * Project a Vector3 onto screen space
  79061. * @param vector defines the Vector3 to project
  79062. * @param world defines the world matrix to use
  79063. * @param transform defines the transform (view x projection) matrix to use
  79064. * @param viewport defines the screen viewport to use
  79065. * @returns the new Vector3
  79066. */
  79067. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  79068. /** @hidden */
  79069. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  79070. /**
  79071. * Unproject from screen space to object space
  79072. * @param source defines the screen space Vector3 to use
  79073. * @param viewportWidth defines the current width of the viewport
  79074. * @param viewportHeight defines the current height of the viewport
  79075. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79076. * @param transform defines the transform (view x projection) matrix to use
  79077. * @returns the new Vector3
  79078. */
  79079. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  79080. /**
  79081. * Unproject from screen space to object space
  79082. * @param source defines the screen space Vector3 to use
  79083. * @param viewportWidth defines the current width of the viewport
  79084. * @param viewportHeight defines the current height of the viewport
  79085. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79086. * @param view defines the view matrix to use
  79087. * @param projection defines the projection matrix to use
  79088. * @returns the new Vector3
  79089. */
  79090. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  79091. /**
  79092. * Unproject from screen space to object space
  79093. * @param source defines the screen space Vector3 to use
  79094. * @param viewportWidth defines the current width of the viewport
  79095. * @param viewportHeight defines the current height of the viewport
  79096. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79097. * @param view defines the view matrix to use
  79098. * @param projection defines the projection matrix to use
  79099. * @param result defines the Vector3 where to store the result
  79100. */
  79101. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  79102. /**
  79103. * Unproject from screen space to object space
  79104. * @param sourceX defines the screen space x coordinate to use
  79105. * @param sourceY defines the screen space y coordinate to use
  79106. * @param sourceZ defines the screen space z coordinate to use
  79107. * @param viewportWidth defines the current width of the viewport
  79108. * @param viewportHeight defines the current height of the viewport
  79109. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79110. * @param view defines the view matrix to use
  79111. * @param projection defines the projection matrix to use
  79112. * @param result defines the Vector3 where to store the result
  79113. */
  79114. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  79115. /**
  79116. * Gets the minimal coordinate values between two Vector3
  79117. * @param left defines the first operand
  79118. * @param right defines the second operand
  79119. * @returns the new Vector3
  79120. */
  79121. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79122. /**
  79123. * Gets the maximal coordinate values between two Vector3
  79124. * @param left defines the first operand
  79125. * @param right defines the second operand
  79126. * @returns the new Vector3
  79127. */
  79128. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79129. /**
  79130. * Returns the distance between the vectors "value1" and "value2"
  79131. * @param value1 defines the first operand
  79132. * @param value2 defines the second operand
  79133. * @returns the distance
  79134. */
  79135. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  79136. /**
  79137. * Returns the squared distance between the vectors "value1" and "value2"
  79138. * @param value1 defines the first operand
  79139. * @param value2 defines the second operand
  79140. * @returns the squared distance
  79141. */
  79142. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  79143. /**
  79144. * Returns a new Vector3 located at the center between "value1" and "value2"
  79145. * @param value1 defines the first operand
  79146. * @param value2 defines the second operand
  79147. * @returns the new Vector3
  79148. */
  79149. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  79150. /**
  79151. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  79152. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  79153. * to something in order to rotate it from its local system to the given target system
  79154. * Note: axis1, axis2 and axis3 are normalized during this operation
  79155. * @param axis1 defines the first axis
  79156. * @param axis2 defines the second axis
  79157. * @param axis3 defines the third axis
  79158. * @returns a new Vector3
  79159. */
  79160. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  79161. /**
  79162. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  79163. * @param axis1 defines the first axis
  79164. * @param axis2 defines the second axis
  79165. * @param axis3 defines the third axis
  79166. * @param ref defines the Vector3 where to store the result
  79167. */
  79168. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  79169. }
  79170. /**
  79171. * Vector4 class created for EulerAngle class conversion to Quaternion
  79172. */
  79173. export class Vector4 {
  79174. /** x value of the vector */
  79175. x: number;
  79176. /** y value of the vector */
  79177. y: number;
  79178. /** z value of the vector */
  79179. z: number;
  79180. /** w value of the vector */
  79181. w: number;
  79182. /**
  79183. * Creates a Vector4 object from the given floats.
  79184. * @param x x value of the vector
  79185. * @param y y value of the vector
  79186. * @param z z value of the vector
  79187. * @param w w value of the vector
  79188. */
  79189. constructor(
  79190. /** x value of the vector */
  79191. x: number,
  79192. /** y value of the vector */
  79193. y: number,
  79194. /** z value of the vector */
  79195. z: number,
  79196. /** w value of the vector */
  79197. w: number);
  79198. /**
  79199. * Returns the string with the Vector4 coordinates.
  79200. * @returns a string containing all the vector values
  79201. */
  79202. toString(): string;
  79203. /**
  79204. * Returns the string "Vector4".
  79205. * @returns "Vector4"
  79206. */
  79207. getClassName(): string;
  79208. /**
  79209. * Returns the Vector4 hash code.
  79210. * @returns a unique hash code
  79211. */
  79212. getHashCode(): number;
  79213. /**
  79214. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  79215. * @returns the resulting array
  79216. */
  79217. asArray(): number[];
  79218. /**
  79219. * Populates the given array from the given index with the Vector4 coordinates.
  79220. * @param array array to populate
  79221. * @param index index of the array to start at (default: 0)
  79222. * @returns the Vector4.
  79223. */
  79224. toArray(array: FloatArray, index?: number): Vector4;
  79225. /**
  79226. * Adds the given vector to the current Vector4.
  79227. * @param otherVector the vector to add
  79228. * @returns the updated Vector4.
  79229. */
  79230. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79231. /**
  79232. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  79233. * @param otherVector the vector to add
  79234. * @returns the resulting vector
  79235. */
  79236. add(otherVector: DeepImmutable<Vector4>): Vector4;
  79237. /**
  79238. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  79239. * @param otherVector the vector to add
  79240. * @param result the vector to store the result
  79241. * @returns the current Vector4.
  79242. */
  79243. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79244. /**
  79245. * Subtract in place the given vector from the current Vector4.
  79246. * @param otherVector the vector to subtract
  79247. * @returns the updated Vector4.
  79248. */
  79249. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79250. /**
  79251. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  79252. * @param otherVector the vector to add
  79253. * @returns the new vector with the result
  79254. */
  79255. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  79256. /**
  79257. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  79258. * @param otherVector the vector to subtract
  79259. * @param result the vector to store the result
  79260. * @returns the current Vector4.
  79261. */
  79262. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79263. /**
  79264. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79265. */
  79266. /**
  79267. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79268. * @param x value to subtract
  79269. * @param y value to subtract
  79270. * @param z value to subtract
  79271. * @param w value to subtract
  79272. * @returns new vector containing the result
  79273. */
  79274. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79275. /**
  79276. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79277. * @param x value to subtract
  79278. * @param y value to subtract
  79279. * @param z value to subtract
  79280. * @param w value to subtract
  79281. * @param result the vector to store the result in
  79282. * @returns the current Vector4.
  79283. */
  79284. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  79285. /**
  79286. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  79287. * @returns a new vector with the negated values
  79288. */
  79289. negate(): Vector4;
  79290. /**
  79291. * Negate this vector in place
  79292. * @returns this
  79293. */
  79294. negateInPlace(): Vector4;
  79295. /**
  79296. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  79297. * @param result defines the Vector3 object where to store the result
  79298. * @returns the current Vector4
  79299. */
  79300. negateToRef(result: Vector4): Vector4;
  79301. /**
  79302. * Multiplies the current Vector4 coordinates by scale (float).
  79303. * @param scale the number to scale with
  79304. * @returns the updated Vector4.
  79305. */
  79306. scaleInPlace(scale: number): Vector4;
  79307. /**
  79308. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  79309. * @param scale the number to scale with
  79310. * @returns a new vector with the result
  79311. */
  79312. scale(scale: number): Vector4;
  79313. /**
  79314. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  79315. * @param scale the number to scale with
  79316. * @param result a vector to store the result in
  79317. * @returns the current Vector4.
  79318. */
  79319. scaleToRef(scale: number, result: Vector4): Vector4;
  79320. /**
  79321. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  79322. * @param scale defines the scale factor
  79323. * @param result defines the Vector4 object where to store the result
  79324. * @returns the unmodified current Vector4
  79325. */
  79326. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  79327. /**
  79328. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  79329. * @param otherVector the vector to compare against
  79330. * @returns true if they are equal
  79331. */
  79332. equals(otherVector: DeepImmutable<Vector4>): boolean;
  79333. /**
  79334. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  79335. * @param otherVector vector to compare against
  79336. * @param epsilon (Default: very small number)
  79337. * @returns true if they are equal
  79338. */
  79339. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  79340. /**
  79341. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  79342. * @param x x value to compare against
  79343. * @param y y value to compare against
  79344. * @param z z value to compare against
  79345. * @param w w value to compare against
  79346. * @returns true if equal
  79347. */
  79348. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  79349. /**
  79350. * Multiplies in place the current Vector4 by the given one.
  79351. * @param otherVector vector to multiple with
  79352. * @returns the updated Vector4.
  79353. */
  79354. multiplyInPlace(otherVector: Vector4): Vector4;
  79355. /**
  79356. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  79357. * @param otherVector vector to multiple with
  79358. * @returns resulting new vector
  79359. */
  79360. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  79361. /**
  79362. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  79363. * @param otherVector vector to multiple with
  79364. * @param result vector to store the result
  79365. * @returns the current Vector4.
  79366. */
  79367. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79368. /**
  79369. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  79370. * @param x x value multiply with
  79371. * @param y y value multiply with
  79372. * @param z z value multiply with
  79373. * @param w w value multiply with
  79374. * @returns resulting new vector
  79375. */
  79376. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  79377. /**
  79378. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  79379. * @param otherVector vector to devide with
  79380. * @returns resulting new vector
  79381. */
  79382. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  79383. /**
  79384. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  79385. * @param otherVector vector to devide with
  79386. * @param result vector to store the result
  79387. * @returns the current Vector4.
  79388. */
  79389. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79390. /**
  79391. * Divides the current Vector3 coordinates by the given ones.
  79392. * @param otherVector vector to devide with
  79393. * @returns the updated Vector3.
  79394. */
  79395. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79396. /**
  79397. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  79398. * @param other defines the second operand
  79399. * @returns the current updated Vector4
  79400. */
  79401. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79402. /**
  79403. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  79404. * @param other defines the second operand
  79405. * @returns the current updated Vector4
  79406. */
  79407. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79408. /**
  79409. * Gets a new Vector4 from current Vector4 floored values
  79410. * @returns a new Vector4
  79411. */
  79412. floor(): Vector4;
  79413. /**
  79414. * Gets a new Vector4 from current Vector3 floored values
  79415. * @returns a new Vector4
  79416. */
  79417. fract(): Vector4;
  79418. /**
  79419. * Returns the Vector4 length (float).
  79420. * @returns the length
  79421. */
  79422. length(): number;
  79423. /**
  79424. * Returns the Vector4 squared length (float).
  79425. * @returns the length squared
  79426. */
  79427. lengthSquared(): number;
  79428. /**
  79429. * Normalizes in place the Vector4.
  79430. * @returns the updated Vector4.
  79431. */
  79432. normalize(): Vector4;
  79433. /**
  79434. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  79435. * @returns this converted to a new vector3
  79436. */
  79437. toVector3(): Vector3;
  79438. /**
  79439. * Returns a new Vector4 copied from the current one.
  79440. * @returns the new cloned vector
  79441. */
  79442. clone(): Vector4;
  79443. /**
  79444. * Updates the current Vector4 with the given one coordinates.
  79445. * @param source the source vector to copy from
  79446. * @returns the updated Vector4.
  79447. */
  79448. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  79449. /**
  79450. * Updates the current Vector4 coordinates with the given floats.
  79451. * @param x float to copy from
  79452. * @param y float to copy from
  79453. * @param z float to copy from
  79454. * @param w float to copy from
  79455. * @returns the updated Vector4.
  79456. */
  79457. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79458. /**
  79459. * Updates the current Vector4 coordinates with the given floats.
  79460. * @param x float to set from
  79461. * @param y float to set from
  79462. * @param z float to set from
  79463. * @param w float to set from
  79464. * @returns the updated Vector4.
  79465. */
  79466. set(x: number, y: number, z: number, w: number): Vector4;
  79467. /**
  79468. * Copies the given float to the current Vector3 coordinates
  79469. * @param v defines the x, y, z and w coordinates of the operand
  79470. * @returns the current updated Vector3
  79471. */
  79472. setAll(v: number): Vector4;
  79473. /**
  79474. * Returns a new Vector4 set from the starting index of the given array.
  79475. * @param array the array to pull values from
  79476. * @param offset the offset into the array to start at
  79477. * @returns the new vector
  79478. */
  79479. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  79480. /**
  79481. * Updates the given vector "result" from the starting index of the given array.
  79482. * @param array the array to pull values from
  79483. * @param offset the offset into the array to start at
  79484. * @param result the vector to store the result in
  79485. */
  79486. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  79487. /**
  79488. * Updates the given vector "result" from the starting index of the given Float32Array.
  79489. * @param array the array to pull values from
  79490. * @param offset the offset into the array to start at
  79491. * @param result the vector to store the result in
  79492. */
  79493. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  79494. /**
  79495. * Updates the given vector "result" coordinates from the given floats.
  79496. * @param x float to set from
  79497. * @param y float to set from
  79498. * @param z float to set from
  79499. * @param w float to set from
  79500. * @param result the vector to the floats in
  79501. */
  79502. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  79503. /**
  79504. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  79505. * @returns the new vector
  79506. */
  79507. static Zero(): Vector4;
  79508. /**
  79509. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  79510. * @returns the new vector
  79511. */
  79512. static One(): Vector4;
  79513. /**
  79514. * Returns a new normalized Vector4 from the given one.
  79515. * @param vector the vector to normalize
  79516. * @returns the vector
  79517. */
  79518. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  79519. /**
  79520. * Updates the given vector "result" from the normalization of the given one.
  79521. * @param vector the vector to normalize
  79522. * @param result the vector to store the result in
  79523. */
  79524. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  79525. /**
  79526. * Returns a vector with the minimum values from the left and right vectors
  79527. * @param left left vector to minimize
  79528. * @param right right vector to minimize
  79529. * @returns a new vector with the minimum of the left and right vector values
  79530. */
  79531. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79532. /**
  79533. * Returns a vector with the maximum values from the left and right vectors
  79534. * @param left left vector to maximize
  79535. * @param right right vector to maximize
  79536. * @returns a new vector with the maximum of the left and right vector values
  79537. */
  79538. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79539. /**
  79540. * Returns the distance (float) between the vectors "value1" and "value2".
  79541. * @param value1 value to calulate the distance between
  79542. * @param value2 value to calulate the distance between
  79543. * @return the distance between the two vectors
  79544. */
  79545. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79546. /**
  79547. * Returns the squared distance (float) between the vectors "value1" and "value2".
  79548. * @param value1 value to calulate the distance between
  79549. * @param value2 value to calulate the distance between
  79550. * @return the distance between the two vectors squared
  79551. */
  79552. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79553. /**
  79554. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  79555. * @param value1 value to calulate the center between
  79556. * @param value2 value to calulate the center between
  79557. * @return the center between the two vectors
  79558. */
  79559. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  79560. /**
  79561. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  79562. * This methods computes transformed normalized direction vectors only.
  79563. * @param vector the vector to transform
  79564. * @param transformation the transformation matrix to apply
  79565. * @returns the new vector
  79566. */
  79567. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  79568. /**
  79569. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  79570. * This methods computes transformed normalized direction vectors only.
  79571. * @param vector the vector to transform
  79572. * @param transformation the transformation matrix to apply
  79573. * @param result the vector to store the result in
  79574. */
  79575. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79576. /**
  79577. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  79578. * This methods computes transformed normalized direction vectors only.
  79579. * @param x value to transform
  79580. * @param y value to transform
  79581. * @param z value to transform
  79582. * @param w value to transform
  79583. * @param transformation the transformation matrix to apply
  79584. * @param result the vector to store the results in
  79585. */
  79586. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79587. /**
  79588. * Creates a new Vector4 from a Vector3
  79589. * @param source defines the source data
  79590. * @param w defines the 4th component (default is 0)
  79591. * @returns a new Vector4
  79592. */
  79593. static FromVector3(source: Vector3, w?: number): Vector4;
  79594. }
  79595. /**
  79596. * Class used to store quaternion data
  79597. * @see https://en.wikipedia.org/wiki/Quaternion
  79598. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  79599. */
  79600. export class Quaternion {
  79601. /** defines the first component (0 by default) */
  79602. x: number;
  79603. /** defines the second component (0 by default) */
  79604. y: number;
  79605. /** defines the third component (0 by default) */
  79606. z: number;
  79607. /** defines the fourth component (1.0 by default) */
  79608. w: number;
  79609. /**
  79610. * Creates a new Quaternion from the given floats
  79611. * @param x defines the first component (0 by default)
  79612. * @param y defines the second component (0 by default)
  79613. * @param z defines the third component (0 by default)
  79614. * @param w defines the fourth component (1.0 by default)
  79615. */
  79616. constructor(
  79617. /** defines the first component (0 by default) */
  79618. x?: number,
  79619. /** defines the second component (0 by default) */
  79620. y?: number,
  79621. /** defines the third component (0 by default) */
  79622. z?: number,
  79623. /** defines the fourth component (1.0 by default) */
  79624. w?: number);
  79625. /**
  79626. * Gets a string representation for the current quaternion
  79627. * @returns a string with the Quaternion coordinates
  79628. */
  79629. toString(): string;
  79630. /**
  79631. * Gets the class name of the quaternion
  79632. * @returns the string "Quaternion"
  79633. */
  79634. getClassName(): string;
  79635. /**
  79636. * Gets a hash code for this quaternion
  79637. * @returns the quaternion hash code
  79638. */
  79639. getHashCode(): number;
  79640. /**
  79641. * Copy the quaternion to an array
  79642. * @returns a new array populated with 4 elements from the quaternion coordinates
  79643. */
  79644. asArray(): number[];
  79645. /**
  79646. * Check if two quaternions are equals
  79647. * @param otherQuaternion defines the second operand
  79648. * @return true if the current quaternion and the given one coordinates are strictly equals
  79649. */
  79650. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  79651. /**
  79652. * Gets a boolean if two quaternions are equals (using an epsilon value)
  79653. * @param otherQuaternion defines the other quaternion
  79654. * @param epsilon defines the minimal distance to consider equality
  79655. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  79656. */
  79657. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  79658. /**
  79659. * Clone the current quaternion
  79660. * @returns a new quaternion copied from the current one
  79661. */
  79662. clone(): Quaternion;
  79663. /**
  79664. * Copy a quaternion to the current one
  79665. * @param other defines the other quaternion
  79666. * @returns the updated current quaternion
  79667. */
  79668. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  79669. /**
  79670. * Updates the current quaternion with the given float coordinates
  79671. * @param x defines the x coordinate
  79672. * @param y defines the y coordinate
  79673. * @param z defines the z coordinate
  79674. * @param w defines the w coordinate
  79675. * @returns the updated current quaternion
  79676. */
  79677. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  79678. /**
  79679. * Updates the current quaternion from the given float coordinates
  79680. * @param x defines the x coordinate
  79681. * @param y defines the y coordinate
  79682. * @param z defines the z coordinate
  79683. * @param w defines the w coordinate
  79684. * @returns the updated current quaternion
  79685. */
  79686. set(x: number, y: number, z: number, w: number): Quaternion;
  79687. /**
  79688. * Adds two quaternions
  79689. * @param other defines the second operand
  79690. * @returns a new quaternion as the addition result of the given one and the current quaternion
  79691. */
  79692. add(other: DeepImmutable<Quaternion>): Quaternion;
  79693. /**
  79694. * Add a quaternion to the current one
  79695. * @param other defines the quaternion to add
  79696. * @returns the current quaternion
  79697. */
  79698. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  79699. /**
  79700. * Subtract two quaternions
  79701. * @param other defines the second operand
  79702. * @returns a new quaternion as the subtraction result of the given one from the current one
  79703. */
  79704. subtract(other: Quaternion): Quaternion;
  79705. /**
  79706. * Multiplies the current quaternion by a scale factor
  79707. * @param value defines the scale factor
  79708. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  79709. */
  79710. scale(value: number): Quaternion;
  79711. /**
  79712. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  79713. * @param scale defines the scale factor
  79714. * @param result defines the Quaternion object where to store the result
  79715. * @returns the unmodified current quaternion
  79716. */
  79717. scaleToRef(scale: number, result: Quaternion): Quaternion;
  79718. /**
  79719. * Multiplies in place the current quaternion by a scale factor
  79720. * @param value defines the scale factor
  79721. * @returns the current modified quaternion
  79722. */
  79723. scaleInPlace(value: number): Quaternion;
  79724. /**
  79725. * Scale the current quaternion values by a factor and add the result to a given quaternion
  79726. * @param scale defines the scale factor
  79727. * @param result defines the Quaternion object where to store the result
  79728. * @returns the unmodified current quaternion
  79729. */
  79730. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  79731. /**
  79732. * Multiplies two quaternions
  79733. * @param q1 defines the second operand
  79734. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  79735. */
  79736. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  79737. /**
  79738. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  79739. * @param q1 defines the second operand
  79740. * @param result defines the target quaternion
  79741. * @returns the current quaternion
  79742. */
  79743. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  79744. /**
  79745. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  79746. * @param q1 defines the second operand
  79747. * @returns the currentupdated quaternion
  79748. */
  79749. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  79750. /**
  79751. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  79752. * @param ref defines the target quaternion
  79753. * @returns the current quaternion
  79754. */
  79755. conjugateToRef(ref: Quaternion): Quaternion;
  79756. /**
  79757. * Conjugates in place (1-q) the current quaternion
  79758. * @returns the current updated quaternion
  79759. */
  79760. conjugateInPlace(): Quaternion;
  79761. /**
  79762. * Conjugates in place (1-q) the current quaternion
  79763. * @returns a new quaternion
  79764. */
  79765. conjugate(): Quaternion;
  79766. /**
  79767. * Gets length of current quaternion
  79768. * @returns the quaternion length (float)
  79769. */
  79770. length(): number;
  79771. /**
  79772. * Normalize in place the current quaternion
  79773. * @returns the current updated quaternion
  79774. */
  79775. normalize(): Quaternion;
  79776. /**
  79777. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  79778. * @param order is a reserved parameter and is ignore for now
  79779. * @returns a new Vector3 containing the Euler angles
  79780. */
  79781. toEulerAngles(order?: string): Vector3;
  79782. /**
  79783. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  79784. * @param result defines the vector which will be filled with the Euler angles
  79785. * @param order is a reserved parameter and is ignore for now
  79786. * @returns the current unchanged quaternion
  79787. */
  79788. toEulerAnglesToRef(result: Vector3): Quaternion;
  79789. /**
  79790. * Updates the given rotation matrix with the current quaternion values
  79791. * @param result defines the target matrix
  79792. * @returns the current unchanged quaternion
  79793. */
  79794. toRotationMatrix(result: Matrix): Quaternion;
  79795. /**
  79796. * Updates the current quaternion from the given rotation matrix values
  79797. * @param matrix defines the source matrix
  79798. * @returns the current updated quaternion
  79799. */
  79800. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79801. /**
  79802. * Creates a new quaternion from a rotation matrix
  79803. * @param matrix defines the source matrix
  79804. * @returns a new quaternion created from the given rotation matrix values
  79805. */
  79806. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79807. /**
  79808. * Updates the given quaternion with the given rotation matrix values
  79809. * @param matrix defines the source matrix
  79810. * @param result defines the target quaternion
  79811. */
  79812. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  79813. /**
  79814. * Returns the dot product (float) between the quaternions "left" and "right"
  79815. * @param left defines the left operand
  79816. * @param right defines the right operand
  79817. * @returns the dot product
  79818. */
  79819. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  79820. /**
  79821. * Checks if the two quaternions are close to each other
  79822. * @param quat0 defines the first quaternion to check
  79823. * @param quat1 defines the second quaternion to check
  79824. * @returns true if the two quaternions are close to each other
  79825. */
  79826. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  79827. /**
  79828. * Creates an empty quaternion
  79829. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  79830. */
  79831. static Zero(): Quaternion;
  79832. /**
  79833. * Inverse a given quaternion
  79834. * @param q defines the source quaternion
  79835. * @returns a new quaternion as the inverted current quaternion
  79836. */
  79837. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  79838. /**
  79839. * Inverse a given quaternion
  79840. * @param q defines the source quaternion
  79841. * @param result the quaternion the result will be stored in
  79842. * @returns the result quaternion
  79843. */
  79844. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  79845. /**
  79846. * Creates an identity quaternion
  79847. * @returns the identity quaternion
  79848. */
  79849. static Identity(): Quaternion;
  79850. /**
  79851. * Gets a boolean indicating if the given quaternion is identity
  79852. * @param quaternion defines the quaternion to check
  79853. * @returns true if the quaternion is identity
  79854. */
  79855. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  79856. /**
  79857. * Creates a quaternion from a rotation around an axis
  79858. * @param axis defines the axis to use
  79859. * @param angle defines the angle to use
  79860. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  79861. */
  79862. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  79863. /**
  79864. * Creates a rotation around an axis and stores it into the given quaternion
  79865. * @param axis defines the axis to use
  79866. * @param angle defines the angle to use
  79867. * @param result defines the target quaternion
  79868. * @returns the target quaternion
  79869. */
  79870. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  79871. /**
  79872. * Creates a new quaternion from data stored into an array
  79873. * @param array defines the data source
  79874. * @param offset defines the offset in the source array where the data starts
  79875. * @returns a new quaternion
  79876. */
  79877. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  79878. /**
  79879. * Updates the given quaternion "result" from the starting index of the given array.
  79880. * @param array the array to pull values from
  79881. * @param offset the offset into the array to start at
  79882. * @param result the quaternion to store the result in
  79883. */
  79884. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  79885. /**
  79886. * Create a quaternion from Euler rotation angles
  79887. * @param x Pitch
  79888. * @param y Yaw
  79889. * @param z Roll
  79890. * @returns the new Quaternion
  79891. */
  79892. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  79893. /**
  79894. * Updates a quaternion from Euler rotation angles
  79895. * @param x Pitch
  79896. * @param y Yaw
  79897. * @param z Roll
  79898. * @param result the quaternion to store the result
  79899. * @returns the updated quaternion
  79900. */
  79901. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  79902. /**
  79903. * Create a quaternion from Euler rotation vector
  79904. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79905. * @returns the new Quaternion
  79906. */
  79907. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  79908. /**
  79909. * Updates a quaternion from Euler rotation vector
  79910. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79911. * @param result the quaternion to store the result
  79912. * @returns the updated quaternion
  79913. */
  79914. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  79915. /**
  79916. * Creates a new quaternion from the given Euler float angles (y, x, z)
  79917. * @param yaw defines the rotation around Y axis
  79918. * @param pitch defines the rotation around X axis
  79919. * @param roll defines the rotation around Z axis
  79920. * @returns the new quaternion
  79921. */
  79922. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  79923. /**
  79924. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  79925. * @param yaw defines the rotation around Y axis
  79926. * @param pitch defines the rotation around X axis
  79927. * @param roll defines the rotation around Z axis
  79928. * @param result defines the target quaternion
  79929. */
  79930. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  79931. /**
  79932. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  79933. * @param alpha defines the rotation around first axis
  79934. * @param beta defines the rotation around second axis
  79935. * @param gamma defines the rotation around third axis
  79936. * @returns the new quaternion
  79937. */
  79938. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  79939. /**
  79940. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  79941. * @param alpha defines the rotation around first axis
  79942. * @param beta defines the rotation around second axis
  79943. * @param gamma defines the rotation around third axis
  79944. * @param result defines the target quaternion
  79945. */
  79946. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  79947. /**
  79948. * 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)
  79949. * @param axis1 defines the first axis
  79950. * @param axis2 defines the second axis
  79951. * @param axis3 defines the third axis
  79952. * @returns the new quaternion
  79953. */
  79954. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  79955. /**
  79956. * 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
  79957. * @param axis1 defines the first axis
  79958. * @param axis2 defines the second axis
  79959. * @param axis3 defines the third axis
  79960. * @param ref defines the target quaternion
  79961. */
  79962. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  79963. /**
  79964. * Interpolates between two quaternions
  79965. * @param left defines first quaternion
  79966. * @param right defines second quaternion
  79967. * @param amount defines the gradient to use
  79968. * @returns the new interpolated quaternion
  79969. */
  79970. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79971. /**
  79972. * Interpolates between two quaternions and stores it into a target quaternion
  79973. * @param left defines first quaternion
  79974. * @param right defines second quaternion
  79975. * @param amount defines the gradient to use
  79976. * @param result defines the target quaternion
  79977. */
  79978. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  79979. /**
  79980. * Interpolate between two quaternions using Hermite interpolation
  79981. * @param value1 defines first quaternion
  79982. * @param tangent1 defines the incoming tangent
  79983. * @param value2 defines second quaternion
  79984. * @param tangent2 defines the outgoing tangent
  79985. * @param amount defines the target quaternion
  79986. * @returns the new interpolated quaternion
  79987. */
  79988. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79989. }
  79990. /**
  79991. * Class used to store matrix data (4x4)
  79992. */
  79993. export class Matrix {
  79994. private static _updateFlagSeed;
  79995. private static _identityReadOnly;
  79996. private _isIdentity;
  79997. private _isIdentityDirty;
  79998. private _isIdentity3x2;
  79999. private _isIdentity3x2Dirty;
  80000. /**
  80001. * Gets the update flag of the matrix which is an unique number for the matrix.
  80002. * It will be incremented every time the matrix data change.
  80003. * You can use it to speed the comparison between two versions of the same matrix.
  80004. */
  80005. updateFlag: number;
  80006. private readonly _m;
  80007. /**
  80008. * Gets the internal data of the matrix
  80009. */
  80010. get m(): DeepImmutable<Float32Array>;
  80011. /** @hidden */
  80012. _markAsUpdated(): void;
  80013. /** @hidden */
  80014. private _updateIdentityStatus;
  80015. /**
  80016. * Creates an empty matrix (filled with zeros)
  80017. */
  80018. constructor();
  80019. /**
  80020. * Check if the current matrix is identity
  80021. * @returns true is the matrix is the identity matrix
  80022. */
  80023. isIdentity(): boolean;
  80024. /**
  80025. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  80026. * @returns true is the matrix is the identity matrix
  80027. */
  80028. isIdentityAs3x2(): boolean;
  80029. /**
  80030. * Gets the determinant of the matrix
  80031. * @returns the matrix determinant
  80032. */
  80033. determinant(): number;
  80034. /**
  80035. * Returns the matrix as a Float32Array
  80036. * @returns the matrix underlying array
  80037. */
  80038. toArray(): DeepImmutable<Float32Array>;
  80039. /**
  80040. * Returns the matrix as a Float32Array
  80041. * @returns the matrix underlying array.
  80042. */
  80043. asArray(): DeepImmutable<Float32Array>;
  80044. /**
  80045. * Inverts the current matrix in place
  80046. * @returns the current inverted matrix
  80047. */
  80048. invert(): Matrix;
  80049. /**
  80050. * Sets all the matrix elements to zero
  80051. * @returns the current matrix
  80052. */
  80053. reset(): Matrix;
  80054. /**
  80055. * Adds the current matrix with a second one
  80056. * @param other defines the matrix to add
  80057. * @returns a new matrix as the addition of the current matrix and the given one
  80058. */
  80059. add(other: DeepImmutable<Matrix>): Matrix;
  80060. /**
  80061. * Sets the given matrix "result" to the addition of the current matrix and the given one
  80062. * @param other defines the matrix to add
  80063. * @param result defines the target matrix
  80064. * @returns the current matrix
  80065. */
  80066. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  80067. /**
  80068. * Adds in place the given matrix to the current matrix
  80069. * @param other defines the second operand
  80070. * @returns the current updated matrix
  80071. */
  80072. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  80073. /**
  80074. * Sets the given matrix to the current inverted Matrix
  80075. * @param other defines the target matrix
  80076. * @returns the unmodified current matrix
  80077. */
  80078. invertToRef(other: Matrix): Matrix;
  80079. /**
  80080. * add a value at the specified position in the current Matrix
  80081. * @param index the index of the value within the matrix. between 0 and 15.
  80082. * @param value the value to be added
  80083. * @returns the current updated matrix
  80084. */
  80085. addAtIndex(index: number, value: number): Matrix;
  80086. /**
  80087. * mutiply the specified position in the current Matrix by a value
  80088. * @param index the index of the value within the matrix. between 0 and 15.
  80089. * @param value the value to be added
  80090. * @returns the current updated matrix
  80091. */
  80092. multiplyAtIndex(index: number, value: number): Matrix;
  80093. /**
  80094. * Inserts the translation vector (using 3 floats) in the current matrix
  80095. * @param x defines the 1st component of the translation
  80096. * @param y defines the 2nd component of the translation
  80097. * @param z defines the 3rd component of the translation
  80098. * @returns the current updated matrix
  80099. */
  80100. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  80101. /**
  80102. * Adds the translation vector (using 3 floats) in the current matrix
  80103. * @param x defines the 1st component of the translation
  80104. * @param y defines the 2nd component of the translation
  80105. * @param z defines the 3rd component of the translation
  80106. * @returns the current updated matrix
  80107. */
  80108. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  80109. /**
  80110. * Inserts the translation vector in the current matrix
  80111. * @param vector3 defines the translation to insert
  80112. * @returns the current updated matrix
  80113. */
  80114. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  80115. /**
  80116. * Gets the translation value of the current matrix
  80117. * @returns a new Vector3 as the extracted translation from the matrix
  80118. */
  80119. getTranslation(): Vector3;
  80120. /**
  80121. * Fill a Vector3 with the extracted translation from the matrix
  80122. * @param result defines the Vector3 where to store the translation
  80123. * @returns the current matrix
  80124. */
  80125. getTranslationToRef(result: Vector3): Matrix;
  80126. /**
  80127. * Remove rotation and scaling part from the matrix
  80128. * @returns the updated matrix
  80129. */
  80130. removeRotationAndScaling(): Matrix;
  80131. /**
  80132. * Multiply two matrices
  80133. * @param other defines the second operand
  80134. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  80135. */
  80136. multiply(other: DeepImmutable<Matrix>): Matrix;
  80137. /**
  80138. * Copy the current matrix from the given one
  80139. * @param other defines the source matrix
  80140. * @returns the current updated matrix
  80141. */
  80142. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  80143. /**
  80144. * Populates the given array from the starting index with the current matrix values
  80145. * @param array defines the target array
  80146. * @param offset defines the offset in the target array where to start storing values
  80147. * @returns the current matrix
  80148. */
  80149. copyToArray(array: Float32Array, offset?: number): Matrix;
  80150. /**
  80151. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  80152. * @param other defines the second operand
  80153. * @param result defines the matrix where to store the multiplication
  80154. * @returns the current matrix
  80155. */
  80156. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  80157. /**
  80158. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  80159. * @param other defines the second operand
  80160. * @param result defines the array where to store the multiplication
  80161. * @param offset defines the offset in the target array where to start storing values
  80162. * @returns the current matrix
  80163. */
  80164. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  80165. /**
  80166. * Check equality between this matrix and a second one
  80167. * @param value defines the second matrix to compare
  80168. * @returns true is the current matrix and the given one values are strictly equal
  80169. */
  80170. equals(value: DeepImmutable<Matrix>): boolean;
  80171. /**
  80172. * Clone the current matrix
  80173. * @returns a new matrix from the current matrix
  80174. */
  80175. clone(): Matrix;
  80176. /**
  80177. * Returns the name of the current matrix class
  80178. * @returns the string "Matrix"
  80179. */
  80180. getClassName(): string;
  80181. /**
  80182. * Gets the hash code of the current matrix
  80183. * @returns the hash code
  80184. */
  80185. getHashCode(): number;
  80186. /**
  80187. * Decomposes the current Matrix into a translation, rotation and scaling components
  80188. * @param scale defines the scale vector3 given as a reference to update
  80189. * @param rotation defines the rotation quaternion given as a reference to update
  80190. * @param translation defines the translation vector3 given as a reference to update
  80191. * @returns true if operation was successful
  80192. */
  80193. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  80194. /**
  80195. * Gets specific row of the matrix
  80196. * @param index defines the number of the row to get
  80197. * @returns the index-th row of the current matrix as a new Vector4
  80198. */
  80199. getRow(index: number): Nullable<Vector4>;
  80200. /**
  80201. * Sets the index-th row of the current matrix to the vector4 values
  80202. * @param index defines the number of the row to set
  80203. * @param row defines the target vector4
  80204. * @returns the updated current matrix
  80205. */
  80206. setRow(index: number, row: Vector4): Matrix;
  80207. /**
  80208. * Compute the transpose of the matrix
  80209. * @returns the new transposed matrix
  80210. */
  80211. transpose(): Matrix;
  80212. /**
  80213. * Compute the transpose of the matrix and store it in a given matrix
  80214. * @param result defines the target matrix
  80215. * @returns the current matrix
  80216. */
  80217. transposeToRef(result: Matrix): Matrix;
  80218. /**
  80219. * Sets the index-th row of the current matrix with the given 4 x float values
  80220. * @param index defines the row index
  80221. * @param x defines the x component to set
  80222. * @param y defines the y component to set
  80223. * @param z defines the z component to set
  80224. * @param w defines the w component to set
  80225. * @returns the updated current matrix
  80226. */
  80227. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  80228. /**
  80229. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  80230. * @param scale defines the scale factor
  80231. * @returns a new matrix
  80232. */
  80233. scale(scale: number): Matrix;
  80234. /**
  80235. * Scale the current matrix values by a factor to a given result matrix
  80236. * @param scale defines the scale factor
  80237. * @param result defines the matrix to store the result
  80238. * @returns the current matrix
  80239. */
  80240. scaleToRef(scale: number, result: Matrix): Matrix;
  80241. /**
  80242. * Scale the current matrix values by a factor and add the result to a given matrix
  80243. * @param scale defines the scale factor
  80244. * @param result defines the Matrix to store the result
  80245. * @returns the current matrix
  80246. */
  80247. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  80248. /**
  80249. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  80250. * @param ref matrix to store the result
  80251. */
  80252. toNormalMatrix(ref: Matrix): void;
  80253. /**
  80254. * Gets only rotation part of the current matrix
  80255. * @returns a new matrix sets to the extracted rotation matrix from the current one
  80256. */
  80257. getRotationMatrix(): Matrix;
  80258. /**
  80259. * Extracts the rotation matrix from the current one and sets it as the given "result"
  80260. * @param result defines the target matrix to store data to
  80261. * @returns the current matrix
  80262. */
  80263. getRotationMatrixToRef(result: Matrix): Matrix;
  80264. /**
  80265. * Toggles model matrix from being right handed to left handed in place and vice versa
  80266. */
  80267. toggleModelMatrixHandInPlace(): void;
  80268. /**
  80269. * Toggles projection matrix from being right handed to left handed in place and vice versa
  80270. */
  80271. toggleProjectionMatrixHandInPlace(): void;
  80272. /**
  80273. * Creates a matrix from an array
  80274. * @param array defines the source array
  80275. * @param offset defines an offset in the source array
  80276. * @returns a new Matrix set from the starting index of the given array
  80277. */
  80278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  80279. /**
  80280. * Copy the content of an array into a given matrix
  80281. * @param array defines the source array
  80282. * @param offset defines an offset in the source array
  80283. * @param result defines the target matrix
  80284. */
  80285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  80286. /**
  80287. * Stores an array into a matrix after having multiplied each component by a given factor
  80288. * @param array defines the source array
  80289. * @param offset defines the offset in the source array
  80290. * @param scale defines the scaling factor
  80291. * @param result defines the target matrix
  80292. */
  80293. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  80294. /**
  80295. * Gets an identity matrix that must not be updated
  80296. */
  80297. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  80298. /**
  80299. * Stores a list of values (16) inside a given matrix
  80300. * @param initialM11 defines 1st value of 1st row
  80301. * @param initialM12 defines 2nd value of 1st row
  80302. * @param initialM13 defines 3rd value of 1st row
  80303. * @param initialM14 defines 4th value of 1st row
  80304. * @param initialM21 defines 1st value of 2nd row
  80305. * @param initialM22 defines 2nd value of 2nd row
  80306. * @param initialM23 defines 3rd value of 2nd row
  80307. * @param initialM24 defines 4th value of 2nd row
  80308. * @param initialM31 defines 1st value of 3rd row
  80309. * @param initialM32 defines 2nd value of 3rd row
  80310. * @param initialM33 defines 3rd value of 3rd row
  80311. * @param initialM34 defines 4th value of 3rd row
  80312. * @param initialM41 defines 1st value of 4th row
  80313. * @param initialM42 defines 2nd value of 4th row
  80314. * @param initialM43 defines 3rd value of 4th row
  80315. * @param initialM44 defines 4th value of 4th row
  80316. * @param result defines the target matrix
  80317. */
  80318. 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;
  80319. /**
  80320. * Creates new matrix from a list of values (16)
  80321. * @param initialM11 defines 1st value of 1st row
  80322. * @param initialM12 defines 2nd value of 1st row
  80323. * @param initialM13 defines 3rd value of 1st row
  80324. * @param initialM14 defines 4th value of 1st row
  80325. * @param initialM21 defines 1st value of 2nd row
  80326. * @param initialM22 defines 2nd value of 2nd row
  80327. * @param initialM23 defines 3rd value of 2nd row
  80328. * @param initialM24 defines 4th value of 2nd row
  80329. * @param initialM31 defines 1st value of 3rd row
  80330. * @param initialM32 defines 2nd value of 3rd row
  80331. * @param initialM33 defines 3rd value of 3rd row
  80332. * @param initialM34 defines 4th value of 3rd row
  80333. * @param initialM41 defines 1st value of 4th row
  80334. * @param initialM42 defines 2nd value of 4th row
  80335. * @param initialM43 defines 3rd value of 4th row
  80336. * @param initialM44 defines 4th value of 4th row
  80337. * @returns the new matrix
  80338. */
  80339. 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;
  80340. /**
  80341. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80342. * @param scale defines the scale vector3
  80343. * @param rotation defines the rotation quaternion
  80344. * @param translation defines the translation vector3
  80345. * @returns a new matrix
  80346. */
  80347. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  80348. /**
  80349. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80350. * @param scale defines the scale vector3
  80351. * @param rotation defines the rotation quaternion
  80352. * @param translation defines the translation vector3
  80353. * @param result defines the target matrix
  80354. */
  80355. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  80356. /**
  80357. * Creates a new identity matrix
  80358. * @returns a new identity matrix
  80359. */
  80360. static Identity(): Matrix;
  80361. /**
  80362. * Creates a new identity matrix and stores the result in a given matrix
  80363. * @param result defines the target matrix
  80364. */
  80365. static IdentityToRef(result: Matrix): void;
  80366. /**
  80367. * Creates a new zero matrix
  80368. * @returns a new zero matrix
  80369. */
  80370. static Zero(): Matrix;
  80371. /**
  80372. * Creates a new rotation matrix for "angle" radians around the X axis
  80373. * @param angle defines the angle (in radians) to use
  80374. * @return the new matrix
  80375. */
  80376. static RotationX(angle: number): Matrix;
  80377. /**
  80378. * Creates a new matrix as the invert of a given matrix
  80379. * @param source defines the source matrix
  80380. * @returns the new matrix
  80381. */
  80382. static Invert(source: DeepImmutable<Matrix>): Matrix;
  80383. /**
  80384. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  80385. * @param angle defines the angle (in radians) to use
  80386. * @param result defines the target matrix
  80387. */
  80388. static RotationXToRef(angle: number, result: Matrix): void;
  80389. /**
  80390. * Creates a new rotation matrix for "angle" radians around the Y axis
  80391. * @param angle defines the angle (in radians) to use
  80392. * @return the new matrix
  80393. */
  80394. static RotationY(angle: number): Matrix;
  80395. /**
  80396. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  80397. * @param angle defines the angle (in radians) to use
  80398. * @param result defines the target matrix
  80399. */
  80400. static RotationYToRef(angle: number, result: Matrix): void;
  80401. /**
  80402. * Creates a new rotation matrix for "angle" radians around the Z axis
  80403. * @param angle defines the angle (in radians) to use
  80404. * @return the new matrix
  80405. */
  80406. static RotationZ(angle: number): Matrix;
  80407. /**
  80408. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  80409. * @param angle defines the angle (in radians) to use
  80410. * @param result defines the target matrix
  80411. */
  80412. static RotationZToRef(angle: number, result: Matrix): void;
  80413. /**
  80414. * Creates a new rotation matrix for "angle" radians around the given axis
  80415. * @param axis defines the axis to use
  80416. * @param angle defines the angle (in radians) to use
  80417. * @return the new matrix
  80418. */
  80419. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  80420. /**
  80421. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  80422. * @param axis defines the axis to use
  80423. * @param angle defines the angle (in radians) to use
  80424. * @param result defines the target matrix
  80425. */
  80426. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  80427. /**
  80428. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  80429. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  80430. * @param from defines the vector to align
  80431. * @param to defines the vector to align to
  80432. * @param result defines the target matrix
  80433. */
  80434. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  80435. /**
  80436. * Creates a rotation matrix
  80437. * @param yaw defines the yaw angle in radians (Y axis)
  80438. * @param pitch defines the pitch angle in radians (X axis)
  80439. * @param roll defines the roll angle in radians (X axis)
  80440. * @returns the new rotation matrix
  80441. */
  80442. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  80443. /**
  80444. * Creates a rotation matrix and stores it in a given matrix
  80445. * @param yaw defines the yaw angle in radians (Y axis)
  80446. * @param pitch defines the pitch angle in radians (X axis)
  80447. * @param roll defines the roll angle in radians (X axis)
  80448. * @param result defines the target matrix
  80449. */
  80450. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  80451. /**
  80452. * Creates a scaling matrix
  80453. * @param x defines the scale factor on X axis
  80454. * @param y defines the scale factor on Y axis
  80455. * @param z defines the scale factor on Z axis
  80456. * @returns the new matrix
  80457. */
  80458. static Scaling(x: number, y: number, z: number): Matrix;
  80459. /**
  80460. * Creates a scaling matrix and stores it in a given matrix
  80461. * @param x defines the scale factor on X axis
  80462. * @param y defines the scale factor on Y axis
  80463. * @param z defines the scale factor on Z axis
  80464. * @param result defines the target matrix
  80465. */
  80466. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  80467. /**
  80468. * Creates a translation matrix
  80469. * @param x defines the translation on X axis
  80470. * @param y defines the translation on Y axis
  80471. * @param z defines the translationon Z axis
  80472. * @returns the new matrix
  80473. */
  80474. static Translation(x: number, y: number, z: number): Matrix;
  80475. /**
  80476. * Creates a translation matrix and stores it in a given matrix
  80477. * @param x defines the translation on X axis
  80478. * @param y defines the translation on Y axis
  80479. * @param z defines the translationon Z axis
  80480. * @param result defines the target matrix
  80481. */
  80482. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  80483. /**
  80484. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80485. * @param startValue defines the start value
  80486. * @param endValue defines the end value
  80487. * @param gradient defines the gradient factor
  80488. * @returns the new matrix
  80489. */
  80490. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80491. /**
  80492. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80493. * @param startValue defines the start value
  80494. * @param endValue defines the end value
  80495. * @param gradient defines the gradient factor
  80496. * @param result defines the Matrix object where to store data
  80497. */
  80498. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80499. /**
  80500. * Builds a new matrix whose values are computed by:
  80501. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80502. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80503. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80504. * @param startValue defines the first matrix
  80505. * @param endValue defines the second matrix
  80506. * @param gradient defines the gradient between the two matrices
  80507. * @returns the new matrix
  80508. */
  80509. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80510. /**
  80511. * Update a matrix to values which are computed by:
  80512. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80513. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80514. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80515. * @param startValue defines the first matrix
  80516. * @param endValue defines the second matrix
  80517. * @param gradient defines the gradient between the two matrices
  80518. * @param result defines the target matrix
  80519. */
  80520. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80521. /**
  80522. * 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"
  80523. * This function works in left handed mode
  80524. * @param eye defines the final position of the entity
  80525. * @param target defines where the entity should look at
  80526. * @param up defines the up vector for the entity
  80527. * @returns the new matrix
  80528. */
  80529. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80530. /**
  80531. * 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".
  80532. * This function works in left handed mode
  80533. * @param eye defines the final position of the entity
  80534. * @param target defines where the entity should look at
  80535. * @param up defines the up vector for the entity
  80536. * @param result defines the target matrix
  80537. */
  80538. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80539. /**
  80540. * 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"
  80541. * This function works in right handed mode
  80542. * @param eye defines the final position of the entity
  80543. * @param target defines where the entity should look at
  80544. * @param up defines the up vector for the entity
  80545. * @returns the new matrix
  80546. */
  80547. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80548. /**
  80549. * 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".
  80550. * This function works in right handed mode
  80551. * @param eye defines the final position of the entity
  80552. * @param target defines where the entity should look at
  80553. * @param up defines the up vector for the entity
  80554. * @param result defines the target matrix
  80555. */
  80556. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80557. /**
  80558. * Create a left-handed orthographic projection matrix
  80559. * @param width defines the viewport width
  80560. * @param height defines the viewport height
  80561. * @param znear defines the near clip plane
  80562. * @param zfar defines the far clip plane
  80563. * @returns a new matrix as a left-handed orthographic projection matrix
  80564. */
  80565. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80566. /**
  80567. * Store a left-handed orthographic projection to a given matrix
  80568. * @param width defines the viewport width
  80569. * @param height defines the viewport height
  80570. * @param znear defines the near clip plane
  80571. * @param zfar defines the far clip plane
  80572. * @param result defines the target matrix
  80573. */
  80574. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  80575. /**
  80576. * Create a left-handed orthographic projection matrix
  80577. * @param left defines the viewport left coordinate
  80578. * @param right defines the viewport right coordinate
  80579. * @param bottom defines the viewport bottom coordinate
  80580. * @param top defines the viewport top coordinate
  80581. * @param znear defines the near clip plane
  80582. * @param zfar defines the far clip plane
  80583. * @returns a new matrix as a left-handed orthographic projection matrix
  80584. */
  80585. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80586. /**
  80587. * Stores a left-handed orthographic projection into a given matrix
  80588. * @param left defines the viewport left coordinate
  80589. * @param right defines the viewport right coordinate
  80590. * @param bottom defines the viewport bottom coordinate
  80591. * @param top defines the viewport top coordinate
  80592. * @param znear defines the near clip plane
  80593. * @param zfar defines the far clip plane
  80594. * @param result defines the target matrix
  80595. */
  80596. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80597. /**
  80598. * Creates a right-handed orthographic projection matrix
  80599. * @param left defines the viewport left coordinate
  80600. * @param right defines the viewport right coordinate
  80601. * @param bottom defines the viewport bottom coordinate
  80602. * @param top defines the viewport top coordinate
  80603. * @param znear defines the near clip plane
  80604. * @param zfar defines the far clip plane
  80605. * @returns a new matrix as a right-handed orthographic projection matrix
  80606. */
  80607. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80608. /**
  80609. * Stores a right-handed orthographic projection into a given matrix
  80610. * @param left defines the viewport left coordinate
  80611. * @param right defines the viewport right coordinate
  80612. * @param bottom defines the viewport bottom coordinate
  80613. * @param top defines the viewport top coordinate
  80614. * @param znear defines the near clip plane
  80615. * @param zfar defines the far clip plane
  80616. * @param result defines the target matrix
  80617. */
  80618. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80619. /**
  80620. * Creates a left-handed perspective projection matrix
  80621. * @param width defines the viewport width
  80622. * @param height defines the viewport height
  80623. * @param znear defines the near clip plane
  80624. * @param zfar defines the far clip plane
  80625. * @returns a new matrix as a left-handed perspective projection matrix
  80626. */
  80627. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80628. /**
  80629. * Creates a left-handed perspective projection matrix
  80630. * @param fov defines the horizontal field of view
  80631. * @param aspect defines the aspect ratio
  80632. * @param znear defines the near clip plane
  80633. * @param zfar defines the far clip plane
  80634. * @returns a new matrix as a left-handed perspective projection matrix
  80635. */
  80636. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80637. /**
  80638. * Stores a left-handed perspective projection into a given matrix
  80639. * @param fov defines the horizontal field of view
  80640. * @param aspect defines the aspect ratio
  80641. * @param znear defines the near clip plane
  80642. * @param zfar defines the far clip plane
  80643. * @param result defines the target matrix
  80644. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80645. */
  80646. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80647. /**
  80648. * Stores a left-handed perspective projection into a given matrix with depth reversed
  80649. * @param fov defines the horizontal field of view
  80650. * @param aspect defines the aspect ratio
  80651. * @param znear defines the near clip plane
  80652. * @param zfar not used as infinity is used as far clip
  80653. * @param result defines the target matrix
  80654. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80655. */
  80656. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80657. /**
  80658. * Creates a right-handed perspective projection matrix
  80659. * @param fov defines the horizontal field of view
  80660. * @param aspect defines the aspect ratio
  80661. * @param znear defines the near clip plane
  80662. * @param zfar defines the far clip plane
  80663. * @returns a new matrix as a right-handed perspective projection matrix
  80664. */
  80665. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80666. /**
  80667. * Stores a right-handed perspective projection into a given 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. * @param result defines the target matrix
  80673. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80674. */
  80675. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80676. /**
  80677. * Stores a right-handed perspective projection into a given matrix
  80678. * @param fov defines the horizontal field of view
  80679. * @param aspect defines the aspect ratio
  80680. * @param znear defines the near clip plane
  80681. * @param zfar not used as infinity is used as far clip
  80682. * @param result defines the target matrix
  80683. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80684. */
  80685. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80686. /**
  80687. * Stores a perspective projection for WebVR info a given matrix
  80688. * @param fov defines the field of view
  80689. * @param znear defines the near clip plane
  80690. * @param zfar defines the far clip plane
  80691. * @param result defines the target matrix
  80692. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  80693. */
  80694. static PerspectiveFovWebVRToRef(fov: {
  80695. upDegrees: number;
  80696. downDegrees: number;
  80697. leftDegrees: number;
  80698. rightDegrees: number;
  80699. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  80700. /**
  80701. * Computes a complete transformation matrix
  80702. * @param viewport defines the viewport to use
  80703. * @param world defines the world matrix
  80704. * @param view defines the view matrix
  80705. * @param projection defines the projection matrix
  80706. * @param zmin defines the near clip plane
  80707. * @param zmax defines the far clip plane
  80708. * @returns the transformation matrix
  80709. */
  80710. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  80711. /**
  80712. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  80713. * @param matrix defines the matrix to use
  80714. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  80715. */
  80716. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  80717. /**
  80718. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  80719. * @param matrix defines the matrix to use
  80720. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  80721. */
  80722. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  80723. /**
  80724. * Compute the transpose of a given matrix
  80725. * @param matrix defines the matrix to transpose
  80726. * @returns the new matrix
  80727. */
  80728. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  80729. /**
  80730. * Compute the transpose of a matrix and store it in a target matrix
  80731. * @param matrix defines the matrix to transpose
  80732. * @param result defines the target matrix
  80733. */
  80734. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  80735. /**
  80736. * Computes a reflection matrix from a plane
  80737. * @param plane defines the reflection plane
  80738. * @returns a new matrix
  80739. */
  80740. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  80741. /**
  80742. * Computes a reflection matrix from a plane
  80743. * @param plane defines the reflection plane
  80744. * @param result defines the target matrix
  80745. */
  80746. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  80747. /**
  80748. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  80749. * @param xaxis defines the value of the 1st axis
  80750. * @param yaxis defines the value of the 2nd axis
  80751. * @param zaxis defines the value of the 3rd axis
  80752. * @param result defines the target matrix
  80753. */
  80754. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  80755. /**
  80756. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  80757. * @param quat defines the quaternion to use
  80758. * @param result defines the target matrix
  80759. */
  80760. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  80761. }
  80762. /**
  80763. * @hidden
  80764. */
  80765. export class TmpVectors {
  80766. static Vector2: Vector2[];
  80767. static Vector3: Vector3[];
  80768. static Vector4: Vector4[];
  80769. static Quaternion: Quaternion[];
  80770. static Matrix: Matrix[];
  80771. }
  80772. }
  80773. declare module BABYLON {
  80774. /**
  80775. * Defines potential orientation for back face culling
  80776. */
  80777. export enum Orientation {
  80778. /**
  80779. * Clockwise
  80780. */
  80781. CW = 0,
  80782. /** Counter clockwise */
  80783. CCW = 1
  80784. }
  80785. /** Class used to represent a Bezier curve */
  80786. export class BezierCurve {
  80787. /**
  80788. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  80789. * @param t defines the time
  80790. * @param x1 defines the left coordinate on X axis
  80791. * @param y1 defines the left coordinate on Y axis
  80792. * @param x2 defines the right coordinate on X axis
  80793. * @param y2 defines the right coordinate on Y axis
  80794. * @returns the interpolated value
  80795. */
  80796. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  80797. }
  80798. /**
  80799. * Defines angle representation
  80800. */
  80801. export class Angle {
  80802. private _radians;
  80803. /**
  80804. * Creates an Angle object of "radians" radians (float).
  80805. * @param radians the angle in radians
  80806. */
  80807. constructor(radians: number);
  80808. /**
  80809. * Get value in degrees
  80810. * @returns the Angle value in degrees (float)
  80811. */
  80812. degrees(): number;
  80813. /**
  80814. * Get value in radians
  80815. * @returns the Angle value in radians (float)
  80816. */
  80817. radians(): number;
  80818. /**
  80819. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  80820. * @param a defines first vector
  80821. * @param b defines second vector
  80822. * @returns a new Angle
  80823. */
  80824. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  80825. /**
  80826. * Gets a new Angle object from the given float in radians
  80827. * @param radians defines the angle value in radians
  80828. * @returns a new Angle
  80829. */
  80830. static FromRadians(radians: number): Angle;
  80831. /**
  80832. * Gets a new Angle object from the given float in degrees
  80833. * @param degrees defines the angle value in degrees
  80834. * @returns a new Angle
  80835. */
  80836. static FromDegrees(degrees: number): Angle;
  80837. }
  80838. /**
  80839. * This represents an arc in a 2d space.
  80840. */
  80841. export class Arc2 {
  80842. /** Defines the start point of the arc */
  80843. startPoint: Vector2;
  80844. /** Defines the mid point of the arc */
  80845. midPoint: Vector2;
  80846. /** Defines the end point of the arc */
  80847. endPoint: Vector2;
  80848. /**
  80849. * Defines the center point of the arc.
  80850. */
  80851. centerPoint: Vector2;
  80852. /**
  80853. * Defines the radius of the arc.
  80854. */
  80855. radius: number;
  80856. /**
  80857. * Defines the angle of the arc (from mid point to end point).
  80858. */
  80859. angle: Angle;
  80860. /**
  80861. * Defines the start angle of the arc (from start point to middle point).
  80862. */
  80863. startAngle: Angle;
  80864. /**
  80865. * Defines the orientation of the arc (clock wise/counter clock wise).
  80866. */
  80867. orientation: Orientation;
  80868. /**
  80869. * Creates an Arc object from the three given points : start, middle and end.
  80870. * @param startPoint Defines the start point of the arc
  80871. * @param midPoint Defines the midlle point of the arc
  80872. * @param endPoint Defines the end point of the arc
  80873. */
  80874. constructor(
  80875. /** Defines the start point of the arc */
  80876. startPoint: Vector2,
  80877. /** Defines the mid point of the arc */
  80878. midPoint: Vector2,
  80879. /** Defines the end point of the arc */
  80880. endPoint: Vector2);
  80881. }
  80882. /**
  80883. * Represents a 2D path made up of multiple 2D points
  80884. */
  80885. export class Path2 {
  80886. private _points;
  80887. private _length;
  80888. /**
  80889. * If the path start and end point are the same
  80890. */
  80891. closed: boolean;
  80892. /**
  80893. * Creates a Path2 object from the starting 2D coordinates x and y.
  80894. * @param x the starting points x value
  80895. * @param y the starting points y value
  80896. */
  80897. constructor(x: number, y: number);
  80898. /**
  80899. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  80900. * @param x the added points x value
  80901. * @param y the added points y value
  80902. * @returns the updated Path2.
  80903. */
  80904. addLineTo(x: number, y: number): Path2;
  80905. /**
  80906. * 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.
  80907. * @param midX middle point x value
  80908. * @param midY middle point y value
  80909. * @param endX end point x value
  80910. * @param endY end point y value
  80911. * @param numberOfSegments (default: 36)
  80912. * @returns the updated Path2.
  80913. */
  80914. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  80915. /**
  80916. * Closes the Path2.
  80917. * @returns the Path2.
  80918. */
  80919. close(): Path2;
  80920. /**
  80921. * Gets the sum of the distance between each sequential point in the path
  80922. * @returns the Path2 total length (float).
  80923. */
  80924. length(): number;
  80925. /**
  80926. * Gets the points which construct the path
  80927. * @returns the Path2 internal array of points.
  80928. */
  80929. getPoints(): Vector2[];
  80930. /**
  80931. * Retreives the point at the distance aways from the starting point
  80932. * @param normalizedLengthPosition the length along the path to retreive the point from
  80933. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  80934. */
  80935. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  80936. /**
  80937. * Creates a new path starting from an x and y position
  80938. * @param x starting x value
  80939. * @param y starting y value
  80940. * @returns a new Path2 starting at the coordinates (x, y).
  80941. */
  80942. static StartingAt(x: number, y: number): Path2;
  80943. }
  80944. /**
  80945. * Represents a 3D path made up of multiple 3D points
  80946. */
  80947. export class Path3D {
  80948. /**
  80949. * an array of Vector3, the curve axis of the Path3D
  80950. */
  80951. path: Vector3[];
  80952. private _curve;
  80953. private _distances;
  80954. private _tangents;
  80955. private _normals;
  80956. private _binormals;
  80957. private _raw;
  80958. private _alignTangentsWithPath;
  80959. private readonly _pointAtData;
  80960. /**
  80961. * new Path3D(path, normal, raw)
  80962. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  80963. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  80964. * @param path an array of Vector3, the curve axis of the Path3D
  80965. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  80966. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  80967. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  80968. */
  80969. constructor(
  80970. /**
  80971. * an array of Vector3, the curve axis of the Path3D
  80972. */
  80973. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  80974. /**
  80975. * Returns the Path3D array of successive Vector3 designing its curve.
  80976. * @returns the Path3D array of successive Vector3 designing its curve.
  80977. */
  80978. getCurve(): Vector3[];
  80979. /**
  80980. * Returns the Path3D array of successive Vector3 designing its curve.
  80981. * @returns the Path3D array of successive Vector3 designing its curve.
  80982. */
  80983. getPoints(): Vector3[];
  80984. /**
  80985. * @returns the computed length (float) of the path.
  80986. */
  80987. length(): number;
  80988. /**
  80989. * Returns an array populated with tangent vectors on each Path3D curve point.
  80990. * @returns an array populated with tangent vectors on each Path3D curve point.
  80991. */
  80992. getTangents(): Vector3[];
  80993. /**
  80994. * Returns an array populated with normal vectors on each Path3D curve point.
  80995. * @returns an array populated with normal vectors on each Path3D curve point.
  80996. */
  80997. getNormals(): Vector3[];
  80998. /**
  80999. * Returns an array populated with binormal vectors on each Path3D curve point.
  81000. * @returns an array populated with binormal vectors on each Path3D curve point.
  81001. */
  81002. getBinormals(): Vector3[];
  81003. /**
  81004. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  81005. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  81006. */
  81007. getDistances(): number[];
  81008. /**
  81009. * Returns an interpolated point along this path
  81010. * @param position the position of the point along this path, from 0.0 to 1.0
  81011. * @returns a new Vector3 as the point
  81012. */
  81013. getPointAt(position: number): Vector3;
  81014. /**
  81015. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  81016. * @param position the position of the point along this path, from 0.0 to 1.0
  81017. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  81018. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  81019. */
  81020. getTangentAt(position: number, interpolated?: boolean): Vector3;
  81021. /**
  81022. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  81023. * @param position the position of the point along this path, from 0.0 to 1.0
  81024. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  81025. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  81026. */
  81027. getNormalAt(position: number, interpolated?: boolean): Vector3;
  81028. /**
  81029. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  81030. * @param position the position of the point along this path, from 0.0 to 1.0
  81031. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  81032. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  81033. */
  81034. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  81035. /**
  81036. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  81037. * @param position the position of the point along this path, from 0.0 to 1.0
  81038. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  81039. */
  81040. getDistanceAt(position: number): number;
  81041. /**
  81042. * Returns the array index of the previous point of an interpolated point along this path
  81043. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81044. * @returns the array index
  81045. */
  81046. getPreviousPointIndexAt(position: number): number;
  81047. /**
  81048. * 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)
  81049. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81050. * @returns the sub position
  81051. */
  81052. getSubPositionAt(position: number): number;
  81053. /**
  81054. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  81055. * @param target the vector of which to get the closest position to
  81056. * @returns the position of the closest virtual point on this path to the target vector
  81057. */
  81058. getClosestPositionTo(target: Vector3): number;
  81059. /**
  81060. * Returns a sub path (slice) of this path
  81061. * @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
  81062. * @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
  81063. * @returns a sub path (slice) of this path
  81064. */
  81065. slice(start?: number, end?: number): Path3D;
  81066. /**
  81067. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  81068. * @param path path which all values are copied into the curves points
  81069. * @param firstNormal which should be projected onto the curve
  81070. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  81071. * @returns the same object updated.
  81072. */
  81073. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  81074. private _compute;
  81075. private _getFirstNonNullVector;
  81076. private _getLastNonNullVector;
  81077. private _normalVector;
  81078. /**
  81079. * Updates the point at data for an interpolated point along this curve
  81080. * @param position the position of the point along this curve, from 0.0 to 1.0
  81081. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  81082. * @returns the (updated) point at data
  81083. */
  81084. private _updatePointAtData;
  81085. /**
  81086. * Updates the point at data from the specified parameters
  81087. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  81088. * @param point the interpolated point
  81089. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  81090. */
  81091. private _setPointAtData;
  81092. /**
  81093. * Updates the point at interpolation matrix for the tangents, normals and binormals
  81094. */
  81095. private _updateInterpolationMatrix;
  81096. }
  81097. /**
  81098. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81099. * A Curve3 is designed from a series of successive Vector3.
  81100. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  81101. */
  81102. export class Curve3 {
  81103. private _points;
  81104. private _length;
  81105. /**
  81106. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  81107. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  81108. * @param v1 (Vector3) the control point
  81109. * @param v2 (Vector3) the end point of the Quadratic Bezier
  81110. * @param nbPoints (integer) the wanted number of points in the curve
  81111. * @returns the created Curve3
  81112. */
  81113. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81114. /**
  81115. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  81116. * @param v0 (Vector3) the origin point of the Cubic Bezier
  81117. * @param v1 (Vector3) the first control point
  81118. * @param v2 (Vector3) the second control point
  81119. * @param v3 (Vector3) the end point of the Cubic Bezier
  81120. * @param nbPoints (integer) the wanted number of points in the curve
  81121. * @returns the created Curve3
  81122. */
  81123. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81124. /**
  81125. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  81126. * @param p1 (Vector3) the origin point of the Hermite Spline
  81127. * @param t1 (Vector3) the tangent vector at the origin point
  81128. * @param p2 (Vector3) the end point of the Hermite Spline
  81129. * @param t2 (Vector3) the tangent vector at the end point
  81130. * @param nbPoints (integer) the wanted number of points in the curve
  81131. * @returns the created Curve3
  81132. */
  81133. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81134. /**
  81135. * Returns a Curve3 object along a CatmullRom Spline curve :
  81136. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  81137. * @param nbPoints (integer) the wanted number of points between each curve control points
  81138. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  81139. * @returns the created Curve3
  81140. */
  81141. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  81142. /**
  81143. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81144. * A Curve3 is designed from a series of successive Vector3.
  81145. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  81146. * @param points points which make up the curve
  81147. */
  81148. constructor(points: Vector3[]);
  81149. /**
  81150. * @returns the Curve3 stored array of successive Vector3
  81151. */
  81152. getPoints(): Vector3[];
  81153. /**
  81154. * @returns the computed length (float) of the curve.
  81155. */
  81156. length(): number;
  81157. /**
  81158. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  81159. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  81160. * curveA and curveB keep unchanged.
  81161. * @param curve the curve to continue from this curve
  81162. * @returns the newly constructed curve
  81163. */
  81164. continue(curve: DeepImmutable<Curve3>): Curve3;
  81165. private _computeLength;
  81166. }
  81167. }
  81168. declare module BABYLON {
  81169. /**
  81170. * This represents the main contract an easing function should follow.
  81171. * Easing functions are used throughout the animation system.
  81172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81173. */
  81174. export interface IEasingFunction {
  81175. /**
  81176. * Given an input gradient between 0 and 1, this returns the corrseponding value
  81177. * of the easing function.
  81178. * The link below provides some of the most common examples of easing functions.
  81179. * @see https://easings.net/
  81180. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81181. * @returns the corresponding value on the curve defined by the easing function
  81182. */
  81183. ease(gradient: number): number;
  81184. }
  81185. /**
  81186. * Base class used for every default easing function.
  81187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81188. */
  81189. export class EasingFunction implements IEasingFunction {
  81190. /**
  81191. * Interpolation follows the mathematical formula associated with the easing function.
  81192. */
  81193. static readonly EASINGMODE_EASEIN: number;
  81194. /**
  81195. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  81196. */
  81197. static readonly EASINGMODE_EASEOUT: number;
  81198. /**
  81199. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  81200. */
  81201. static readonly EASINGMODE_EASEINOUT: number;
  81202. private _easingMode;
  81203. /**
  81204. * Sets the easing mode of the current function.
  81205. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  81206. */
  81207. setEasingMode(easingMode: number): void;
  81208. /**
  81209. * Gets the current easing mode.
  81210. * @returns the easing mode
  81211. */
  81212. getEasingMode(): number;
  81213. /**
  81214. * @hidden
  81215. */
  81216. easeInCore(gradient: number): number;
  81217. /**
  81218. * Given an input gradient between 0 and 1, this returns the corresponding value
  81219. * of the easing function.
  81220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81221. * @returns the corresponding value on the curve defined by the easing function
  81222. */
  81223. ease(gradient: number): number;
  81224. }
  81225. /**
  81226. * Easing function with a circle shape (see link below).
  81227. * @see https://easings.net/#easeInCirc
  81228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81229. */
  81230. export class CircleEase extends EasingFunction implements IEasingFunction {
  81231. /** @hidden */
  81232. easeInCore(gradient: number): number;
  81233. }
  81234. /**
  81235. * Easing function with a ease back shape (see link below).
  81236. * @see https://easings.net/#easeInBack
  81237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81238. */
  81239. export class BackEase extends EasingFunction implements IEasingFunction {
  81240. /** Defines the amplitude of the function */
  81241. amplitude: number;
  81242. /**
  81243. * Instantiates a back ease easing
  81244. * @see https://easings.net/#easeInBack
  81245. * @param amplitude Defines the amplitude of the function
  81246. */
  81247. constructor(
  81248. /** Defines the amplitude of the function */
  81249. amplitude?: number);
  81250. /** @hidden */
  81251. easeInCore(gradient: number): number;
  81252. }
  81253. /**
  81254. * Easing function with a bouncing shape (see link below).
  81255. * @see https://easings.net/#easeInBounce
  81256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81257. */
  81258. export class BounceEase extends EasingFunction implements IEasingFunction {
  81259. /** Defines the number of bounces */
  81260. bounces: number;
  81261. /** Defines the amplitude of the bounce */
  81262. bounciness: number;
  81263. /**
  81264. * Instantiates a bounce easing
  81265. * @see https://easings.net/#easeInBounce
  81266. * @param bounces Defines the number of bounces
  81267. * @param bounciness Defines the amplitude of the bounce
  81268. */
  81269. constructor(
  81270. /** Defines the number of bounces */
  81271. bounces?: number,
  81272. /** Defines the amplitude of the bounce */
  81273. bounciness?: number);
  81274. /** @hidden */
  81275. easeInCore(gradient: number): number;
  81276. }
  81277. /**
  81278. * Easing function with a power of 3 shape (see link below).
  81279. * @see https://easings.net/#easeInCubic
  81280. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81281. */
  81282. export class CubicEase extends EasingFunction implements IEasingFunction {
  81283. /** @hidden */
  81284. easeInCore(gradient: number): number;
  81285. }
  81286. /**
  81287. * Easing function with an elastic shape (see link below).
  81288. * @see https://easings.net/#easeInElastic
  81289. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81290. */
  81291. export class ElasticEase extends EasingFunction implements IEasingFunction {
  81292. /** Defines the number of oscillations*/
  81293. oscillations: number;
  81294. /** Defines the amplitude of the oscillations*/
  81295. springiness: number;
  81296. /**
  81297. * Instantiates an elastic easing function
  81298. * @see https://easings.net/#easeInElastic
  81299. * @param oscillations Defines the number of oscillations
  81300. * @param springiness Defines the amplitude of the oscillations
  81301. */
  81302. constructor(
  81303. /** Defines the number of oscillations*/
  81304. oscillations?: number,
  81305. /** Defines the amplitude of the oscillations*/
  81306. springiness?: number);
  81307. /** @hidden */
  81308. easeInCore(gradient: number): number;
  81309. }
  81310. /**
  81311. * Easing function with an exponential shape (see link below).
  81312. * @see https://easings.net/#easeInExpo
  81313. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81314. */
  81315. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  81316. /** Defines the exponent of the function */
  81317. exponent: number;
  81318. /**
  81319. * Instantiates an exponential easing function
  81320. * @see https://easings.net/#easeInExpo
  81321. * @param exponent Defines the exponent of the function
  81322. */
  81323. constructor(
  81324. /** Defines the exponent of the function */
  81325. exponent?: number);
  81326. /** @hidden */
  81327. easeInCore(gradient: number): number;
  81328. }
  81329. /**
  81330. * Easing function with a power shape (see link below).
  81331. * @see https://easings.net/#easeInQuad
  81332. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81333. */
  81334. export class PowerEase extends EasingFunction implements IEasingFunction {
  81335. /** Defines the power of the function */
  81336. power: number;
  81337. /**
  81338. * Instantiates an power base easing function
  81339. * @see https://easings.net/#easeInQuad
  81340. * @param power Defines the power of the function
  81341. */
  81342. constructor(
  81343. /** Defines the power of the function */
  81344. power?: number);
  81345. /** @hidden */
  81346. easeInCore(gradient: number): number;
  81347. }
  81348. /**
  81349. * Easing function with a power of 2 shape (see link below).
  81350. * @see https://easings.net/#easeInQuad
  81351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81352. */
  81353. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  81354. /** @hidden */
  81355. easeInCore(gradient: number): number;
  81356. }
  81357. /**
  81358. * Easing function with a power of 4 shape (see link below).
  81359. * @see https://easings.net/#easeInQuart
  81360. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81361. */
  81362. export class QuarticEase extends EasingFunction implements IEasingFunction {
  81363. /** @hidden */
  81364. easeInCore(gradient: number): number;
  81365. }
  81366. /**
  81367. * Easing function with a power of 5 shape (see link below).
  81368. * @see https://easings.net/#easeInQuint
  81369. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81370. */
  81371. export class QuinticEase extends EasingFunction implements IEasingFunction {
  81372. /** @hidden */
  81373. easeInCore(gradient: number): number;
  81374. }
  81375. /**
  81376. * Easing function with a sin shape (see link below).
  81377. * @see https://easings.net/#easeInSine
  81378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81379. */
  81380. export class SineEase extends EasingFunction implements IEasingFunction {
  81381. /** @hidden */
  81382. easeInCore(gradient: number): number;
  81383. }
  81384. /**
  81385. * Easing function with a bezier shape (see link below).
  81386. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81387. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81388. */
  81389. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  81390. /** Defines the x component of the start tangent in the bezier curve */
  81391. x1: number;
  81392. /** Defines the y component of the start tangent in the bezier curve */
  81393. y1: number;
  81394. /** Defines the x component of the end tangent in the bezier curve */
  81395. x2: number;
  81396. /** Defines the y component of the end tangent in the bezier curve */
  81397. y2: number;
  81398. /**
  81399. * Instantiates a bezier function
  81400. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81401. * @param x1 Defines the x component of the start tangent in the bezier curve
  81402. * @param y1 Defines the y component of the start tangent in the bezier curve
  81403. * @param x2 Defines the x component of the end tangent in the bezier curve
  81404. * @param y2 Defines the y component of the end tangent in the bezier curve
  81405. */
  81406. constructor(
  81407. /** Defines the x component of the start tangent in the bezier curve */
  81408. x1?: number,
  81409. /** Defines the y component of the start tangent in the bezier curve */
  81410. y1?: number,
  81411. /** Defines the x component of the end tangent in the bezier curve */
  81412. x2?: number,
  81413. /** Defines the y component of the end tangent in the bezier curve */
  81414. y2?: number);
  81415. /** @hidden */
  81416. easeInCore(gradient: number): number;
  81417. }
  81418. }
  81419. declare module BABYLON {
  81420. /**
  81421. * Class used to hold a RBG color
  81422. */
  81423. export class Color3 {
  81424. /**
  81425. * Defines the red component (between 0 and 1, default is 0)
  81426. */
  81427. r: number;
  81428. /**
  81429. * Defines the green component (between 0 and 1, default is 0)
  81430. */
  81431. g: number;
  81432. /**
  81433. * Defines the blue component (between 0 and 1, default is 0)
  81434. */
  81435. b: number;
  81436. /**
  81437. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  81438. * @param r defines the red component (between 0 and 1, default is 0)
  81439. * @param g defines the green component (between 0 and 1, default is 0)
  81440. * @param b defines the blue component (between 0 and 1, default is 0)
  81441. */
  81442. constructor(
  81443. /**
  81444. * Defines the red component (between 0 and 1, default is 0)
  81445. */
  81446. r?: number,
  81447. /**
  81448. * Defines the green component (between 0 and 1, default is 0)
  81449. */
  81450. g?: number,
  81451. /**
  81452. * Defines the blue component (between 0 and 1, default is 0)
  81453. */
  81454. b?: number);
  81455. /**
  81456. * Creates a string with the Color3 current values
  81457. * @returns the string representation of the Color3 object
  81458. */
  81459. toString(): string;
  81460. /**
  81461. * Returns the string "Color3"
  81462. * @returns "Color3"
  81463. */
  81464. getClassName(): string;
  81465. /**
  81466. * Compute the Color3 hash code
  81467. * @returns an unique number that can be used to hash Color3 objects
  81468. */
  81469. getHashCode(): number;
  81470. /**
  81471. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  81472. * @param array defines the array where to store the r,g,b components
  81473. * @param index defines an optional index in the target array to define where to start storing values
  81474. * @returns the current Color3 object
  81475. */
  81476. toArray(array: FloatArray, index?: number): Color3;
  81477. /**
  81478. * Returns a new Color4 object from the current Color3 and the given alpha
  81479. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  81480. * @returns a new Color4 object
  81481. */
  81482. toColor4(alpha?: number): Color4;
  81483. /**
  81484. * Returns a new array populated with 3 numeric elements : red, green and blue values
  81485. * @returns the new array
  81486. */
  81487. asArray(): number[];
  81488. /**
  81489. * Returns the luminance value
  81490. * @returns a float value
  81491. */
  81492. toLuminance(): number;
  81493. /**
  81494. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  81495. * @param otherColor defines the second operand
  81496. * @returns the new Color3 object
  81497. */
  81498. multiply(otherColor: DeepImmutable<Color3>): Color3;
  81499. /**
  81500. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  81501. * @param otherColor defines the second operand
  81502. * @param result defines the Color3 object where to store the result
  81503. * @returns the current Color3
  81504. */
  81505. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81506. /**
  81507. * Determines equality between Color3 objects
  81508. * @param otherColor defines the second operand
  81509. * @returns true if the rgb values are equal to the given ones
  81510. */
  81511. equals(otherColor: DeepImmutable<Color3>): boolean;
  81512. /**
  81513. * Determines equality between the current Color3 object and a set of r,b,g values
  81514. * @param r defines the red component to check
  81515. * @param g defines the green component to check
  81516. * @param b defines the blue component to check
  81517. * @returns true if the rgb values are equal to the given ones
  81518. */
  81519. equalsFloats(r: number, g: number, b: number): boolean;
  81520. /**
  81521. * Multiplies in place each rgb value by scale
  81522. * @param scale defines the scaling factor
  81523. * @returns the updated Color3
  81524. */
  81525. scale(scale: number): Color3;
  81526. /**
  81527. * Multiplies the rgb values by scale and stores the result into "result"
  81528. * @param scale defines the scaling factor
  81529. * @param result defines the Color3 object where to store the result
  81530. * @returns the unmodified current Color3
  81531. */
  81532. scaleToRef(scale: number, result: Color3): Color3;
  81533. /**
  81534. * Scale the current Color3 values by a factor and add the result to a given Color3
  81535. * @param scale defines the scale factor
  81536. * @param result defines color to store the result into
  81537. * @returns the unmodified current Color3
  81538. */
  81539. scaleAndAddToRef(scale: number, result: Color3): Color3;
  81540. /**
  81541. * Clamps the rgb values by the min and max values and stores the result into "result"
  81542. * @param min defines minimum clamping value (default is 0)
  81543. * @param max defines maximum clamping value (default is 1)
  81544. * @param result defines color to store the result into
  81545. * @returns the original Color3
  81546. */
  81547. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  81548. /**
  81549. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  81550. * @param otherColor defines the second operand
  81551. * @returns the new Color3
  81552. */
  81553. add(otherColor: DeepImmutable<Color3>): Color3;
  81554. /**
  81555. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  81556. * @param otherColor defines the second operand
  81557. * @param result defines Color3 object to store the result into
  81558. * @returns the unmodified current Color3
  81559. */
  81560. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81561. /**
  81562. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  81563. * @param otherColor defines the second operand
  81564. * @returns the new Color3
  81565. */
  81566. subtract(otherColor: DeepImmutable<Color3>): Color3;
  81567. /**
  81568. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  81569. * @param otherColor defines the second operand
  81570. * @param result defines Color3 object to store the result into
  81571. * @returns the unmodified current Color3
  81572. */
  81573. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81574. /**
  81575. * Copy the current object
  81576. * @returns a new Color3 copied the current one
  81577. */
  81578. clone(): Color3;
  81579. /**
  81580. * Copies the rgb values from the source in the current Color3
  81581. * @param source defines the source Color3 object
  81582. * @returns the updated Color3 object
  81583. */
  81584. copyFrom(source: DeepImmutable<Color3>): Color3;
  81585. /**
  81586. * Updates the Color3 rgb values from the given floats
  81587. * @param r defines the red component to read from
  81588. * @param g defines the green component to read from
  81589. * @param b defines the blue component to read from
  81590. * @returns the current Color3 object
  81591. */
  81592. copyFromFloats(r: number, g: number, b: number): Color3;
  81593. /**
  81594. * Updates the Color3 rgb values from the given floats
  81595. * @param r defines the red component to read from
  81596. * @param g defines the green component to read from
  81597. * @param b defines the blue component to read from
  81598. * @returns the current Color3 object
  81599. */
  81600. set(r: number, g: number, b: number): Color3;
  81601. /**
  81602. * Compute the Color3 hexadecimal code as a string
  81603. * @returns a string containing the hexadecimal representation of the Color3 object
  81604. */
  81605. toHexString(): string;
  81606. /**
  81607. * Computes a new Color3 converted from the current one to linear space
  81608. * @returns a new Color3 object
  81609. */
  81610. toLinearSpace(): Color3;
  81611. /**
  81612. * Converts current color in rgb space to HSV values
  81613. * @returns a new color3 representing the HSV values
  81614. */
  81615. toHSV(): Color3;
  81616. /**
  81617. * Converts current color in rgb space to HSV values
  81618. * @param result defines the Color3 where to store the HSV values
  81619. */
  81620. toHSVToRef(result: Color3): void;
  81621. /**
  81622. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  81623. * @param convertedColor defines the Color3 object where to store the linear space version
  81624. * @returns the unmodified Color3
  81625. */
  81626. toLinearSpaceToRef(convertedColor: Color3): Color3;
  81627. /**
  81628. * Computes a new Color3 converted from the current one to gamma space
  81629. * @returns a new Color3 object
  81630. */
  81631. toGammaSpace(): Color3;
  81632. /**
  81633. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  81634. * @param convertedColor defines the Color3 object where to store the gamma space version
  81635. * @returns the unmodified Color3
  81636. */
  81637. toGammaSpaceToRef(convertedColor: Color3): Color3;
  81638. private static _BlackReadOnly;
  81639. /**
  81640. * Convert Hue, saturation and value to a Color3 (RGB)
  81641. * @param hue defines the hue
  81642. * @param saturation defines the saturation
  81643. * @param value defines the value
  81644. * @param result defines the Color3 where to store the RGB values
  81645. */
  81646. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  81647. /**
  81648. * Creates a new Color3 from the string containing valid hexadecimal values
  81649. * @param hex defines a string containing valid hexadecimal values
  81650. * @returns a new Color3 object
  81651. */
  81652. static FromHexString(hex: string): Color3;
  81653. /**
  81654. * Creates a new Color3 from the starting index of the given array
  81655. * @param array defines the source array
  81656. * @param offset defines an offset in the source array
  81657. * @returns a new Color3 object
  81658. */
  81659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  81660. /**
  81661. * Creates a new Color3 from integer values (< 256)
  81662. * @param r defines the red component to read from (value between 0 and 255)
  81663. * @param g defines the green component to read from (value between 0 and 255)
  81664. * @param b defines the blue component to read from (value between 0 and 255)
  81665. * @returns a new Color3 object
  81666. */
  81667. static FromInts(r: number, g: number, b: number): Color3;
  81668. /**
  81669. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81670. * @param start defines the start Color3 value
  81671. * @param end defines the end Color3 value
  81672. * @param amount defines the gradient value between start and end
  81673. * @returns a new Color3 object
  81674. */
  81675. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  81676. /**
  81677. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81678. * @param left defines the start value
  81679. * @param right defines the end value
  81680. * @param amount defines the gradient factor
  81681. * @param result defines the Color3 object where to store the result
  81682. */
  81683. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  81684. /**
  81685. * Returns a Color3 value containing a red color
  81686. * @returns a new Color3 object
  81687. */
  81688. static Red(): Color3;
  81689. /**
  81690. * Returns a Color3 value containing a green color
  81691. * @returns a new Color3 object
  81692. */
  81693. static Green(): Color3;
  81694. /**
  81695. * Returns a Color3 value containing a blue color
  81696. * @returns a new Color3 object
  81697. */
  81698. static Blue(): Color3;
  81699. /**
  81700. * Returns a Color3 value containing a black color
  81701. * @returns a new Color3 object
  81702. */
  81703. static Black(): Color3;
  81704. /**
  81705. * Gets a Color3 value containing a black color that must not be updated
  81706. */
  81707. static get BlackReadOnly(): DeepImmutable<Color3>;
  81708. /**
  81709. * Returns a Color3 value containing a white color
  81710. * @returns a new Color3 object
  81711. */
  81712. static White(): Color3;
  81713. /**
  81714. * Returns a Color3 value containing a purple color
  81715. * @returns a new Color3 object
  81716. */
  81717. static Purple(): Color3;
  81718. /**
  81719. * Returns a Color3 value containing a magenta color
  81720. * @returns a new Color3 object
  81721. */
  81722. static Magenta(): Color3;
  81723. /**
  81724. * Returns a Color3 value containing a yellow color
  81725. * @returns a new Color3 object
  81726. */
  81727. static Yellow(): Color3;
  81728. /**
  81729. * Returns a Color3 value containing a gray color
  81730. * @returns a new Color3 object
  81731. */
  81732. static Gray(): Color3;
  81733. /**
  81734. * Returns a Color3 value containing a teal color
  81735. * @returns a new Color3 object
  81736. */
  81737. static Teal(): Color3;
  81738. /**
  81739. * Returns a Color3 value containing a random color
  81740. * @returns a new Color3 object
  81741. */
  81742. static Random(): Color3;
  81743. }
  81744. /**
  81745. * Class used to hold a RBGA color
  81746. */
  81747. export class Color4 {
  81748. /**
  81749. * Defines the red component (between 0 and 1, default is 0)
  81750. */
  81751. r: number;
  81752. /**
  81753. * Defines the green component (between 0 and 1, default is 0)
  81754. */
  81755. g: number;
  81756. /**
  81757. * Defines the blue component (between 0 and 1, default is 0)
  81758. */
  81759. b: number;
  81760. /**
  81761. * Defines the alpha component (between 0 and 1, default is 1)
  81762. */
  81763. a: number;
  81764. /**
  81765. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  81766. * @param r defines the red component (between 0 and 1, default is 0)
  81767. * @param g defines the green component (between 0 and 1, default is 0)
  81768. * @param b defines the blue component (between 0 and 1, default is 0)
  81769. * @param a defines the alpha component (between 0 and 1, default is 1)
  81770. */
  81771. constructor(
  81772. /**
  81773. * Defines the red component (between 0 and 1, default is 0)
  81774. */
  81775. r?: number,
  81776. /**
  81777. * Defines the green component (between 0 and 1, default is 0)
  81778. */
  81779. g?: number,
  81780. /**
  81781. * Defines the blue component (between 0 and 1, default is 0)
  81782. */
  81783. b?: number,
  81784. /**
  81785. * Defines the alpha component (between 0 and 1, default is 1)
  81786. */
  81787. a?: number);
  81788. /**
  81789. * Adds in place the given Color4 values to the current Color4 object
  81790. * @param right defines the second operand
  81791. * @returns the current updated Color4 object
  81792. */
  81793. addInPlace(right: DeepImmutable<Color4>): Color4;
  81794. /**
  81795. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  81796. * @returns the new array
  81797. */
  81798. asArray(): number[];
  81799. /**
  81800. * Stores from the starting index in the given array the Color4 successive values
  81801. * @param array defines the array where to store the r,g,b components
  81802. * @param index defines an optional index in the target array to define where to start storing values
  81803. * @returns the current Color4 object
  81804. */
  81805. toArray(array: number[], index?: number): Color4;
  81806. /**
  81807. * Determines equality between Color4 objects
  81808. * @param otherColor defines the second operand
  81809. * @returns true if the rgba values are equal to the given ones
  81810. */
  81811. equals(otherColor: DeepImmutable<Color4>): boolean;
  81812. /**
  81813. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  81814. * @param right defines the second operand
  81815. * @returns a new Color4 object
  81816. */
  81817. add(right: DeepImmutable<Color4>): Color4;
  81818. /**
  81819. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  81820. * @param right defines the second operand
  81821. * @returns a new Color4 object
  81822. */
  81823. subtract(right: DeepImmutable<Color4>): Color4;
  81824. /**
  81825. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  81826. * @param right defines the second operand
  81827. * @param result defines the Color4 object where to store the result
  81828. * @returns the current Color4 object
  81829. */
  81830. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  81831. /**
  81832. * Creates a new Color4 with the current Color4 values multiplied by scale
  81833. * @param scale defines the scaling factor to apply
  81834. * @returns a new Color4 object
  81835. */
  81836. scale(scale: number): Color4;
  81837. /**
  81838. * Multiplies the current Color4 values by scale and stores the result in "result"
  81839. * @param scale defines the scaling factor to apply
  81840. * @param result defines the Color4 object where to store the result
  81841. * @returns the current unmodified Color4
  81842. */
  81843. scaleToRef(scale: number, result: Color4): Color4;
  81844. /**
  81845. * Scale the current Color4 values by a factor and add the result to a given Color4
  81846. * @param scale defines the scale factor
  81847. * @param result defines the Color4 object where to store the result
  81848. * @returns the unmodified current Color4
  81849. */
  81850. scaleAndAddToRef(scale: number, result: Color4): Color4;
  81851. /**
  81852. * Clamps the rgb values by the min and max values and stores the result into "result"
  81853. * @param min defines minimum clamping value (default is 0)
  81854. * @param max defines maximum clamping value (default is 1)
  81855. * @param result defines color to store the result into.
  81856. * @returns the cuurent Color4
  81857. */
  81858. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  81859. /**
  81860. * Multipy an Color4 value by another and return a new Color4 object
  81861. * @param color defines the Color4 value to multiply by
  81862. * @returns a new Color4 object
  81863. */
  81864. multiply(color: Color4): Color4;
  81865. /**
  81866. * Multipy a Color4 value by another and push the result in a reference value
  81867. * @param color defines the Color4 value to multiply by
  81868. * @param result defines the Color4 to fill the result in
  81869. * @returns the result Color4
  81870. */
  81871. multiplyToRef(color: Color4, result: Color4): Color4;
  81872. /**
  81873. * Creates a string with the Color4 current values
  81874. * @returns the string representation of the Color4 object
  81875. */
  81876. toString(): string;
  81877. /**
  81878. * Returns the string "Color4"
  81879. * @returns "Color4"
  81880. */
  81881. getClassName(): string;
  81882. /**
  81883. * Compute the Color4 hash code
  81884. * @returns an unique number that can be used to hash Color4 objects
  81885. */
  81886. getHashCode(): number;
  81887. /**
  81888. * Creates a new Color4 copied from the current one
  81889. * @returns a new Color4 object
  81890. */
  81891. clone(): Color4;
  81892. /**
  81893. * Copies the given Color4 values into the current one
  81894. * @param source defines the source Color4 object
  81895. * @returns the current updated Color4 object
  81896. */
  81897. copyFrom(source: Color4): Color4;
  81898. /**
  81899. * Copies the given float values into the current one
  81900. * @param r defines the red component to read from
  81901. * @param g defines the green component to read from
  81902. * @param b defines the blue component to read from
  81903. * @param a defines the alpha component to read from
  81904. * @returns the current updated Color4 object
  81905. */
  81906. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  81907. /**
  81908. * Copies the given float values into the current one
  81909. * @param r defines the red component to read from
  81910. * @param g defines the green component to read from
  81911. * @param b defines the blue component to read from
  81912. * @param a defines the alpha component to read from
  81913. * @returns the current updated Color4 object
  81914. */
  81915. set(r: number, g: number, b: number, a: number): Color4;
  81916. /**
  81917. * Compute the Color4 hexadecimal code as a string
  81918. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  81919. * @returns a string containing the hexadecimal representation of the Color4 object
  81920. */
  81921. toHexString(returnAsColor3?: boolean): string;
  81922. /**
  81923. * Computes a new Color4 converted from the current one to linear space
  81924. * @returns a new Color4 object
  81925. */
  81926. toLinearSpace(): Color4;
  81927. /**
  81928. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  81929. * @param convertedColor defines the Color4 object where to store the linear space version
  81930. * @returns the unmodified Color4
  81931. */
  81932. toLinearSpaceToRef(convertedColor: Color4): Color4;
  81933. /**
  81934. * Computes a new Color4 converted from the current one to gamma space
  81935. * @returns a new Color4 object
  81936. */
  81937. toGammaSpace(): Color4;
  81938. /**
  81939. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  81940. * @param convertedColor defines the Color4 object where to store the gamma space version
  81941. * @returns the unmodified Color4
  81942. */
  81943. toGammaSpaceToRef(convertedColor: Color4): Color4;
  81944. /**
  81945. * Creates a new Color4 from the string containing valid hexadecimal values
  81946. * @param hex defines a string containing valid hexadecimal values
  81947. * @returns a new Color4 object
  81948. */
  81949. static FromHexString(hex: string): Color4;
  81950. /**
  81951. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81952. * @param left defines the start value
  81953. * @param right defines the end value
  81954. * @param amount defines the gradient factor
  81955. * @returns a new Color4 object
  81956. */
  81957. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  81958. /**
  81959. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81960. * @param left defines the start value
  81961. * @param right defines the end value
  81962. * @param amount defines the gradient factor
  81963. * @param result defines the Color4 object where to store data
  81964. */
  81965. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  81966. /**
  81967. * Creates a new Color4 from a Color3 and an alpha value
  81968. * @param color3 defines the source Color3 to read from
  81969. * @param alpha defines the alpha component (1.0 by default)
  81970. * @returns a new Color4 object
  81971. */
  81972. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  81973. /**
  81974. * Creates a new Color4 from the starting index element of the given array
  81975. * @param array defines the source array to read from
  81976. * @param offset defines the offset in the source array
  81977. * @returns a new Color4 object
  81978. */
  81979. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  81980. /**
  81981. * Creates a new Color3 from integer values (< 256)
  81982. * @param r defines the red component to read from (value between 0 and 255)
  81983. * @param g defines the green component to read from (value between 0 and 255)
  81984. * @param b defines the blue component to read from (value between 0 and 255)
  81985. * @param a defines the alpha component to read from (value between 0 and 255)
  81986. * @returns a new Color3 object
  81987. */
  81988. static FromInts(r: number, g: number, b: number, a: number): Color4;
  81989. /**
  81990. * Check the content of a given array and convert it to an array containing RGBA data
  81991. * If the original array was already containing count * 4 values then it is returned directly
  81992. * @param colors defines the array to check
  81993. * @param count defines the number of RGBA data to expect
  81994. * @returns an array containing count * 4 values (RGBA)
  81995. */
  81996. static CheckColors4(colors: number[], count: number): number[];
  81997. }
  81998. /**
  81999. * @hidden
  82000. */
  82001. export class TmpColors {
  82002. static Color3: Color3[];
  82003. static Color4: Color4[];
  82004. }
  82005. }
  82006. declare module BABYLON {
  82007. /**
  82008. * Defines an interface which represents an animation key frame
  82009. */
  82010. export interface IAnimationKey {
  82011. /**
  82012. * Frame of the key frame
  82013. */
  82014. frame: number;
  82015. /**
  82016. * Value at the specifies key frame
  82017. */
  82018. value: any;
  82019. /**
  82020. * The input tangent for the cubic hermite spline
  82021. */
  82022. inTangent?: any;
  82023. /**
  82024. * The output tangent for the cubic hermite spline
  82025. */
  82026. outTangent?: any;
  82027. /**
  82028. * The animation interpolation type
  82029. */
  82030. interpolation?: AnimationKeyInterpolation;
  82031. }
  82032. /**
  82033. * Enum for the animation key frame interpolation type
  82034. */
  82035. export enum AnimationKeyInterpolation {
  82036. /**
  82037. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  82038. */
  82039. STEP = 1
  82040. }
  82041. }
  82042. declare module BABYLON {
  82043. /**
  82044. * Represents the range of an animation
  82045. */
  82046. export class AnimationRange {
  82047. /**The name of the animation range**/
  82048. name: string;
  82049. /**The starting frame of the animation */
  82050. from: number;
  82051. /**The ending frame of the animation*/
  82052. to: number;
  82053. /**
  82054. * Initializes the range of an animation
  82055. * @param name The name of the animation range
  82056. * @param from The starting frame of the animation
  82057. * @param to The ending frame of the animation
  82058. */
  82059. constructor(
  82060. /**The name of the animation range**/
  82061. name: string,
  82062. /**The starting frame of the animation */
  82063. from: number,
  82064. /**The ending frame of the animation*/
  82065. to: number);
  82066. /**
  82067. * Makes a copy of the animation range
  82068. * @returns A copy of the animation range
  82069. */
  82070. clone(): AnimationRange;
  82071. }
  82072. }
  82073. declare module BABYLON {
  82074. /**
  82075. * Composed of a frame, and an action function
  82076. */
  82077. export class AnimationEvent {
  82078. /** The frame for which the event is triggered **/
  82079. frame: number;
  82080. /** The event to perform when triggered **/
  82081. action: (currentFrame: number) => void;
  82082. /** Specifies if the event should be triggered only once**/
  82083. onlyOnce?: boolean | undefined;
  82084. /**
  82085. * Specifies if the animation event is done
  82086. */
  82087. isDone: boolean;
  82088. /**
  82089. * Initializes the animation event
  82090. * @param frame The frame for which the event is triggered
  82091. * @param action The event to perform when triggered
  82092. * @param onlyOnce Specifies if the event should be triggered only once
  82093. */
  82094. constructor(
  82095. /** The frame for which the event is triggered **/
  82096. frame: number,
  82097. /** The event to perform when triggered **/
  82098. action: (currentFrame: number) => void,
  82099. /** Specifies if the event should be triggered only once**/
  82100. onlyOnce?: boolean | undefined);
  82101. /** @hidden */
  82102. _clone(): AnimationEvent;
  82103. }
  82104. }
  82105. declare module BABYLON {
  82106. /**
  82107. * Interface used to define a behavior
  82108. */
  82109. export interface Behavior<T> {
  82110. /** gets or sets behavior's name */
  82111. name: string;
  82112. /**
  82113. * Function called when the behavior needs to be initialized (after attaching it to a target)
  82114. */
  82115. init(): void;
  82116. /**
  82117. * Called when the behavior is attached to a target
  82118. * @param target defines the target where the behavior is attached to
  82119. */
  82120. attach(target: T): void;
  82121. /**
  82122. * Called when the behavior is detached from its target
  82123. */
  82124. detach(): void;
  82125. }
  82126. /**
  82127. * Interface implemented by classes supporting behaviors
  82128. */
  82129. export interface IBehaviorAware<T> {
  82130. /**
  82131. * Attach a behavior
  82132. * @param behavior defines the behavior to attach
  82133. * @returns the current host
  82134. */
  82135. addBehavior(behavior: Behavior<T>): T;
  82136. /**
  82137. * Remove a behavior from the current object
  82138. * @param behavior defines the behavior to detach
  82139. * @returns the current host
  82140. */
  82141. removeBehavior(behavior: Behavior<T>): T;
  82142. /**
  82143. * Gets a behavior using its name to search
  82144. * @param name defines the name to search
  82145. * @returns the behavior or null if not found
  82146. */
  82147. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  82148. }
  82149. }
  82150. declare module BABYLON {
  82151. /**
  82152. * Defines an array and its length.
  82153. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  82154. */
  82155. export interface ISmartArrayLike<T> {
  82156. /**
  82157. * The data of the array.
  82158. */
  82159. data: Array<T>;
  82160. /**
  82161. * The active length of the array.
  82162. */
  82163. length: number;
  82164. }
  82165. /**
  82166. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82167. */
  82168. export class SmartArray<T> implements ISmartArrayLike<T> {
  82169. /**
  82170. * The full set of data from the array.
  82171. */
  82172. data: Array<T>;
  82173. /**
  82174. * The active length of the array.
  82175. */
  82176. length: number;
  82177. protected _id: number;
  82178. /**
  82179. * Instantiates a Smart Array.
  82180. * @param capacity defines the default capacity of the array.
  82181. */
  82182. constructor(capacity: number);
  82183. /**
  82184. * Pushes a value at the end of the active data.
  82185. * @param value defines the object to push in the array.
  82186. */
  82187. push(value: T): void;
  82188. /**
  82189. * Iterates over the active data and apply the lambda to them.
  82190. * @param func defines the action to apply on each value.
  82191. */
  82192. forEach(func: (content: T) => void): void;
  82193. /**
  82194. * Sorts the full sets of data.
  82195. * @param compareFn defines the comparison function to apply.
  82196. */
  82197. sort(compareFn: (a: T, b: T) => number): void;
  82198. /**
  82199. * Resets the active data to an empty array.
  82200. */
  82201. reset(): void;
  82202. /**
  82203. * Releases all the data from the array as well as the array.
  82204. */
  82205. dispose(): void;
  82206. /**
  82207. * Concats the active data with a given array.
  82208. * @param array defines the data to concatenate with.
  82209. */
  82210. concat(array: any): void;
  82211. /**
  82212. * Returns the position of a value in the active data.
  82213. * @param value defines the value to find the index for
  82214. * @returns the index if found in the active data otherwise -1
  82215. */
  82216. indexOf(value: T): number;
  82217. /**
  82218. * Returns whether an element is part of the active data.
  82219. * @param value defines the value to look for
  82220. * @returns true if found in the active data otherwise false
  82221. */
  82222. contains(value: T): boolean;
  82223. private static _GlobalId;
  82224. }
  82225. /**
  82226. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82227. * The data in this array can only be present once
  82228. */
  82229. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  82230. private _duplicateId;
  82231. /**
  82232. * Pushes a value at the end of the active data.
  82233. * THIS DOES NOT PREVENT DUPPLICATE DATA
  82234. * @param value defines the object to push in the array.
  82235. */
  82236. push(value: T): void;
  82237. /**
  82238. * Pushes a value at the end of the active data.
  82239. * If the data is already present, it won t be added again
  82240. * @param value defines the object to push in the array.
  82241. * @returns true if added false if it was already present
  82242. */
  82243. pushNoDuplicate(value: T): boolean;
  82244. /**
  82245. * Resets the active data to an empty array.
  82246. */
  82247. reset(): void;
  82248. /**
  82249. * Concats the active data with a given array.
  82250. * This ensures no dupplicate will be present in the result.
  82251. * @param array defines the data to concatenate with.
  82252. */
  82253. concatWithNoDuplicate(array: any): void;
  82254. }
  82255. }
  82256. declare module BABYLON {
  82257. /**
  82258. * @ignore
  82259. * This is a list of all the different input types that are available in the application.
  82260. * Fo instance: ArcRotateCameraGamepadInput...
  82261. */
  82262. export var CameraInputTypes: {};
  82263. /**
  82264. * This is the contract to implement in order to create a new input class.
  82265. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  82266. */
  82267. export interface ICameraInput<TCamera extends Camera> {
  82268. /**
  82269. * Defines the camera the input is attached to.
  82270. */
  82271. camera: Nullable<TCamera>;
  82272. /**
  82273. * Gets the class name of the current intput.
  82274. * @returns the class name
  82275. */
  82276. getClassName(): string;
  82277. /**
  82278. * Get the friendly name associated with the input class.
  82279. * @returns the input friendly name
  82280. */
  82281. getSimpleName(): string;
  82282. /**
  82283. * Attach the input controls to a specific dom element to get the input from.
  82284. * @param element Defines the element the controls should be listened from
  82285. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82286. */
  82287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82288. /**
  82289. * Detach the current controls from the specified dom element.
  82290. * @param element Defines the element to stop listening the inputs from
  82291. */
  82292. detachControl(element: Nullable<HTMLElement>): void;
  82293. /**
  82294. * Update the current camera state depending on the inputs that have been used this frame.
  82295. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82296. */
  82297. checkInputs?: () => void;
  82298. }
  82299. /**
  82300. * Represents a map of input types to input instance or input index to input instance.
  82301. */
  82302. export interface CameraInputsMap<TCamera extends Camera> {
  82303. /**
  82304. * Accessor to the input by input type.
  82305. */
  82306. [name: string]: ICameraInput<TCamera>;
  82307. /**
  82308. * Accessor to the input by input index.
  82309. */
  82310. [idx: number]: ICameraInput<TCamera>;
  82311. }
  82312. /**
  82313. * This represents the input manager used within a camera.
  82314. * It helps dealing with all the different kind of input attached to a camera.
  82315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82316. */
  82317. export class CameraInputsManager<TCamera extends Camera> {
  82318. /**
  82319. * Defines the list of inputs attahed to the camera.
  82320. */
  82321. attached: CameraInputsMap<TCamera>;
  82322. /**
  82323. * Defines the dom element the camera is collecting inputs from.
  82324. * This is null if the controls have not been attached.
  82325. */
  82326. attachedElement: Nullable<HTMLElement>;
  82327. /**
  82328. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82329. */
  82330. noPreventDefault: boolean;
  82331. /**
  82332. * Defined the camera the input manager belongs to.
  82333. */
  82334. camera: TCamera;
  82335. /**
  82336. * Update the current camera state depending on the inputs that have been used this frame.
  82337. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82338. */
  82339. checkInputs: () => void;
  82340. /**
  82341. * Instantiate a new Camera Input Manager.
  82342. * @param camera Defines the camera the input manager blongs to
  82343. */
  82344. constructor(camera: TCamera);
  82345. /**
  82346. * Add an input method to a camera
  82347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82348. * @param input camera input method
  82349. */
  82350. add(input: ICameraInput<TCamera>): void;
  82351. /**
  82352. * Remove a specific input method from a camera
  82353. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  82354. * @param inputToRemove camera input method
  82355. */
  82356. remove(inputToRemove: ICameraInput<TCamera>): void;
  82357. /**
  82358. * Remove a specific input type from a camera
  82359. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  82360. * @param inputType the type of the input to remove
  82361. */
  82362. removeByType(inputType: string): void;
  82363. private _addCheckInputs;
  82364. /**
  82365. * Attach the input controls to the currently attached dom element to listen the events from.
  82366. * @param input Defines the input to attach
  82367. */
  82368. attachInput(input: ICameraInput<TCamera>): void;
  82369. /**
  82370. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  82371. * @param element Defines the dom element to collect the events from
  82372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82373. */
  82374. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  82375. /**
  82376. * Detach the current manager inputs controls from a specific dom element.
  82377. * @param element Defines the dom element to collect the events from
  82378. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  82379. */
  82380. detachElement(element: HTMLElement, disconnect?: boolean): void;
  82381. /**
  82382. * Rebuild the dynamic inputCheck function from the current list of
  82383. * defined inputs in the manager.
  82384. */
  82385. rebuildInputCheck(): void;
  82386. /**
  82387. * Remove all attached input methods from a camera
  82388. */
  82389. clear(): void;
  82390. /**
  82391. * Serialize the current input manager attached to a camera.
  82392. * This ensures than once parsed,
  82393. * the input associated to the camera will be identical to the current ones
  82394. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  82395. */
  82396. serialize(serializedCamera: any): void;
  82397. /**
  82398. * Parses an input manager serialized JSON to restore the previous list of inputs
  82399. * and states associated to a camera.
  82400. * @param parsedCamera Defines the JSON to parse
  82401. */
  82402. parse(parsedCamera: any): void;
  82403. }
  82404. }
  82405. declare module BABYLON {
  82406. /**
  82407. * Class used to store data that will be store in GPU memory
  82408. */
  82409. export class Buffer {
  82410. private _engine;
  82411. private _buffer;
  82412. /** @hidden */
  82413. _data: Nullable<DataArray>;
  82414. private _updatable;
  82415. private _instanced;
  82416. private _divisor;
  82417. /**
  82418. * Gets the byte stride.
  82419. */
  82420. readonly byteStride: number;
  82421. /**
  82422. * Constructor
  82423. * @param engine the engine
  82424. * @param data the data to use for this buffer
  82425. * @param updatable whether the data is updatable
  82426. * @param stride the stride (optional)
  82427. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82428. * @param instanced whether the buffer is instanced (optional)
  82429. * @param useBytes set to true if the stride in in bytes (optional)
  82430. * @param divisor sets an optional divisor for instances (1 by default)
  82431. */
  82432. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  82433. /**
  82434. * Create a new VertexBuffer based on the current buffer
  82435. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82436. * @param offset defines offset in the buffer (0 by default)
  82437. * @param size defines the size in floats of attributes (position is 3 for instance)
  82438. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82439. * @param instanced defines if the vertex buffer contains indexed data
  82440. * @param useBytes defines if the offset and stride are in bytes *
  82441. * @param divisor sets an optional divisor for instances (1 by default)
  82442. * @returns the new vertex buffer
  82443. */
  82444. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  82445. /**
  82446. * Gets a boolean indicating if the Buffer is updatable?
  82447. * @returns true if the buffer is updatable
  82448. */
  82449. isUpdatable(): boolean;
  82450. /**
  82451. * Gets current buffer's data
  82452. * @returns a DataArray or null
  82453. */
  82454. getData(): Nullable<DataArray>;
  82455. /**
  82456. * Gets underlying native buffer
  82457. * @returns underlying native buffer
  82458. */
  82459. getBuffer(): Nullable<DataBuffer>;
  82460. /**
  82461. * Gets the stride in float32 units (i.e. byte stride / 4).
  82462. * May not be an integer if the byte stride is not divisible by 4.
  82463. * @returns the stride in float32 units
  82464. * @deprecated Please use byteStride instead.
  82465. */
  82466. getStrideSize(): number;
  82467. /**
  82468. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82469. * @param data defines the data to store
  82470. */
  82471. create(data?: Nullable<DataArray>): void;
  82472. /** @hidden */
  82473. _rebuild(): void;
  82474. /**
  82475. * Update current buffer data
  82476. * @param data defines the data to store
  82477. */
  82478. update(data: DataArray): void;
  82479. /**
  82480. * Updates the data directly.
  82481. * @param data the new data
  82482. * @param offset the new offset
  82483. * @param vertexCount the vertex count (optional)
  82484. * @param useBytes set to true if the offset is in bytes
  82485. */
  82486. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  82487. /**
  82488. * Release all resources
  82489. */
  82490. dispose(): void;
  82491. }
  82492. /**
  82493. * Specialized buffer used to store vertex data
  82494. */
  82495. export class VertexBuffer {
  82496. /** @hidden */
  82497. _buffer: Buffer;
  82498. private _kind;
  82499. private _size;
  82500. private _ownsBuffer;
  82501. private _instanced;
  82502. private _instanceDivisor;
  82503. /**
  82504. * The byte type.
  82505. */
  82506. static readonly BYTE: number;
  82507. /**
  82508. * The unsigned byte type.
  82509. */
  82510. static readonly UNSIGNED_BYTE: number;
  82511. /**
  82512. * The short type.
  82513. */
  82514. static readonly SHORT: number;
  82515. /**
  82516. * The unsigned short type.
  82517. */
  82518. static readonly UNSIGNED_SHORT: number;
  82519. /**
  82520. * The integer type.
  82521. */
  82522. static readonly INT: number;
  82523. /**
  82524. * The unsigned integer type.
  82525. */
  82526. static readonly UNSIGNED_INT: number;
  82527. /**
  82528. * The float type.
  82529. */
  82530. static readonly FLOAT: number;
  82531. /**
  82532. * Gets or sets the instance divisor when in instanced mode
  82533. */
  82534. get instanceDivisor(): number;
  82535. set instanceDivisor(value: number);
  82536. /**
  82537. * Gets the byte stride.
  82538. */
  82539. readonly byteStride: number;
  82540. /**
  82541. * Gets the byte offset.
  82542. */
  82543. readonly byteOffset: number;
  82544. /**
  82545. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  82546. */
  82547. readonly normalized: boolean;
  82548. /**
  82549. * Gets the data type of each component in the array.
  82550. */
  82551. readonly type: number;
  82552. /**
  82553. * Constructor
  82554. * @param engine the engine
  82555. * @param data the data to use for this vertex buffer
  82556. * @param kind the vertex buffer kind
  82557. * @param updatable whether the data is updatable
  82558. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82559. * @param stride the stride (optional)
  82560. * @param instanced whether the buffer is instanced (optional)
  82561. * @param offset the offset of the data (optional)
  82562. * @param size the number of components (optional)
  82563. * @param type the type of the component (optional)
  82564. * @param normalized whether the data contains normalized data (optional)
  82565. * @param useBytes set to true if stride and offset are in bytes (optional)
  82566. * @param divisor defines the instance divisor to use (1 by default)
  82567. */
  82568. 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);
  82569. /** @hidden */
  82570. _rebuild(): void;
  82571. /**
  82572. * Returns the kind of the VertexBuffer (string)
  82573. * @returns a string
  82574. */
  82575. getKind(): string;
  82576. /**
  82577. * Gets a boolean indicating if the VertexBuffer is updatable?
  82578. * @returns true if the buffer is updatable
  82579. */
  82580. isUpdatable(): boolean;
  82581. /**
  82582. * Gets current buffer's data
  82583. * @returns a DataArray or null
  82584. */
  82585. getData(): Nullable<DataArray>;
  82586. /**
  82587. * Gets underlying native buffer
  82588. * @returns underlying native buffer
  82589. */
  82590. getBuffer(): Nullable<DataBuffer>;
  82591. /**
  82592. * Gets the stride in float32 units (i.e. byte stride / 4).
  82593. * May not be an integer if the byte stride is not divisible by 4.
  82594. * @returns the stride in float32 units
  82595. * @deprecated Please use byteStride instead.
  82596. */
  82597. getStrideSize(): number;
  82598. /**
  82599. * Returns the offset as a multiple of the type byte length.
  82600. * @returns the offset in bytes
  82601. * @deprecated Please use byteOffset instead.
  82602. */
  82603. getOffset(): number;
  82604. /**
  82605. * Returns the number of components per vertex attribute (integer)
  82606. * @returns the size in float
  82607. */
  82608. getSize(): number;
  82609. /**
  82610. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82611. * @returns true if this buffer is instanced
  82612. */
  82613. getIsInstanced(): boolean;
  82614. /**
  82615. * Returns the instancing divisor, zero for non-instanced (integer).
  82616. * @returns a number
  82617. */
  82618. getInstanceDivisor(): number;
  82619. /**
  82620. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82621. * @param data defines the data to store
  82622. */
  82623. create(data?: DataArray): void;
  82624. /**
  82625. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82626. * This function will create a new buffer if the current one is not updatable
  82627. * @param data defines the data to store
  82628. */
  82629. update(data: DataArray): void;
  82630. /**
  82631. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82632. * Returns the directly updated WebGLBuffer.
  82633. * @param data the new data
  82634. * @param offset the new offset
  82635. * @param useBytes set to true if the offset is in bytes
  82636. */
  82637. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  82638. /**
  82639. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82640. */
  82641. dispose(): void;
  82642. /**
  82643. * Enumerates each value of this vertex buffer as numbers.
  82644. * @param count the number of values to enumerate
  82645. * @param callback the callback function called for each value
  82646. */
  82647. forEach(count: number, callback: (value: number, index: number) => void): void;
  82648. /**
  82649. * Positions
  82650. */
  82651. static readonly PositionKind: string;
  82652. /**
  82653. * Normals
  82654. */
  82655. static readonly NormalKind: string;
  82656. /**
  82657. * Tangents
  82658. */
  82659. static readonly TangentKind: string;
  82660. /**
  82661. * Texture coordinates
  82662. */
  82663. static readonly UVKind: string;
  82664. /**
  82665. * Texture coordinates 2
  82666. */
  82667. static readonly UV2Kind: string;
  82668. /**
  82669. * Texture coordinates 3
  82670. */
  82671. static readonly UV3Kind: string;
  82672. /**
  82673. * Texture coordinates 4
  82674. */
  82675. static readonly UV4Kind: string;
  82676. /**
  82677. * Texture coordinates 5
  82678. */
  82679. static readonly UV5Kind: string;
  82680. /**
  82681. * Texture coordinates 6
  82682. */
  82683. static readonly UV6Kind: string;
  82684. /**
  82685. * Colors
  82686. */
  82687. static readonly ColorKind: string;
  82688. /**
  82689. * Matrix indices (for bones)
  82690. */
  82691. static readonly MatricesIndicesKind: string;
  82692. /**
  82693. * Matrix weights (for bones)
  82694. */
  82695. static readonly MatricesWeightsKind: string;
  82696. /**
  82697. * Additional matrix indices (for bones)
  82698. */
  82699. static readonly MatricesIndicesExtraKind: string;
  82700. /**
  82701. * Additional matrix weights (for bones)
  82702. */
  82703. static readonly MatricesWeightsExtraKind: string;
  82704. /**
  82705. * Deduces the stride given a kind.
  82706. * @param kind The kind string to deduce
  82707. * @returns The deduced stride
  82708. */
  82709. static DeduceStride(kind: string): number;
  82710. /**
  82711. * Gets the byte length of the given type.
  82712. * @param type the type
  82713. * @returns the number of bytes
  82714. */
  82715. static GetTypeByteLength(type: number): number;
  82716. /**
  82717. * Enumerates each value of the given parameters as numbers.
  82718. * @param data the data to enumerate
  82719. * @param byteOffset the byte offset of the data
  82720. * @param byteStride the byte stride of the data
  82721. * @param componentCount the number of components per element
  82722. * @param componentType the type of the component
  82723. * @param count the number of values to enumerate
  82724. * @param normalized whether the data is normalized
  82725. * @param callback the callback function called for each value
  82726. */
  82727. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  82728. private static _GetFloatValue;
  82729. }
  82730. }
  82731. declare module BABYLON {
  82732. /**
  82733. * @hidden
  82734. */
  82735. export class IntersectionInfo {
  82736. bu: Nullable<number>;
  82737. bv: Nullable<number>;
  82738. distance: number;
  82739. faceId: number;
  82740. subMeshId: number;
  82741. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  82742. }
  82743. }
  82744. declare module BABYLON {
  82745. /**
  82746. * Class used to store bounding sphere information
  82747. */
  82748. export class BoundingSphere {
  82749. /**
  82750. * Gets the center of the bounding sphere in local space
  82751. */
  82752. readonly center: Vector3;
  82753. /**
  82754. * Radius of the bounding sphere in local space
  82755. */
  82756. radius: number;
  82757. /**
  82758. * Gets the center of the bounding sphere in world space
  82759. */
  82760. readonly centerWorld: Vector3;
  82761. /**
  82762. * Radius of the bounding sphere in world space
  82763. */
  82764. radiusWorld: number;
  82765. /**
  82766. * Gets the minimum vector in local space
  82767. */
  82768. readonly minimum: Vector3;
  82769. /**
  82770. * Gets the maximum vector in local space
  82771. */
  82772. readonly maximum: Vector3;
  82773. private _worldMatrix;
  82774. private static readonly TmpVector3;
  82775. /**
  82776. * Creates a new bounding sphere
  82777. * @param min defines the minimum vector (in local space)
  82778. * @param max defines the maximum vector (in local space)
  82779. * @param worldMatrix defines the new world matrix
  82780. */
  82781. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82782. /**
  82783. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  82784. * @param min defines the new minimum vector (in local space)
  82785. * @param max defines the new maximum vector (in local space)
  82786. * @param worldMatrix defines the new world matrix
  82787. */
  82788. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82789. /**
  82790. * Scale the current bounding sphere by applying a scale factor
  82791. * @param factor defines the scale factor to apply
  82792. * @returns the current bounding box
  82793. */
  82794. scale(factor: number): BoundingSphere;
  82795. /**
  82796. * Gets the world matrix of the bounding box
  82797. * @returns a matrix
  82798. */
  82799. getWorldMatrix(): DeepImmutable<Matrix>;
  82800. /** @hidden */
  82801. _update(worldMatrix: DeepImmutable<Matrix>): void;
  82802. /**
  82803. * Tests if the bounding sphere is intersecting the frustum planes
  82804. * @param frustumPlanes defines the frustum planes to test
  82805. * @returns true if there is an intersection
  82806. */
  82807. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82808. /**
  82809. * Tests if the bounding sphere center is in between the frustum planes.
  82810. * Used for optimistic fast inclusion.
  82811. * @param frustumPlanes defines the frustum planes to test
  82812. * @returns true if the sphere center is in between the frustum planes
  82813. */
  82814. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82815. /**
  82816. * Tests if a point is inside the bounding sphere
  82817. * @param point defines the point to test
  82818. * @returns true if the point is inside the bounding sphere
  82819. */
  82820. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82821. /**
  82822. * Checks if two sphere intersct
  82823. * @param sphere0 sphere 0
  82824. * @param sphere1 sphere 1
  82825. * @returns true if the speres intersect
  82826. */
  82827. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  82828. }
  82829. }
  82830. declare module BABYLON {
  82831. /**
  82832. * Class used to store bounding box information
  82833. */
  82834. export class BoundingBox implements ICullable {
  82835. /**
  82836. * Gets the 8 vectors representing the bounding box in local space
  82837. */
  82838. readonly vectors: Vector3[];
  82839. /**
  82840. * Gets the center of the bounding box in local space
  82841. */
  82842. readonly center: Vector3;
  82843. /**
  82844. * Gets the center of the bounding box in world space
  82845. */
  82846. readonly centerWorld: Vector3;
  82847. /**
  82848. * Gets the extend size in local space
  82849. */
  82850. readonly extendSize: Vector3;
  82851. /**
  82852. * Gets the extend size in world space
  82853. */
  82854. readonly extendSizeWorld: Vector3;
  82855. /**
  82856. * Gets the OBB (object bounding box) directions
  82857. */
  82858. readonly directions: Vector3[];
  82859. /**
  82860. * Gets the 8 vectors representing the bounding box in world space
  82861. */
  82862. readonly vectorsWorld: Vector3[];
  82863. /**
  82864. * Gets the minimum vector in world space
  82865. */
  82866. readonly minimumWorld: Vector3;
  82867. /**
  82868. * Gets the maximum vector in world space
  82869. */
  82870. readonly maximumWorld: Vector3;
  82871. /**
  82872. * Gets the minimum vector in local space
  82873. */
  82874. readonly minimum: Vector3;
  82875. /**
  82876. * Gets the maximum vector in local space
  82877. */
  82878. readonly maximum: Vector3;
  82879. private _worldMatrix;
  82880. private static readonly TmpVector3;
  82881. /**
  82882. * @hidden
  82883. */
  82884. _tag: number;
  82885. /**
  82886. * Creates a new bounding box
  82887. * @param min defines the minimum vector (in local space)
  82888. * @param max defines the maximum vector (in local space)
  82889. * @param worldMatrix defines the new world matrix
  82890. */
  82891. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82892. /**
  82893. * Recreates the entire bounding box from scratch as if we call the constructor in place
  82894. * @param min defines the new minimum vector (in local space)
  82895. * @param max defines the new maximum vector (in local space)
  82896. * @param worldMatrix defines the new world matrix
  82897. */
  82898. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82899. /**
  82900. * Scale the current bounding box by applying a scale factor
  82901. * @param factor defines the scale factor to apply
  82902. * @returns the current bounding box
  82903. */
  82904. scale(factor: number): BoundingBox;
  82905. /**
  82906. * Gets the world matrix of the bounding box
  82907. * @returns a matrix
  82908. */
  82909. getWorldMatrix(): DeepImmutable<Matrix>;
  82910. /** @hidden */
  82911. _update(world: DeepImmutable<Matrix>): void;
  82912. /**
  82913. * Tests if the bounding box is intersecting the frustum planes
  82914. * @param frustumPlanes defines the frustum planes to test
  82915. * @returns true if there is an intersection
  82916. */
  82917. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82918. /**
  82919. * Tests if the bounding box is entirely inside the frustum planes
  82920. * @param frustumPlanes defines the frustum planes to test
  82921. * @returns true if there is an inclusion
  82922. */
  82923. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82924. /**
  82925. * Tests if a point is inside the bounding box
  82926. * @param point defines the point to test
  82927. * @returns true if the point is inside the bounding box
  82928. */
  82929. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82930. /**
  82931. * Tests if the bounding box intersects with a bounding sphere
  82932. * @param sphere defines the sphere to test
  82933. * @returns true if there is an intersection
  82934. */
  82935. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  82936. /**
  82937. * Tests if the bounding box intersects with a box defined by a min and max vectors
  82938. * @param min defines the min vector to use
  82939. * @param max defines the max vector to use
  82940. * @returns true if there is an intersection
  82941. */
  82942. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  82943. /**
  82944. * Tests if two bounding boxes are intersections
  82945. * @param box0 defines the first box to test
  82946. * @param box1 defines the second box to test
  82947. * @returns true if there is an intersection
  82948. */
  82949. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  82950. /**
  82951. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  82952. * @param minPoint defines the minimum vector of the bounding box
  82953. * @param maxPoint defines the maximum vector of the bounding box
  82954. * @param sphereCenter defines the sphere center
  82955. * @param sphereRadius defines the sphere radius
  82956. * @returns true if there is an intersection
  82957. */
  82958. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  82959. /**
  82960. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  82961. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82962. * @param frustumPlanes defines the frustum planes to test
  82963. * @return true if there is an inclusion
  82964. */
  82965. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82966. /**
  82967. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  82968. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82969. * @param frustumPlanes defines the frustum planes to test
  82970. * @return true if there is an intersection
  82971. */
  82972. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82973. }
  82974. }
  82975. declare module BABYLON {
  82976. /** @hidden */
  82977. export class Collider {
  82978. /** Define if a collision was found */
  82979. collisionFound: boolean;
  82980. /**
  82981. * Define last intersection point in local space
  82982. */
  82983. intersectionPoint: Vector3;
  82984. /**
  82985. * Define last collided mesh
  82986. */
  82987. collidedMesh: Nullable<AbstractMesh>;
  82988. private _collisionPoint;
  82989. private _planeIntersectionPoint;
  82990. private _tempVector;
  82991. private _tempVector2;
  82992. private _tempVector3;
  82993. private _tempVector4;
  82994. private _edge;
  82995. private _baseToVertex;
  82996. private _destinationPoint;
  82997. private _slidePlaneNormal;
  82998. private _displacementVector;
  82999. /** @hidden */
  83000. _radius: Vector3;
  83001. /** @hidden */
  83002. _retry: number;
  83003. private _velocity;
  83004. private _basePoint;
  83005. private _epsilon;
  83006. /** @hidden */
  83007. _velocityWorldLength: number;
  83008. /** @hidden */
  83009. _basePointWorld: Vector3;
  83010. private _velocityWorld;
  83011. private _normalizedVelocity;
  83012. /** @hidden */
  83013. _initialVelocity: Vector3;
  83014. /** @hidden */
  83015. _initialPosition: Vector3;
  83016. private _nearestDistance;
  83017. private _collisionMask;
  83018. get collisionMask(): number;
  83019. set collisionMask(mask: number);
  83020. /**
  83021. * Gets the plane normal used to compute the sliding response (in local space)
  83022. */
  83023. get slidePlaneNormal(): Vector3;
  83024. /** @hidden */
  83025. _initialize(source: Vector3, dir: Vector3, e: number): void;
  83026. /** @hidden */
  83027. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  83028. /** @hidden */
  83029. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  83030. /** @hidden */
  83031. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83032. /** @hidden */
  83033. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83034. /** @hidden */
  83035. _getResponse(pos: Vector3, vel: Vector3): void;
  83036. }
  83037. }
  83038. declare module BABYLON {
  83039. /**
  83040. * Interface for cullable objects
  83041. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  83042. */
  83043. export interface ICullable {
  83044. /**
  83045. * Checks if the object or part of the object is in the frustum
  83046. * @param frustumPlanes Camera near/planes
  83047. * @returns true if the object is in frustum otherwise false
  83048. */
  83049. isInFrustum(frustumPlanes: Plane[]): boolean;
  83050. /**
  83051. * Checks if a cullable object (mesh...) is in the camera frustum
  83052. * Unlike isInFrustum this cheks the full bounding box
  83053. * @param frustumPlanes Camera near/planes
  83054. * @returns true if the object is in frustum otherwise false
  83055. */
  83056. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83057. }
  83058. /**
  83059. * Info for a bounding data of a mesh
  83060. */
  83061. export class BoundingInfo implements ICullable {
  83062. /**
  83063. * Bounding box for the mesh
  83064. */
  83065. readonly boundingBox: BoundingBox;
  83066. /**
  83067. * Bounding sphere for the mesh
  83068. */
  83069. readonly boundingSphere: BoundingSphere;
  83070. private _isLocked;
  83071. private static readonly TmpVector3;
  83072. /**
  83073. * Constructs bounding info
  83074. * @param minimum min vector of the bounding box/sphere
  83075. * @param maximum max vector of the bounding box/sphere
  83076. * @param worldMatrix defines the new world matrix
  83077. */
  83078. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83079. /**
  83080. * Recreates the entire bounding info from scratch as if we call the constructor in place
  83081. * @param min defines the new minimum vector (in local space)
  83082. * @param max defines the new maximum vector (in local space)
  83083. * @param worldMatrix defines the new world matrix
  83084. */
  83085. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83086. /**
  83087. * min vector of the bounding box/sphere
  83088. */
  83089. get minimum(): Vector3;
  83090. /**
  83091. * max vector of the bounding box/sphere
  83092. */
  83093. get maximum(): Vector3;
  83094. /**
  83095. * If the info is locked and won't be updated to avoid perf overhead
  83096. */
  83097. get isLocked(): boolean;
  83098. set isLocked(value: boolean);
  83099. /**
  83100. * Updates the bounding sphere and box
  83101. * @param world world matrix to be used to update
  83102. */
  83103. update(world: DeepImmutable<Matrix>): void;
  83104. /**
  83105. * Recreate the bounding info to be centered around a specific point given a specific extend.
  83106. * @param center New center of the bounding info
  83107. * @param extend New extend of the bounding info
  83108. * @returns the current bounding info
  83109. */
  83110. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  83111. /**
  83112. * Scale the current bounding info by applying a scale factor
  83113. * @param factor defines the scale factor to apply
  83114. * @returns the current bounding info
  83115. */
  83116. scale(factor: number): BoundingInfo;
  83117. /**
  83118. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  83119. * @param frustumPlanes defines the frustum to test
  83120. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  83121. * @returns true if the bounding info is in the frustum planes
  83122. */
  83123. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  83124. /**
  83125. * Gets the world distance between the min and max points of the bounding box
  83126. */
  83127. get diagonalLength(): number;
  83128. /**
  83129. * Checks if a cullable object (mesh...) is in the camera frustum
  83130. * Unlike isInFrustum this cheks the full bounding box
  83131. * @param frustumPlanes Camera near/planes
  83132. * @returns true if the object is in frustum otherwise false
  83133. */
  83134. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83135. /** @hidden */
  83136. _checkCollision(collider: Collider): boolean;
  83137. /**
  83138. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  83139. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83140. * @param point the point to check intersection with
  83141. * @returns if the point intersects
  83142. */
  83143. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83144. /**
  83145. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  83146. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83147. * @param boundingInfo the bounding info to check intersection with
  83148. * @param precise if the intersection should be done using OBB
  83149. * @returns if the bounding info intersects
  83150. */
  83151. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  83152. }
  83153. }
  83154. declare module BABYLON {
  83155. /**
  83156. * Extracts minimum and maximum values from a list of indexed positions
  83157. * @param positions defines the positions to use
  83158. * @param indices defines the indices to the positions
  83159. * @param indexStart defines the start index
  83160. * @param indexCount defines the end index
  83161. * @param bias defines bias value to add to the result
  83162. * @return minimum and maximum values
  83163. */
  83164. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  83165. minimum: Vector3;
  83166. maximum: Vector3;
  83167. };
  83168. /**
  83169. * Extracts minimum and maximum values from a list of positions
  83170. * @param positions defines the positions to use
  83171. * @param start defines the start index in the positions array
  83172. * @param count defines the number of positions to handle
  83173. * @param bias defines bias value to add to the result
  83174. * @param stride defines the stride size to use (distance between two positions in the positions array)
  83175. * @return minimum and maximum values
  83176. */
  83177. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  83178. minimum: Vector3;
  83179. maximum: Vector3;
  83180. };
  83181. }
  83182. declare module BABYLON {
  83183. /** @hidden */
  83184. export class WebGLDataBuffer extends DataBuffer {
  83185. private _buffer;
  83186. constructor(resource: WebGLBuffer);
  83187. get underlyingResource(): any;
  83188. }
  83189. }
  83190. declare module BABYLON {
  83191. /** @hidden */
  83192. export class WebGLPipelineContext implements IPipelineContext {
  83193. engine: ThinEngine;
  83194. program: Nullable<WebGLProgram>;
  83195. context?: WebGLRenderingContext;
  83196. vertexShader?: WebGLShader;
  83197. fragmentShader?: WebGLShader;
  83198. isParallelCompiled: boolean;
  83199. onCompiled?: () => void;
  83200. transformFeedback?: WebGLTransformFeedback | null;
  83201. vertexCompilationError: Nullable<string>;
  83202. fragmentCompilationError: Nullable<string>;
  83203. programLinkError: Nullable<string>;
  83204. programValidationError: Nullable<string>;
  83205. get isAsync(): boolean;
  83206. get isReady(): boolean;
  83207. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  83208. _getVertexShaderCode(): string | null;
  83209. _getFragmentShaderCode(): string | null;
  83210. }
  83211. }
  83212. declare module BABYLON {
  83213. interface ThinEngine {
  83214. /**
  83215. * Create an uniform buffer
  83216. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83217. * @param elements defines the content of the uniform buffer
  83218. * @returns the webGL uniform buffer
  83219. */
  83220. createUniformBuffer(elements: FloatArray): DataBuffer;
  83221. /**
  83222. * Create a dynamic uniform buffer
  83223. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83224. * @param elements defines the content of the uniform buffer
  83225. * @returns the webGL uniform buffer
  83226. */
  83227. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  83228. /**
  83229. * Update an existing uniform buffer
  83230. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83231. * @param uniformBuffer defines the target uniform buffer
  83232. * @param elements defines the content to update
  83233. * @param offset defines the offset in the uniform buffer where update should start
  83234. * @param count defines the size of the data to update
  83235. */
  83236. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83237. /**
  83238. * Bind an uniform buffer to the current webGL context
  83239. * @param buffer defines the buffer to bind
  83240. */
  83241. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  83242. /**
  83243. * Bind a buffer to the current webGL context at a given location
  83244. * @param buffer defines the buffer to bind
  83245. * @param location defines the index where to bind the buffer
  83246. */
  83247. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  83248. /**
  83249. * Bind a specific block at a given index in a specific shader program
  83250. * @param pipelineContext defines the pipeline context to use
  83251. * @param blockName defines the block name
  83252. * @param index defines the index where to bind the block
  83253. */
  83254. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  83255. }
  83256. }
  83257. declare module BABYLON {
  83258. /**
  83259. * Uniform buffer objects.
  83260. *
  83261. * Handles blocks of uniform on the GPU.
  83262. *
  83263. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83264. *
  83265. * For more information, please refer to :
  83266. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83267. */
  83268. export class UniformBuffer {
  83269. private _engine;
  83270. private _buffer;
  83271. private _data;
  83272. private _bufferData;
  83273. private _dynamic?;
  83274. private _uniformLocations;
  83275. private _uniformSizes;
  83276. private _uniformLocationPointer;
  83277. private _needSync;
  83278. private _noUBO;
  83279. private _currentEffect;
  83280. /** @hidden */
  83281. _alreadyBound: boolean;
  83282. private static _MAX_UNIFORM_SIZE;
  83283. private static _tempBuffer;
  83284. /**
  83285. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83286. * This is dynamic to allow compat with webgl 1 and 2.
  83287. * You will need to pass the name of the uniform as well as the value.
  83288. */
  83289. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83290. /**
  83291. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83292. * This is dynamic to allow compat with webgl 1 and 2.
  83293. * You will need to pass the name of the uniform as well as the value.
  83294. */
  83295. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83296. /**
  83297. * Lambda to Update a single float in a uniform buffer.
  83298. * This is dynamic to allow compat with webgl 1 and 2.
  83299. * You will need to pass the name of the uniform as well as the value.
  83300. */
  83301. updateFloat: (name: string, x: number) => void;
  83302. /**
  83303. * Lambda to Update a vec2 of float in a uniform buffer.
  83304. * This is dynamic to allow compat with webgl 1 and 2.
  83305. * You will need to pass the name of the uniform as well as the value.
  83306. */
  83307. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83308. /**
  83309. * Lambda to Update a vec3 of float in a uniform buffer.
  83310. * This is dynamic to allow compat with webgl 1 and 2.
  83311. * You will need to pass the name of the uniform as well as the value.
  83312. */
  83313. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83314. /**
  83315. * Lambda to Update a vec4 of float in a uniform buffer.
  83316. * This is dynamic to allow compat with webgl 1 and 2.
  83317. * You will need to pass the name of the uniform as well as the value.
  83318. */
  83319. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83320. /**
  83321. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83322. * This is dynamic to allow compat with webgl 1 and 2.
  83323. * You will need to pass the name of the uniform as well as the value.
  83324. */
  83325. updateMatrix: (name: string, mat: Matrix) => void;
  83326. /**
  83327. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83328. * This is dynamic to allow compat with webgl 1 and 2.
  83329. * You will need to pass the name of the uniform as well as the value.
  83330. */
  83331. updateVector3: (name: string, vector: Vector3) => void;
  83332. /**
  83333. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83334. * This is dynamic to allow compat with webgl 1 and 2.
  83335. * You will need to pass the name of the uniform as well as the value.
  83336. */
  83337. updateVector4: (name: string, vector: Vector4) => void;
  83338. /**
  83339. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83340. * This is dynamic to allow compat with webgl 1 and 2.
  83341. * You will need to pass the name of the uniform as well as the value.
  83342. */
  83343. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83344. /**
  83345. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83346. * This is dynamic to allow compat with webgl 1 and 2.
  83347. * You will need to pass the name of the uniform as well as the value.
  83348. */
  83349. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83350. /**
  83351. * Instantiates a new Uniform buffer objects.
  83352. *
  83353. * Handles blocks of uniform on the GPU.
  83354. *
  83355. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83356. *
  83357. * For more information, please refer to :
  83358. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83359. * @param engine Define the engine the buffer is associated with
  83360. * @param data Define the data contained in the buffer
  83361. * @param dynamic Define if the buffer is updatable
  83362. */
  83363. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83364. /**
  83365. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83366. * or just falling back on setUniformXXX calls.
  83367. */
  83368. get useUbo(): boolean;
  83369. /**
  83370. * Indicates if the WebGL underlying uniform buffer is in sync
  83371. * with the javascript cache data.
  83372. */
  83373. get isSync(): boolean;
  83374. /**
  83375. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83376. * Also, a dynamic UniformBuffer will disable cache verification and always
  83377. * update the underlying WebGL uniform buffer to the GPU.
  83378. * @returns if Dynamic, otherwise false
  83379. */
  83380. isDynamic(): boolean;
  83381. /**
  83382. * The data cache on JS side.
  83383. * @returns the underlying data as a float array
  83384. */
  83385. getData(): Float32Array;
  83386. /**
  83387. * The underlying WebGL Uniform buffer.
  83388. * @returns the webgl buffer
  83389. */
  83390. getBuffer(): Nullable<DataBuffer>;
  83391. /**
  83392. * std140 layout specifies how to align data within an UBO structure.
  83393. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83394. * for specs.
  83395. */
  83396. private _fillAlignment;
  83397. /**
  83398. * Adds an uniform in the buffer.
  83399. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83400. * for the layout to be correct !
  83401. * @param name Name of the uniform, as used in the uniform block in the shader.
  83402. * @param size Data size, or data directly.
  83403. */
  83404. addUniform(name: string, size: number | number[]): void;
  83405. /**
  83406. * Adds a Matrix 4x4 to the uniform buffer.
  83407. * @param name Name of the uniform, as used in the uniform block in the shader.
  83408. * @param mat A 4x4 matrix.
  83409. */
  83410. addMatrix(name: string, mat: Matrix): void;
  83411. /**
  83412. * Adds a vec2 to the uniform buffer.
  83413. * @param name Name of the uniform, as used in the uniform block in the shader.
  83414. * @param x Define the x component value of the vec2
  83415. * @param y Define the y component value of the vec2
  83416. */
  83417. addFloat2(name: string, x: number, y: number): void;
  83418. /**
  83419. * Adds a vec3 to the uniform buffer.
  83420. * @param name Name of the uniform, as used in the uniform block in the shader.
  83421. * @param x Define the x component value of the vec3
  83422. * @param y Define the y component value of the vec3
  83423. * @param z Define the z component value of the vec3
  83424. */
  83425. addFloat3(name: string, x: number, y: number, z: number): void;
  83426. /**
  83427. * Adds a vec3 to the uniform buffer.
  83428. * @param name Name of the uniform, as used in the uniform block in the shader.
  83429. * @param color Define the vec3 from a Color
  83430. */
  83431. addColor3(name: string, color: Color3): void;
  83432. /**
  83433. * Adds a vec4 to the uniform buffer.
  83434. * @param name Name of the uniform, as used in the uniform block in the shader.
  83435. * @param color Define the rgb components from a Color
  83436. * @param alpha Define the a component of the vec4
  83437. */
  83438. addColor4(name: string, color: Color3, alpha: number): void;
  83439. /**
  83440. * Adds a vec3 to the uniform buffer.
  83441. * @param name Name of the uniform, as used in the uniform block in the shader.
  83442. * @param vector Define the vec3 components from a Vector
  83443. */
  83444. addVector3(name: string, vector: Vector3): void;
  83445. /**
  83446. * Adds a Matrix 3x3 to the uniform buffer.
  83447. * @param name Name of the uniform, as used in the uniform block in the shader.
  83448. */
  83449. addMatrix3x3(name: string): void;
  83450. /**
  83451. * Adds a Matrix 2x2 to the uniform buffer.
  83452. * @param name Name of the uniform, as used in the uniform block in the shader.
  83453. */
  83454. addMatrix2x2(name: string): void;
  83455. /**
  83456. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83457. */
  83458. create(): void;
  83459. /** @hidden */
  83460. _rebuild(): void;
  83461. /**
  83462. * Updates the WebGL Uniform Buffer on the GPU.
  83463. * If the `dynamic` flag is set to true, no cache comparison is done.
  83464. * Otherwise, the buffer will be updated only if the cache differs.
  83465. */
  83466. update(): void;
  83467. /**
  83468. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83469. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83470. * @param data Define the flattened data
  83471. * @param size Define the size of the data.
  83472. */
  83473. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83474. private _valueCache;
  83475. private _cacheMatrix;
  83476. private _updateMatrix3x3ForUniform;
  83477. private _updateMatrix3x3ForEffect;
  83478. private _updateMatrix2x2ForEffect;
  83479. private _updateMatrix2x2ForUniform;
  83480. private _updateFloatForEffect;
  83481. private _updateFloatForUniform;
  83482. private _updateFloat2ForEffect;
  83483. private _updateFloat2ForUniform;
  83484. private _updateFloat3ForEffect;
  83485. private _updateFloat3ForUniform;
  83486. private _updateFloat4ForEffect;
  83487. private _updateFloat4ForUniform;
  83488. private _updateMatrixForEffect;
  83489. private _updateMatrixForUniform;
  83490. private _updateVector3ForEffect;
  83491. private _updateVector3ForUniform;
  83492. private _updateVector4ForEffect;
  83493. private _updateVector4ForUniform;
  83494. private _updateColor3ForEffect;
  83495. private _updateColor3ForUniform;
  83496. private _updateColor4ForEffect;
  83497. private _updateColor4ForUniform;
  83498. /**
  83499. * Sets a sampler uniform on the effect.
  83500. * @param name Define the name of the sampler.
  83501. * @param texture Define the texture to set in the sampler
  83502. */
  83503. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83504. /**
  83505. * Directly updates the value of the uniform in the cache AND on the GPU.
  83506. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83507. * @param data Define the flattened data
  83508. */
  83509. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83510. /**
  83511. * Binds this uniform buffer to an effect.
  83512. * @param effect Define the effect to bind the buffer to
  83513. * @param name Name of the uniform block in the shader.
  83514. */
  83515. bindToEffect(effect: Effect, name: string): void;
  83516. /**
  83517. * Disposes the uniform buffer.
  83518. */
  83519. dispose(): void;
  83520. }
  83521. }
  83522. declare module BABYLON {
  83523. /**
  83524. * Enum that determines the text-wrapping mode to use.
  83525. */
  83526. export enum InspectableType {
  83527. /**
  83528. * Checkbox for booleans
  83529. */
  83530. Checkbox = 0,
  83531. /**
  83532. * Sliders for numbers
  83533. */
  83534. Slider = 1,
  83535. /**
  83536. * Vector3
  83537. */
  83538. Vector3 = 2,
  83539. /**
  83540. * Quaternions
  83541. */
  83542. Quaternion = 3,
  83543. /**
  83544. * Color3
  83545. */
  83546. Color3 = 4,
  83547. /**
  83548. * String
  83549. */
  83550. String = 5
  83551. }
  83552. /**
  83553. * Interface used to define custom inspectable properties.
  83554. * This interface is used by the inspector to display custom property grids
  83555. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83556. */
  83557. export interface IInspectable {
  83558. /**
  83559. * Gets the label to display
  83560. */
  83561. label: string;
  83562. /**
  83563. * Gets the name of the property to edit
  83564. */
  83565. propertyName: string;
  83566. /**
  83567. * Gets the type of the editor to use
  83568. */
  83569. type: InspectableType;
  83570. /**
  83571. * Gets the minimum value of the property when using in "slider" mode
  83572. */
  83573. min?: number;
  83574. /**
  83575. * Gets the maximum value of the property when using in "slider" mode
  83576. */
  83577. max?: number;
  83578. /**
  83579. * Gets the setp to use when using in "slider" mode
  83580. */
  83581. step?: number;
  83582. }
  83583. }
  83584. declare module BABYLON {
  83585. /**
  83586. * Class used to provide helper for timing
  83587. */
  83588. export class TimingTools {
  83589. /**
  83590. * Polyfill for setImmediate
  83591. * @param action defines the action to execute after the current execution block
  83592. */
  83593. static SetImmediate(action: () => void): void;
  83594. }
  83595. }
  83596. declare module BABYLON {
  83597. /**
  83598. * Class used to enable instatition of objects by class name
  83599. */
  83600. export class InstantiationTools {
  83601. /**
  83602. * Use this object to register external classes like custom textures or material
  83603. * to allow the laoders to instantiate them
  83604. */
  83605. static RegisteredExternalClasses: {
  83606. [key: string]: Object;
  83607. };
  83608. /**
  83609. * Tries to instantiate a new object from a given class name
  83610. * @param className defines the class name to instantiate
  83611. * @returns the new object or null if the system was not able to do the instantiation
  83612. */
  83613. static Instantiate(className: string): any;
  83614. }
  83615. }
  83616. declare module BABYLON {
  83617. /**
  83618. * Define options used to create a depth texture
  83619. */
  83620. export class DepthTextureCreationOptions {
  83621. /** Specifies whether or not a stencil should be allocated in the texture */
  83622. generateStencil?: boolean;
  83623. /** Specifies whether or not bilinear filtering is enable on the texture */
  83624. bilinearFiltering?: boolean;
  83625. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83626. comparisonFunction?: number;
  83627. /** Specifies if the created texture is a cube texture */
  83628. isCube?: boolean;
  83629. }
  83630. }
  83631. declare module BABYLON {
  83632. interface ThinEngine {
  83633. /**
  83634. * Creates a depth stencil cube texture.
  83635. * This is only available in WebGL 2.
  83636. * @param size The size of face edge in the cube texture.
  83637. * @param options The options defining the cube texture.
  83638. * @returns The cube texture
  83639. */
  83640. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  83641. /**
  83642. * Creates a cube texture
  83643. * @param rootUrl defines the url where the files to load is located
  83644. * @param scene defines the current scene
  83645. * @param files defines the list of files to load (1 per face)
  83646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83647. * @param onLoad defines an optional callback raised when the texture is loaded
  83648. * @param onError defines an optional callback raised if there is an issue to load the texture
  83649. * @param format defines the format of the data
  83650. * @param forcedExtension defines the extension to use to pick the right loader
  83651. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83652. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83653. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83654. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  83655. * @returns the cube texture as an InternalTexture
  83656. */
  83657. 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;
  83658. /**
  83659. * Creates a cube texture
  83660. * @param rootUrl defines the url where the files to load is located
  83661. * @param scene defines the current scene
  83662. * @param files defines the list of files to load (1 per face)
  83663. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83664. * @param onLoad defines an optional callback raised when the texture is loaded
  83665. * @param onError defines an optional callback raised if there is an issue to load the texture
  83666. * @param format defines the format of the data
  83667. * @param forcedExtension defines the extension to use to pick the right loader
  83668. * @returns the cube texture as an InternalTexture
  83669. */
  83670. 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;
  83671. /**
  83672. * Creates a cube texture
  83673. * @param rootUrl defines the url where the files to load is located
  83674. * @param scene defines the current scene
  83675. * @param files defines the list of files to load (1 per face)
  83676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83677. * @param onLoad defines an optional callback raised when the texture is loaded
  83678. * @param onError defines an optional callback raised if there is an issue to load the texture
  83679. * @param format defines the format of the data
  83680. * @param forcedExtension defines the extension to use to pick the right loader
  83681. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83682. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83683. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83684. * @returns the cube texture as an InternalTexture
  83685. */
  83686. 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;
  83687. /** @hidden */
  83688. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  83689. /** @hidden */
  83690. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  83691. /** @hidden */
  83692. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83693. /** @hidden */
  83694. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83695. /**
  83696. * @hidden
  83697. */
  83698. _setCubeMapTextureParams(loadMipmap: boolean): void;
  83699. }
  83700. }
  83701. declare module BABYLON {
  83702. /**
  83703. * Class for creating a cube texture
  83704. */
  83705. export class CubeTexture extends BaseTexture {
  83706. private _delayedOnLoad;
  83707. /**
  83708. * Observable triggered once the texture has been loaded.
  83709. */
  83710. onLoadObservable: Observable<CubeTexture>;
  83711. /**
  83712. * The url of the texture
  83713. */
  83714. url: string;
  83715. /**
  83716. * Gets or sets the center of the bounding box associated with the cube texture.
  83717. * It must define where the camera used to render the texture was set
  83718. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83719. */
  83720. boundingBoxPosition: Vector3;
  83721. private _boundingBoxSize;
  83722. /**
  83723. * Gets or sets the size of the bounding box associated with the cube texture
  83724. * When defined, the cubemap will switch to local mode
  83725. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83726. * @example https://www.babylonjs-playground.com/#RNASML
  83727. */
  83728. set boundingBoxSize(value: Vector3);
  83729. /**
  83730. * Returns the bounding box size
  83731. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83732. */
  83733. get boundingBoxSize(): Vector3;
  83734. protected _rotationY: number;
  83735. /**
  83736. * Sets texture matrix rotation angle around Y axis in radians.
  83737. */
  83738. set rotationY(value: number);
  83739. /**
  83740. * Gets texture matrix rotation angle around Y axis radians.
  83741. */
  83742. get rotationY(): number;
  83743. /**
  83744. * Are mip maps generated for this texture or not.
  83745. */
  83746. get noMipmap(): boolean;
  83747. private _noMipmap;
  83748. private _files;
  83749. protected _forcedExtension: Nullable<string>;
  83750. private _extensions;
  83751. private _textureMatrix;
  83752. private _format;
  83753. private _createPolynomials;
  83754. /** @hidden */
  83755. _prefiltered: boolean;
  83756. /**
  83757. * Creates a cube texture from an array of image urls
  83758. * @param files defines an array of image urls
  83759. * @param scene defines the hosting scene
  83760. * @param noMipmap specifies if mip maps are not used
  83761. * @returns a cube texture
  83762. */
  83763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  83764. /**
  83765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  83766. * @param url defines the url of the prefiltered texture
  83767. * @param scene defines the scene the texture is attached to
  83768. * @param forcedExtension defines the extension of the file if different from the url
  83769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83770. * @return the prefiltered texture
  83771. */
  83772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  83773. /**
  83774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  83775. * as prefiltered data.
  83776. * @param rootUrl defines the url of the texture or the root name of the six images
  83777. * @param null defines the scene or engine the texture is attached to
  83778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  83779. * @param noMipmap defines if mipmaps should be created or not
  83780. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  83781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  83782. * @param onError defines a callback triggered in case of error during load
  83783. * @param format defines the internal format to use for the texture once loaded
  83784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  83785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  83786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83789. * @return the cube texture
  83790. */
  83791. 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);
  83792. /**
  83793. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  83794. */
  83795. get isPrefiltered(): boolean;
  83796. /**
  83797. * Get the current class name of the texture useful for serialization or dynamic coding.
  83798. * @returns "CubeTexture"
  83799. */
  83800. getClassName(): string;
  83801. /**
  83802. * Update the url (and optional buffer) of this texture if url was null during construction.
  83803. * @param url the url of the texture
  83804. * @param forcedExtension defines the extension to use
  83805. * @param onLoad callback called when the texture is loaded (defaults to null)
  83806. * @param prefiltered Defines whether the updated texture is prefiltered or not
  83807. */
  83808. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  83809. /**
  83810. * Delays loading of the cube texture
  83811. * @param forcedExtension defines the extension to use
  83812. */
  83813. delayLoad(forcedExtension?: string): void;
  83814. /**
  83815. * Returns the reflection texture matrix
  83816. * @returns the reflection texture matrix
  83817. */
  83818. getReflectionTextureMatrix(): Matrix;
  83819. /**
  83820. * Sets the reflection texture matrix
  83821. * @param value Reflection texture matrix
  83822. */
  83823. setReflectionTextureMatrix(value: Matrix): void;
  83824. /**
  83825. * Parses text to create a cube texture
  83826. * @param parsedTexture define the serialized text to read from
  83827. * @param scene defines the hosting scene
  83828. * @param rootUrl defines the root url of the cube texture
  83829. * @returns a cube texture
  83830. */
  83831. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  83832. /**
  83833. * Makes a clone, or deep copy, of the cube texture
  83834. * @returns a new cube texture
  83835. */
  83836. clone(): CubeTexture;
  83837. }
  83838. }
  83839. declare module BABYLON {
  83840. /**
  83841. * Manages the defines for the Material
  83842. */
  83843. export class MaterialDefines {
  83844. /** @hidden */
  83845. protected _keys: string[];
  83846. private _isDirty;
  83847. /** @hidden */
  83848. _renderId: number;
  83849. /** @hidden */
  83850. _areLightsDirty: boolean;
  83851. /** @hidden */
  83852. _areLightsDisposed: boolean;
  83853. /** @hidden */
  83854. _areAttributesDirty: boolean;
  83855. /** @hidden */
  83856. _areTexturesDirty: boolean;
  83857. /** @hidden */
  83858. _areFresnelDirty: boolean;
  83859. /** @hidden */
  83860. _areMiscDirty: boolean;
  83861. /** @hidden */
  83862. _areImageProcessingDirty: boolean;
  83863. /** @hidden */
  83864. _normals: boolean;
  83865. /** @hidden */
  83866. _uvs: boolean;
  83867. /** @hidden */
  83868. _needNormals: boolean;
  83869. /** @hidden */
  83870. _needUVs: boolean;
  83871. [id: string]: any;
  83872. /**
  83873. * Specifies if the material needs to be re-calculated
  83874. */
  83875. get isDirty(): boolean;
  83876. /**
  83877. * Marks the material to indicate that it has been re-calculated
  83878. */
  83879. markAsProcessed(): void;
  83880. /**
  83881. * Marks the material to indicate that it needs to be re-calculated
  83882. */
  83883. markAsUnprocessed(): void;
  83884. /**
  83885. * Marks the material to indicate all of its defines need to be re-calculated
  83886. */
  83887. markAllAsDirty(): void;
  83888. /**
  83889. * Marks the material to indicate that image processing needs to be re-calculated
  83890. */
  83891. markAsImageProcessingDirty(): void;
  83892. /**
  83893. * Marks the material to indicate the lights need to be re-calculated
  83894. * @param disposed Defines whether the light is dirty due to dispose or not
  83895. */
  83896. markAsLightDirty(disposed?: boolean): void;
  83897. /**
  83898. * Marks the attribute state as changed
  83899. */
  83900. markAsAttributesDirty(): void;
  83901. /**
  83902. * Marks the texture state as changed
  83903. */
  83904. markAsTexturesDirty(): void;
  83905. /**
  83906. * Marks the fresnel state as changed
  83907. */
  83908. markAsFresnelDirty(): void;
  83909. /**
  83910. * Marks the misc state as changed
  83911. */
  83912. markAsMiscDirty(): void;
  83913. /**
  83914. * Rebuilds the material defines
  83915. */
  83916. rebuild(): void;
  83917. /**
  83918. * Specifies if two material defines are equal
  83919. * @param other - A material define instance to compare to
  83920. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  83921. */
  83922. isEqual(other: MaterialDefines): boolean;
  83923. /**
  83924. * Clones this instance's defines to another instance
  83925. * @param other - material defines to clone values to
  83926. */
  83927. cloneTo(other: MaterialDefines): void;
  83928. /**
  83929. * Resets the material define values
  83930. */
  83931. reset(): void;
  83932. /**
  83933. * Converts the material define values to a string
  83934. * @returns - String of material define information
  83935. */
  83936. toString(): string;
  83937. }
  83938. }
  83939. declare module BABYLON {
  83940. /**
  83941. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  83942. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  83943. * 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;
  83944. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  83945. */
  83946. export class ColorCurves {
  83947. private _dirty;
  83948. private _tempColor;
  83949. private _globalCurve;
  83950. private _highlightsCurve;
  83951. private _midtonesCurve;
  83952. private _shadowsCurve;
  83953. private _positiveCurve;
  83954. private _negativeCurve;
  83955. private _globalHue;
  83956. private _globalDensity;
  83957. private _globalSaturation;
  83958. private _globalExposure;
  83959. /**
  83960. * Gets the global Hue value.
  83961. * 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).
  83962. */
  83963. get globalHue(): number;
  83964. /**
  83965. * Sets the global Hue value.
  83966. * 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).
  83967. */
  83968. set globalHue(value: number);
  83969. /**
  83970. * Gets the global Density value.
  83971. * 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.
  83972. * Values less than zero provide a filter of opposite hue.
  83973. */
  83974. get globalDensity(): number;
  83975. /**
  83976. * Sets the global Density value.
  83977. * 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.
  83978. * Values less than zero provide a filter of opposite hue.
  83979. */
  83980. set globalDensity(value: number);
  83981. /**
  83982. * Gets the global Saturation value.
  83983. * 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.
  83984. */
  83985. get globalSaturation(): number;
  83986. /**
  83987. * Sets the global Saturation value.
  83988. * 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.
  83989. */
  83990. set globalSaturation(value: number);
  83991. /**
  83992. * Gets the global Exposure value.
  83993. * 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.
  83994. */
  83995. get globalExposure(): number;
  83996. /**
  83997. * Sets the global Exposure value.
  83998. * 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.
  83999. */
  84000. set globalExposure(value: number);
  84001. private _highlightsHue;
  84002. private _highlightsDensity;
  84003. private _highlightsSaturation;
  84004. private _highlightsExposure;
  84005. /**
  84006. * Gets the highlights Hue value.
  84007. * 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).
  84008. */
  84009. get highlightsHue(): number;
  84010. /**
  84011. * Sets the highlights Hue value.
  84012. * 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).
  84013. */
  84014. set highlightsHue(value: number);
  84015. /**
  84016. * Gets the highlights Density value.
  84017. * 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.
  84018. * Values less than zero provide a filter of opposite hue.
  84019. */
  84020. get highlightsDensity(): number;
  84021. /**
  84022. * Sets the highlights Density value.
  84023. * 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.
  84024. * Values less than zero provide a filter of opposite hue.
  84025. */
  84026. set highlightsDensity(value: number);
  84027. /**
  84028. * Gets the highlights Saturation value.
  84029. * 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.
  84030. */
  84031. get highlightsSaturation(): number;
  84032. /**
  84033. * Sets the highlights Saturation value.
  84034. * 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.
  84035. */
  84036. set highlightsSaturation(value: number);
  84037. /**
  84038. * Gets the highlights Exposure value.
  84039. * 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.
  84040. */
  84041. get highlightsExposure(): number;
  84042. /**
  84043. * Sets the highlights Exposure value.
  84044. * 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.
  84045. */
  84046. set highlightsExposure(value: number);
  84047. private _midtonesHue;
  84048. private _midtonesDensity;
  84049. private _midtonesSaturation;
  84050. private _midtonesExposure;
  84051. /**
  84052. * Gets the midtones Hue value.
  84053. * 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).
  84054. */
  84055. get midtonesHue(): number;
  84056. /**
  84057. * Sets the midtones Hue value.
  84058. * 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).
  84059. */
  84060. set midtonesHue(value: number);
  84061. /**
  84062. * Gets the midtones Density value.
  84063. * 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.
  84064. * Values less than zero provide a filter of opposite hue.
  84065. */
  84066. get midtonesDensity(): number;
  84067. /**
  84068. * Sets the midtones Density value.
  84069. * 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.
  84070. * Values less than zero provide a filter of opposite hue.
  84071. */
  84072. set midtonesDensity(value: number);
  84073. /**
  84074. * Gets the midtones Saturation value.
  84075. * 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.
  84076. */
  84077. get midtonesSaturation(): number;
  84078. /**
  84079. * Sets the midtones Saturation value.
  84080. * 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.
  84081. */
  84082. set midtonesSaturation(value: number);
  84083. /**
  84084. * Gets the midtones Exposure value.
  84085. * 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.
  84086. */
  84087. get midtonesExposure(): number;
  84088. /**
  84089. * Sets the midtones Exposure value.
  84090. * 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.
  84091. */
  84092. set midtonesExposure(value: number);
  84093. private _shadowsHue;
  84094. private _shadowsDensity;
  84095. private _shadowsSaturation;
  84096. private _shadowsExposure;
  84097. /**
  84098. * Gets the shadows Hue value.
  84099. * 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).
  84100. */
  84101. get shadowsHue(): number;
  84102. /**
  84103. * Sets the shadows Hue value.
  84104. * 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).
  84105. */
  84106. set shadowsHue(value: number);
  84107. /**
  84108. * Gets the shadows Density value.
  84109. * 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.
  84110. * Values less than zero provide a filter of opposite hue.
  84111. */
  84112. get shadowsDensity(): number;
  84113. /**
  84114. * Sets the shadows Density value.
  84115. * 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.
  84116. * Values less than zero provide a filter of opposite hue.
  84117. */
  84118. set shadowsDensity(value: number);
  84119. /**
  84120. * Gets the shadows Saturation value.
  84121. * 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.
  84122. */
  84123. get shadowsSaturation(): number;
  84124. /**
  84125. * Sets the shadows Saturation value.
  84126. * 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.
  84127. */
  84128. set shadowsSaturation(value: number);
  84129. /**
  84130. * Gets the shadows Exposure value.
  84131. * 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.
  84132. */
  84133. get shadowsExposure(): number;
  84134. /**
  84135. * Sets the shadows Exposure value.
  84136. * 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.
  84137. */
  84138. set shadowsExposure(value: number);
  84139. /**
  84140. * Returns the class name
  84141. * @returns The class name
  84142. */
  84143. getClassName(): string;
  84144. /**
  84145. * Binds the color curves to the shader.
  84146. * @param colorCurves The color curve to bind
  84147. * @param effect The effect to bind to
  84148. * @param positiveUniform The positive uniform shader parameter
  84149. * @param neutralUniform The neutral uniform shader parameter
  84150. * @param negativeUniform The negative uniform shader parameter
  84151. */
  84152. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  84153. /**
  84154. * Prepare the list of uniforms associated with the ColorCurves effects.
  84155. * @param uniformsList The list of uniforms used in the effect
  84156. */
  84157. static PrepareUniforms(uniformsList: string[]): void;
  84158. /**
  84159. * Returns color grading data based on a hue, density, saturation and exposure value.
  84160. * @param filterHue The hue of the color filter.
  84161. * @param filterDensity The density of the color filter.
  84162. * @param saturation The saturation.
  84163. * @param exposure The exposure.
  84164. * @param result The result data container.
  84165. */
  84166. private getColorGradingDataToRef;
  84167. /**
  84168. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  84169. * @param value The input slider value in range [-100,100].
  84170. * @returns Adjusted value.
  84171. */
  84172. private static applyColorGradingSliderNonlinear;
  84173. /**
  84174. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  84175. * @param hue The hue (H) input.
  84176. * @param saturation The saturation (S) input.
  84177. * @param brightness The brightness (B) input.
  84178. * @result An RGBA color represented as Vector4.
  84179. */
  84180. private static fromHSBToRef;
  84181. /**
  84182. * Returns a value clamped between min and max
  84183. * @param value The value to clamp
  84184. * @param min The minimum of value
  84185. * @param max The maximum of value
  84186. * @returns The clamped value.
  84187. */
  84188. private static clamp;
  84189. /**
  84190. * Clones the current color curve instance.
  84191. * @return The cloned curves
  84192. */
  84193. clone(): ColorCurves;
  84194. /**
  84195. * Serializes the current color curve instance to a json representation.
  84196. * @return a JSON representation
  84197. */
  84198. serialize(): any;
  84199. /**
  84200. * Parses the color curve from a json representation.
  84201. * @param source the JSON source to parse
  84202. * @return The parsed curves
  84203. */
  84204. static Parse(source: any): ColorCurves;
  84205. }
  84206. }
  84207. declare module BABYLON {
  84208. /**
  84209. * Interface to follow in your material defines to integrate easily the
  84210. * Image proccessing functions.
  84211. * @hidden
  84212. */
  84213. export interface IImageProcessingConfigurationDefines {
  84214. IMAGEPROCESSING: boolean;
  84215. VIGNETTE: boolean;
  84216. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84217. VIGNETTEBLENDMODEOPAQUE: boolean;
  84218. TONEMAPPING: boolean;
  84219. TONEMAPPING_ACES: boolean;
  84220. CONTRAST: boolean;
  84221. EXPOSURE: boolean;
  84222. COLORCURVES: boolean;
  84223. COLORGRADING: boolean;
  84224. COLORGRADING3D: boolean;
  84225. SAMPLER3DGREENDEPTH: boolean;
  84226. SAMPLER3DBGRMAP: boolean;
  84227. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84228. }
  84229. /**
  84230. * @hidden
  84231. */
  84232. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  84233. IMAGEPROCESSING: boolean;
  84234. VIGNETTE: boolean;
  84235. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84236. VIGNETTEBLENDMODEOPAQUE: boolean;
  84237. TONEMAPPING: boolean;
  84238. TONEMAPPING_ACES: boolean;
  84239. CONTRAST: boolean;
  84240. COLORCURVES: boolean;
  84241. COLORGRADING: boolean;
  84242. COLORGRADING3D: boolean;
  84243. SAMPLER3DGREENDEPTH: boolean;
  84244. SAMPLER3DBGRMAP: boolean;
  84245. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84246. EXPOSURE: boolean;
  84247. constructor();
  84248. }
  84249. /**
  84250. * This groups together the common properties used for image processing either in direct forward pass
  84251. * or through post processing effect depending on the use of the image processing pipeline in your scene
  84252. * or not.
  84253. */
  84254. export class ImageProcessingConfiguration {
  84255. /**
  84256. * Default tone mapping applied in BabylonJS.
  84257. */
  84258. static readonly TONEMAPPING_STANDARD: number;
  84259. /**
  84260. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  84261. * to other engines rendering to increase portability.
  84262. */
  84263. static readonly TONEMAPPING_ACES: number;
  84264. /**
  84265. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  84266. */
  84267. colorCurves: Nullable<ColorCurves>;
  84268. private _colorCurvesEnabled;
  84269. /**
  84270. * Gets wether the color curves effect is enabled.
  84271. */
  84272. get colorCurvesEnabled(): boolean;
  84273. /**
  84274. * Sets wether the color curves effect is enabled.
  84275. */
  84276. set colorCurvesEnabled(value: boolean);
  84277. private _colorGradingTexture;
  84278. /**
  84279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84280. */
  84281. get colorGradingTexture(): Nullable<BaseTexture>;
  84282. /**
  84283. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84284. */
  84285. set colorGradingTexture(value: Nullable<BaseTexture>);
  84286. private _colorGradingEnabled;
  84287. /**
  84288. * Gets wether the color grading effect is enabled.
  84289. */
  84290. get colorGradingEnabled(): boolean;
  84291. /**
  84292. * Sets wether the color grading effect is enabled.
  84293. */
  84294. set colorGradingEnabled(value: boolean);
  84295. private _colorGradingWithGreenDepth;
  84296. /**
  84297. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  84298. */
  84299. get colorGradingWithGreenDepth(): boolean;
  84300. /**
  84301. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  84302. */
  84303. set colorGradingWithGreenDepth(value: boolean);
  84304. private _colorGradingBGR;
  84305. /**
  84306. * Gets wether the color grading texture contains BGR values.
  84307. */
  84308. get colorGradingBGR(): boolean;
  84309. /**
  84310. * Sets wether the color grading texture contains BGR values.
  84311. */
  84312. set colorGradingBGR(value: boolean);
  84313. /** @hidden */
  84314. _exposure: number;
  84315. /**
  84316. * Gets the Exposure used in the effect.
  84317. */
  84318. get exposure(): number;
  84319. /**
  84320. * Sets the Exposure used in the effect.
  84321. */
  84322. set exposure(value: number);
  84323. private _toneMappingEnabled;
  84324. /**
  84325. * Gets wether the tone mapping effect is enabled.
  84326. */
  84327. get toneMappingEnabled(): boolean;
  84328. /**
  84329. * Sets wether the tone mapping effect is enabled.
  84330. */
  84331. set toneMappingEnabled(value: boolean);
  84332. private _toneMappingType;
  84333. /**
  84334. * Gets the type of tone mapping effect.
  84335. */
  84336. get toneMappingType(): number;
  84337. /**
  84338. * Sets the type of tone mapping effect used in BabylonJS.
  84339. */
  84340. set toneMappingType(value: number);
  84341. protected _contrast: number;
  84342. /**
  84343. * Gets the contrast used in the effect.
  84344. */
  84345. get contrast(): number;
  84346. /**
  84347. * Sets the contrast used in the effect.
  84348. */
  84349. set contrast(value: number);
  84350. /**
  84351. * Vignette stretch size.
  84352. */
  84353. vignetteStretch: number;
  84354. /**
  84355. * Vignette centre X Offset.
  84356. */
  84357. vignetteCentreX: number;
  84358. /**
  84359. * Vignette centre Y Offset.
  84360. */
  84361. vignetteCentreY: number;
  84362. /**
  84363. * Vignette weight or intensity of the vignette effect.
  84364. */
  84365. vignetteWeight: number;
  84366. /**
  84367. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  84368. * if vignetteEnabled is set to true.
  84369. */
  84370. vignetteColor: Color4;
  84371. /**
  84372. * Camera field of view used by the Vignette effect.
  84373. */
  84374. vignetteCameraFov: number;
  84375. private _vignetteBlendMode;
  84376. /**
  84377. * Gets the vignette blend mode allowing different kind of effect.
  84378. */
  84379. get vignetteBlendMode(): number;
  84380. /**
  84381. * Sets the vignette blend mode allowing different kind of effect.
  84382. */
  84383. set vignetteBlendMode(value: number);
  84384. private _vignetteEnabled;
  84385. /**
  84386. * Gets wether the vignette effect is enabled.
  84387. */
  84388. get vignetteEnabled(): boolean;
  84389. /**
  84390. * Sets wether the vignette effect is enabled.
  84391. */
  84392. set vignetteEnabled(value: boolean);
  84393. private _applyByPostProcess;
  84394. /**
  84395. * Gets wether the image processing is applied through a post process or not.
  84396. */
  84397. get applyByPostProcess(): boolean;
  84398. /**
  84399. * Sets wether the image processing is applied through a post process or not.
  84400. */
  84401. set applyByPostProcess(value: boolean);
  84402. private _isEnabled;
  84403. /**
  84404. * Gets wether the image processing is enabled or not.
  84405. */
  84406. get isEnabled(): boolean;
  84407. /**
  84408. * Sets wether the image processing is enabled or not.
  84409. */
  84410. set isEnabled(value: boolean);
  84411. /**
  84412. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  84413. */
  84414. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  84415. /**
  84416. * Method called each time the image processing information changes requires to recompile the effect.
  84417. */
  84418. protected _updateParameters(): void;
  84419. /**
  84420. * Gets the current class name.
  84421. * @return "ImageProcessingConfiguration"
  84422. */
  84423. getClassName(): string;
  84424. /**
  84425. * Prepare the list of uniforms associated with the Image Processing effects.
  84426. * @param uniforms The list of uniforms used in the effect
  84427. * @param defines the list of defines currently in use
  84428. */
  84429. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  84430. /**
  84431. * Prepare the list of samplers associated with the Image Processing effects.
  84432. * @param samplersList The list of uniforms used in the effect
  84433. * @param defines the list of defines currently in use
  84434. */
  84435. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  84436. /**
  84437. * Prepare the list of defines associated to the shader.
  84438. * @param defines the list of defines to complete
  84439. * @param forPostProcess Define if we are currently in post process mode or not
  84440. */
  84441. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  84442. /**
  84443. * Returns true if all the image processing information are ready.
  84444. * @returns True if ready, otherwise, false
  84445. */
  84446. isReady(): boolean;
  84447. /**
  84448. * Binds the image processing to the shader.
  84449. * @param effect The effect to bind to
  84450. * @param overrideAspectRatio Override the aspect ratio of the effect
  84451. */
  84452. bind(effect: Effect, overrideAspectRatio?: number): void;
  84453. /**
  84454. * Clones the current image processing instance.
  84455. * @return The cloned image processing
  84456. */
  84457. clone(): ImageProcessingConfiguration;
  84458. /**
  84459. * Serializes the current image processing instance to a json representation.
  84460. * @return a JSON representation
  84461. */
  84462. serialize(): any;
  84463. /**
  84464. * Parses the image processing from a json representation.
  84465. * @param source the JSON source to parse
  84466. * @return The parsed image processing
  84467. */
  84468. static Parse(source: any): ImageProcessingConfiguration;
  84469. private static _VIGNETTEMODE_MULTIPLY;
  84470. private static _VIGNETTEMODE_OPAQUE;
  84471. /**
  84472. * Used to apply the vignette as a mix with the pixel color.
  84473. */
  84474. static get VIGNETTEMODE_MULTIPLY(): number;
  84475. /**
  84476. * Used to apply the vignette as a replacement of the pixel color.
  84477. */
  84478. static get VIGNETTEMODE_OPAQUE(): number;
  84479. }
  84480. }
  84481. declare module BABYLON {
  84482. /** @hidden */
  84483. export var postprocessVertexShader: {
  84484. name: string;
  84485. shader: string;
  84486. };
  84487. }
  84488. declare module BABYLON {
  84489. interface ThinEngine {
  84490. /**
  84491. * Creates a new render target texture
  84492. * @param size defines the size of the texture
  84493. * @param options defines the options used to create the texture
  84494. * @returns a new render target texture stored in an InternalTexture
  84495. */
  84496. createRenderTargetTexture(size: number | {
  84497. width: number;
  84498. height: number;
  84499. layers?: number;
  84500. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84501. /**
  84502. * Creates a depth stencil texture.
  84503. * This is only available in WebGL 2 or with the depth texture extension available.
  84504. * @param size The size of face edge in the texture.
  84505. * @param options The options defining the texture.
  84506. * @returns The texture
  84507. */
  84508. createDepthStencilTexture(size: number | {
  84509. width: number;
  84510. height: number;
  84511. layers?: number;
  84512. }, options: DepthTextureCreationOptions): InternalTexture;
  84513. /** @hidden */
  84514. _createDepthStencilTexture(size: number | {
  84515. width: number;
  84516. height: number;
  84517. layers?: number;
  84518. }, options: DepthTextureCreationOptions): InternalTexture;
  84519. }
  84520. }
  84521. declare module BABYLON {
  84522. /** Defines supported spaces */
  84523. export enum Space {
  84524. /** Local (object) space */
  84525. LOCAL = 0,
  84526. /** World space */
  84527. WORLD = 1,
  84528. /** Bone space */
  84529. BONE = 2
  84530. }
  84531. /** Defines the 3 main axes */
  84532. export class Axis {
  84533. /** X axis */
  84534. static X: Vector3;
  84535. /** Y axis */
  84536. static Y: Vector3;
  84537. /** Z axis */
  84538. static Z: Vector3;
  84539. }
  84540. }
  84541. declare module BABYLON {
  84542. /**
  84543. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  84544. * This is the base of the follow, arc rotate cameras and Free camera
  84545. * @see http://doc.babylonjs.com/features/cameras
  84546. */
  84547. export class TargetCamera extends Camera {
  84548. private static _RigCamTransformMatrix;
  84549. private static _TargetTransformMatrix;
  84550. private static _TargetFocalPoint;
  84551. /**
  84552. * Define the current direction the camera is moving to
  84553. */
  84554. cameraDirection: Vector3;
  84555. /**
  84556. * Define the current rotation the camera is rotating to
  84557. */
  84558. cameraRotation: Vector2;
  84559. /**
  84560. * When set, the up vector of the camera will be updated by the rotation of the camera
  84561. */
  84562. updateUpVectorFromRotation: boolean;
  84563. private _tmpQuaternion;
  84564. /**
  84565. * Define the current rotation of the camera
  84566. */
  84567. rotation: Vector3;
  84568. /**
  84569. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  84570. */
  84571. rotationQuaternion: Quaternion;
  84572. /**
  84573. * Define the current speed of the camera
  84574. */
  84575. speed: number;
  84576. /**
  84577. * Add constraint to the camera to prevent it to move freely in all directions and
  84578. * around all axis.
  84579. */
  84580. noRotationConstraint: boolean;
  84581. /**
  84582. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  84583. * panning
  84584. */
  84585. invertRotation: boolean;
  84586. /**
  84587. * Speed multiplier for inverse camera panning
  84588. */
  84589. inverseRotationSpeed: number;
  84590. /**
  84591. * Define the current target of the camera as an object or a position.
  84592. */
  84593. lockedTarget: any;
  84594. /** @hidden */
  84595. _currentTarget: Vector3;
  84596. /** @hidden */
  84597. _initialFocalDistance: number;
  84598. /** @hidden */
  84599. _viewMatrix: Matrix;
  84600. /** @hidden */
  84601. _camMatrix: Matrix;
  84602. /** @hidden */
  84603. _cameraTransformMatrix: Matrix;
  84604. /** @hidden */
  84605. _cameraRotationMatrix: Matrix;
  84606. /** @hidden */
  84607. _referencePoint: Vector3;
  84608. /** @hidden */
  84609. _transformedReferencePoint: Vector3;
  84610. protected _globalCurrentTarget: Vector3;
  84611. protected _globalCurrentUpVector: Vector3;
  84612. /** @hidden */
  84613. _reset: () => void;
  84614. private _defaultUp;
  84615. /**
  84616. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  84617. * This is the base of the follow, arc rotate cameras and Free camera
  84618. * @see http://doc.babylonjs.com/features/cameras
  84619. * @param name Defines the name of the camera in the scene
  84620. * @param position Defines the start position of the camera in the scene
  84621. * @param scene Defines the scene the camera belongs to
  84622. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84623. */
  84624. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84625. /**
  84626. * Gets the position in front of the camera at a given distance.
  84627. * @param distance The distance from the camera we want the position to be
  84628. * @returns the position
  84629. */
  84630. getFrontPosition(distance: number): Vector3;
  84631. /** @hidden */
  84632. _getLockedTargetPosition(): Nullable<Vector3>;
  84633. private _storedPosition;
  84634. private _storedRotation;
  84635. private _storedRotationQuaternion;
  84636. /**
  84637. * Store current camera state of the camera (fov, position, rotation, etc..)
  84638. * @returns the camera
  84639. */
  84640. storeState(): Camera;
  84641. /**
  84642. * Restored camera state. You must call storeState() first
  84643. * @returns whether it was successful or not
  84644. * @hidden
  84645. */
  84646. _restoreStateValues(): boolean;
  84647. /** @hidden */
  84648. _initCache(): void;
  84649. /** @hidden */
  84650. _updateCache(ignoreParentClass?: boolean): void;
  84651. /** @hidden */
  84652. _isSynchronizedViewMatrix(): boolean;
  84653. /** @hidden */
  84654. _computeLocalCameraSpeed(): number;
  84655. /**
  84656. * Defines the target the camera should look at.
  84657. * @param target Defines the new target as a Vector or a mesh
  84658. */
  84659. setTarget(target: Vector3): void;
  84660. /**
  84661. * Return the current target position of the camera. This value is expressed in local space.
  84662. * @returns the target position
  84663. */
  84664. getTarget(): Vector3;
  84665. /** @hidden */
  84666. _decideIfNeedsToMove(): boolean;
  84667. /** @hidden */
  84668. _updatePosition(): void;
  84669. /** @hidden */
  84670. _checkInputs(): void;
  84671. protected _updateCameraRotationMatrix(): void;
  84672. /**
  84673. * 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)
  84674. * @returns the current camera
  84675. */
  84676. private _rotateUpVectorWithCameraRotationMatrix;
  84677. private _cachedRotationZ;
  84678. private _cachedQuaternionRotationZ;
  84679. /** @hidden */
  84680. _getViewMatrix(): Matrix;
  84681. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  84682. /**
  84683. * @hidden
  84684. */
  84685. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  84686. /**
  84687. * @hidden
  84688. */
  84689. _updateRigCameras(): void;
  84690. private _getRigCamPositionAndTarget;
  84691. /**
  84692. * Gets the current object class name.
  84693. * @return the class name
  84694. */
  84695. getClassName(): string;
  84696. }
  84697. }
  84698. declare module BABYLON {
  84699. /**
  84700. * Gather the list of keyboard event types as constants.
  84701. */
  84702. export class KeyboardEventTypes {
  84703. /**
  84704. * The keydown event is fired when a key becomes active (pressed).
  84705. */
  84706. static readonly KEYDOWN: number;
  84707. /**
  84708. * The keyup event is fired when a key has been released.
  84709. */
  84710. static readonly KEYUP: number;
  84711. }
  84712. /**
  84713. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84714. */
  84715. export class KeyboardInfo {
  84716. /**
  84717. * Defines the type of event (KeyboardEventTypes)
  84718. */
  84719. type: number;
  84720. /**
  84721. * Defines the related dom event
  84722. */
  84723. event: KeyboardEvent;
  84724. /**
  84725. * Instantiates a new keyboard info.
  84726. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84727. * @param type Defines the type of event (KeyboardEventTypes)
  84728. * @param event Defines the related dom event
  84729. */
  84730. constructor(
  84731. /**
  84732. * Defines the type of event (KeyboardEventTypes)
  84733. */
  84734. type: number,
  84735. /**
  84736. * Defines the related dom event
  84737. */
  84738. event: KeyboardEvent);
  84739. }
  84740. /**
  84741. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84742. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  84743. */
  84744. export class KeyboardInfoPre extends KeyboardInfo {
  84745. /**
  84746. * Defines the type of event (KeyboardEventTypes)
  84747. */
  84748. type: number;
  84749. /**
  84750. * Defines the related dom event
  84751. */
  84752. event: KeyboardEvent;
  84753. /**
  84754. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  84755. */
  84756. skipOnPointerObservable: boolean;
  84757. /**
  84758. * Instantiates a new keyboard pre info.
  84759. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84760. * @param type Defines the type of event (KeyboardEventTypes)
  84761. * @param event Defines the related dom event
  84762. */
  84763. constructor(
  84764. /**
  84765. * Defines the type of event (KeyboardEventTypes)
  84766. */
  84767. type: number,
  84768. /**
  84769. * Defines the related dom event
  84770. */
  84771. event: KeyboardEvent);
  84772. }
  84773. }
  84774. declare module BABYLON {
  84775. /**
  84776. * Manage the keyboard inputs to control the movement of a free camera.
  84777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84778. */
  84779. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  84780. /**
  84781. * Defines the camera the input is attached to.
  84782. */
  84783. camera: FreeCamera;
  84784. /**
  84785. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84786. */
  84787. keysUp: number[];
  84788. /**
  84789. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  84790. */
  84791. keysUpward: number[];
  84792. /**
  84793. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84794. */
  84795. keysDown: number[];
  84796. /**
  84797. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  84798. */
  84799. keysDownward: number[];
  84800. /**
  84801. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84802. */
  84803. keysLeft: number[];
  84804. /**
  84805. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84806. */
  84807. keysRight: number[];
  84808. private _keys;
  84809. private _onCanvasBlurObserver;
  84810. private _onKeyboardObserver;
  84811. private _engine;
  84812. private _scene;
  84813. /**
  84814. * Attach the input controls to a specific dom element to get the input from.
  84815. * @param element Defines the element the controls should be listened from
  84816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84817. */
  84818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84819. /**
  84820. * Detach the current controls from the specified dom element.
  84821. * @param element Defines the element to stop listening the inputs from
  84822. */
  84823. detachControl(element: Nullable<HTMLElement>): void;
  84824. /**
  84825. * Update the current camera state depending on the inputs that have been used this frame.
  84826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84827. */
  84828. checkInputs(): void;
  84829. /**
  84830. * Gets the class name of the current intput.
  84831. * @returns the class name
  84832. */
  84833. getClassName(): string;
  84834. /** @hidden */
  84835. _onLostFocus(): void;
  84836. /**
  84837. * Get the friendly name associated with the input class.
  84838. * @returns the input friendly name
  84839. */
  84840. getSimpleName(): string;
  84841. }
  84842. }
  84843. declare module BABYLON {
  84844. /**
  84845. * Interface describing all the common properties and methods a shadow light needs to implement.
  84846. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  84847. * as well as binding the different shadow properties to the effects.
  84848. */
  84849. export interface IShadowLight extends Light {
  84850. /**
  84851. * The light id in the scene (used in scene.findLighById for instance)
  84852. */
  84853. id: string;
  84854. /**
  84855. * The position the shdow will be casted from.
  84856. */
  84857. position: Vector3;
  84858. /**
  84859. * In 2d mode (needCube being false), the direction used to cast the shadow.
  84860. */
  84861. direction: Vector3;
  84862. /**
  84863. * The transformed position. Position of the light in world space taking parenting in account.
  84864. */
  84865. transformedPosition: Vector3;
  84866. /**
  84867. * The transformed direction. Direction of the light in world space taking parenting in account.
  84868. */
  84869. transformedDirection: Vector3;
  84870. /**
  84871. * The friendly name of the light in the scene.
  84872. */
  84873. name: string;
  84874. /**
  84875. * Defines the shadow projection clipping minimum z value.
  84876. */
  84877. shadowMinZ: number;
  84878. /**
  84879. * Defines the shadow projection clipping maximum z value.
  84880. */
  84881. shadowMaxZ: number;
  84882. /**
  84883. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84884. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84885. */
  84886. computeTransformedInformation(): boolean;
  84887. /**
  84888. * Gets the scene the light belongs to.
  84889. * @returns The scene
  84890. */
  84891. getScene(): Scene;
  84892. /**
  84893. * Callback defining a custom Projection Matrix Builder.
  84894. * This can be used to override the default projection matrix computation.
  84895. */
  84896. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84897. /**
  84898. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84899. * @param matrix The materix to updated with the projection information
  84900. * @param viewMatrix The transform matrix of the light
  84901. * @param renderList The list of mesh to render in the map
  84902. * @returns The current light
  84903. */
  84904. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84905. /**
  84906. * Gets the current depth scale used in ESM.
  84907. * @returns The scale
  84908. */
  84909. getDepthScale(): number;
  84910. /**
  84911. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84912. * @returns true if a cube texture needs to be use
  84913. */
  84914. needCube(): boolean;
  84915. /**
  84916. * Detects if the projection matrix requires to be recomputed this frame.
  84917. * @returns true if it requires to be recomputed otherwise, false.
  84918. */
  84919. needProjectionMatrixCompute(): boolean;
  84920. /**
  84921. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84922. */
  84923. forceProjectionMatrixCompute(): void;
  84924. /**
  84925. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84926. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84927. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84928. */
  84929. getShadowDirection(faceIndex?: number): Vector3;
  84930. /**
  84931. * Gets the minZ used for shadow according to both the scene and the light.
  84932. * @param activeCamera The camera we are returning the min for
  84933. * @returns the depth min z
  84934. */
  84935. getDepthMinZ(activeCamera: Camera): number;
  84936. /**
  84937. * Gets the maxZ used for shadow according to both the scene and the light.
  84938. * @param activeCamera The camera we are returning the max for
  84939. * @returns the depth max z
  84940. */
  84941. getDepthMaxZ(activeCamera: Camera): number;
  84942. }
  84943. /**
  84944. * Base implementation IShadowLight
  84945. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  84946. */
  84947. export abstract class ShadowLight extends Light implements IShadowLight {
  84948. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  84949. protected _position: Vector3;
  84950. protected _setPosition(value: Vector3): void;
  84951. /**
  84952. * Sets the position the shadow will be casted from. Also use as the light position for both
  84953. * point and spot lights.
  84954. */
  84955. get position(): Vector3;
  84956. /**
  84957. * Sets the position the shadow will be casted from. Also use as the light position for both
  84958. * point and spot lights.
  84959. */
  84960. set position(value: Vector3);
  84961. protected _direction: Vector3;
  84962. protected _setDirection(value: Vector3): void;
  84963. /**
  84964. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  84965. * Also use as the light direction on spot and directional lights.
  84966. */
  84967. get direction(): Vector3;
  84968. /**
  84969. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  84970. * Also use as the light direction on spot and directional lights.
  84971. */
  84972. set direction(value: Vector3);
  84973. protected _shadowMinZ: number;
  84974. /**
  84975. * Gets the shadow projection clipping minimum z value.
  84976. */
  84977. get shadowMinZ(): number;
  84978. /**
  84979. * Sets the shadow projection clipping minimum z value.
  84980. */
  84981. set shadowMinZ(value: number);
  84982. protected _shadowMaxZ: number;
  84983. /**
  84984. * Sets the shadow projection clipping maximum z value.
  84985. */
  84986. get shadowMaxZ(): number;
  84987. /**
  84988. * Gets the shadow projection clipping maximum z value.
  84989. */
  84990. set shadowMaxZ(value: number);
  84991. /**
  84992. * Callback defining a custom Projection Matrix Builder.
  84993. * This can be used to override the default projection matrix computation.
  84994. */
  84995. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84996. /**
  84997. * The transformed position. Position of the light in world space taking parenting in account.
  84998. */
  84999. transformedPosition: Vector3;
  85000. /**
  85001. * The transformed direction. Direction of the light in world space taking parenting in account.
  85002. */
  85003. transformedDirection: Vector3;
  85004. private _needProjectionMatrixCompute;
  85005. /**
  85006. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  85007. * @returns true if the information has been computed, false if it does not need to (no parenting)
  85008. */
  85009. computeTransformedInformation(): boolean;
  85010. /**
  85011. * Return the depth scale used for the shadow map.
  85012. * @returns the depth scale.
  85013. */
  85014. getDepthScale(): number;
  85015. /**
  85016. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  85017. * @param faceIndex The index of the face we are computed the direction to generate shadow
  85018. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  85019. */
  85020. getShadowDirection(faceIndex?: number): Vector3;
  85021. /**
  85022. * Returns the ShadowLight absolute position in the World.
  85023. * @returns the position vector in world space
  85024. */
  85025. getAbsolutePosition(): Vector3;
  85026. /**
  85027. * Sets the ShadowLight direction toward the passed target.
  85028. * @param target The point to target in local space
  85029. * @returns the updated ShadowLight direction
  85030. */
  85031. setDirectionToTarget(target: Vector3): Vector3;
  85032. /**
  85033. * Returns the light rotation in euler definition.
  85034. * @returns the x y z rotation in local space.
  85035. */
  85036. getRotation(): Vector3;
  85037. /**
  85038. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  85039. * @returns true if a cube texture needs to be use
  85040. */
  85041. needCube(): boolean;
  85042. /**
  85043. * Detects if the projection matrix requires to be recomputed this frame.
  85044. * @returns true if it requires to be recomputed otherwise, false.
  85045. */
  85046. needProjectionMatrixCompute(): boolean;
  85047. /**
  85048. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  85049. */
  85050. forceProjectionMatrixCompute(): void;
  85051. /** @hidden */
  85052. _initCache(): void;
  85053. /** @hidden */
  85054. _isSynchronized(): boolean;
  85055. /**
  85056. * Computes the world matrix of the node
  85057. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85058. * @returns the world matrix
  85059. */
  85060. computeWorldMatrix(force?: boolean): Matrix;
  85061. /**
  85062. * Gets the minZ used for shadow according to both the scene and the light.
  85063. * @param activeCamera The camera we are returning the min for
  85064. * @returns the depth min z
  85065. */
  85066. getDepthMinZ(activeCamera: Camera): number;
  85067. /**
  85068. * Gets the maxZ used for shadow according to both the scene and the light.
  85069. * @param activeCamera The camera we are returning the max for
  85070. * @returns the depth max z
  85071. */
  85072. getDepthMaxZ(activeCamera: Camera): number;
  85073. /**
  85074. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  85075. * @param matrix The materix to updated with the projection information
  85076. * @param viewMatrix The transform matrix of the light
  85077. * @param renderList The list of mesh to render in the map
  85078. * @returns The current light
  85079. */
  85080. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  85081. }
  85082. }
  85083. declare module BABYLON {
  85084. /**
  85085. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85086. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85087. */
  85088. export class EffectFallbacks implements IEffectFallbacks {
  85089. private _defines;
  85090. private _currentRank;
  85091. private _maxRank;
  85092. private _mesh;
  85093. /**
  85094. * Removes the fallback from the bound mesh.
  85095. */
  85096. unBindMesh(): void;
  85097. /**
  85098. * Adds a fallback on the specified property.
  85099. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85100. * @param define The name of the define in the shader
  85101. */
  85102. addFallback(rank: number, define: string): void;
  85103. /**
  85104. * Sets the mesh to use CPU skinning when needing to fallback.
  85105. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85106. * @param mesh The mesh to use the fallbacks.
  85107. */
  85108. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85109. /**
  85110. * Checks to see if more fallbacks are still availible.
  85111. */
  85112. get hasMoreFallbacks(): boolean;
  85113. /**
  85114. * Removes the defines that should be removed when falling back.
  85115. * @param currentDefines defines the current define statements for the shader.
  85116. * @param effect defines the current effect we try to compile
  85117. * @returns The resulting defines with defines of the current rank removed.
  85118. */
  85119. reduce(currentDefines: string, effect: Effect): string;
  85120. }
  85121. }
  85122. declare module BABYLON {
  85123. /**
  85124. * "Static Class" containing the most commonly used helper while dealing with material for
  85125. * rendering purpose.
  85126. *
  85127. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  85128. *
  85129. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  85130. */
  85131. export class MaterialHelper {
  85132. /**
  85133. * Bind the current view position to an effect.
  85134. * @param effect The effect to be bound
  85135. * @param scene The scene the eyes position is used from
  85136. * @param variableName name of the shader variable that will hold the eye position
  85137. */
  85138. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  85139. /**
  85140. * Helps preparing the defines values about the UVs in used in the effect.
  85141. * UVs are shared as much as we can accross channels in the shaders.
  85142. * @param texture The texture we are preparing the UVs for
  85143. * @param defines The defines to update
  85144. * @param key The channel key "diffuse", "specular"... used in the shader
  85145. */
  85146. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  85147. /**
  85148. * Binds a texture matrix value to its corrsponding uniform
  85149. * @param texture The texture to bind the matrix for
  85150. * @param uniformBuffer The uniform buffer receivin the data
  85151. * @param key The channel key "diffuse", "specular"... used in the shader
  85152. */
  85153. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  85154. /**
  85155. * Gets the current status of the fog (should it be enabled?)
  85156. * @param mesh defines the mesh to evaluate for fog support
  85157. * @param scene defines the hosting scene
  85158. * @returns true if fog must be enabled
  85159. */
  85160. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  85161. /**
  85162. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  85163. * @param mesh defines the current mesh
  85164. * @param scene defines the current scene
  85165. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  85166. * @param pointsCloud defines if point cloud rendering has to be turned on
  85167. * @param fogEnabled defines if fog has to be turned on
  85168. * @param alphaTest defines if alpha testing has to be turned on
  85169. * @param defines defines the current list of defines
  85170. */
  85171. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  85172. /**
  85173. * Helper used to prepare the list of defines associated with frame values for shader compilation
  85174. * @param scene defines the current scene
  85175. * @param engine defines the current engine
  85176. * @param defines specifies the list of active defines
  85177. * @param useInstances defines if instances have to be turned on
  85178. * @param useClipPlane defines if clip plane have to be turned on
  85179. */
  85180. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  85181. /**
  85182. * Prepares the defines for bones
  85183. * @param mesh The mesh containing the geometry data we will draw
  85184. * @param defines The defines to update
  85185. */
  85186. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  85187. /**
  85188. * Prepares the defines for morph targets
  85189. * @param mesh The mesh containing the geometry data we will draw
  85190. * @param defines The defines to update
  85191. */
  85192. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  85193. /**
  85194. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  85195. * @param mesh The mesh containing the geometry data we will draw
  85196. * @param defines The defines to update
  85197. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  85198. * @param useBones Precise whether bones should be used or not (override mesh info)
  85199. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  85200. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  85201. * @returns false if defines are considered not dirty and have not been checked
  85202. */
  85203. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  85204. /**
  85205. * Prepares the defines related to multiview
  85206. * @param scene The scene we are intending to draw
  85207. * @param defines The defines to update
  85208. */
  85209. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  85210. /**
  85211. * Prepares the defines related to the light information passed in parameter
  85212. * @param scene The scene we are intending to draw
  85213. * @param mesh The mesh the effect is compiling for
  85214. * @param light The light the effect is compiling for
  85215. * @param lightIndex The index of the light
  85216. * @param defines The defines to update
  85217. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85218. * @param state Defines the current state regarding what is needed (normals, etc...)
  85219. */
  85220. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  85221. needNormals: boolean;
  85222. needRebuild: boolean;
  85223. shadowEnabled: boolean;
  85224. specularEnabled: boolean;
  85225. lightmapMode: boolean;
  85226. }): void;
  85227. /**
  85228. * Prepares the defines related to the light information passed in parameter
  85229. * @param scene The scene we are intending to draw
  85230. * @param mesh The mesh the effect is compiling for
  85231. * @param defines The defines to update
  85232. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85233. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  85234. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  85235. * @returns true if normals will be required for the rest of the effect
  85236. */
  85237. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  85238. /**
  85239. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  85240. * @param lightIndex defines the light index
  85241. * @param uniformsList The uniform list
  85242. * @param samplersList The sampler list
  85243. * @param projectedLightTexture defines if projected texture must be used
  85244. * @param uniformBuffersList defines an optional list of uniform buffers
  85245. */
  85246. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  85247. /**
  85248. * Prepares the uniforms and samplers list to be used in the effect
  85249. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  85250. * @param samplersList The sampler list
  85251. * @param defines The defines helping in the list generation
  85252. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  85253. */
  85254. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  85255. /**
  85256. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  85257. * @param defines The defines to update while falling back
  85258. * @param fallbacks The authorized effect fallbacks
  85259. * @param maxSimultaneousLights The maximum number of lights allowed
  85260. * @param rank the current rank of the Effect
  85261. * @returns The newly affected rank
  85262. */
  85263. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  85264. private static _TmpMorphInfluencers;
  85265. /**
  85266. * Prepares the list of attributes required for morph targets according to the effect defines.
  85267. * @param attribs The current list of supported attribs
  85268. * @param mesh The mesh to prepare the morph targets attributes for
  85269. * @param influencers The number of influencers
  85270. */
  85271. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  85272. /**
  85273. * Prepares the list of attributes required for morph targets according to the effect defines.
  85274. * @param attribs The current list of supported attribs
  85275. * @param mesh The mesh to prepare the morph targets attributes for
  85276. * @param defines The current Defines of the effect
  85277. */
  85278. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  85279. /**
  85280. * Prepares the list of attributes required for bones according to the effect defines.
  85281. * @param attribs The current list of supported attribs
  85282. * @param mesh The mesh to prepare the bones attributes for
  85283. * @param defines The current Defines of the effect
  85284. * @param fallbacks The current efffect fallback strategy
  85285. */
  85286. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  85287. /**
  85288. * Check and prepare the list of attributes required for instances according to the effect defines.
  85289. * @param attribs The current list of supported attribs
  85290. * @param defines The current MaterialDefines of the effect
  85291. */
  85292. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  85293. /**
  85294. * Add the list of attributes required for instances to the attribs array.
  85295. * @param attribs The current list of supported attribs
  85296. */
  85297. static PushAttributesForInstances(attribs: string[]): void;
  85298. /**
  85299. * Binds the light information to the effect.
  85300. * @param light The light containing the generator
  85301. * @param effect The effect we are binding the data to
  85302. * @param lightIndex The light index in the effect used to render
  85303. */
  85304. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  85305. /**
  85306. * Binds the lights information from the scene to the effect for the given mesh.
  85307. * @param light Light to bind
  85308. * @param lightIndex Light index
  85309. * @param scene The scene where the light belongs to
  85310. * @param effect The effect we are binding the data to
  85311. * @param useSpecular Defines if specular is supported
  85312. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85313. */
  85314. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  85315. /**
  85316. * Binds the lights information from the scene to the effect for the given mesh.
  85317. * @param scene The scene the lights belongs to
  85318. * @param mesh The mesh we are binding the information to render
  85319. * @param effect The effect we are binding the data to
  85320. * @param defines The generated defines for the effect
  85321. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  85322. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85323. */
  85324. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  85325. private static _tempFogColor;
  85326. /**
  85327. * Binds the fog information from the scene to the effect for the given mesh.
  85328. * @param scene The scene the lights belongs to
  85329. * @param mesh The mesh we are binding the information to render
  85330. * @param effect The effect we are binding the data to
  85331. * @param linearSpace Defines if the fog effect is applied in linear space
  85332. */
  85333. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  85334. /**
  85335. * Binds the bones information from the mesh to the effect.
  85336. * @param mesh The mesh we are binding the information to render
  85337. * @param effect The effect we are binding the data to
  85338. */
  85339. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  85340. /**
  85341. * Binds the morph targets information from the mesh to the effect.
  85342. * @param abstractMesh The mesh we are binding the information to render
  85343. * @param effect The effect we are binding the data to
  85344. */
  85345. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  85346. /**
  85347. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  85348. * @param defines The generated defines used in the effect
  85349. * @param effect The effect we are binding the data to
  85350. * @param scene The scene we are willing to render with logarithmic scale for
  85351. */
  85352. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  85353. /**
  85354. * Binds the clip plane information from the scene to the effect.
  85355. * @param scene The scene the clip plane information are extracted from
  85356. * @param effect The effect we are binding the data to
  85357. */
  85358. static BindClipPlane(effect: Effect, scene: Scene): void;
  85359. }
  85360. }
  85361. declare module BABYLON {
  85362. /** @hidden */
  85363. export var packingFunctions: {
  85364. name: string;
  85365. shader: string;
  85366. };
  85367. }
  85368. declare module BABYLON {
  85369. /** @hidden */
  85370. export var bayerDitherFunctions: {
  85371. name: string;
  85372. shader: string;
  85373. };
  85374. }
  85375. declare module BABYLON {
  85376. /** @hidden */
  85377. export var shadowMapFragmentDeclaration: {
  85378. name: string;
  85379. shader: string;
  85380. };
  85381. }
  85382. declare module BABYLON {
  85383. /** @hidden */
  85384. export var clipPlaneFragmentDeclaration: {
  85385. name: string;
  85386. shader: string;
  85387. };
  85388. }
  85389. declare module BABYLON {
  85390. /** @hidden */
  85391. export var clipPlaneFragment: {
  85392. name: string;
  85393. shader: string;
  85394. };
  85395. }
  85396. declare module BABYLON {
  85397. /** @hidden */
  85398. export var shadowMapFragment: {
  85399. name: string;
  85400. shader: string;
  85401. };
  85402. }
  85403. declare module BABYLON {
  85404. /** @hidden */
  85405. export var shadowMapPixelShader: {
  85406. name: string;
  85407. shader: string;
  85408. };
  85409. }
  85410. declare module BABYLON {
  85411. /** @hidden */
  85412. export var bonesDeclaration: {
  85413. name: string;
  85414. shader: string;
  85415. };
  85416. }
  85417. declare module BABYLON {
  85418. /** @hidden */
  85419. export var morphTargetsVertexGlobalDeclaration: {
  85420. name: string;
  85421. shader: string;
  85422. };
  85423. }
  85424. declare module BABYLON {
  85425. /** @hidden */
  85426. export var morphTargetsVertexDeclaration: {
  85427. name: string;
  85428. shader: string;
  85429. };
  85430. }
  85431. declare module BABYLON {
  85432. /** @hidden */
  85433. export var instancesDeclaration: {
  85434. name: string;
  85435. shader: string;
  85436. };
  85437. }
  85438. declare module BABYLON {
  85439. /** @hidden */
  85440. export var helperFunctions: {
  85441. name: string;
  85442. shader: string;
  85443. };
  85444. }
  85445. declare module BABYLON {
  85446. /** @hidden */
  85447. export var shadowMapVertexDeclaration: {
  85448. name: string;
  85449. shader: string;
  85450. };
  85451. }
  85452. declare module BABYLON {
  85453. /** @hidden */
  85454. export var clipPlaneVertexDeclaration: {
  85455. name: string;
  85456. shader: string;
  85457. };
  85458. }
  85459. declare module BABYLON {
  85460. /** @hidden */
  85461. export var morphTargetsVertex: {
  85462. name: string;
  85463. shader: string;
  85464. };
  85465. }
  85466. declare module BABYLON {
  85467. /** @hidden */
  85468. export var instancesVertex: {
  85469. name: string;
  85470. shader: string;
  85471. };
  85472. }
  85473. declare module BABYLON {
  85474. /** @hidden */
  85475. export var bonesVertex: {
  85476. name: string;
  85477. shader: string;
  85478. };
  85479. }
  85480. declare module BABYLON {
  85481. /** @hidden */
  85482. export var shadowMapVertexNormalBias: {
  85483. name: string;
  85484. shader: string;
  85485. };
  85486. }
  85487. declare module BABYLON {
  85488. /** @hidden */
  85489. export var shadowMapVertexMetric: {
  85490. name: string;
  85491. shader: string;
  85492. };
  85493. }
  85494. declare module BABYLON {
  85495. /** @hidden */
  85496. export var clipPlaneVertex: {
  85497. name: string;
  85498. shader: string;
  85499. };
  85500. }
  85501. declare module BABYLON {
  85502. /** @hidden */
  85503. export var shadowMapVertexShader: {
  85504. name: string;
  85505. shader: string;
  85506. };
  85507. }
  85508. declare module BABYLON {
  85509. /** @hidden */
  85510. export var depthBoxBlurPixelShader: {
  85511. name: string;
  85512. shader: string;
  85513. };
  85514. }
  85515. declare module BABYLON {
  85516. /** @hidden */
  85517. export var shadowMapFragmentSoftTransparentShadow: {
  85518. name: string;
  85519. shader: string;
  85520. };
  85521. }
  85522. declare module BABYLON {
  85523. /**
  85524. * Class representing a ray with position and direction
  85525. */
  85526. export class Ray {
  85527. /** origin point */
  85528. origin: Vector3;
  85529. /** direction */
  85530. direction: Vector3;
  85531. /** length of the ray */
  85532. length: number;
  85533. private static readonly TmpVector3;
  85534. private _tmpRay;
  85535. /**
  85536. * Creates a new ray
  85537. * @param origin origin point
  85538. * @param direction direction
  85539. * @param length length of the ray
  85540. */
  85541. constructor(
  85542. /** origin point */
  85543. origin: Vector3,
  85544. /** direction */
  85545. direction: Vector3,
  85546. /** length of the ray */
  85547. length?: number);
  85548. /**
  85549. * Checks if the ray intersects a box
  85550. * This does not account for the ray lenght by design to improve perfs.
  85551. * @param minimum bound of the box
  85552. * @param maximum bound of the box
  85553. * @param intersectionTreshold extra extend to be added to the box in all direction
  85554. * @returns if the box was hit
  85555. */
  85556. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  85557. /**
  85558. * Checks if the ray intersects a box
  85559. * This does not account for the ray lenght by design to improve perfs.
  85560. * @param box the bounding box to check
  85561. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  85562. * @returns if the box was hit
  85563. */
  85564. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  85565. /**
  85566. * If the ray hits a sphere
  85567. * @param sphere the bounding sphere to check
  85568. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  85569. * @returns true if it hits the sphere
  85570. */
  85571. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  85572. /**
  85573. * If the ray hits a triange
  85574. * @param vertex0 triangle vertex
  85575. * @param vertex1 triangle vertex
  85576. * @param vertex2 triangle vertex
  85577. * @returns intersection information if hit
  85578. */
  85579. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  85580. /**
  85581. * Checks if ray intersects a plane
  85582. * @param plane the plane to check
  85583. * @returns the distance away it was hit
  85584. */
  85585. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  85586. /**
  85587. * Calculate the intercept of a ray on a given axis
  85588. * @param axis to check 'x' | 'y' | 'z'
  85589. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  85590. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  85591. */
  85592. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  85593. /**
  85594. * Checks if ray intersects a mesh
  85595. * @param mesh the mesh to check
  85596. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85597. * @returns picking info of the intersecton
  85598. */
  85599. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  85600. /**
  85601. * Checks if ray intersects a mesh
  85602. * @param meshes the meshes to check
  85603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85604. * @param results array to store result in
  85605. * @returns Array of picking infos
  85606. */
  85607. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  85608. private _comparePickingInfo;
  85609. private static smallnum;
  85610. private static rayl;
  85611. /**
  85612. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  85613. * @param sega the first point of the segment to test the intersection against
  85614. * @param segb the second point of the segment to test the intersection against
  85615. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  85616. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  85617. */
  85618. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  85619. /**
  85620. * Update the ray from viewport position
  85621. * @param x position
  85622. * @param y y position
  85623. * @param viewportWidth viewport width
  85624. * @param viewportHeight viewport height
  85625. * @param world world matrix
  85626. * @param view view matrix
  85627. * @param projection projection matrix
  85628. * @returns this ray updated
  85629. */
  85630. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85631. /**
  85632. * Creates a ray with origin and direction of 0,0,0
  85633. * @returns the new ray
  85634. */
  85635. static Zero(): Ray;
  85636. /**
  85637. * Creates a new ray from screen space and viewport
  85638. * @param x position
  85639. * @param y y position
  85640. * @param viewportWidth viewport width
  85641. * @param viewportHeight viewport height
  85642. * @param world world matrix
  85643. * @param view view matrix
  85644. * @param projection projection matrix
  85645. * @returns new ray
  85646. */
  85647. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85648. /**
  85649. * 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
  85650. * transformed to the given world matrix.
  85651. * @param origin The origin point
  85652. * @param end The end point
  85653. * @param world a matrix to transform the ray to. Default is the identity matrix.
  85654. * @returns the new ray
  85655. */
  85656. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  85657. /**
  85658. * Transforms a ray by a matrix
  85659. * @param ray ray to transform
  85660. * @param matrix matrix to apply
  85661. * @returns the resulting new ray
  85662. */
  85663. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  85664. /**
  85665. * Transforms a ray by a matrix
  85666. * @param ray ray to transform
  85667. * @param matrix matrix to apply
  85668. * @param result ray to store result in
  85669. */
  85670. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  85671. /**
  85672. * Unproject a ray from screen space to object space
  85673. * @param sourceX defines the screen space x coordinate to use
  85674. * @param sourceY defines the screen space y coordinate to use
  85675. * @param viewportWidth defines the current width of the viewport
  85676. * @param viewportHeight defines the current height of the viewport
  85677. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85678. * @param view defines the view matrix to use
  85679. * @param projection defines the projection matrix to use
  85680. */
  85681. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  85682. }
  85683. /**
  85684. * Type used to define predicate used to select faces when a mesh intersection is detected
  85685. */
  85686. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  85687. interface Scene {
  85688. /** @hidden */
  85689. _tempPickingRay: Nullable<Ray>;
  85690. /** @hidden */
  85691. _cachedRayForTransform: Ray;
  85692. /** @hidden */
  85693. _pickWithRayInverseMatrix: Matrix;
  85694. /** @hidden */
  85695. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  85696. /** @hidden */
  85697. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  85698. }
  85699. }
  85700. declare module BABYLON {
  85701. /**
  85702. * Groups all the scene component constants in one place to ease maintenance.
  85703. * @hidden
  85704. */
  85705. export class SceneComponentConstants {
  85706. static readonly NAME_EFFECTLAYER: string;
  85707. static readonly NAME_LAYER: string;
  85708. static readonly NAME_LENSFLARESYSTEM: string;
  85709. static readonly NAME_BOUNDINGBOXRENDERER: string;
  85710. static readonly NAME_PARTICLESYSTEM: string;
  85711. static readonly NAME_GAMEPAD: string;
  85712. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  85713. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  85714. static readonly NAME_DEPTHRENDERER: string;
  85715. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  85716. static readonly NAME_SPRITE: string;
  85717. static readonly NAME_OUTLINERENDERER: string;
  85718. static readonly NAME_PROCEDURALTEXTURE: string;
  85719. static readonly NAME_SHADOWGENERATOR: string;
  85720. static readonly NAME_OCTREE: string;
  85721. static readonly NAME_PHYSICSENGINE: string;
  85722. static readonly NAME_AUDIO: string;
  85723. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  85724. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85725. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  85726. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85727. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  85728. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  85729. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  85730. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  85731. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  85732. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  85733. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  85734. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  85735. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  85736. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  85737. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  85738. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  85739. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  85740. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  85741. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  85742. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  85743. static readonly STEP_AFTERRENDER_AUDIO: number;
  85744. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  85745. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  85746. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  85747. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  85748. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  85749. static readonly STEP_POINTERMOVE_SPRITE: number;
  85750. static readonly STEP_POINTERDOWN_SPRITE: number;
  85751. static readonly STEP_POINTERUP_SPRITE: number;
  85752. }
  85753. /**
  85754. * This represents a scene component.
  85755. *
  85756. * This is used to decouple the dependency the scene is having on the different workloads like
  85757. * layers, post processes...
  85758. */
  85759. export interface ISceneComponent {
  85760. /**
  85761. * The name of the component. Each component must have a unique name.
  85762. */
  85763. name: string;
  85764. /**
  85765. * The scene the component belongs to.
  85766. */
  85767. scene: Scene;
  85768. /**
  85769. * Register the component to one instance of a scene.
  85770. */
  85771. register(): void;
  85772. /**
  85773. * Rebuilds the elements related to this component in case of
  85774. * context lost for instance.
  85775. */
  85776. rebuild(): void;
  85777. /**
  85778. * Disposes the component and the associated ressources.
  85779. */
  85780. dispose(): void;
  85781. }
  85782. /**
  85783. * This represents a SERIALIZABLE scene component.
  85784. *
  85785. * This extends Scene Component to add Serialization methods on top.
  85786. */
  85787. export interface ISceneSerializableComponent extends ISceneComponent {
  85788. /**
  85789. * Adds all the elements from the container to the scene
  85790. * @param container the container holding the elements
  85791. */
  85792. addFromContainer(container: AbstractScene): void;
  85793. /**
  85794. * Removes all the elements in the container from the scene
  85795. * @param container contains the elements to remove
  85796. * @param dispose if the removed element should be disposed (default: false)
  85797. */
  85798. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  85799. /**
  85800. * Serializes the component data to the specified json object
  85801. * @param serializationObject The object to serialize to
  85802. */
  85803. serialize(serializationObject: any): void;
  85804. }
  85805. /**
  85806. * Strong typing of a Mesh related stage step action
  85807. */
  85808. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  85809. /**
  85810. * Strong typing of a Evaluate Sub Mesh related stage step action
  85811. */
  85812. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  85813. /**
  85814. * Strong typing of a Active Mesh related stage step action
  85815. */
  85816. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  85817. /**
  85818. * Strong typing of a Camera related stage step action
  85819. */
  85820. export type CameraStageAction = (camera: Camera) => void;
  85821. /**
  85822. * Strong typing of a Camera Frame buffer related stage step action
  85823. */
  85824. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  85825. /**
  85826. * Strong typing of a Render Target related stage step action
  85827. */
  85828. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  85829. /**
  85830. * Strong typing of a RenderingGroup related stage step action
  85831. */
  85832. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  85833. /**
  85834. * Strong typing of a Mesh Render related stage step action
  85835. */
  85836. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  85837. /**
  85838. * Strong typing of a simple stage step action
  85839. */
  85840. export type SimpleStageAction = () => void;
  85841. /**
  85842. * Strong typing of a render target action.
  85843. */
  85844. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  85845. /**
  85846. * Strong typing of a pointer move action.
  85847. */
  85848. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  85849. /**
  85850. * Strong typing of a pointer up/down action.
  85851. */
  85852. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  85853. /**
  85854. * Representation of a stage in the scene (Basically a list of ordered steps)
  85855. * @hidden
  85856. */
  85857. export class Stage<T extends Function> extends Array<{
  85858. index: number;
  85859. component: ISceneComponent;
  85860. action: T;
  85861. }> {
  85862. /**
  85863. * Hide ctor from the rest of the world.
  85864. * @param items The items to add.
  85865. */
  85866. private constructor();
  85867. /**
  85868. * Creates a new Stage.
  85869. * @returns A new instance of a Stage
  85870. */
  85871. static Create<T extends Function>(): Stage<T>;
  85872. /**
  85873. * Registers a step in an ordered way in the targeted stage.
  85874. * @param index Defines the position to register the step in
  85875. * @param component Defines the component attached to the step
  85876. * @param action Defines the action to launch during the step
  85877. */
  85878. registerStep(index: number, component: ISceneComponent, action: T): void;
  85879. /**
  85880. * Clears all the steps from the stage.
  85881. */
  85882. clear(): void;
  85883. }
  85884. }
  85885. declare module BABYLON {
  85886. interface Scene {
  85887. /** @hidden */
  85888. _pointerOverSprite: Nullable<Sprite>;
  85889. /** @hidden */
  85890. _pickedDownSprite: Nullable<Sprite>;
  85891. /** @hidden */
  85892. _tempSpritePickingRay: Nullable<Ray>;
  85893. /**
  85894. * All of the sprite managers added to this scene
  85895. * @see http://doc.babylonjs.com/babylon101/sprites
  85896. */
  85897. spriteManagers: Array<ISpriteManager>;
  85898. /**
  85899. * An event triggered when sprites rendering is about to start
  85900. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85901. */
  85902. onBeforeSpritesRenderingObservable: Observable<Scene>;
  85903. /**
  85904. * An event triggered when sprites rendering is done
  85905. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85906. */
  85907. onAfterSpritesRenderingObservable: Observable<Scene>;
  85908. /** @hidden */
  85909. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85910. /** Launch a ray to try to pick a sprite in the scene
  85911. * @param x position on screen
  85912. * @param y position on screen
  85913. * @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
  85914. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85915. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85916. * @returns a PickingInfo
  85917. */
  85918. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85919. /** Use the given ray to pick a sprite in the scene
  85920. * @param ray The ray (in world space) to use to pick meshes
  85921. * @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
  85922. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85923. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85924. * @returns a PickingInfo
  85925. */
  85926. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85927. /** @hidden */
  85928. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85929. /** Launch a ray to try to pick sprites in the scene
  85930. * @param x position on screen
  85931. * @param y position on screen
  85932. * @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
  85933. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85934. * @returns a PickingInfo array
  85935. */
  85936. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85937. /** Use the given ray to pick sprites in the scene
  85938. * @param ray The ray (in world space) to use to pick meshes
  85939. * @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
  85940. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85941. * @returns a PickingInfo array
  85942. */
  85943. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85944. /**
  85945. * Force the sprite under the pointer
  85946. * @param sprite defines the sprite to use
  85947. */
  85948. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  85949. /**
  85950. * Gets the sprite under the pointer
  85951. * @returns a Sprite or null if no sprite is under the pointer
  85952. */
  85953. getPointerOverSprite(): Nullable<Sprite>;
  85954. }
  85955. /**
  85956. * Defines the sprite scene component responsible to manage sprites
  85957. * in a given scene.
  85958. */
  85959. export class SpriteSceneComponent implements ISceneComponent {
  85960. /**
  85961. * The component name helpfull to identify the component in the list of scene components.
  85962. */
  85963. readonly name: string;
  85964. /**
  85965. * The scene the component belongs to.
  85966. */
  85967. scene: Scene;
  85968. /** @hidden */
  85969. private _spritePredicate;
  85970. /**
  85971. * Creates a new instance of the component for the given scene
  85972. * @param scene Defines the scene to register the component in
  85973. */
  85974. constructor(scene: Scene);
  85975. /**
  85976. * Registers the component in a given scene
  85977. */
  85978. register(): void;
  85979. /**
  85980. * Rebuilds the elements related to this component in case of
  85981. * context lost for instance.
  85982. */
  85983. rebuild(): void;
  85984. /**
  85985. * Disposes the component and the associated ressources.
  85986. */
  85987. dispose(): void;
  85988. private _pickSpriteButKeepRay;
  85989. private _pointerMove;
  85990. private _pointerDown;
  85991. private _pointerUp;
  85992. }
  85993. }
  85994. declare module BABYLON {
  85995. /** @hidden */
  85996. export var fogFragmentDeclaration: {
  85997. name: string;
  85998. shader: string;
  85999. };
  86000. }
  86001. declare module BABYLON {
  86002. /** @hidden */
  86003. export var fogFragment: {
  86004. name: string;
  86005. shader: string;
  86006. };
  86007. }
  86008. declare module BABYLON {
  86009. /** @hidden */
  86010. export var spritesPixelShader: {
  86011. name: string;
  86012. shader: string;
  86013. };
  86014. }
  86015. declare module BABYLON {
  86016. /** @hidden */
  86017. export var fogVertexDeclaration: {
  86018. name: string;
  86019. shader: string;
  86020. };
  86021. }
  86022. declare module BABYLON {
  86023. /** @hidden */
  86024. export var spritesVertexShader: {
  86025. name: string;
  86026. shader: string;
  86027. };
  86028. }
  86029. declare module BABYLON {
  86030. /**
  86031. * Defines the minimum interface to fullfil in order to be a sprite manager.
  86032. */
  86033. export interface ISpriteManager extends IDisposable {
  86034. /**
  86035. * Restricts the camera to viewing objects with the same layerMask.
  86036. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  86037. */
  86038. layerMask: number;
  86039. /**
  86040. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86041. */
  86042. isPickable: boolean;
  86043. /**
  86044. * Gets the hosting scene
  86045. */
  86046. scene: Scene;
  86047. /**
  86048. * Specifies the rendering group id for this mesh (0 by default)
  86049. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86050. */
  86051. renderingGroupId: number;
  86052. /**
  86053. * Defines the list of sprites managed by the manager.
  86054. */
  86055. sprites: Array<Sprite>;
  86056. /**
  86057. * Tests the intersection of a sprite with a specific ray.
  86058. * @param ray The ray we are sending to test the collision
  86059. * @param camera The camera space we are sending rays in
  86060. * @param predicate A predicate allowing excluding sprites from the list of object to test
  86061. * @param fastCheck defines if the first intersection will be used (and not the closest)
  86062. * @returns picking info or null.
  86063. */
  86064. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  86065. /**
  86066. * Intersects the sprites with a ray
  86067. * @param ray defines the ray to intersect with
  86068. * @param camera defines the current active camera
  86069. * @param predicate defines a predicate used to select candidate sprites
  86070. * @returns null if no hit or a PickingInfo array
  86071. */
  86072. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  86073. /**
  86074. * Renders the list of sprites on screen.
  86075. */
  86076. render(): void;
  86077. }
  86078. /**
  86079. * Class used to manage multiple sprites on the same spritesheet
  86080. * @see http://doc.babylonjs.com/babylon101/sprites
  86081. */
  86082. export class SpriteManager implements ISpriteManager {
  86083. /** defines the manager's name */
  86084. name: string;
  86085. /** Gets the list of sprites */
  86086. sprites: Sprite[];
  86087. /** Gets or sets the rendering group id (0 by default) */
  86088. renderingGroupId: number;
  86089. /** Gets or sets camera layer mask */
  86090. layerMask: number;
  86091. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  86092. fogEnabled: boolean;
  86093. /** Gets or sets a boolean indicating if the sprites are pickable */
  86094. isPickable: boolean;
  86095. /** Defines the default width of a cell in the spritesheet */
  86096. cellWidth: number;
  86097. /** Defines the default height of a cell in the spritesheet */
  86098. cellHeight: number;
  86099. /** Associative array from JSON sprite data file */
  86100. private _cellData;
  86101. /** Array of sprite names from JSON sprite data file */
  86102. private _spriteMap;
  86103. /** True when packed cell data from JSON file is ready*/
  86104. private _packedAndReady;
  86105. private _textureContent;
  86106. /**
  86107. * An event triggered when the manager is disposed.
  86108. */
  86109. onDisposeObservable: Observable<SpriteManager>;
  86110. private _onDisposeObserver;
  86111. /**
  86112. * Callback called when the manager is disposed
  86113. */
  86114. set onDispose(callback: () => void);
  86115. private _capacity;
  86116. private _fromPacked;
  86117. private _spriteTexture;
  86118. private _epsilon;
  86119. private _scene;
  86120. private _vertexData;
  86121. private _buffer;
  86122. private _vertexBuffers;
  86123. private _indexBuffer;
  86124. private _effectBase;
  86125. private _effectFog;
  86126. /**
  86127. * Gets or sets the unique id of the sprite
  86128. */
  86129. uniqueId: number;
  86130. /**
  86131. * Gets the array of sprites
  86132. */
  86133. get children(): Sprite[];
  86134. /**
  86135. * Gets the hosting scene
  86136. */
  86137. get scene(): Scene;
  86138. /**
  86139. * Gets or sets the spritesheet texture
  86140. */
  86141. get texture(): Texture;
  86142. set texture(value: Texture);
  86143. private _blendMode;
  86144. /**
  86145. * Blend mode use to render the particle, it can be any of
  86146. * the static Constants.ALPHA_x properties provided in this class.
  86147. * Default value is Constants.ALPHA_COMBINE
  86148. */
  86149. get blendMode(): number;
  86150. set blendMode(blendMode: number);
  86151. /** Disables writing to the depth buffer when rendering the sprites.
  86152. * It can be handy to disable depth writing when using textures without alpha channel
  86153. * and setting some specific blend modes.
  86154. */
  86155. disableDepthWrite: boolean;
  86156. /**
  86157. * Creates a new sprite manager
  86158. * @param name defines the manager's name
  86159. * @param imgUrl defines the sprite sheet url
  86160. * @param capacity defines the maximum allowed number of sprites
  86161. * @param cellSize defines the size of a sprite cell
  86162. * @param scene defines the hosting scene
  86163. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  86164. * @param samplingMode defines the smapling mode to use with spritesheet
  86165. * @param fromPacked set to false; do not alter
  86166. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  86167. */
  86168. constructor(
  86169. /** defines the manager's name */
  86170. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  86171. /**
  86172. * Returns the string "SpriteManager"
  86173. * @returns "SpriteManager"
  86174. */
  86175. getClassName(): string;
  86176. private _makePacked;
  86177. private _appendSpriteVertex;
  86178. private _checkTextureAlpha;
  86179. /**
  86180. * Intersects the sprites with a ray
  86181. * @param ray defines the ray to intersect with
  86182. * @param camera defines the current active camera
  86183. * @param predicate defines a predicate used to select candidate sprites
  86184. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  86185. * @returns null if no hit or a PickingInfo
  86186. */
  86187. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  86188. /**
  86189. * Intersects the sprites with a ray
  86190. * @param ray defines the ray to intersect with
  86191. * @param camera defines the current active camera
  86192. * @param predicate defines a predicate used to select candidate sprites
  86193. * @returns null if no hit or a PickingInfo array
  86194. */
  86195. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  86196. /**
  86197. * Render all child sprites
  86198. */
  86199. render(): void;
  86200. /**
  86201. * Release associated resources
  86202. */
  86203. dispose(): void;
  86204. }
  86205. }
  86206. declare module BABYLON {
  86207. /** Interface used by value gradients (color, factor, ...) */
  86208. export interface IValueGradient {
  86209. /**
  86210. * Gets or sets the gradient value (between 0 and 1)
  86211. */
  86212. gradient: number;
  86213. }
  86214. /** Class used to store color4 gradient */
  86215. export class ColorGradient implements IValueGradient {
  86216. /**
  86217. * Gets or sets the gradient value (between 0 and 1)
  86218. */
  86219. gradient: number;
  86220. /**
  86221. * Gets or sets first associated color
  86222. */
  86223. color1: Color4;
  86224. /**
  86225. * Gets or sets second associated color
  86226. */
  86227. color2?: Color4 | undefined;
  86228. /**
  86229. * Creates a new color4 gradient
  86230. * @param gradient gets or sets the gradient value (between 0 and 1)
  86231. * @param color1 gets or sets first associated color
  86232. * @param color2 gets or sets first second color
  86233. */
  86234. constructor(
  86235. /**
  86236. * Gets or sets the gradient value (between 0 and 1)
  86237. */
  86238. gradient: number,
  86239. /**
  86240. * Gets or sets first associated color
  86241. */
  86242. color1: Color4,
  86243. /**
  86244. * Gets or sets second associated color
  86245. */
  86246. color2?: Color4 | undefined);
  86247. /**
  86248. * Will get a color picked randomly between color1 and color2.
  86249. * If color2 is undefined then color1 will be used
  86250. * @param result defines the target Color4 to store the result in
  86251. */
  86252. getColorToRef(result: Color4): void;
  86253. }
  86254. /** Class used to store color 3 gradient */
  86255. export class Color3Gradient implements IValueGradient {
  86256. /**
  86257. * Gets or sets the gradient value (between 0 and 1)
  86258. */
  86259. gradient: number;
  86260. /**
  86261. * Gets or sets the associated color
  86262. */
  86263. color: Color3;
  86264. /**
  86265. * Creates a new color3 gradient
  86266. * @param gradient gets or sets the gradient value (between 0 and 1)
  86267. * @param color gets or sets associated color
  86268. */
  86269. constructor(
  86270. /**
  86271. * Gets or sets the gradient value (between 0 and 1)
  86272. */
  86273. gradient: number,
  86274. /**
  86275. * Gets or sets the associated color
  86276. */
  86277. color: Color3);
  86278. }
  86279. /** Class used to store factor gradient */
  86280. export class FactorGradient implements IValueGradient {
  86281. /**
  86282. * Gets or sets the gradient value (between 0 and 1)
  86283. */
  86284. gradient: number;
  86285. /**
  86286. * Gets or sets first associated factor
  86287. */
  86288. factor1: number;
  86289. /**
  86290. * Gets or sets second associated factor
  86291. */
  86292. factor2?: number | undefined;
  86293. /**
  86294. * Creates a new factor gradient
  86295. * @param gradient gets or sets the gradient value (between 0 and 1)
  86296. * @param factor1 gets or sets first associated factor
  86297. * @param factor2 gets or sets second associated factor
  86298. */
  86299. constructor(
  86300. /**
  86301. * Gets or sets the gradient value (between 0 and 1)
  86302. */
  86303. gradient: number,
  86304. /**
  86305. * Gets or sets first associated factor
  86306. */
  86307. factor1: number,
  86308. /**
  86309. * Gets or sets second associated factor
  86310. */
  86311. factor2?: number | undefined);
  86312. /**
  86313. * Will get a number picked randomly between factor1 and factor2.
  86314. * If factor2 is undefined then factor1 will be used
  86315. * @returns the picked number
  86316. */
  86317. getFactor(): number;
  86318. }
  86319. /**
  86320. * Helper used to simplify some generic gradient tasks
  86321. */
  86322. export class GradientHelper {
  86323. /**
  86324. * Gets the current gradient from an array of IValueGradient
  86325. * @param ratio defines the current ratio to get
  86326. * @param gradients defines the array of IValueGradient
  86327. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86328. */
  86329. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86330. }
  86331. }
  86332. declare module BABYLON {
  86333. /**
  86334. * Interface for the size containing width and height
  86335. */
  86336. export interface ISize {
  86337. /**
  86338. * Width
  86339. */
  86340. width: number;
  86341. /**
  86342. * Heighht
  86343. */
  86344. height: number;
  86345. }
  86346. /**
  86347. * Size containing widht and height
  86348. */
  86349. export class Size implements ISize {
  86350. /**
  86351. * Width
  86352. */
  86353. width: number;
  86354. /**
  86355. * Height
  86356. */
  86357. height: number;
  86358. /**
  86359. * Creates a Size object from the given width and height (floats).
  86360. * @param width width of the new size
  86361. * @param height height of the new size
  86362. */
  86363. constructor(width: number, height: number);
  86364. /**
  86365. * Returns a string with the Size width and height
  86366. * @returns a string with the Size width and height
  86367. */
  86368. toString(): string;
  86369. /**
  86370. * "Size"
  86371. * @returns the string "Size"
  86372. */
  86373. getClassName(): string;
  86374. /**
  86375. * Returns the Size hash code.
  86376. * @returns a hash code for a unique width and height
  86377. */
  86378. getHashCode(): number;
  86379. /**
  86380. * Updates the current size from the given one.
  86381. * @param src the given size
  86382. */
  86383. copyFrom(src: Size): void;
  86384. /**
  86385. * Updates in place the current Size from the given floats.
  86386. * @param width width of the new size
  86387. * @param height height of the new size
  86388. * @returns the updated Size.
  86389. */
  86390. copyFromFloats(width: number, height: number): Size;
  86391. /**
  86392. * Updates in place the current Size from the given floats.
  86393. * @param width width to set
  86394. * @param height height to set
  86395. * @returns the updated Size.
  86396. */
  86397. set(width: number, height: number): Size;
  86398. /**
  86399. * Multiplies the width and height by numbers
  86400. * @param w factor to multiple the width by
  86401. * @param h factor to multiple the height by
  86402. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86403. */
  86404. multiplyByFloats(w: number, h: number): Size;
  86405. /**
  86406. * Clones the size
  86407. * @returns a new Size copied from the given one.
  86408. */
  86409. clone(): Size;
  86410. /**
  86411. * True if the current Size and the given one width and height are strictly equal.
  86412. * @param other the other size to compare against
  86413. * @returns True if the current Size and the given one width and height are strictly equal.
  86414. */
  86415. equals(other: Size): boolean;
  86416. /**
  86417. * The surface of the Size : width * height (float).
  86418. */
  86419. get surface(): number;
  86420. /**
  86421. * Create a new size of zero
  86422. * @returns a new Size set to (0.0, 0.0)
  86423. */
  86424. static Zero(): Size;
  86425. /**
  86426. * Sums the width and height of two sizes
  86427. * @param otherSize size to add to this size
  86428. * @returns a new Size set as the addition result of the current Size and the given one.
  86429. */
  86430. add(otherSize: Size): Size;
  86431. /**
  86432. * Subtracts the width and height of two
  86433. * @param otherSize size to subtract to this size
  86434. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86435. */
  86436. subtract(otherSize: Size): Size;
  86437. /**
  86438. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86439. * @param start starting size to lerp between
  86440. * @param end end size to lerp between
  86441. * @param amount amount to lerp between the start and end values
  86442. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86443. */
  86444. static Lerp(start: Size, end: Size, amount: number): Size;
  86445. }
  86446. }
  86447. declare module BABYLON {
  86448. interface ThinEngine {
  86449. /**
  86450. * Creates a dynamic texture
  86451. * @param width defines the width of the texture
  86452. * @param height defines the height of the texture
  86453. * @param generateMipMaps defines if the engine should generate the mip levels
  86454. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86455. * @returns the dynamic texture inside an InternalTexture
  86456. */
  86457. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86458. /**
  86459. * Update the content of a dynamic texture
  86460. * @param texture defines the texture to update
  86461. * @param canvas defines the canvas containing the source
  86462. * @param invertY defines if data must be stored with Y axis inverted
  86463. * @param premulAlpha defines if alpha is stored as premultiplied
  86464. * @param format defines the format of the data
  86465. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86466. */
  86467. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86468. }
  86469. }
  86470. declare module BABYLON {
  86471. /**
  86472. * Helper class used to generate a canvas to manipulate images
  86473. */
  86474. export class CanvasGenerator {
  86475. /**
  86476. * Create a new canvas (or offscreen canvas depending on the context)
  86477. * @param width defines the expected width
  86478. * @param height defines the expected height
  86479. * @return a new canvas or offscreen canvas
  86480. */
  86481. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86482. }
  86483. }
  86484. declare module BABYLON {
  86485. /**
  86486. * A class extending Texture allowing drawing on a texture
  86487. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86488. */
  86489. export class DynamicTexture extends Texture {
  86490. private _generateMipMaps;
  86491. private _canvas;
  86492. private _context;
  86493. /**
  86494. * Creates a DynamicTexture
  86495. * @param name defines the name of the texture
  86496. * @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
  86497. * @param scene defines the scene where you want the texture
  86498. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86499. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86500. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86501. */
  86502. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86503. /**
  86504. * Get the current class name of the texture useful for serialization or dynamic coding.
  86505. * @returns "DynamicTexture"
  86506. */
  86507. getClassName(): string;
  86508. /**
  86509. * Gets the current state of canRescale
  86510. */
  86511. get canRescale(): boolean;
  86512. private _recreate;
  86513. /**
  86514. * Scales the texture
  86515. * @param ratio the scale factor to apply to both width and height
  86516. */
  86517. scale(ratio: number): void;
  86518. /**
  86519. * Resizes the texture
  86520. * @param width the new width
  86521. * @param height the new height
  86522. */
  86523. scaleTo(width: number, height: number): void;
  86524. /**
  86525. * Gets the context of the canvas used by the texture
  86526. * @returns the canvas context of the dynamic texture
  86527. */
  86528. getContext(): CanvasRenderingContext2D;
  86529. /**
  86530. * Clears the texture
  86531. */
  86532. clear(): void;
  86533. /**
  86534. * Updates the texture
  86535. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86536. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  86537. */
  86538. update(invertY?: boolean, premulAlpha?: boolean): void;
  86539. /**
  86540. * Draws text onto the texture
  86541. * @param text defines the text to be drawn
  86542. * @param x defines the placement of the text from the left
  86543. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  86544. * @param font defines the font to be used with font-style, font-size, font-name
  86545. * @param color defines the color used for the text
  86546. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  86547. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86548. * @param update defines whether texture is immediately update (default is true)
  86549. */
  86550. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  86551. /**
  86552. * Clones the texture
  86553. * @returns the clone of the texture.
  86554. */
  86555. clone(): DynamicTexture;
  86556. /**
  86557. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  86558. * @returns a serialized dynamic texture object
  86559. */
  86560. serialize(): any;
  86561. /** @hidden */
  86562. _rebuild(): void;
  86563. }
  86564. }
  86565. declare module BABYLON {
  86566. interface ThinEngine {
  86567. /**
  86568. * Creates a raw texture
  86569. * @param data defines the data to store in the texture
  86570. * @param width defines the width of the texture
  86571. * @param height defines the height of the texture
  86572. * @param format defines the format of the data
  86573. * @param generateMipMaps defines if the engine should generate the mip levels
  86574. * @param invertY defines if data must be stored with Y axis inverted
  86575. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86576. * @param compression defines the compression used (null by default)
  86577. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86578. * @returns the raw texture inside an InternalTexture
  86579. */
  86580. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  86581. /**
  86582. * Update a raw texture
  86583. * @param texture defines the texture to update
  86584. * @param data defines the data to store in the texture
  86585. * @param format defines the format of the data
  86586. * @param invertY defines if data must be stored with Y axis inverted
  86587. */
  86588. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86589. /**
  86590. * Update a raw texture
  86591. * @param texture defines the texture to update
  86592. * @param data defines the data to store in the texture
  86593. * @param format defines the format of the data
  86594. * @param invertY defines if data must be stored with Y axis inverted
  86595. * @param compression defines the compression used (null by default)
  86596. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86597. */
  86598. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  86599. /**
  86600. * Creates a new raw cube texture
  86601. * @param data defines the array of data to use to create each face
  86602. * @param size defines the size of the textures
  86603. * @param format defines the format of the data
  86604. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86605. * @param generateMipMaps defines if the engine should generate the mip levels
  86606. * @param invertY defines if data must be stored with Y axis inverted
  86607. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86608. * @param compression defines the compression used (null by default)
  86609. * @returns the cube texture as an InternalTexture
  86610. */
  86611. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  86612. /**
  86613. * Update a raw cube texture
  86614. * @param texture defines the texture to udpdate
  86615. * @param data defines the data to store
  86616. * @param format defines the data format
  86617. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86618. * @param invertY defines if data must be stored with Y axis inverted
  86619. */
  86620. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  86621. /**
  86622. * Update a raw cube texture
  86623. * @param texture defines the texture to udpdate
  86624. * @param data defines the data to store
  86625. * @param format defines the data format
  86626. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86627. * @param invertY defines if data must be stored with Y axis inverted
  86628. * @param compression defines the compression used (null by default)
  86629. */
  86630. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  86631. /**
  86632. * Update a raw cube texture
  86633. * @param texture defines the texture to udpdate
  86634. * @param data defines the data to store
  86635. * @param format defines the data format
  86636. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86637. * @param invertY defines if data must be stored with Y axis inverted
  86638. * @param compression defines the compression used (null by default)
  86639. * @param level defines which level of the texture to update
  86640. */
  86641. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  86642. /**
  86643. * Creates a new raw cube texture from a specified url
  86644. * @param url defines the url where the data is located
  86645. * @param scene defines the current scene
  86646. * @param size defines the size of the textures
  86647. * @param format defines the format of the data
  86648. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86649. * @param noMipmap defines if the engine should avoid generating the mip levels
  86650. * @param callback defines a callback used to extract texture data from loaded data
  86651. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86652. * @param onLoad defines a callback called when texture is loaded
  86653. * @param onError defines a callback called if there is an error
  86654. * @returns the cube texture as an InternalTexture
  86655. */
  86656. 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;
  86657. /**
  86658. * Creates a new raw cube texture from a specified url
  86659. * @param url defines the url where the data is located
  86660. * @param scene defines the current scene
  86661. * @param size defines the size of the textures
  86662. * @param format defines the format of the data
  86663. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86664. * @param noMipmap defines if the engine should avoid generating the mip levels
  86665. * @param callback defines a callback used to extract texture data from loaded data
  86666. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86667. * @param onLoad defines a callback called when texture is loaded
  86668. * @param onError defines a callback called if there is an error
  86669. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86670. * @param invertY defines if data must be stored with Y axis inverted
  86671. * @returns the cube texture as an InternalTexture
  86672. */
  86673. 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;
  86674. /**
  86675. * Creates a new raw 3D texture
  86676. * @param data defines the data used to create the texture
  86677. * @param width defines the width of the texture
  86678. * @param height defines the height of the texture
  86679. * @param depth defines the depth of the texture
  86680. * @param format defines the format of the texture
  86681. * @param generateMipMaps defines if the engine must generate mip levels
  86682. * @param invertY defines if data must be stored with Y axis inverted
  86683. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86684. * @param compression defines the compressed used (can be null)
  86685. * @param textureType defines the compressed used (can be null)
  86686. * @returns a new raw 3D texture (stored in an InternalTexture)
  86687. */
  86688. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86689. /**
  86690. * Update a raw 3D texture
  86691. * @param texture defines the texture to update
  86692. * @param data defines the data to store
  86693. * @param format defines the data format
  86694. * @param invertY defines if data must be stored with Y axis inverted
  86695. */
  86696. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86697. /**
  86698. * Update a raw 3D texture
  86699. * @param texture defines the texture to update
  86700. * @param data defines the data to store
  86701. * @param format defines the data format
  86702. * @param invertY defines if data must be stored with Y axis inverted
  86703. * @param compression defines the used compression (can be null)
  86704. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86705. */
  86706. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86707. /**
  86708. * Creates a new raw 2D array texture
  86709. * @param data defines the data used to create the texture
  86710. * @param width defines the width of the texture
  86711. * @param height defines the height of the texture
  86712. * @param depth defines the number of layers of the texture
  86713. * @param format defines the format of the texture
  86714. * @param generateMipMaps defines if the engine must generate mip levels
  86715. * @param invertY defines if data must be stored with Y axis inverted
  86716. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86717. * @param compression defines the compressed used (can be null)
  86718. * @param textureType defines the compressed used (can be null)
  86719. * @returns a new raw 2D array texture (stored in an InternalTexture)
  86720. */
  86721. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86722. /**
  86723. * Update a raw 2D array texture
  86724. * @param texture defines the texture to update
  86725. * @param data defines the data to store
  86726. * @param format defines the data format
  86727. * @param invertY defines if data must be stored with Y axis inverted
  86728. */
  86729. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86730. /**
  86731. * Update a raw 2D array texture
  86732. * @param texture defines the texture to update
  86733. * @param data defines the data to store
  86734. * @param format defines the data format
  86735. * @param invertY defines if data must be stored with Y axis inverted
  86736. * @param compression defines the used compression (can be null)
  86737. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86738. */
  86739. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86740. }
  86741. }
  86742. declare module BABYLON {
  86743. /**
  86744. * Raw texture can help creating a texture directly from an array of data.
  86745. * This can be super useful if you either get the data from an uncompressed source or
  86746. * if you wish to create your texture pixel by pixel.
  86747. */
  86748. export class RawTexture extends Texture {
  86749. /**
  86750. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86751. */
  86752. format: number;
  86753. /**
  86754. * Instantiates a new RawTexture.
  86755. * Raw texture can help creating a texture directly from an array of data.
  86756. * This can be super useful if you either get the data from an uncompressed source or
  86757. * if you wish to create your texture pixel by pixel.
  86758. * @param data define the array of data to use to create the texture
  86759. * @param width define the width of the texture
  86760. * @param height define the height of the texture
  86761. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86762. * @param scene define the scene the texture belongs to
  86763. * @param generateMipMaps define whether mip maps should be generated or not
  86764. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86765. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86766. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86767. */
  86768. constructor(data: ArrayBufferView, width: number, height: number,
  86769. /**
  86770. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86771. */
  86772. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  86773. /**
  86774. * Updates the texture underlying data.
  86775. * @param data Define the new data of the texture
  86776. */
  86777. update(data: ArrayBufferView): void;
  86778. /**
  86779. * Creates a luminance texture from some data.
  86780. * @param data Define the texture data
  86781. * @param width Define the width of the texture
  86782. * @param height Define the height of the texture
  86783. * @param scene Define the scene the texture belongs to
  86784. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86787. * @returns the luminance texture
  86788. */
  86789. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86790. /**
  86791. * Creates a luminance alpha texture from some data.
  86792. * @param data Define the texture data
  86793. * @param width Define the width of the texture
  86794. * @param height Define the height of the texture
  86795. * @param scene Define the scene the texture belongs to
  86796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86799. * @returns the luminance alpha texture
  86800. */
  86801. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86802. /**
  86803. * Creates an alpha texture from some data.
  86804. * @param data Define the texture data
  86805. * @param width Define the width of the texture
  86806. * @param height Define the height of the texture
  86807. * @param scene Define the scene the texture belongs to
  86808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86811. * @returns the alpha texture
  86812. */
  86813. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86814. /**
  86815. * Creates a RGB texture from some data.
  86816. * @param data Define the texture data
  86817. * @param width Define the width of the texture
  86818. * @param height Define the height of the texture
  86819. * @param scene Define the scene the texture belongs to
  86820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86823. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86824. * @returns the RGB alpha texture
  86825. */
  86826. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86827. /**
  86828. * Creates a RGBA texture from some data.
  86829. * @param data Define the texture data
  86830. * @param width Define the width of the texture
  86831. * @param height Define the height of the texture
  86832. * @param scene Define the scene the texture belongs to
  86833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86836. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86837. * @returns the RGBA texture
  86838. */
  86839. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86840. /**
  86841. * Creates a R texture from some data.
  86842. * @param data Define the texture data
  86843. * @param width Define the width of the texture
  86844. * @param height Define the height of the texture
  86845. * @param scene Define the scene the texture belongs to
  86846. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86847. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86848. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86849. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86850. * @returns the R texture
  86851. */
  86852. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86853. }
  86854. }
  86855. declare module BABYLON {
  86856. interface AbstractScene {
  86857. /**
  86858. * The list of procedural textures added to the scene
  86859. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86860. */
  86861. proceduralTextures: Array<ProceduralTexture>;
  86862. }
  86863. /**
  86864. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  86865. * in a given scene.
  86866. */
  86867. export class ProceduralTextureSceneComponent implements ISceneComponent {
  86868. /**
  86869. * The component name helpfull to identify the component in the list of scene components.
  86870. */
  86871. readonly name: string;
  86872. /**
  86873. * The scene the component belongs to.
  86874. */
  86875. scene: Scene;
  86876. /**
  86877. * Creates a new instance of the component for the given scene
  86878. * @param scene Defines the scene to register the component in
  86879. */
  86880. constructor(scene: Scene);
  86881. /**
  86882. * Registers the component in a given scene
  86883. */
  86884. register(): void;
  86885. /**
  86886. * Rebuilds the elements related to this component in case of
  86887. * context lost for instance.
  86888. */
  86889. rebuild(): void;
  86890. /**
  86891. * Disposes the component and the associated ressources.
  86892. */
  86893. dispose(): void;
  86894. private _beforeClear;
  86895. }
  86896. }
  86897. declare module BABYLON {
  86898. interface ThinEngine {
  86899. /**
  86900. * Creates a new render target cube texture
  86901. * @param size defines the size of the texture
  86902. * @param options defines the options used to create the texture
  86903. * @returns a new render target cube texture stored in an InternalTexture
  86904. */
  86905. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86906. }
  86907. }
  86908. declare module BABYLON {
  86909. /** @hidden */
  86910. export var proceduralVertexShader: {
  86911. name: string;
  86912. shader: string;
  86913. };
  86914. }
  86915. declare module BABYLON {
  86916. /**
  86917. * 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.
  86918. * This is the base class of any Procedural texture and contains most of the shareable code.
  86919. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86920. */
  86921. export class ProceduralTexture extends Texture {
  86922. isCube: boolean;
  86923. /**
  86924. * Define if the texture is enabled or not (disabled texture will not render)
  86925. */
  86926. isEnabled: boolean;
  86927. /**
  86928. * Define if the texture must be cleared before rendering (default is true)
  86929. */
  86930. autoClear: boolean;
  86931. /**
  86932. * Callback called when the texture is generated
  86933. */
  86934. onGenerated: () => void;
  86935. /**
  86936. * Event raised when the texture is generated
  86937. */
  86938. onGeneratedObservable: Observable<ProceduralTexture>;
  86939. /** @hidden */
  86940. _generateMipMaps: boolean;
  86941. /** @hidden **/
  86942. _effect: Effect;
  86943. /** @hidden */
  86944. _textures: {
  86945. [key: string]: Texture;
  86946. };
  86947. /** @hidden */
  86948. protected _fallbackTexture: Nullable<Texture>;
  86949. private _size;
  86950. private _currentRefreshId;
  86951. private _frameId;
  86952. private _refreshRate;
  86953. private _vertexBuffers;
  86954. private _indexBuffer;
  86955. private _uniforms;
  86956. private _samplers;
  86957. private _fragment;
  86958. private _floats;
  86959. private _ints;
  86960. private _floatsArrays;
  86961. private _colors3;
  86962. private _colors4;
  86963. private _vectors2;
  86964. private _vectors3;
  86965. private _matrices;
  86966. private _fallbackTextureUsed;
  86967. private _fullEngine;
  86968. private _cachedDefines;
  86969. private _contentUpdateId;
  86970. private _contentData;
  86971. /**
  86972. * Instantiates a new procedural texture.
  86973. * 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.
  86974. * This is the base class of any Procedural texture and contains most of the shareable code.
  86975. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86976. * @param name Define the name of the texture
  86977. * @param size Define the size of the texture to create
  86978. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  86979. * @param scene Define the scene the texture belongs to
  86980. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  86981. * @param generateMipMaps Define if the texture should creates mip maps or not
  86982. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  86983. */
  86984. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  86985. /**
  86986. * The effect that is created when initializing the post process.
  86987. * @returns The created effect corresponding the the postprocess.
  86988. */
  86989. getEffect(): Effect;
  86990. /**
  86991. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  86992. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  86993. */
  86994. getContent(): Nullable<ArrayBufferView>;
  86995. private _createIndexBuffer;
  86996. /** @hidden */
  86997. _rebuild(): void;
  86998. /**
  86999. * Resets the texture in order to recreate its associated resources.
  87000. * This can be called in case of context loss
  87001. */
  87002. reset(): void;
  87003. protected _getDefines(): string;
  87004. /**
  87005. * Is the texture ready to be used ? (rendered at least once)
  87006. * @returns true if ready, otherwise, false.
  87007. */
  87008. isReady(): boolean;
  87009. /**
  87010. * Resets the refresh counter of the texture and start bak from scratch.
  87011. * Could be useful to regenerate the texture if it is setup to render only once.
  87012. */
  87013. resetRefreshCounter(): void;
  87014. /**
  87015. * Set the fragment shader to use in order to render the texture.
  87016. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87017. */
  87018. setFragment(fragment: any): void;
  87019. /**
  87020. * Define the refresh rate of the texture or the rendering frequency.
  87021. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87022. */
  87023. get refreshRate(): number;
  87024. set refreshRate(value: number);
  87025. /** @hidden */
  87026. _shouldRender(): boolean;
  87027. /**
  87028. * Get the size the texture is rendering at.
  87029. * @returns the size (texture is always squared)
  87030. */
  87031. getRenderSize(): number;
  87032. /**
  87033. * Resize the texture to new value.
  87034. * @param size Define the new size the texture should have
  87035. * @param generateMipMaps Define whether the new texture should create mip maps
  87036. */
  87037. resize(size: number, generateMipMaps: boolean): void;
  87038. private _checkUniform;
  87039. /**
  87040. * Set a texture in the shader program used to render.
  87041. * @param name Define the name of the uniform samplers as defined in the shader
  87042. * @param texture Define the texture to bind to this sampler
  87043. * @return the texture itself allowing "fluent" like uniform updates
  87044. */
  87045. setTexture(name: string, texture: Texture): ProceduralTexture;
  87046. /**
  87047. * Set a float in the shader.
  87048. * @param name Define the name of the uniform as defined in the shader
  87049. * @param value Define the value to give to the uniform
  87050. * @return the texture itself allowing "fluent" like uniform updates
  87051. */
  87052. setFloat(name: string, value: number): ProceduralTexture;
  87053. /**
  87054. * Set a int in the shader.
  87055. * @param name Define the name of the uniform as defined in the shader
  87056. * @param value Define the value to give to the uniform
  87057. * @return the texture itself allowing "fluent" like uniform updates
  87058. */
  87059. setInt(name: string, value: number): ProceduralTexture;
  87060. /**
  87061. * Set an array of floats in the shader.
  87062. * @param name Define the name of the uniform as defined in the shader
  87063. * @param value Define the value to give to the uniform
  87064. * @return the texture itself allowing "fluent" like uniform updates
  87065. */
  87066. setFloats(name: string, value: number[]): ProceduralTexture;
  87067. /**
  87068. * Set a vec3 in the shader from a Color3.
  87069. * @param name Define the name of the uniform as defined in the shader
  87070. * @param value Define the value to give to the uniform
  87071. * @return the texture itself allowing "fluent" like uniform updates
  87072. */
  87073. setColor3(name: string, value: Color3): ProceduralTexture;
  87074. /**
  87075. * Set a vec4 in the shader from a Color4.
  87076. * @param name Define the name of the uniform as defined in the shader
  87077. * @param value Define the value to give to the uniform
  87078. * @return the texture itself allowing "fluent" like uniform updates
  87079. */
  87080. setColor4(name: string, value: Color4): ProceduralTexture;
  87081. /**
  87082. * Set a vec2 in the shader from a Vector2.
  87083. * @param name Define the name of the uniform as defined in the shader
  87084. * @param value Define the value to give to the uniform
  87085. * @return the texture itself allowing "fluent" like uniform updates
  87086. */
  87087. setVector2(name: string, value: Vector2): ProceduralTexture;
  87088. /**
  87089. * Set a vec3 in the shader from a Vector3.
  87090. * @param name Define the name of the uniform as defined in the shader
  87091. * @param value Define the value to give to the uniform
  87092. * @return the texture itself allowing "fluent" like uniform updates
  87093. */
  87094. setVector3(name: string, value: Vector3): ProceduralTexture;
  87095. /**
  87096. * Set a mat4 in the shader from a MAtrix.
  87097. * @param name Define the name of the uniform as defined in the shader
  87098. * @param value Define the value to give to the uniform
  87099. * @return the texture itself allowing "fluent" like uniform updates
  87100. */
  87101. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87102. /**
  87103. * Render the texture to its associated render target.
  87104. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87105. */
  87106. render(useCameraPostProcess?: boolean): void;
  87107. /**
  87108. * Clone the texture.
  87109. * @returns the cloned texture
  87110. */
  87111. clone(): ProceduralTexture;
  87112. /**
  87113. * Dispose the texture and release its asoociated resources.
  87114. */
  87115. dispose(): void;
  87116. }
  87117. }
  87118. declare module BABYLON {
  87119. /**
  87120. * This represents the base class for particle system in Babylon.
  87121. * 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.
  87122. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87123. * @example https://doc.babylonjs.com/babylon101/particles
  87124. */
  87125. export class BaseParticleSystem {
  87126. /**
  87127. * Source color is added to the destination color without alpha affecting the result
  87128. */
  87129. static BLENDMODE_ONEONE: number;
  87130. /**
  87131. * Blend current color and particle color using particle’s alpha
  87132. */
  87133. static BLENDMODE_STANDARD: number;
  87134. /**
  87135. * Add current color and particle color multiplied by particle’s alpha
  87136. */
  87137. static BLENDMODE_ADD: number;
  87138. /**
  87139. * Multiply current color with particle color
  87140. */
  87141. static BLENDMODE_MULTIPLY: number;
  87142. /**
  87143. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87144. */
  87145. static BLENDMODE_MULTIPLYADD: number;
  87146. /**
  87147. * List of animations used by the particle system.
  87148. */
  87149. animations: Animation[];
  87150. /**
  87151. * Gets or sets the unique id of the particle system
  87152. */
  87153. uniqueId: number;
  87154. /**
  87155. * The id of the Particle system.
  87156. */
  87157. id: string;
  87158. /**
  87159. * The friendly name of the Particle system.
  87160. */
  87161. name: string;
  87162. /**
  87163. * Snippet ID if the particle system was created from the snippet server
  87164. */
  87165. snippetId: string;
  87166. /**
  87167. * The rendering group used by the Particle system to chose when to render.
  87168. */
  87169. renderingGroupId: number;
  87170. /**
  87171. * The emitter represents the Mesh or position we are attaching the particle system to.
  87172. */
  87173. emitter: Nullable<AbstractMesh | Vector3>;
  87174. /**
  87175. * The maximum number of particles to emit per frame
  87176. */
  87177. emitRate: number;
  87178. /**
  87179. * If you want to launch only a few particles at once, that can be done, as well.
  87180. */
  87181. manualEmitCount: number;
  87182. /**
  87183. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87184. */
  87185. updateSpeed: number;
  87186. /**
  87187. * The amount of time the particle system is running (depends of the overall update speed).
  87188. */
  87189. targetStopDuration: number;
  87190. /**
  87191. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87192. */
  87193. disposeOnStop: boolean;
  87194. /**
  87195. * Minimum power of emitting particles.
  87196. */
  87197. minEmitPower: number;
  87198. /**
  87199. * Maximum power of emitting particles.
  87200. */
  87201. maxEmitPower: number;
  87202. /**
  87203. * Minimum life time of emitting particles.
  87204. */
  87205. minLifeTime: number;
  87206. /**
  87207. * Maximum life time of emitting particles.
  87208. */
  87209. maxLifeTime: number;
  87210. /**
  87211. * Minimum Size of emitting particles.
  87212. */
  87213. minSize: number;
  87214. /**
  87215. * Maximum Size of emitting particles.
  87216. */
  87217. maxSize: number;
  87218. /**
  87219. * Minimum scale of emitting particles on X axis.
  87220. */
  87221. minScaleX: number;
  87222. /**
  87223. * Maximum scale of emitting particles on X axis.
  87224. */
  87225. maxScaleX: number;
  87226. /**
  87227. * Minimum scale of emitting particles on Y axis.
  87228. */
  87229. minScaleY: number;
  87230. /**
  87231. * Maximum scale of emitting particles on Y axis.
  87232. */
  87233. maxScaleY: number;
  87234. /**
  87235. * Gets or sets the minimal initial rotation in radians.
  87236. */
  87237. minInitialRotation: number;
  87238. /**
  87239. * Gets or sets the maximal initial rotation in radians.
  87240. */
  87241. maxInitialRotation: number;
  87242. /**
  87243. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87244. */
  87245. minAngularSpeed: number;
  87246. /**
  87247. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87248. */
  87249. maxAngularSpeed: number;
  87250. /**
  87251. * The texture used to render each particle. (this can be a spritesheet)
  87252. */
  87253. particleTexture: Nullable<Texture>;
  87254. /**
  87255. * The layer mask we are rendering the particles through.
  87256. */
  87257. layerMask: number;
  87258. /**
  87259. * This can help using your own shader to render the particle system.
  87260. * The according effect will be created
  87261. */
  87262. customShader: any;
  87263. /**
  87264. * By default particle system starts as soon as they are created. This prevents the
  87265. * automatic start to happen and let you decide when to start emitting particles.
  87266. */
  87267. preventAutoStart: boolean;
  87268. private _noiseTexture;
  87269. /**
  87270. * Gets or sets a texture used to add random noise to particle positions
  87271. */
  87272. get noiseTexture(): Nullable<ProceduralTexture>;
  87273. set noiseTexture(value: Nullable<ProceduralTexture>);
  87274. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87275. noiseStrength: Vector3;
  87276. /**
  87277. * Callback triggered when the particle animation is ending.
  87278. */
  87279. onAnimationEnd: Nullable<() => void>;
  87280. /**
  87281. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87282. */
  87283. blendMode: number;
  87284. /**
  87285. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87286. * to override the particles.
  87287. */
  87288. forceDepthWrite: boolean;
  87289. /** 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 */
  87290. preWarmCycles: number;
  87291. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87292. preWarmStepOffset: number;
  87293. /**
  87294. * 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)
  87295. */
  87296. spriteCellChangeSpeed: number;
  87297. /**
  87298. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87299. */
  87300. startSpriteCellID: number;
  87301. /**
  87302. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87303. */
  87304. endSpriteCellID: number;
  87305. /**
  87306. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87307. */
  87308. spriteCellWidth: number;
  87309. /**
  87310. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87311. */
  87312. spriteCellHeight: number;
  87313. /**
  87314. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87315. */
  87316. spriteRandomStartCell: boolean;
  87317. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87318. translationPivot: Vector2;
  87319. /** @hidden */
  87320. protected _isAnimationSheetEnabled: boolean;
  87321. /**
  87322. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87323. */
  87324. beginAnimationOnStart: boolean;
  87325. /**
  87326. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87327. */
  87328. beginAnimationFrom: number;
  87329. /**
  87330. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87331. */
  87332. beginAnimationTo: number;
  87333. /**
  87334. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87335. */
  87336. beginAnimationLoop: boolean;
  87337. /**
  87338. * Gets or sets a world offset applied to all particles
  87339. */
  87340. worldOffset: Vector3;
  87341. /**
  87342. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87343. */
  87344. get isAnimationSheetEnabled(): boolean;
  87345. set isAnimationSheetEnabled(value: boolean);
  87346. /**
  87347. * Get hosting scene
  87348. * @returns the scene
  87349. */
  87350. getScene(): Scene;
  87351. /**
  87352. * You can use gravity if you want to give an orientation to your particles.
  87353. */
  87354. gravity: Vector3;
  87355. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87356. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87357. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87358. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87359. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87360. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87361. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87362. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87363. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87364. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87365. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87366. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87367. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87368. /**
  87369. * Defines the delay in milliseconds before starting the system (0 by default)
  87370. */
  87371. startDelay: number;
  87372. /**
  87373. * Gets the current list of drag gradients.
  87374. * You must use addDragGradient and removeDragGradient to udpate this list
  87375. * @returns the list of drag gradients
  87376. */
  87377. getDragGradients(): Nullable<Array<FactorGradient>>;
  87378. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87379. limitVelocityDamping: number;
  87380. /**
  87381. * Gets the current list of limit velocity gradients.
  87382. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87383. * @returns the list of limit velocity gradients
  87384. */
  87385. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87386. /**
  87387. * Gets the current list of color gradients.
  87388. * You must use addColorGradient and removeColorGradient to udpate this list
  87389. * @returns the list of color gradients
  87390. */
  87391. getColorGradients(): Nullable<Array<ColorGradient>>;
  87392. /**
  87393. * Gets the current list of size gradients.
  87394. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87395. * @returns the list of size gradients
  87396. */
  87397. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87398. /**
  87399. * Gets the current list of color remap gradients.
  87400. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87401. * @returns the list of color remap gradients
  87402. */
  87403. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87404. /**
  87405. * Gets the current list of alpha remap gradients.
  87406. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87407. * @returns the list of alpha remap gradients
  87408. */
  87409. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87410. /**
  87411. * Gets the current list of life time gradients.
  87412. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87413. * @returns the list of life time gradients
  87414. */
  87415. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87416. /**
  87417. * Gets the current list of angular speed gradients.
  87418. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87419. * @returns the list of angular speed gradients
  87420. */
  87421. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87422. /**
  87423. * Gets the current list of velocity gradients.
  87424. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87425. * @returns the list of velocity gradients
  87426. */
  87427. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87428. /**
  87429. * Gets the current list of start size gradients.
  87430. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87431. * @returns the list of start size gradients
  87432. */
  87433. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87434. /**
  87435. * Gets the current list of emit rate gradients.
  87436. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87437. * @returns the list of emit rate gradients
  87438. */
  87439. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87440. /**
  87441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87442. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87443. */
  87444. get direction1(): Vector3;
  87445. set direction1(value: Vector3);
  87446. /**
  87447. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87448. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87449. */
  87450. get direction2(): Vector3;
  87451. set direction2(value: Vector3);
  87452. /**
  87453. * 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.
  87454. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87455. */
  87456. get minEmitBox(): Vector3;
  87457. set minEmitBox(value: Vector3);
  87458. /**
  87459. * 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.
  87460. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87461. */
  87462. get maxEmitBox(): Vector3;
  87463. set maxEmitBox(value: Vector3);
  87464. /**
  87465. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87466. */
  87467. color1: Color4;
  87468. /**
  87469. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87470. */
  87471. color2: Color4;
  87472. /**
  87473. * Color the particle will have at the end of its lifetime
  87474. */
  87475. colorDead: Color4;
  87476. /**
  87477. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87478. */
  87479. textureMask: Color4;
  87480. /**
  87481. * The particle emitter type defines the emitter used by the particle system.
  87482. * It can be for example box, sphere, or cone...
  87483. */
  87484. particleEmitterType: IParticleEmitterType;
  87485. /** @hidden */
  87486. _isSubEmitter: boolean;
  87487. /**
  87488. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87489. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87490. */
  87491. billboardMode: number;
  87492. protected _isBillboardBased: boolean;
  87493. /**
  87494. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87495. */
  87496. get isBillboardBased(): boolean;
  87497. set isBillboardBased(value: boolean);
  87498. /**
  87499. * The scene the particle system belongs to.
  87500. */
  87501. protected _scene: Scene;
  87502. /**
  87503. * Local cache of defines for image processing.
  87504. */
  87505. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87506. /**
  87507. * Default configuration related to image processing available in the standard Material.
  87508. */
  87509. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87510. /**
  87511. * Gets the image processing configuration used either in this material.
  87512. */
  87513. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87514. /**
  87515. * Sets the Default image processing configuration used either in the this material.
  87516. *
  87517. * If sets to null, the scene one is in use.
  87518. */
  87519. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87520. /**
  87521. * Attaches a new image processing configuration to the Standard Material.
  87522. * @param configuration
  87523. */
  87524. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87525. /** @hidden */
  87526. protected _reset(): void;
  87527. /** @hidden */
  87528. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87529. /**
  87530. * Instantiates a particle system.
  87531. * 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.
  87532. * @param name The name of the particle system
  87533. */
  87534. constructor(name: string);
  87535. /**
  87536. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87537. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87538. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87539. * @returns the emitter
  87540. */
  87541. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87542. /**
  87543. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87544. * @param radius The radius of the hemisphere to emit from
  87545. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87546. * @returns the emitter
  87547. */
  87548. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87549. /**
  87550. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87551. * @param radius The radius of the sphere to emit from
  87552. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87553. * @returns the emitter
  87554. */
  87555. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87556. /**
  87557. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87558. * @param radius The radius of the sphere to emit from
  87559. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87560. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87561. * @returns the emitter
  87562. */
  87563. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87564. /**
  87565. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87566. * @param radius The radius of the emission cylinder
  87567. * @param height The height of the emission cylinder
  87568. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87569. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87570. * @returns the emitter
  87571. */
  87572. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87573. /**
  87574. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87575. * @param radius The radius of the cylinder to emit from
  87576. * @param height The height of the emission cylinder
  87577. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87580. * @returns the emitter
  87581. */
  87582. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87583. /**
  87584. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87585. * @param radius The radius of the cone to emit from
  87586. * @param angle The base angle of the cone
  87587. * @returns the emitter
  87588. */
  87589. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87590. /**
  87591. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  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. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87595. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87596. * @returns the emitter
  87597. */
  87598. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87599. }
  87600. }
  87601. declare module BABYLON {
  87602. /**
  87603. * Type of sub emitter
  87604. */
  87605. export enum SubEmitterType {
  87606. /**
  87607. * Attached to the particle over it's lifetime
  87608. */
  87609. ATTACHED = 0,
  87610. /**
  87611. * Created when the particle dies
  87612. */
  87613. END = 1
  87614. }
  87615. /**
  87616. * Sub emitter class used to emit particles from an existing particle
  87617. */
  87618. export class SubEmitter {
  87619. /**
  87620. * the particle system to be used by the sub emitter
  87621. */
  87622. particleSystem: ParticleSystem;
  87623. /**
  87624. * Type of the submitter (Default: END)
  87625. */
  87626. type: SubEmitterType;
  87627. /**
  87628. * 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)
  87629. * Note: This only is supported when using an emitter of type Mesh
  87630. */
  87631. inheritDirection: boolean;
  87632. /**
  87633. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87634. */
  87635. inheritedVelocityAmount: number;
  87636. /**
  87637. * Creates a sub emitter
  87638. * @param particleSystem the particle system to be used by the sub emitter
  87639. */
  87640. constructor(
  87641. /**
  87642. * the particle system to be used by the sub emitter
  87643. */
  87644. particleSystem: ParticleSystem);
  87645. /**
  87646. * Clones the sub emitter
  87647. * @returns the cloned sub emitter
  87648. */
  87649. clone(): SubEmitter;
  87650. /**
  87651. * Serialize current object to a JSON object
  87652. * @returns the serialized object
  87653. */
  87654. serialize(): any;
  87655. /** @hidden */
  87656. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87657. /**
  87658. * Creates a new SubEmitter from a serialized JSON version
  87659. * @param serializationObject defines the JSON object to read from
  87660. * @param scene defines the hosting scene
  87661. * @param rootUrl defines the rootUrl for data loading
  87662. * @returns a new SubEmitter
  87663. */
  87664. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87665. /** Release associated resources */
  87666. dispose(): void;
  87667. }
  87668. }
  87669. declare module BABYLON {
  87670. /** @hidden */
  87671. export var imageProcessingDeclaration: {
  87672. name: string;
  87673. shader: string;
  87674. };
  87675. }
  87676. declare module BABYLON {
  87677. /** @hidden */
  87678. export var imageProcessingFunctions: {
  87679. name: string;
  87680. shader: string;
  87681. };
  87682. }
  87683. declare module BABYLON {
  87684. /** @hidden */
  87685. export var particlesPixelShader: {
  87686. name: string;
  87687. shader: string;
  87688. };
  87689. }
  87690. declare module BABYLON {
  87691. /** @hidden */
  87692. export var particlesVertexShader: {
  87693. name: string;
  87694. shader: string;
  87695. };
  87696. }
  87697. declare module BABYLON {
  87698. /**
  87699. * This represents a particle system in Babylon.
  87700. * 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.
  87701. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87702. * @example https://doc.babylonjs.com/babylon101/particles
  87703. */
  87704. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87705. /**
  87706. * Billboard mode will only apply to Y axis
  87707. */
  87708. static readonly BILLBOARDMODE_Y: number;
  87709. /**
  87710. * Billboard mode will apply to all axes
  87711. */
  87712. static readonly BILLBOARDMODE_ALL: number;
  87713. /**
  87714. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87715. */
  87716. static readonly BILLBOARDMODE_STRETCHED: number;
  87717. /**
  87718. * This function can be defined to provide custom update for active particles.
  87719. * This function will be called instead of regular update (age, position, color, etc.).
  87720. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87721. */
  87722. updateFunction: (particles: Particle[]) => void;
  87723. private _emitterWorldMatrix;
  87724. /**
  87725. * This function can be defined to specify initial direction for every new particle.
  87726. * It by default use the emitterType defined function
  87727. */
  87728. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87729. /**
  87730. * This function can be defined to specify initial position for every new particle.
  87731. * It by default use the emitterType defined function
  87732. */
  87733. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87734. /**
  87735. * @hidden
  87736. */
  87737. _inheritedVelocityOffset: Vector3;
  87738. /**
  87739. * An event triggered when the system is disposed
  87740. */
  87741. onDisposeObservable: Observable<ParticleSystem>;
  87742. private _onDisposeObserver;
  87743. /**
  87744. * Sets a callback that will be triggered when the system is disposed
  87745. */
  87746. set onDispose(callback: () => void);
  87747. private _particles;
  87748. private _epsilon;
  87749. private _capacity;
  87750. private _stockParticles;
  87751. private _newPartsExcess;
  87752. private _vertexData;
  87753. private _vertexBuffer;
  87754. private _vertexBuffers;
  87755. private _spriteBuffer;
  87756. private _indexBuffer;
  87757. private _effect;
  87758. private _customEffect;
  87759. private _cachedDefines;
  87760. private _scaledColorStep;
  87761. private _colorDiff;
  87762. private _scaledDirection;
  87763. private _scaledGravity;
  87764. private _currentRenderId;
  87765. private _alive;
  87766. private _useInstancing;
  87767. private _started;
  87768. private _stopped;
  87769. private _actualFrame;
  87770. private _scaledUpdateSpeed;
  87771. private _vertexBufferSize;
  87772. /** @hidden */
  87773. _currentEmitRateGradient: Nullable<FactorGradient>;
  87774. /** @hidden */
  87775. _currentEmitRate1: number;
  87776. /** @hidden */
  87777. _currentEmitRate2: number;
  87778. /** @hidden */
  87779. _currentStartSizeGradient: Nullable<FactorGradient>;
  87780. /** @hidden */
  87781. _currentStartSize1: number;
  87782. /** @hidden */
  87783. _currentStartSize2: number;
  87784. private readonly _rawTextureWidth;
  87785. private _rampGradientsTexture;
  87786. private _useRampGradients;
  87787. /** Gets or sets a boolean indicating that ramp gradients must be used
  87788. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87789. */
  87790. get useRampGradients(): boolean;
  87791. set useRampGradients(value: boolean);
  87792. /**
  87793. * 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.
  87794. * 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: [])
  87795. */
  87796. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  87797. private _subEmitters;
  87798. /**
  87799. * @hidden
  87800. * If the particle systems emitter should be disposed when the particle system is disposed
  87801. */
  87802. _disposeEmitterOnDispose: boolean;
  87803. /**
  87804. * The current active Sub-systems, this property is used by the root particle system only.
  87805. */
  87806. activeSubSystems: Array<ParticleSystem>;
  87807. /**
  87808. * Specifies if the particles are updated in emitter local space or world space
  87809. */
  87810. isLocal: boolean;
  87811. private _rootParticleSystem;
  87812. /**
  87813. * Gets the current list of active particles
  87814. */
  87815. get particles(): Particle[];
  87816. /**
  87817. * Gets the number of particles active at the same time.
  87818. * @returns The number of active particles.
  87819. */
  87820. getActiveCount(): number;
  87821. /**
  87822. * Returns the string "ParticleSystem"
  87823. * @returns a string containing the class name
  87824. */
  87825. getClassName(): string;
  87826. /**
  87827. * Gets a boolean indicating that the system is stopping
  87828. * @returns true if the system is currently stopping
  87829. */
  87830. isStopping(): boolean;
  87831. /**
  87832. * Instantiates a particle system.
  87833. * 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.
  87834. * @param name The name of the particle system
  87835. * @param capacity The max number of particles alive at the same time
  87836. * @param scene The scene the particle system belongs to
  87837. * @param customEffect a custom effect used to change the way particles are rendered by default
  87838. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  87839. * @param epsilon Offset used to render the particles
  87840. */
  87841. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  87842. private _addFactorGradient;
  87843. private _removeFactorGradient;
  87844. /**
  87845. * Adds a new life time gradient
  87846. * @param gradient defines the gradient to use (between 0 and 1)
  87847. * @param factor defines the life time factor to affect to the specified gradient
  87848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87849. * @returns the current particle system
  87850. */
  87851. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87852. /**
  87853. * Remove a specific life time gradient
  87854. * @param gradient defines the gradient to remove
  87855. * @returns the current particle system
  87856. */
  87857. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87858. /**
  87859. * Adds a new size gradient
  87860. * @param gradient defines the gradient to use (between 0 and 1)
  87861. * @param factor defines the size factor to affect to the specified gradient
  87862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87863. * @returns the current particle system
  87864. */
  87865. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87866. /**
  87867. * Remove a specific size gradient
  87868. * @param gradient defines the gradient to remove
  87869. * @returns the current particle system
  87870. */
  87871. removeSizeGradient(gradient: number): IParticleSystem;
  87872. /**
  87873. * Adds a new color remap gradient
  87874. * @param gradient defines the gradient to use (between 0 and 1)
  87875. * @param min defines the color remap minimal range
  87876. * @param max defines the color remap maximal range
  87877. * @returns the current particle system
  87878. */
  87879. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87880. /**
  87881. * Remove a specific color remap gradient
  87882. * @param gradient defines the gradient to remove
  87883. * @returns the current particle system
  87884. */
  87885. removeColorRemapGradient(gradient: number): IParticleSystem;
  87886. /**
  87887. * Adds a new alpha remap gradient
  87888. * @param gradient defines the gradient to use (between 0 and 1)
  87889. * @param min defines the alpha remap minimal range
  87890. * @param max defines the alpha remap maximal range
  87891. * @returns the current particle system
  87892. */
  87893. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87894. /**
  87895. * Remove a specific alpha remap gradient
  87896. * @param gradient defines the gradient to remove
  87897. * @returns the current particle system
  87898. */
  87899. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  87900. /**
  87901. * Adds a new angular speed gradient
  87902. * @param gradient defines the gradient to use (between 0 and 1)
  87903. * @param factor defines the angular speed to affect to the specified gradient
  87904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87905. * @returns the current particle system
  87906. */
  87907. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87908. /**
  87909. * Remove a specific angular speed gradient
  87910. * @param gradient defines the gradient to remove
  87911. * @returns the current particle system
  87912. */
  87913. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87914. /**
  87915. * Adds a new velocity gradient
  87916. * @param gradient defines the gradient to use (between 0 and 1)
  87917. * @param factor defines the velocity to affect to the specified gradient
  87918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87919. * @returns the current particle system
  87920. */
  87921. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87922. /**
  87923. * Remove a specific velocity gradient
  87924. * @param gradient defines the gradient to remove
  87925. * @returns the current particle system
  87926. */
  87927. removeVelocityGradient(gradient: number): IParticleSystem;
  87928. /**
  87929. * Adds a new limit velocity gradient
  87930. * @param gradient defines the gradient to use (between 0 and 1)
  87931. * @param factor defines the limit velocity value to affect to the specified gradient
  87932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87933. * @returns the current particle system
  87934. */
  87935. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87936. /**
  87937. * Remove a specific limit velocity gradient
  87938. * @param gradient defines the gradient to remove
  87939. * @returns the current particle system
  87940. */
  87941. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87942. /**
  87943. * Adds a new drag gradient
  87944. * @param gradient defines the gradient to use (between 0 and 1)
  87945. * @param factor defines the drag value to affect to the specified gradient
  87946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87947. * @returns the current particle system
  87948. */
  87949. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87950. /**
  87951. * Remove a specific drag gradient
  87952. * @param gradient defines the gradient to remove
  87953. * @returns the current particle system
  87954. */
  87955. removeDragGradient(gradient: number): IParticleSystem;
  87956. /**
  87957. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87958. * @param gradient defines the gradient to use (between 0 and 1)
  87959. * @param factor defines the emit rate value to affect to the specified gradient
  87960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87961. * @returns the current particle system
  87962. */
  87963. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87964. /**
  87965. * Remove a specific emit rate gradient
  87966. * @param gradient defines the gradient to remove
  87967. * @returns the current particle system
  87968. */
  87969. removeEmitRateGradient(gradient: number): IParticleSystem;
  87970. /**
  87971. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87972. * @param gradient defines the gradient to use (between 0 and 1)
  87973. * @param factor defines the start size value to affect to the specified gradient
  87974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87975. * @returns the current particle system
  87976. */
  87977. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87978. /**
  87979. * Remove a specific start size gradient
  87980. * @param gradient defines the gradient to remove
  87981. * @returns the current particle system
  87982. */
  87983. removeStartSizeGradient(gradient: number): IParticleSystem;
  87984. private _createRampGradientTexture;
  87985. /**
  87986. * Gets the current list of ramp gradients.
  87987. * You must use addRampGradient and removeRampGradient to udpate this list
  87988. * @returns the list of ramp gradients
  87989. */
  87990. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87991. /** Force the system to rebuild all gradients that need to be resync */
  87992. forceRefreshGradients(): void;
  87993. private _syncRampGradientTexture;
  87994. /**
  87995. * Adds a new ramp gradient used to remap particle colors
  87996. * @param gradient defines the gradient to use (between 0 and 1)
  87997. * @param color defines the color to affect to the specified gradient
  87998. * @returns the current particle system
  87999. */
  88000. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88001. /**
  88002. * Remove a specific ramp gradient
  88003. * @param gradient defines the gradient to remove
  88004. * @returns the current particle system
  88005. */
  88006. removeRampGradient(gradient: number): ParticleSystem;
  88007. /**
  88008. * Adds a new color gradient
  88009. * @param gradient defines the gradient to use (between 0 and 1)
  88010. * @param color1 defines the color to affect to the specified gradient
  88011. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88012. * @returns this particle system
  88013. */
  88014. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88015. /**
  88016. * Remove a specific color gradient
  88017. * @param gradient defines the gradient to remove
  88018. * @returns this particle system
  88019. */
  88020. removeColorGradient(gradient: number): IParticleSystem;
  88021. private _fetchR;
  88022. protected _reset(): void;
  88023. private _resetEffect;
  88024. private _createVertexBuffers;
  88025. private _createIndexBuffer;
  88026. /**
  88027. * Gets the maximum number of particles active at the same time.
  88028. * @returns The max number of active particles.
  88029. */
  88030. getCapacity(): number;
  88031. /**
  88032. * Gets whether there are still active particles in the system.
  88033. * @returns True if it is alive, otherwise false.
  88034. */
  88035. isAlive(): boolean;
  88036. /**
  88037. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88038. * @returns True if it has been started, otherwise false.
  88039. */
  88040. isStarted(): boolean;
  88041. private _prepareSubEmitterInternalArray;
  88042. /**
  88043. * Starts the particle system and begins to emit
  88044. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88045. */
  88046. start(delay?: number): void;
  88047. /**
  88048. * Stops the particle system.
  88049. * @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.
  88050. */
  88051. stop(stopSubEmitters?: boolean): void;
  88052. /**
  88053. * Remove all active particles
  88054. */
  88055. reset(): void;
  88056. /**
  88057. * @hidden (for internal use only)
  88058. */
  88059. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88060. /**
  88061. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88062. * Its lifetime will start back at 0.
  88063. */
  88064. recycleParticle: (particle: Particle) => void;
  88065. private _stopSubEmitters;
  88066. private _createParticle;
  88067. private _removeFromRoot;
  88068. private _emitFromParticle;
  88069. private _update;
  88070. /** @hidden */
  88071. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88072. /** @hidden */
  88073. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88074. /** @hidden */
  88075. private _getEffect;
  88076. /**
  88077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88078. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88079. */
  88080. animate(preWarmOnly?: boolean): void;
  88081. private _appendParticleVertices;
  88082. /**
  88083. * Rebuilds the particle system.
  88084. */
  88085. rebuild(): void;
  88086. /**
  88087. * Is this system ready to be used/rendered
  88088. * @return true if the system is ready
  88089. */
  88090. isReady(): boolean;
  88091. private _render;
  88092. /**
  88093. * Renders the particle system in its current state.
  88094. * @returns the current number of particles
  88095. */
  88096. render(): number;
  88097. /**
  88098. * Disposes the particle system and free the associated resources
  88099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88100. */
  88101. dispose(disposeTexture?: boolean): void;
  88102. /**
  88103. * Clones the particle system.
  88104. * @param name The name of the cloned object
  88105. * @param newEmitter The new emitter to use
  88106. * @returns the cloned particle system
  88107. */
  88108. clone(name: string, newEmitter: any): ParticleSystem;
  88109. /**
  88110. * Serializes the particle system to a JSON object
  88111. * @param serializeTexture defines if the texture must be serialized as well
  88112. * @returns the JSON object
  88113. */
  88114. serialize(serializeTexture?: boolean): any;
  88115. /** @hidden */
  88116. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  88117. /** @hidden */
  88118. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88119. /**
  88120. * Parses a JSON object to create a particle system.
  88121. * @param parsedParticleSystem The JSON object to parse
  88122. * @param scene The scene to create the particle system in
  88123. * @param rootUrl The root url to use to load external dependencies like texture
  88124. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88125. * @returns the Parsed particle system
  88126. */
  88127. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88128. }
  88129. }
  88130. declare module BABYLON {
  88131. /**
  88132. * A particle represents one of the element emitted by a particle system.
  88133. * This is mainly define by its coordinates, direction, velocity and age.
  88134. */
  88135. export class Particle {
  88136. /**
  88137. * The particle system the particle belongs to.
  88138. */
  88139. particleSystem: ParticleSystem;
  88140. private static _Count;
  88141. /**
  88142. * Unique ID of the particle
  88143. */
  88144. id: number;
  88145. /**
  88146. * The world position of the particle in the scene.
  88147. */
  88148. position: Vector3;
  88149. /**
  88150. * The world direction of the particle in the scene.
  88151. */
  88152. direction: Vector3;
  88153. /**
  88154. * The color of the particle.
  88155. */
  88156. color: Color4;
  88157. /**
  88158. * The color change of the particle per step.
  88159. */
  88160. colorStep: Color4;
  88161. /**
  88162. * Defines how long will the life of the particle be.
  88163. */
  88164. lifeTime: number;
  88165. /**
  88166. * The current age of the particle.
  88167. */
  88168. age: number;
  88169. /**
  88170. * The current size of the particle.
  88171. */
  88172. size: number;
  88173. /**
  88174. * The current scale of the particle.
  88175. */
  88176. scale: Vector2;
  88177. /**
  88178. * The current angle of the particle.
  88179. */
  88180. angle: number;
  88181. /**
  88182. * Defines how fast is the angle changing.
  88183. */
  88184. angularSpeed: number;
  88185. /**
  88186. * Defines the cell index used by the particle to be rendered from a sprite.
  88187. */
  88188. cellIndex: number;
  88189. /**
  88190. * The information required to support color remapping
  88191. */
  88192. remapData: Vector4;
  88193. /** @hidden */
  88194. _randomCellOffset?: number;
  88195. /** @hidden */
  88196. _initialDirection: Nullable<Vector3>;
  88197. /** @hidden */
  88198. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88199. /** @hidden */
  88200. _initialStartSpriteCellID: number;
  88201. /** @hidden */
  88202. _initialEndSpriteCellID: number;
  88203. /** @hidden */
  88204. _currentColorGradient: Nullable<ColorGradient>;
  88205. /** @hidden */
  88206. _currentColor1: Color4;
  88207. /** @hidden */
  88208. _currentColor2: Color4;
  88209. /** @hidden */
  88210. _currentSizeGradient: Nullable<FactorGradient>;
  88211. /** @hidden */
  88212. _currentSize1: number;
  88213. /** @hidden */
  88214. _currentSize2: number;
  88215. /** @hidden */
  88216. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88217. /** @hidden */
  88218. _currentAngularSpeed1: number;
  88219. /** @hidden */
  88220. _currentAngularSpeed2: number;
  88221. /** @hidden */
  88222. _currentVelocityGradient: Nullable<FactorGradient>;
  88223. /** @hidden */
  88224. _currentVelocity1: number;
  88225. /** @hidden */
  88226. _currentVelocity2: number;
  88227. /** @hidden */
  88228. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88229. /** @hidden */
  88230. _currentLimitVelocity1: number;
  88231. /** @hidden */
  88232. _currentLimitVelocity2: number;
  88233. /** @hidden */
  88234. _currentDragGradient: Nullable<FactorGradient>;
  88235. /** @hidden */
  88236. _currentDrag1: number;
  88237. /** @hidden */
  88238. _currentDrag2: number;
  88239. /** @hidden */
  88240. _randomNoiseCoordinates1: Vector3;
  88241. /** @hidden */
  88242. _randomNoiseCoordinates2: Vector3;
  88243. /** @hidden */
  88244. _localPosition?: Vector3;
  88245. /**
  88246. * Creates a new instance Particle
  88247. * @param particleSystem the particle system the particle belongs to
  88248. */
  88249. constructor(
  88250. /**
  88251. * The particle system the particle belongs to.
  88252. */
  88253. particleSystem: ParticleSystem);
  88254. private updateCellInfoFromSystem;
  88255. /**
  88256. * Defines how the sprite cell index is updated for the particle
  88257. */
  88258. updateCellIndex(): void;
  88259. /** @hidden */
  88260. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88261. /** @hidden */
  88262. _inheritParticleInfoToSubEmitters(): void;
  88263. /** @hidden */
  88264. _reset(): void;
  88265. /**
  88266. * Copy the properties of particle to another one.
  88267. * @param other the particle to copy the information to.
  88268. */
  88269. copyTo(other: Particle): void;
  88270. }
  88271. }
  88272. declare module BABYLON {
  88273. /**
  88274. * Particle emitter represents a volume emitting particles.
  88275. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88276. */
  88277. export interface IParticleEmitterType {
  88278. /**
  88279. * Called by the particle System when the direction is computed for the created particle.
  88280. * @param worldMatrix is the world matrix of the particle system
  88281. * @param directionToUpdate is the direction vector to update with the result
  88282. * @param particle is the particle we are computed the direction for
  88283. * @param isLocal defines if the direction should be set in local space
  88284. */
  88285. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88286. /**
  88287. * Called by the particle System when the position is computed for the created particle.
  88288. * @param worldMatrix is the world matrix of the particle system
  88289. * @param positionToUpdate is the position vector to update with the result
  88290. * @param particle is the particle we are computed the position for
  88291. * @param isLocal defines if the position should be set in local space
  88292. */
  88293. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88294. /**
  88295. * Clones the current emitter and returns a copy of it
  88296. * @returns the new emitter
  88297. */
  88298. clone(): IParticleEmitterType;
  88299. /**
  88300. * Called by the GPUParticleSystem to setup the update shader
  88301. * @param effect defines the update shader
  88302. */
  88303. applyToShader(effect: Effect): void;
  88304. /**
  88305. * Returns a string to use to update the GPU particles update shader
  88306. * @returns the effect defines string
  88307. */
  88308. getEffectDefines(): string;
  88309. /**
  88310. * Returns a string representing the class name
  88311. * @returns a string containing the class name
  88312. */
  88313. getClassName(): string;
  88314. /**
  88315. * Serializes the particle system to a JSON object.
  88316. * @returns the JSON object
  88317. */
  88318. serialize(): any;
  88319. /**
  88320. * Parse properties from a JSON object
  88321. * @param serializationObject defines the JSON object
  88322. * @param scene defines the hosting scene
  88323. */
  88324. parse(serializationObject: any, scene: Scene): void;
  88325. }
  88326. }
  88327. declare module BABYLON {
  88328. /**
  88329. * Particle emitter emitting particles from the inside of a box.
  88330. * It emits the particles randomly between 2 given directions.
  88331. */
  88332. export class BoxParticleEmitter implements IParticleEmitterType {
  88333. /**
  88334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88335. */
  88336. direction1: Vector3;
  88337. /**
  88338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88339. */
  88340. direction2: Vector3;
  88341. /**
  88342. * 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.
  88343. */
  88344. minEmitBox: Vector3;
  88345. /**
  88346. * 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.
  88347. */
  88348. maxEmitBox: Vector3;
  88349. /**
  88350. * Creates a new instance BoxParticleEmitter
  88351. */
  88352. constructor();
  88353. /**
  88354. * Called by the particle System when the direction is computed for the created particle.
  88355. * @param worldMatrix is the world matrix of the particle system
  88356. * @param directionToUpdate is the direction vector to update with the result
  88357. * @param particle is the particle we are computed the direction for
  88358. * @param isLocal defines if the direction should be set in local space
  88359. */
  88360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88361. /**
  88362. * Called by the particle System when the position is computed for the created particle.
  88363. * @param worldMatrix is the world matrix of the particle system
  88364. * @param positionToUpdate is the position vector to update with the result
  88365. * @param particle is the particle we are computed the position for
  88366. * @param isLocal defines if the position should be set in local space
  88367. */
  88368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88369. /**
  88370. * Clones the current emitter and returns a copy of it
  88371. * @returns the new emitter
  88372. */
  88373. clone(): BoxParticleEmitter;
  88374. /**
  88375. * Called by the GPUParticleSystem to setup the update shader
  88376. * @param effect defines the update shader
  88377. */
  88378. applyToShader(effect: Effect): void;
  88379. /**
  88380. * Returns a string to use to update the GPU particles update shader
  88381. * @returns a string containng the defines string
  88382. */
  88383. getEffectDefines(): string;
  88384. /**
  88385. * Returns the string "BoxParticleEmitter"
  88386. * @returns a string containing the class name
  88387. */
  88388. getClassName(): string;
  88389. /**
  88390. * Serializes the particle system to a JSON object.
  88391. * @returns the JSON object
  88392. */
  88393. serialize(): any;
  88394. /**
  88395. * Parse properties from a JSON object
  88396. * @param serializationObject defines the JSON object
  88397. */
  88398. parse(serializationObject: any): void;
  88399. }
  88400. }
  88401. declare module BABYLON {
  88402. /**
  88403. * Particle emitter emitting particles from the inside of a cone.
  88404. * It emits the particles alongside the cone volume from the base to the particle.
  88405. * The emission direction might be randomized.
  88406. */
  88407. export class ConeParticleEmitter implements IParticleEmitterType {
  88408. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88409. directionRandomizer: number;
  88410. private _radius;
  88411. private _angle;
  88412. private _height;
  88413. /**
  88414. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88415. */
  88416. radiusRange: number;
  88417. /**
  88418. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88419. */
  88420. heightRange: number;
  88421. /**
  88422. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88423. */
  88424. emitFromSpawnPointOnly: boolean;
  88425. /**
  88426. * Gets or sets the radius of the emission cone
  88427. */
  88428. get radius(): number;
  88429. set radius(value: number);
  88430. /**
  88431. * Gets or sets the angle of the emission cone
  88432. */
  88433. get angle(): number;
  88434. set angle(value: number);
  88435. private _buildHeight;
  88436. /**
  88437. * Creates a new instance ConeParticleEmitter
  88438. * @param radius the radius of the emission cone (1 by default)
  88439. * @param angle the cone base angle (PI by default)
  88440. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88441. */
  88442. constructor(radius?: number, angle?: number,
  88443. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88444. directionRandomizer?: number);
  88445. /**
  88446. * Called by the particle System when the direction is computed for the created particle.
  88447. * @param worldMatrix is the world matrix of the particle system
  88448. * @param directionToUpdate is the direction vector to update with the result
  88449. * @param particle is the particle we are computed the direction for
  88450. * @param isLocal defines if the direction should be set in local space
  88451. */
  88452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88453. /**
  88454. * Called by the particle System when the position is computed for the created particle.
  88455. * @param worldMatrix is the world matrix of the particle system
  88456. * @param positionToUpdate is the position vector to update with the result
  88457. * @param particle is the particle we are computed the position for
  88458. * @param isLocal defines if the position should be set in local space
  88459. */
  88460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88461. /**
  88462. * Clones the current emitter and returns a copy of it
  88463. * @returns the new emitter
  88464. */
  88465. clone(): ConeParticleEmitter;
  88466. /**
  88467. * Called by the GPUParticleSystem to setup the update shader
  88468. * @param effect defines the update shader
  88469. */
  88470. applyToShader(effect: Effect): void;
  88471. /**
  88472. * Returns a string to use to update the GPU particles update shader
  88473. * @returns a string containng the defines string
  88474. */
  88475. getEffectDefines(): string;
  88476. /**
  88477. * Returns the string "ConeParticleEmitter"
  88478. * @returns a string containing the class name
  88479. */
  88480. getClassName(): string;
  88481. /**
  88482. * Serializes the particle system to a JSON object.
  88483. * @returns the JSON object
  88484. */
  88485. serialize(): any;
  88486. /**
  88487. * Parse properties from a JSON object
  88488. * @param serializationObject defines the JSON object
  88489. */
  88490. parse(serializationObject: any): void;
  88491. }
  88492. }
  88493. declare module BABYLON {
  88494. /**
  88495. * Particle emitter emitting particles from the inside of a cylinder.
  88496. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88497. */
  88498. export class CylinderParticleEmitter implements IParticleEmitterType {
  88499. /**
  88500. * The radius of the emission cylinder.
  88501. */
  88502. radius: number;
  88503. /**
  88504. * The height of the emission cylinder.
  88505. */
  88506. height: number;
  88507. /**
  88508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88509. */
  88510. radiusRange: number;
  88511. /**
  88512. * How much to randomize the particle direction [0-1].
  88513. */
  88514. directionRandomizer: number;
  88515. /**
  88516. * Creates a new instance CylinderParticleEmitter
  88517. * @param radius the radius of the emission cylinder (1 by default)
  88518. * @param height the height of the emission cylinder (1 by default)
  88519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88521. */
  88522. constructor(
  88523. /**
  88524. * The radius of the emission cylinder.
  88525. */
  88526. radius?: number,
  88527. /**
  88528. * The height of the emission cylinder.
  88529. */
  88530. height?: number,
  88531. /**
  88532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88533. */
  88534. radiusRange?: number,
  88535. /**
  88536. * How much to randomize the particle direction [0-1].
  88537. */
  88538. directionRandomizer?: number);
  88539. /**
  88540. * Called by the particle System when the direction is computed for the created particle.
  88541. * @param worldMatrix is the world matrix of the particle system
  88542. * @param directionToUpdate is the direction vector to update with the result
  88543. * @param particle is the particle we are computed the direction for
  88544. * @param isLocal defines if the direction should be set in local space
  88545. */
  88546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88547. /**
  88548. * Called by the particle System when the position is computed for the created particle.
  88549. * @param worldMatrix is the world matrix of the particle system
  88550. * @param positionToUpdate is the position vector to update with the result
  88551. * @param particle is the particle we are computed the position for
  88552. * @param isLocal defines if the position should be set in local space
  88553. */
  88554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88555. /**
  88556. * Clones the current emitter and returns a copy of it
  88557. * @returns the new emitter
  88558. */
  88559. clone(): CylinderParticleEmitter;
  88560. /**
  88561. * Called by the GPUParticleSystem to setup the update shader
  88562. * @param effect defines the update shader
  88563. */
  88564. applyToShader(effect: Effect): void;
  88565. /**
  88566. * Returns a string to use to update the GPU particles update shader
  88567. * @returns a string containng the defines string
  88568. */
  88569. getEffectDefines(): string;
  88570. /**
  88571. * Returns the string "CylinderParticleEmitter"
  88572. * @returns a string containing the class name
  88573. */
  88574. getClassName(): string;
  88575. /**
  88576. * Serializes the particle system to a JSON object.
  88577. * @returns the JSON object
  88578. */
  88579. serialize(): any;
  88580. /**
  88581. * Parse properties from a JSON object
  88582. * @param serializationObject defines the JSON object
  88583. */
  88584. parse(serializationObject: any): void;
  88585. }
  88586. /**
  88587. * Particle emitter emitting particles from the inside of a cylinder.
  88588. * It emits the particles randomly between two vectors.
  88589. */
  88590. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88591. /**
  88592. * The min limit of the emission direction.
  88593. */
  88594. direction1: Vector3;
  88595. /**
  88596. * The max limit of the emission direction.
  88597. */
  88598. direction2: Vector3;
  88599. /**
  88600. * Creates a new instance CylinderDirectedParticleEmitter
  88601. * @param radius the radius of the emission cylinder (1 by default)
  88602. * @param height the height of the emission cylinder (1 by default)
  88603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88604. * @param direction1 the min limit of the emission direction (up vector by default)
  88605. * @param direction2 the max limit of the emission direction (up vector by default)
  88606. */
  88607. constructor(radius?: number, height?: number, radiusRange?: number,
  88608. /**
  88609. * The min limit of the emission direction.
  88610. */
  88611. direction1?: Vector3,
  88612. /**
  88613. * The max limit of the emission direction.
  88614. */
  88615. direction2?: Vector3);
  88616. /**
  88617. * Called by the particle System when the direction is computed for the created particle.
  88618. * @param worldMatrix is the world matrix of the particle system
  88619. * @param directionToUpdate is the direction vector to update with the result
  88620. * @param particle is the particle we are computed the direction for
  88621. */
  88622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88623. /**
  88624. * Clones the current emitter and returns a copy of it
  88625. * @returns the new emitter
  88626. */
  88627. clone(): CylinderDirectedParticleEmitter;
  88628. /**
  88629. * Called by the GPUParticleSystem to setup the update shader
  88630. * @param effect defines the update shader
  88631. */
  88632. applyToShader(effect: Effect): void;
  88633. /**
  88634. * Returns a string to use to update the GPU particles update shader
  88635. * @returns a string containng the defines string
  88636. */
  88637. getEffectDefines(): string;
  88638. /**
  88639. * Returns the string "CylinderDirectedParticleEmitter"
  88640. * @returns a string containing the class name
  88641. */
  88642. getClassName(): string;
  88643. /**
  88644. * Serializes the particle system to a JSON object.
  88645. * @returns the JSON object
  88646. */
  88647. serialize(): any;
  88648. /**
  88649. * Parse properties from a JSON object
  88650. * @param serializationObject defines the JSON object
  88651. */
  88652. parse(serializationObject: any): void;
  88653. }
  88654. }
  88655. declare module BABYLON {
  88656. /**
  88657. * Particle emitter emitting particles from the inside of a hemisphere.
  88658. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88659. */
  88660. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88661. /**
  88662. * The radius of the emission hemisphere.
  88663. */
  88664. radius: number;
  88665. /**
  88666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88667. */
  88668. radiusRange: number;
  88669. /**
  88670. * How much to randomize the particle direction [0-1].
  88671. */
  88672. directionRandomizer: number;
  88673. /**
  88674. * Creates a new instance HemisphericParticleEmitter
  88675. * @param radius the radius of the emission hemisphere (1 by default)
  88676. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88677. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88678. */
  88679. constructor(
  88680. /**
  88681. * The radius of the emission hemisphere.
  88682. */
  88683. radius?: number,
  88684. /**
  88685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88686. */
  88687. radiusRange?: number,
  88688. /**
  88689. * How much to randomize the particle direction [0-1].
  88690. */
  88691. directionRandomizer?: number);
  88692. /**
  88693. * Called by the particle System when the direction is computed for the created particle.
  88694. * @param worldMatrix is the world matrix of the particle system
  88695. * @param directionToUpdate is the direction vector to update with the result
  88696. * @param particle is the particle we are computed the direction for
  88697. * @param isLocal defines if the direction should be set in local space
  88698. */
  88699. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88700. /**
  88701. * Called by the particle System when the position is computed for the created particle.
  88702. * @param worldMatrix is the world matrix of the particle system
  88703. * @param positionToUpdate is the position vector to update with the result
  88704. * @param particle is the particle we are computed the position for
  88705. * @param isLocal defines if the position should be set in local space
  88706. */
  88707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88708. /**
  88709. * Clones the current emitter and returns a copy of it
  88710. * @returns the new emitter
  88711. */
  88712. clone(): HemisphericParticleEmitter;
  88713. /**
  88714. * Called by the GPUParticleSystem to setup the update shader
  88715. * @param effect defines the update shader
  88716. */
  88717. applyToShader(effect: Effect): void;
  88718. /**
  88719. * Returns a string to use to update the GPU particles update shader
  88720. * @returns a string containng the defines string
  88721. */
  88722. getEffectDefines(): string;
  88723. /**
  88724. * Returns the string "HemisphericParticleEmitter"
  88725. * @returns a string containing the class name
  88726. */
  88727. getClassName(): string;
  88728. /**
  88729. * Serializes the particle system to a JSON object.
  88730. * @returns the JSON object
  88731. */
  88732. serialize(): any;
  88733. /**
  88734. * Parse properties from a JSON object
  88735. * @param serializationObject defines the JSON object
  88736. */
  88737. parse(serializationObject: any): void;
  88738. }
  88739. }
  88740. declare module BABYLON {
  88741. /**
  88742. * Particle emitter emitting particles from a point.
  88743. * It emits the particles randomly between 2 given directions.
  88744. */
  88745. export class PointParticleEmitter implements IParticleEmitterType {
  88746. /**
  88747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88748. */
  88749. direction1: Vector3;
  88750. /**
  88751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88752. */
  88753. direction2: Vector3;
  88754. /**
  88755. * Creates a new instance PointParticleEmitter
  88756. */
  88757. constructor();
  88758. /**
  88759. * Called by the particle System when the direction is computed for the created particle.
  88760. * @param worldMatrix is the world matrix of the particle system
  88761. * @param directionToUpdate is the direction vector to update with the result
  88762. * @param particle is the particle we are computed the direction for
  88763. * @param isLocal defines if the direction should be set in local space
  88764. */
  88765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88766. /**
  88767. * Called by the particle System when the position is computed for the created particle.
  88768. * @param worldMatrix is the world matrix of the particle system
  88769. * @param positionToUpdate is the position vector to update with the result
  88770. * @param particle is the particle we are computed the position for
  88771. * @param isLocal defines if the position should be set in local space
  88772. */
  88773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88774. /**
  88775. * Clones the current emitter and returns a copy of it
  88776. * @returns the new emitter
  88777. */
  88778. clone(): PointParticleEmitter;
  88779. /**
  88780. * Called by the GPUParticleSystem to setup the update shader
  88781. * @param effect defines the update shader
  88782. */
  88783. applyToShader(effect: Effect): void;
  88784. /**
  88785. * Returns a string to use to update the GPU particles update shader
  88786. * @returns a string containng the defines string
  88787. */
  88788. getEffectDefines(): string;
  88789. /**
  88790. * Returns the string "PointParticleEmitter"
  88791. * @returns a string containing the class name
  88792. */
  88793. getClassName(): string;
  88794. /**
  88795. * Serializes the particle system to a JSON object.
  88796. * @returns the JSON object
  88797. */
  88798. serialize(): any;
  88799. /**
  88800. * Parse properties from a JSON object
  88801. * @param serializationObject defines the JSON object
  88802. */
  88803. parse(serializationObject: any): void;
  88804. }
  88805. }
  88806. declare module BABYLON {
  88807. /**
  88808. * Particle emitter emitting particles from the inside of a sphere.
  88809. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88810. */
  88811. export class SphereParticleEmitter implements IParticleEmitterType {
  88812. /**
  88813. * The radius of the emission sphere.
  88814. */
  88815. radius: number;
  88816. /**
  88817. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88818. */
  88819. radiusRange: number;
  88820. /**
  88821. * How much to randomize the particle direction [0-1].
  88822. */
  88823. directionRandomizer: number;
  88824. /**
  88825. * Creates a new instance SphereParticleEmitter
  88826. * @param radius the radius of the emission sphere (1 by default)
  88827. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88828. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88829. */
  88830. constructor(
  88831. /**
  88832. * The radius of the emission sphere.
  88833. */
  88834. radius?: number,
  88835. /**
  88836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88837. */
  88838. radiusRange?: number,
  88839. /**
  88840. * How much to randomize the particle direction [0-1].
  88841. */
  88842. directionRandomizer?: number);
  88843. /**
  88844. * Called by the particle System when the direction is computed for the created particle.
  88845. * @param worldMatrix is the world matrix of the particle system
  88846. * @param directionToUpdate is the direction vector to update with the result
  88847. * @param particle is the particle we are computed the direction for
  88848. * @param isLocal defines if the direction should be set in local space
  88849. */
  88850. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88851. /**
  88852. * Called by the particle System when the position is computed for the created particle.
  88853. * @param worldMatrix is the world matrix of the particle system
  88854. * @param positionToUpdate is the position vector to update with the result
  88855. * @param particle is the particle we are computed the position for
  88856. * @param isLocal defines if the position should be set in local space
  88857. */
  88858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88859. /**
  88860. * Clones the current emitter and returns a copy of it
  88861. * @returns the new emitter
  88862. */
  88863. clone(): SphereParticleEmitter;
  88864. /**
  88865. * Called by the GPUParticleSystem to setup the update shader
  88866. * @param effect defines the update shader
  88867. */
  88868. applyToShader(effect: Effect): void;
  88869. /**
  88870. * Returns a string to use to update the GPU particles update shader
  88871. * @returns a string containng the defines string
  88872. */
  88873. getEffectDefines(): string;
  88874. /**
  88875. * Returns the string "SphereParticleEmitter"
  88876. * @returns a string containing the class name
  88877. */
  88878. getClassName(): string;
  88879. /**
  88880. * Serializes the particle system to a JSON object.
  88881. * @returns the JSON object
  88882. */
  88883. serialize(): any;
  88884. /**
  88885. * Parse properties from a JSON object
  88886. * @param serializationObject defines the JSON object
  88887. */
  88888. parse(serializationObject: any): void;
  88889. }
  88890. /**
  88891. * Particle emitter emitting particles from the inside of a sphere.
  88892. * It emits the particles randomly between two vectors.
  88893. */
  88894. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  88895. /**
  88896. * The min limit of the emission direction.
  88897. */
  88898. direction1: Vector3;
  88899. /**
  88900. * The max limit of the emission direction.
  88901. */
  88902. direction2: Vector3;
  88903. /**
  88904. * Creates a new instance SphereDirectedParticleEmitter
  88905. * @param radius the radius of the emission sphere (1 by default)
  88906. * @param direction1 the min limit of the emission direction (up vector by default)
  88907. * @param direction2 the max limit of the emission direction (up vector by default)
  88908. */
  88909. constructor(radius?: number,
  88910. /**
  88911. * The min limit of the emission direction.
  88912. */
  88913. direction1?: Vector3,
  88914. /**
  88915. * The max limit of the emission direction.
  88916. */
  88917. direction2?: Vector3);
  88918. /**
  88919. * Called by the particle System when the direction is computed for the created particle.
  88920. * @param worldMatrix is the world matrix of the particle system
  88921. * @param directionToUpdate is the direction vector to update with the result
  88922. * @param particle is the particle we are computed the direction for
  88923. */
  88924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88925. /**
  88926. * Clones the current emitter and returns a copy of it
  88927. * @returns the new emitter
  88928. */
  88929. clone(): SphereDirectedParticleEmitter;
  88930. /**
  88931. * Called by the GPUParticleSystem to setup the update shader
  88932. * @param effect defines the update shader
  88933. */
  88934. applyToShader(effect: Effect): void;
  88935. /**
  88936. * Returns a string to use to update the GPU particles update shader
  88937. * @returns a string containng the defines string
  88938. */
  88939. getEffectDefines(): string;
  88940. /**
  88941. * Returns the string "SphereDirectedParticleEmitter"
  88942. * @returns a string containing the class name
  88943. */
  88944. getClassName(): string;
  88945. /**
  88946. * Serializes the particle system to a JSON object.
  88947. * @returns the JSON object
  88948. */
  88949. serialize(): any;
  88950. /**
  88951. * Parse properties from a JSON object
  88952. * @param serializationObject defines the JSON object
  88953. */
  88954. parse(serializationObject: any): void;
  88955. }
  88956. }
  88957. declare module BABYLON {
  88958. /**
  88959. * Particle emitter emitting particles from a custom list of positions.
  88960. */
  88961. export class CustomParticleEmitter implements IParticleEmitterType {
  88962. /**
  88963. * Gets or sets the position generator that will create the inital position of each particle.
  88964. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88965. */
  88966. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  88967. /**
  88968. * Gets or sets the destination generator that will create the final destination of each particle.
  88969. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88970. */
  88971. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  88972. /**
  88973. * Creates a new instance CustomParticleEmitter
  88974. */
  88975. constructor();
  88976. /**
  88977. * Called by the particle System when the direction is computed for the created particle.
  88978. * @param worldMatrix is the world matrix of the particle system
  88979. * @param directionToUpdate is the direction vector to update with the result
  88980. * @param particle is the particle we are computed the direction for
  88981. * @param isLocal defines if the direction should be set in local space
  88982. */
  88983. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88984. /**
  88985. * Called by the particle System when the position is computed for the created particle.
  88986. * @param worldMatrix is the world matrix of the particle system
  88987. * @param positionToUpdate is the position vector to update with the result
  88988. * @param particle is the particle we are computed the position for
  88989. * @param isLocal defines if the position should be set in local space
  88990. */
  88991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88992. /**
  88993. * Clones the current emitter and returns a copy of it
  88994. * @returns the new emitter
  88995. */
  88996. clone(): CustomParticleEmitter;
  88997. /**
  88998. * Called by the GPUParticleSystem to setup the update shader
  88999. * @param effect defines the update shader
  89000. */
  89001. applyToShader(effect: Effect): void;
  89002. /**
  89003. * Returns a string to use to update the GPU particles update shader
  89004. * @returns a string containng the defines string
  89005. */
  89006. getEffectDefines(): string;
  89007. /**
  89008. * Returns the string "PointParticleEmitter"
  89009. * @returns a string containing the class name
  89010. */
  89011. getClassName(): string;
  89012. /**
  89013. * Serializes the particle system to a JSON object.
  89014. * @returns the JSON object
  89015. */
  89016. serialize(): any;
  89017. /**
  89018. * Parse properties from a JSON object
  89019. * @param serializationObject defines the JSON object
  89020. */
  89021. parse(serializationObject: any): void;
  89022. }
  89023. }
  89024. declare module BABYLON {
  89025. /**
  89026. * Particle emitter emitting particles from the inside of a box.
  89027. * It emits the particles randomly between 2 given directions.
  89028. */
  89029. export class MeshParticleEmitter implements IParticleEmitterType {
  89030. private _indices;
  89031. private _positions;
  89032. private _normals;
  89033. private _storedNormal;
  89034. private _mesh;
  89035. /**
  89036. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89037. */
  89038. direction1: Vector3;
  89039. /**
  89040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89041. */
  89042. direction2: Vector3;
  89043. /**
  89044. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  89045. */
  89046. useMeshNormalsForDirection: boolean;
  89047. /** Defines the mesh to use as source */
  89048. get mesh(): Nullable<AbstractMesh>;
  89049. set mesh(value: Nullable<AbstractMesh>);
  89050. /**
  89051. * Creates a new instance MeshParticleEmitter
  89052. * @param mesh defines the mesh to use as source
  89053. */
  89054. constructor(mesh?: Nullable<AbstractMesh>);
  89055. /**
  89056. * Called by the particle System when the direction is computed for the created particle.
  89057. * @param worldMatrix is the world matrix of the particle system
  89058. * @param directionToUpdate is the direction vector to update with the result
  89059. * @param particle is the particle we are computed the direction for
  89060. * @param isLocal defines if the direction should be set in local space
  89061. */
  89062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89063. /**
  89064. * Called by the particle System when the position is computed for the created particle.
  89065. * @param worldMatrix is the world matrix of the particle system
  89066. * @param positionToUpdate is the position vector to update with the result
  89067. * @param particle is the particle we are computed the position for
  89068. * @param isLocal defines if the position should be set in local space
  89069. */
  89070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89071. /**
  89072. * Clones the current emitter and returns a copy of it
  89073. * @returns the new emitter
  89074. */
  89075. clone(): MeshParticleEmitter;
  89076. /**
  89077. * Called by the GPUParticleSystem to setup the update shader
  89078. * @param effect defines the update shader
  89079. */
  89080. applyToShader(effect: Effect): void;
  89081. /**
  89082. * Returns a string to use to update the GPU particles update shader
  89083. * @returns a string containng the defines string
  89084. */
  89085. getEffectDefines(): string;
  89086. /**
  89087. * Returns the string "BoxParticleEmitter"
  89088. * @returns a string containing the class name
  89089. */
  89090. getClassName(): string;
  89091. /**
  89092. * Serializes the particle system to a JSON object.
  89093. * @returns the JSON object
  89094. */
  89095. serialize(): any;
  89096. /**
  89097. * Parse properties from a JSON object
  89098. * @param serializationObject defines the JSON object
  89099. * @param scene defines the hosting scene
  89100. */
  89101. parse(serializationObject: any, scene: Scene): void;
  89102. }
  89103. }
  89104. declare module BABYLON {
  89105. /**
  89106. * Interface representing a particle system in Babylon.js.
  89107. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89108. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89109. */
  89110. export interface IParticleSystem {
  89111. /**
  89112. * List of animations used by the particle system.
  89113. */
  89114. animations: Animation[];
  89115. /**
  89116. * The id of the Particle system.
  89117. */
  89118. id: string;
  89119. /**
  89120. * The name of the Particle system.
  89121. */
  89122. name: string;
  89123. /**
  89124. * The emitter represents the Mesh or position we are attaching the particle system to.
  89125. */
  89126. emitter: Nullable<AbstractMesh | Vector3>;
  89127. /**
  89128. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89129. */
  89130. isBillboardBased: boolean;
  89131. /**
  89132. * The rendering group used by the Particle system to chose when to render.
  89133. */
  89134. renderingGroupId: number;
  89135. /**
  89136. * The layer mask we are rendering the particles through.
  89137. */
  89138. layerMask: number;
  89139. /**
  89140. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89141. */
  89142. updateSpeed: number;
  89143. /**
  89144. * The amount of time the particle system is running (depends of the overall update speed).
  89145. */
  89146. targetStopDuration: number;
  89147. /**
  89148. * The texture used to render each particle. (this can be a spritesheet)
  89149. */
  89150. particleTexture: Nullable<Texture>;
  89151. /**
  89152. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89153. */
  89154. blendMode: number;
  89155. /**
  89156. * Minimum life time of emitting particles.
  89157. */
  89158. minLifeTime: number;
  89159. /**
  89160. * Maximum life time of emitting particles.
  89161. */
  89162. maxLifeTime: number;
  89163. /**
  89164. * Minimum Size of emitting particles.
  89165. */
  89166. minSize: number;
  89167. /**
  89168. * Maximum Size of emitting particles.
  89169. */
  89170. maxSize: number;
  89171. /**
  89172. * Minimum scale of emitting particles on X axis.
  89173. */
  89174. minScaleX: number;
  89175. /**
  89176. * Maximum scale of emitting particles on X axis.
  89177. */
  89178. maxScaleX: number;
  89179. /**
  89180. * Minimum scale of emitting particles on Y axis.
  89181. */
  89182. minScaleY: number;
  89183. /**
  89184. * Maximum scale of emitting particles on Y axis.
  89185. */
  89186. maxScaleY: number;
  89187. /**
  89188. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89189. */
  89190. color1: Color4;
  89191. /**
  89192. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89193. */
  89194. color2: Color4;
  89195. /**
  89196. * Color the particle will have at the end of its lifetime.
  89197. */
  89198. colorDead: Color4;
  89199. /**
  89200. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89201. */
  89202. emitRate: number;
  89203. /**
  89204. * You can use gravity if you want to give an orientation to your particles.
  89205. */
  89206. gravity: Vector3;
  89207. /**
  89208. * Minimum power of emitting particles.
  89209. */
  89210. minEmitPower: number;
  89211. /**
  89212. * Maximum power of emitting particles.
  89213. */
  89214. maxEmitPower: number;
  89215. /**
  89216. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89217. */
  89218. minAngularSpeed: number;
  89219. /**
  89220. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89221. */
  89222. maxAngularSpeed: number;
  89223. /**
  89224. * Gets or sets the minimal initial rotation in radians.
  89225. */
  89226. minInitialRotation: number;
  89227. /**
  89228. * Gets or sets the maximal initial rotation in radians.
  89229. */
  89230. maxInitialRotation: number;
  89231. /**
  89232. * The particle emitter type defines the emitter used by the particle system.
  89233. * It can be for example box, sphere, or cone...
  89234. */
  89235. particleEmitterType: Nullable<IParticleEmitterType>;
  89236. /**
  89237. * Defines the delay in milliseconds before starting the system (0 by default)
  89238. */
  89239. startDelay: number;
  89240. /**
  89241. * 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
  89242. */
  89243. preWarmCycles: number;
  89244. /**
  89245. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89246. */
  89247. preWarmStepOffset: number;
  89248. /**
  89249. * 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)
  89250. */
  89251. spriteCellChangeSpeed: number;
  89252. /**
  89253. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89254. */
  89255. startSpriteCellID: number;
  89256. /**
  89257. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89258. */
  89259. endSpriteCellID: number;
  89260. /**
  89261. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89262. */
  89263. spriteCellWidth: number;
  89264. /**
  89265. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89266. */
  89267. spriteCellHeight: number;
  89268. /**
  89269. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89270. */
  89271. spriteRandomStartCell: boolean;
  89272. /**
  89273. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89274. */
  89275. isAnimationSheetEnabled: boolean;
  89276. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89277. translationPivot: Vector2;
  89278. /**
  89279. * Gets or sets a texture used to add random noise to particle positions
  89280. */
  89281. noiseTexture: Nullable<BaseTexture>;
  89282. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89283. noiseStrength: Vector3;
  89284. /**
  89285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89287. */
  89288. billboardMode: number;
  89289. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89290. limitVelocityDamping: number;
  89291. /**
  89292. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89293. */
  89294. beginAnimationOnStart: boolean;
  89295. /**
  89296. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89297. */
  89298. beginAnimationFrom: number;
  89299. /**
  89300. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89301. */
  89302. beginAnimationTo: number;
  89303. /**
  89304. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89305. */
  89306. beginAnimationLoop: boolean;
  89307. /**
  89308. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89309. */
  89310. disposeOnStop: boolean;
  89311. /**
  89312. * Specifies if the particles are updated in emitter local space or world space
  89313. */
  89314. isLocal: boolean;
  89315. /** Snippet ID if the particle system was created from the snippet server */
  89316. snippetId: string;
  89317. /**
  89318. * Gets the maximum number of particles active at the same time.
  89319. * @returns The max number of active particles.
  89320. */
  89321. getCapacity(): number;
  89322. /**
  89323. * Gets the number of particles active at the same time.
  89324. * @returns The number of active particles.
  89325. */
  89326. getActiveCount(): number;
  89327. /**
  89328. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89329. * @returns True if it has been started, otherwise false.
  89330. */
  89331. isStarted(): boolean;
  89332. /**
  89333. * Animates the particle system for this frame.
  89334. */
  89335. animate(): void;
  89336. /**
  89337. * Renders the particle system in its current state.
  89338. * @returns the current number of particles
  89339. */
  89340. render(): number;
  89341. /**
  89342. * Dispose the particle system and frees its associated resources.
  89343. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89344. */
  89345. dispose(disposeTexture?: boolean): void;
  89346. /**
  89347. * Clones the particle system.
  89348. * @param name The name of the cloned object
  89349. * @param newEmitter The new emitter to use
  89350. * @returns the cloned particle system
  89351. */
  89352. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89353. /**
  89354. * Serializes the particle system to a JSON object
  89355. * @param serializeTexture defines if the texture must be serialized as well
  89356. * @returns the JSON object
  89357. */
  89358. serialize(serializeTexture: boolean): any;
  89359. /**
  89360. * Rebuild the particle system
  89361. */
  89362. rebuild(): void;
  89363. /** Force the system to rebuild all gradients that need to be resync */
  89364. forceRefreshGradients(): void;
  89365. /**
  89366. * Starts the particle system and begins to emit
  89367. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89368. */
  89369. start(delay?: number): void;
  89370. /**
  89371. * Stops the particle system.
  89372. */
  89373. stop(): void;
  89374. /**
  89375. * Remove all active particles
  89376. */
  89377. reset(): void;
  89378. /**
  89379. * Gets a boolean indicating that the system is stopping
  89380. * @returns true if the system is currently stopping
  89381. */
  89382. isStopping(): boolean;
  89383. /**
  89384. * Is this system ready to be used/rendered
  89385. * @return true if the system is ready
  89386. */
  89387. isReady(): boolean;
  89388. /**
  89389. * Returns the string "ParticleSystem"
  89390. * @returns a string containing the class name
  89391. */
  89392. getClassName(): string;
  89393. /**
  89394. * Adds a new color gradient
  89395. * @param gradient defines the gradient to use (between 0 and 1)
  89396. * @param color1 defines the color to affect to the specified gradient
  89397. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89398. * @returns the current particle system
  89399. */
  89400. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89401. /**
  89402. * Remove a specific color gradient
  89403. * @param gradient defines the gradient to remove
  89404. * @returns the current particle system
  89405. */
  89406. removeColorGradient(gradient: number): IParticleSystem;
  89407. /**
  89408. * Adds a new size gradient
  89409. * @param gradient defines the gradient to use (between 0 and 1)
  89410. * @param factor defines the size factor to affect to the specified gradient
  89411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89412. * @returns the current particle system
  89413. */
  89414. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89415. /**
  89416. * Remove a specific size gradient
  89417. * @param gradient defines the gradient to remove
  89418. * @returns the current particle system
  89419. */
  89420. removeSizeGradient(gradient: number): IParticleSystem;
  89421. /**
  89422. * Gets the current list of color gradients.
  89423. * You must use addColorGradient and removeColorGradient to udpate this list
  89424. * @returns the list of color gradients
  89425. */
  89426. getColorGradients(): Nullable<Array<ColorGradient>>;
  89427. /**
  89428. * Gets the current list of size gradients.
  89429. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89430. * @returns the list of size gradients
  89431. */
  89432. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89433. /**
  89434. * Gets the current list of angular speed gradients.
  89435. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89436. * @returns the list of angular speed gradients
  89437. */
  89438. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89439. /**
  89440. * Adds a new angular speed gradient
  89441. * @param gradient defines the gradient to use (between 0 and 1)
  89442. * @param factor defines the angular speed to affect to the specified gradient
  89443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89444. * @returns the current particle system
  89445. */
  89446. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89447. /**
  89448. * Remove a specific angular speed gradient
  89449. * @param gradient defines the gradient to remove
  89450. * @returns the current particle system
  89451. */
  89452. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89453. /**
  89454. * Gets the current list of velocity gradients.
  89455. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89456. * @returns the list of velocity gradients
  89457. */
  89458. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89459. /**
  89460. * Adds a new velocity gradient
  89461. * @param gradient defines the gradient to use (between 0 and 1)
  89462. * @param factor defines the velocity to affect to the specified gradient
  89463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89464. * @returns the current particle system
  89465. */
  89466. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89467. /**
  89468. * Remove a specific velocity gradient
  89469. * @param gradient defines the gradient to remove
  89470. * @returns the current particle system
  89471. */
  89472. removeVelocityGradient(gradient: number): IParticleSystem;
  89473. /**
  89474. * Gets the current list of limit velocity gradients.
  89475. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89476. * @returns the list of limit velocity gradients
  89477. */
  89478. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89479. /**
  89480. * Adds a new limit velocity gradient
  89481. * @param gradient defines the gradient to use (between 0 and 1)
  89482. * @param factor defines the limit velocity to affect to the specified gradient
  89483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89484. * @returns the current particle system
  89485. */
  89486. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89487. /**
  89488. * Remove a specific limit velocity gradient
  89489. * @param gradient defines the gradient to remove
  89490. * @returns the current particle system
  89491. */
  89492. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89493. /**
  89494. * Adds a new drag gradient
  89495. * @param gradient defines the gradient to use (between 0 and 1)
  89496. * @param factor defines the drag to affect to the specified gradient
  89497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89498. * @returns the current particle system
  89499. */
  89500. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89501. /**
  89502. * Remove a specific drag gradient
  89503. * @param gradient defines the gradient to remove
  89504. * @returns the current particle system
  89505. */
  89506. removeDragGradient(gradient: number): IParticleSystem;
  89507. /**
  89508. * Gets the current list of drag gradients.
  89509. * You must use addDragGradient and removeDragGradient to udpate this list
  89510. * @returns the list of drag gradients
  89511. */
  89512. getDragGradients(): Nullable<Array<FactorGradient>>;
  89513. /**
  89514. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89515. * @param gradient defines the gradient to use (between 0 and 1)
  89516. * @param factor defines the emit rate to affect to the specified gradient
  89517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89518. * @returns the current particle system
  89519. */
  89520. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89521. /**
  89522. * Remove a specific emit rate gradient
  89523. * @param gradient defines the gradient to remove
  89524. * @returns the current particle system
  89525. */
  89526. removeEmitRateGradient(gradient: number): IParticleSystem;
  89527. /**
  89528. * Gets the current list of emit rate gradients.
  89529. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89530. * @returns the list of emit rate gradients
  89531. */
  89532. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89533. /**
  89534. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89535. * @param gradient defines the gradient to use (between 0 and 1)
  89536. * @param factor defines the start size to affect to the specified gradient
  89537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89538. * @returns the current particle system
  89539. */
  89540. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89541. /**
  89542. * Remove a specific start size gradient
  89543. * @param gradient defines the gradient to remove
  89544. * @returns the current particle system
  89545. */
  89546. removeStartSizeGradient(gradient: number): IParticleSystem;
  89547. /**
  89548. * Gets the current list of start size gradients.
  89549. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89550. * @returns the list of start size gradients
  89551. */
  89552. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89553. /**
  89554. * Adds a new life time gradient
  89555. * @param gradient defines the gradient to use (between 0 and 1)
  89556. * @param factor defines the life time factor to affect to the specified gradient
  89557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89558. * @returns the current particle system
  89559. */
  89560. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89561. /**
  89562. * Remove a specific life time gradient
  89563. * @param gradient defines the gradient to remove
  89564. * @returns the current particle system
  89565. */
  89566. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89567. /**
  89568. * Gets the current list of life time gradients.
  89569. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89570. * @returns the list of life time gradients
  89571. */
  89572. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89573. /**
  89574. * Gets the current list of color gradients.
  89575. * You must use addColorGradient and removeColorGradient to udpate this list
  89576. * @returns the list of color gradients
  89577. */
  89578. getColorGradients(): Nullable<Array<ColorGradient>>;
  89579. /**
  89580. * Adds a new ramp gradient used to remap particle colors
  89581. * @param gradient defines the gradient to use (between 0 and 1)
  89582. * @param color defines the color to affect to the specified gradient
  89583. * @returns the current particle system
  89584. */
  89585. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89586. /**
  89587. * Gets the current list of ramp gradients.
  89588. * You must use addRampGradient and removeRampGradient to udpate this list
  89589. * @returns the list of ramp gradients
  89590. */
  89591. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89592. /** Gets or sets a boolean indicating that ramp gradients must be used
  89593. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89594. */
  89595. useRampGradients: boolean;
  89596. /**
  89597. * Adds a new color remap gradient
  89598. * @param gradient defines the gradient to use (between 0 and 1)
  89599. * @param min defines the color remap minimal range
  89600. * @param max defines the color remap maximal range
  89601. * @returns the current particle system
  89602. */
  89603. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89604. /**
  89605. * Gets the current list of color remap gradients.
  89606. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89607. * @returns the list of color remap gradients
  89608. */
  89609. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89610. /**
  89611. * Adds a new alpha remap gradient
  89612. * @param gradient defines the gradient to use (between 0 and 1)
  89613. * @param min defines the alpha remap minimal range
  89614. * @param max defines the alpha remap maximal range
  89615. * @returns the current particle system
  89616. */
  89617. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89618. /**
  89619. * Gets the current list of alpha remap gradients.
  89620. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89621. * @returns the list of alpha remap gradients
  89622. */
  89623. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89624. /**
  89625. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89628. * @returns the emitter
  89629. */
  89630. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89631. /**
  89632. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89633. * @param radius The radius of the hemisphere to emit from
  89634. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89635. * @returns the emitter
  89636. */
  89637. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89638. /**
  89639. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89640. * @param radius The radius of the sphere to emit from
  89641. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89642. * @returns the emitter
  89643. */
  89644. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89645. /**
  89646. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89647. * @param radius The radius of the sphere to emit from
  89648. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89649. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89650. * @returns the emitter
  89651. */
  89652. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89653. /**
  89654. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89655. * @param radius The radius of the emission cylinder
  89656. * @param height The height of the emission cylinder
  89657. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89658. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89659. * @returns the emitter
  89660. */
  89661. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89662. /**
  89663. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89664. * @param radius The radius of the cylinder to emit from
  89665. * @param height The height of the emission cylinder
  89666. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89669. * @returns the emitter
  89670. */
  89671. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89672. /**
  89673. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89674. * @param radius The radius of the cone to emit from
  89675. * @param angle The base angle of the cone
  89676. * @returns the emitter
  89677. */
  89678. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89679. /**
  89680. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  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. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89684. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89685. * @returns the emitter
  89686. */
  89687. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89688. /**
  89689. * Get hosting scene
  89690. * @returns the scene
  89691. */
  89692. getScene(): Scene;
  89693. }
  89694. }
  89695. declare module BABYLON {
  89696. /**
  89697. * 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.
  89698. * @see https://doc.babylonjs.com/how_to/transformnode
  89699. */
  89700. export class TransformNode extends Node {
  89701. /**
  89702. * Object will not rotate to face the camera
  89703. */
  89704. static BILLBOARDMODE_NONE: number;
  89705. /**
  89706. * Object will rotate to face the camera but only on the x axis
  89707. */
  89708. static BILLBOARDMODE_X: number;
  89709. /**
  89710. * Object will rotate to face the camera but only on the y axis
  89711. */
  89712. static BILLBOARDMODE_Y: number;
  89713. /**
  89714. * Object will rotate to face the camera but only on the z axis
  89715. */
  89716. static BILLBOARDMODE_Z: number;
  89717. /**
  89718. * Object will rotate to face the camera
  89719. */
  89720. static BILLBOARDMODE_ALL: number;
  89721. /**
  89722. * Object will rotate to face the camera's position instead of orientation
  89723. */
  89724. static BILLBOARDMODE_USE_POSITION: number;
  89725. private _forward;
  89726. private _forwardInverted;
  89727. private _up;
  89728. private _right;
  89729. private _rightInverted;
  89730. private _position;
  89731. private _rotation;
  89732. private _rotationQuaternion;
  89733. protected _scaling: Vector3;
  89734. protected _isDirty: boolean;
  89735. private _transformToBoneReferal;
  89736. private _isAbsoluteSynced;
  89737. private _billboardMode;
  89738. /**
  89739. * Gets or sets the billboard mode. Default is 0.
  89740. *
  89741. * | Value | Type | Description |
  89742. * | --- | --- | --- |
  89743. * | 0 | BILLBOARDMODE_NONE | |
  89744. * | 1 | BILLBOARDMODE_X | |
  89745. * | 2 | BILLBOARDMODE_Y | |
  89746. * | 4 | BILLBOARDMODE_Z | |
  89747. * | 7 | BILLBOARDMODE_ALL | |
  89748. *
  89749. */
  89750. get billboardMode(): number;
  89751. set billboardMode(value: number);
  89752. private _preserveParentRotationForBillboard;
  89753. /**
  89754. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  89755. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  89756. */
  89757. get preserveParentRotationForBillboard(): boolean;
  89758. set preserveParentRotationForBillboard(value: boolean);
  89759. /**
  89760. * 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
  89761. */
  89762. scalingDeterminant: number;
  89763. private _infiniteDistance;
  89764. /**
  89765. * Gets or sets the distance of the object to max, often used by skybox
  89766. */
  89767. get infiniteDistance(): boolean;
  89768. set infiniteDistance(value: boolean);
  89769. /**
  89770. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89771. * By default the system will update normals to compensate
  89772. */
  89773. ignoreNonUniformScaling: boolean;
  89774. /**
  89775. * 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
  89776. */
  89777. reIntegrateRotationIntoRotationQuaternion: boolean;
  89778. /** @hidden */
  89779. _poseMatrix: Nullable<Matrix>;
  89780. /** @hidden */
  89781. _localMatrix: Matrix;
  89782. private _usePivotMatrix;
  89783. private _absolutePosition;
  89784. private _absoluteScaling;
  89785. private _absoluteRotationQuaternion;
  89786. private _pivotMatrix;
  89787. private _pivotMatrixInverse;
  89788. protected _postMultiplyPivotMatrix: boolean;
  89789. protected _isWorldMatrixFrozen: boolean;
  89790. /** @hidden */
  89791. _indexInSceneTransformNodesArray: number;
  89792. /**
  89793. * An event triggered after the world matrix is updated
  89794. */
  89795. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  89796. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  89797. /**
  89798. * Gets a string identifying the name of the class
  89799. * @returns "TransformNode" string
  89800. */
  89801. getClassName(): string;
  89802. /**
  89803. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89804. */
  89805. get position(): Vector3;
  89806. set position(newPosition: Vector3);
  89807. /**
  89808. * 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)).
  89809. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89810. */
  89811. get rotation(): Vector3;
  89812. set rotation(newRotation: Vector3);
  89813. /**
  89814. * 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)).
  89815. */
  89816. get scaling(): Vector3;
  89817. set scaling(newScaling: Vector3);
  89818. /**
  89819. * 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).
  89820. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89821. */
  89822. get rotationQuaternion(): Nullable<Quaternion>;
  89823. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  89824. /**
  89825. * The forward direction of that transform in world space.
  89826. */
  89827. get forward(): Vector3;
  89828. /**
  89829. * The up direction of that transform in world space.
  89830. */
  89831. get up(): Vector3;
  89832. /**
  89833. * The right direction of that transform in world space.
  89834. */
  89835. get right(): Vector3;
  89836. /**
  89837. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89838. * @param matrix the matrix to copy the pose from
  89839. * @returns this TransformNode.
  89840. */
  89841. updatePoseMatrix(matrix: Matrix): TransformNode;
  89842. /**
  89843. * Returns the mesh Pose matrix.
  89844. * @returns the pose matrix
  89845. */
  89846. getPoseMatrix(): Matrix;
  89847. /** @hidden */
  89848. _isSynchronized(): boolean;
  89849. /** @hidden */
  89850. _initCache(): void;
  89851. /**
  89852. * Flag the transform node as dirty (Forcing it to update everything)
  89853. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89854. * @returns this transform node
  89855. */
  89856. markAsDirty(property: string): TransformNode;
  89857. /**
  89858. * Returns the current mesh absolute position.
  89859. * Returns a Vector3.
  89860. */
  89861. get absolutePosition(): Vector3;
  89862. /**
  89863. * Returns the current mesh absolute scaling.
  89864. * Returns a Vector3.
  89865. */
  89866. get absoluteScaling(): Vector3;
  89867. /**
  89868. * Returns the current mesh absolute rotation.
  89869. * Returns a Quaternion.
  89870. */
  89871. get absoluteRotationQuaternion(): Quaternion;
  89872. /**
  89873. * Sets a new matrix to apply before all other transformation
  89874. * @param matrix defines the transform matrix
  89875. * @returns the current TransformNode
  89876. */
  89877. setPreTransformMatrix(matrix: Matrix): TransformNode;
  89878. /**
  89879. * Sets a new pivot matrix to the current node
  89880. * @param matrix defines the new pivot matrix to use
  89881. * @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
  89882. * @returns the current TransformNode
  89883. */
  89884. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  89885. /**
  89886. * Returns the mesh pivot matrix.
  89887. * Default : Identity.
  89888. * @returns the matrix
  89889. */
  89890. getPivotMatrix(): Matrix;
  89891. /**
  89892. * Instantiate (when possible) or clone that node with its hierarchy
  89893. * @param newParent defines the new parent to use for the instance (or clone)
  89894. * @param options defines options to configure how copy is done
  89895. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  89896. * @returns an instance (or a clone) of the current node with its hiearchy
  89897. */
  89898. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  89899. doNotInstantiate: boolean;
  89900. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  89901. /**
  89902. * Prevents the World matrix to be computed any longer
  89903. * @param newWorldMatrix defines an optional matrix to use as world matrix
  89904. * @returns the TransformNode.
  89905. */
  89906. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  89907. /**
  89908. * Allows back the World matrix computation.
  89909. * @returns the TransformNode.
  89910. */
  89911. unfreezeWorldMatrix(): this;
  89912. /**
  89913. * True if the World matrix has been frozen.
  89914. */
  89915. get isWorldMatrixFrozen(): boolean;
  89916. /**
  89917. * Retuns the mesh absolute position in the World.
  89918. * @returns a Vector3.
  89919. */
  89920. getAbsolutePosition(): Vector3;
  89921. /**
  89922. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89923. * @param absolutePosition the absolute position to set
  89924. * @returns the TransformNode.
  89925. */
  89926. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89927. /**
  89928. * Sets the mesh position in its local space.
  89929. * @param vector3 the position to set in localspace
  89930. * @returns the TransformNode.
  89931. */
  89932. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  89933. /**
  89934. * Returns the mesh position in the local space from the current World matrix values.
  89935. * @returns a new Vector3.
  89936. */
  89937. getPositionExpressedInLocalSpace(): Vector3;
  89938. /**
  89939. * Translates the mesh along the passed Vector3 in its local space.
  89940. * @param vector3 the distance to translate in localspace
  89941. * @returns the TransformNode.
  89942. */
  89943. locallyTranslate(vector3: Vector3): TransformNode;
  89944. private static _lookAtVectorCache;
  89945. /**
  89946. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89947. * @param targetPoint the position (must be in same space as current mesh) to look at
  89948. * @param yawCor optional yaw (y-axis) correction in radians
  89949. * @param pitchCor optional pitch (x-axis) correction in radians
  89950. * @param rollCor optional roll (z-axis) correction in radians
  89951. * @param space the choosen space of the target
  89952. * @returns the TransformNode.
  89953. */
  89954. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  89955. /**
  89956. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89957. * This Vector3 is expressed in the World space.
  89958. * @param localAxis axis to rotate
  89959. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89960. */
  89961. getDirection(localAxis: Vector3): Vector3;
  89962. /**
  89963. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89964. * localAxis is expressed in the mesh local space.
  89965. * result is computed in the Wordl space from the mesh World matrix.
  89966. * @param localAxis axis to rotate
  89967. * @param result the resulting transformnode
  89968. * @returns this TransformNode.
  89969. */
  89970. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  89971. /**
  89972. * Sets this transform node rotation to the given local axis.
  89973. * @param localAxis the axis in local space
  89974. * @param yawCor optional yaw (y-axis) correction in radians
  89975. * @param pitchCor optional pitch (x-axis) correction in radians
  89976. * @param rollCor optional roll (z-axis) correction in radians
  89977. * @returns this TransformNode
  89978. */
  89979. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  89980. /**
  89981. * Sets a new pivot point to the current node
  89982. * @param point defines the new pivot point to use
  89983. * @param space defines if the point is in world or local space (local by default)
  89984. * @returns the current TransformNode
  89985. */
  89986. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  89987. /**
  89988. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89989. * @returns the pivot point
  89990. */
  89991. getPivotPoint(): Vector3;
  89992. /**
  89993. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89994. * @param result the vector3 to store the result
  89995. * @returns this TransformNode.
  89996. */
  89997. getPivotPointToRef(result: Vector3): TransformNode;
  89998. /**
  89999. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  90000. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  90001. */
  90002. getAbsolutePivotPoint(): Vector3;
  90003. /**
  90004. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  90005. * @param result vector3 to store the result
  90006. * @returns this TransformNode.
  90007. */
  90008. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  90009. /**
  90010. * Defines the passed node as the parent of the current node.
  90011. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  90012. * @see https://doc.babylonjs.com/how_to/parenting
  90013. * @param node the node ot set as the parent
  90014. * @returns this TransformNode.
  90015. */
  90016. setParent(node: Nullable<Node>): TransformNode;
  90017. private _nonUniformScaling;
  90018. /**
  90019. * True if the scaling property of this object is non uniform eg. (1,2,1)
  90020. */
  90021. get nonUniformScaling(): boolean;
  90022. /** @hidden */
  90023. _updateNonUniformScalingState(value: boolean): boolean;
  90024. /**
  90025. * Attach the current TransformNode to another TransformNode associated with a bone
  90026. * @param bone Bone affecting the TransformNode
  90027. * @param affectedTransformNode TransformNode associated with the bone
  90028. * @returns this object
  90029. */
  90030. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  90031. /**
  90032. * Detach the transform node if its associated with a bone
  90033. * @returns this object
  90034. */
  90035. detachFromBone(): TransformNode;
  90036. private static _rotationAxisCache;
  90037. /**
  90038. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  90039. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90040. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90041. * The passed axis is also normalized.
  90042. * @param axis the axis to rotate around
  90043. * @param amount the amount to rotate in radians
  90044. * @param space Space to rotate in (Default: local)
  90045. * @returns the TransformNode.
  90046. */
  90047. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90048. /**
  90049. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  90050. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90051. * The passed axis is also normalized. .
  90052. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90053. * @param point the point to rotate around
  90054. * @param axis the axis to rotate around
  90055. * @param amount the amount to rotate in radians
  90056. * @returns the TransformNode
  90057. */
  90058. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  90059. /**
  90060. * Translates the mesh along the axis vector for the passed distance in the given space.
  90061. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90062. * @param axis the axis to translate in
  90063. * @param distance the distance to translate
  90064. * @param space Space to rotate in (Default: local)
  90065. * @returns the TransformNode.
  90066. */
  90067. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90068. /**
  90069. * Adds a rotation step to the mesh current rotation.
  90070. * x, y, z are Euler angles expressed in radians.
  90071. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90072. * This means this rotation is made in the mesh local space only.
  90073. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90074. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90075. * ```javascript
  90076. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90077. * ```
  90078. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90079. * 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.
  90080. * @param x Rotation to add
  90081. * @param y Rotation to add
  90082. * @param z Rotation to add
  90083. * @returns the TransformNode.
  90084. */
  90085. addRotation(x: number, y: number, z: number): TransformNode;
  90086. /**
  90087. * @hidden
  90088. */
  90089. protected _getEffectiveParent(): Nullable<Node>;
  90090. /**
  90091. * Computes the world matrix of the node
  90092. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90093. * @returns the world matrix
  90094. */
  90095. computeWorldMatrix(force?: boolean): Matrix;
  90096. /**
  90097. * Resets this nodeTransform's local matrix to Matrix.Identity().
  90098. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  90099. */
  90100. resetLocalMatrix(independentOfChildren?: boolean): void;
  90101. protected _afterComputeWorldMatrix(): void;
  90102. /**
  90103. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  90104. * @param func callback function to add
  90105. *
  90106. * @returns the TransformNode.
  90107. */
  90108. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  90109. /**
  90110. * Removes a registered callback function.
  90111. * @param func callback function to remove
  90112. * @returns the TransformNode.
  90113. */
  90114. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  90115. /**
  90116. * Gets the position of the current mesh in camera space
  90117. * @param camera defines the camera to use
  90118. * @returns a position
  90119. */
  90120. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  90121. /**
  90122. * Returns the distance from the mesh to the active camera
  90123. * @param camera defines the camera to use
  90124. * @returns the distance
  90125. */
  90126. getDistanceToCamera(camera?: Nullable<Camera>): number;
  90127. /**
  90128. * Clone the current transform node
  90129. * @param name Name of the new clone
  90130. * @param newParent New parent for the clone
  90131. * @param doNotCloneChildren Do not clone children hierarchy
  90132. * @returns the new transform node
  90133. */
  90134. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  90135. /**
  90136. * Serializes the objects information.
  90137. * @param currentSerializationObject defines the object to serialize in
  90138. * @returns the serialized object
  90139. */
  90140. serialize(currentSerializationObject?: any): any;
  90141. /**
  90142. * Returns a new TransformNode object parsed from the source provided.
  90143. * @param parsedTransformNode is the source.
  90144. * @param scene the scne the object belongs to
  90145. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  90146. * @returns a new TransformNode object parsed from the source provided.
  90147. */
  90148. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  90149. /**
  90150. * Get all child-transformNodes of this node
  90151. * @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
  90152. * @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
  90153. * @returns an array of TransformNode
  90154. */
  90155. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  90156. /**
  90157. * Releases resources associated with this transform node.
  90158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90160. */
  90161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90162. /**
  90163. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90164. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90165. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90166. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90167. * @returns the current mesh
  90168. */
  90169. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  90170. private _syncAbsoluteScalingAndRotation;
  90171. }
  90172. }
  90173. declare module BABYLON {
  90174. /**
  90175. * Class used to override all child animations of a given target
  90176. */
  90177. export class AnimationPropertiesOverride {
  90178. /**
  90179. * Gets or sets a value indicating if animation blending must be used
  90180. */
  90181. enableBlending: boolean;
  90182. /**
  90183. * Gets or sets the blending speed to use when enableBlending is true
  90184. */
  90185. blendingSpeed: number;
  90186. /**
  90187. * Gets or sets the default loop mode to use
  90188. */
  90189. loopMode: number;
  90190. }
  90191. }
  90192. declare module BABYLON {
  90193. /**
  90194. * Class used to store bone information
  90195. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90196. */
  90197. export class Bone extends Node {
  90198. /**
  90199. * defines the bone name
  90200. */
  90201. name: string;
  90202. private static _tmpVecs;
  90203. private static _tmpQuat;
  90204. private static _tmpMats;
  90205. /**
  90206. * Gets the list of child bones
  90207. */
  90208. children: Bone[];
  90209. /** Gets the animations associated with this bone */
  90210. animations: Animation[];
  90211. /**
  90212. * Gets or sets bone length
  90213. */
  90214. length: number;
  90215. /**
  90216. * @hidden Internal only
  90217. * Set this value to map this bone to a different index in the transform matrices
  90218. * Set this value to -1 to exclude the bone from the transform matrices
  90219. */
  90220. _index: Nullable<number>;
  90221. private _skeleton;
  90222. private _localMatrix;
  90223. private _restPose;
  90224. private _baseMatrix;
  90225. private _absoluteTransform;
  90226. private _invertedAbsoluteTransform;
  90227. private _parent;
  90228. private _scalingDeterminant;
  90229. private _worldTransform;
  90230. private _localScaling;
  90231. private _localRotation;
  90232. private _localPosition;
  90233. private _needToDecompose;
  90234. private _needToCompose;
  90235. /** @hidden */
  90236. _linkedTransformNode: Nullable<TransformNode>;
  90237. /** @hidden */
  90238. _waitingTransformNodeId: Nullable<string>;
  90239. /** @hidden */
  90240. get _matrix(): Matrix;
  90241. /** @hidden */
  90242. set _matrix(value: Matrix);
  90243. /**
  90244. * Create a new bone
  90245. * @param name defines the bone name
  90246. * @param skeleton defines the parent skeleton
  90247. * @param parentBone defines the parent (can be null if the bone is the root)
  90248. * @param localMatrix defines the local matrix
  90249. * @param restPose defines the rest pose matrix
  90250. * @param baseMatrix defines the base matrix
  90251. * @param index defines index of the bone in the hiearchy
  90252. */
  90253. constructor(
  90254. /**
  90255. * defines the bone name
  90256. */
  90257. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  90258. /**
  90259. * Gets the current object class name.
  90260. * @return the class name
  90261. */
  90262. getClassName(): string;
  90263. /**
  90264. * Gets the parent skeleton
  90265. * @returns a skeleton
  90266. */
  90267. getSkeleton(): Skeleton;
  90268. /**
  90269. * Gets parent bone
  90270. * @returns a bone or null if the bone is the root of the bone hierarchy
  90271. */
  90272. getParent(): Nullable<Bone>;
  90273. /**
  90274. * Returns an array containing the root bones
  90275. * @returns an array containing the root bones
  90276. */
  90277. getChildren(): Array<Bone>;
  90278. /**
  90279. * Gets the node index in matrix array generated for rendering
  90280. * @returns the node index
  90281. */
  90282. getIndex(): number;
  90283. /**
  90284. * Sets the parent bone
  90285. * @param parent defines the parent (can be null if the bone is the root)
  90286. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90287. */
  90288. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  90289. /**
  90290. * Gets the local matrix
  90291. * @returns a matrix
  90292. */
  90293. getLocalMatrix(): Matrix;
  90294. /**
  90295. * Gets the base matrix (initial matrix which remains unchanged)
  90296. * @returns a matrix
  90297. */
  90298. getBaseMatrix(): Matrix;
  90299. /**
  90300. * Gets the rest pose matrix
  90301. * @returns a matrix
  90302. */
  90303. getRestPose(): Matrix;
  90304. /**
  90305. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  90306. */
  90307. getWorldMatrix(): Matrix;
  90308. /**
  90309. * Sets the local matrix to rest pose matrix
  90310. */
  90311. returnToRest(): void;
  90312. /**
  90313. * Gets the inverse of the absolute transform matrix.
  90314. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  90315. * @returns a matrix
  90316. */
  90317. getInvertedAbsoluteTransform(): Matrix;
  90318. /**
  90319. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  90320. * @returns a matrix
  90321. */
  90322. getAbsoluteTransform(): Matrix;
  90323. /**
  90324. * Links with the given transform node.
  90325. * The local matrix of this bone is copied from the transform node every frame.
  90326. * @param transformNode defines the transform node to link to
  90327. */
  90328. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  90329. /**
  90330. * Gets the node used to drive the bone's transformation
  90331. * @returns a transform node or null
  90332. */
  90333. getTransformNode(): Nullable<TransformNode>;
  90334. /** Gets or sets current position (in local space) */
  90335. get position(): Vector3;
  90336. set position(newPosition: Vector3);
  90337. /** Gets or sets current rotation (in local space) */
  90338. get rotation(): Vector3;
  90339. set rotation(newRotation: Vector3);
  90340. /** Gets or sets current rotation quaternion (in local space) */
  90341. get rotationQuaternion(): Quaternion;
  90342. set rotationQuaternion(newRotation: Quaternion);
  90343. /** Gets or sets current scaling (in local space) */
  90344. get scaling(): Vector3;
  90345. set scaling(newScaling: Vector3);
  90346. /**
  90347. * Gets the animation properties override
  90348. */
  90349. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90350. private _decompose;
  90351. private _compose;
  90352. /**
  90353. * Update the base and local matrices
  90354. * @param matrix defines the new base or local matrix
  90355. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90356. * @param updateLocalMatrix defines if the local matrix should be updated
  90357. */
  90358. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  90359. /** @hidden */
  90360. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  90361. /**
  90362. * Flag the bone as dirty (Forcing it to update everything)
  90363. */
  90364. markAsDirty(): void;
  90365. /** @hidden */
  90366. _markAsDirtyAndCompose(): void;
  90367. private _markAsDirtyAndDecompose;
  90368. /**
  90369. * Translate the bone in local or world space
  90370. * @param vec The amount to translate the bone
  90371. * @param space The space that the translation is in
  90372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90373. */
  90374. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90375. /**
  90376. * Set the postion of the bone in local or world space
  90377. * @param position The position to set the bone
  90378. * @param space The space that the position is in
  90379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90380. */
  90381. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90382. /**
  90383. * Set the absolute position of the bone (world space)
  90384. * @param position The position to set the bone
  90385. * @param mesh The mesh that this bone is attached to
  90386. */
  90387. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  90388. /**
  90389. * Scale the bone on the x, y and z axes (in local space)
  90390. * @param x The amount to scale the bone on the x axis
  90391. * @param y The amount to scale the bone on the y axis
  90392. * @param z The amount to scale the bone on the z axis
  90393. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  90394. */
  90395. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  90396. /**
  90397. * Set the bone scaling in local space
  90398. * @param scale defines the scaling vector
  90399. */
  90400. setScale(scale: Vector3): void;
  90401. /**
  90402. * Gets the current scaling in local space
  90403. * @returns the current scaling vector
  90404. */
  90405. getScale(): Vector3;
  90406. /**
  90407. * Gets the current scaling in local space and stores it in a target vector
  90408. * @param result defines the target vector
  90409. */
  90410. getScaleToRef(result: Vector3): void;
  90411. /**
  90412. * Set the yaw, pitch, and roll of the bone in local or world space
  90413. * @param yaw The rotation of the bone on the y axis
  90414. * @param pitch The rotation of the bone on the x axis
  90415. * @param roll The rotation of the bone on the z axis
  90416. * @param space The space that the axes of rotation are in
  90417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90418. */
  90419. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  90420. /**
  90421. * Add a rotation to the bone on an axis in local or world space
  90422. * @param axis The axis to rotate the bone on
  90423. * @param amount The amount to rotate the bone
  90424. * @param space The space that the axis is in
  90425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90426. */
  90427. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  90428. /**
  90429. * Set the rotation of the bone to a particular axis angle in local or world space
  90430. * @param axis The axis to rotate the bone on
  90431. * @param angle The angle that the bone should be rotated to
  90432. * @param space The space that the axis is in
  90433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90434. */
  90435. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  90436. /**
  90437. * Set the euler rotation of the bone in local of world space
  90438. * @param rotation The euler rotation that the bone should be set to
  90439. * @param space The space that the rotation is in
  90440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90441. */
  90442. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90443. /**
  90444. * Set the quaternion rotation of the bone in local of world space
  90445. * @param quat The quaternion rotation that the bone should be set to
  90446. * @param space The space that the rotation is in
  90447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90448. */
  90449. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  90450. /**
  90451. * Set the rotation matrix of the bone in local of world space
  90452. * @param rotMat The rotation matrix that the bone should be set to
  90453. * @param space The space that the rotation is in
  90454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90455. */
  90456. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  90457. private _rotateWithMatrix;
  90458. private _getNegativeRotationToRef;
  90459. /**
  90460. * Get the position of the bone in local or world space
  90461. * @param space The space that the returned position is in
  90462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90463. * @returns The position of the bone
  90464. */
  90465. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90466. /**
  90467. * Copy the position of the bone to a vector3 in local or world space
  90468. * @param space The space that the returned position is in
  90469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90470. * @param result The vector3 to copy the position to
  90471. */
  90472. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  90473. /**
  90474. * Get the absolute position of the bone (world space)
  90475. * @param mesh The mesh that this bone is attached to
  90476. * @returns The absolute position of the bone
  90477. */
  90478. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  90479. /**
  90480. * Copy the absolute position of the bone (world space) to the result param
  90481. * @param mesh The mesh that this bone is attached to
  90482. * @param result The vector3 to copy the absolute position to
  90483. */
  90484. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  90485. /**
  90486. * Compute the absolute transforms of this bone and its children
  90487. */
  90488. computeAbsoluteTransforms(): void;
  90489. /**
  90490. * Get the world direction from an axis that is in the local space of the bone
  90491. * @param localAxis The local direction that is used to compute the world direction
  90492. * @param mesh The mesh that this bone is attached to
  90493. * @returns The world direction
  90494. */
  90495. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90496. /**
  90497. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  90498. * @param localAxis The local direction that is used to compute the world direction
  90499. * @param mesh The mesh that this bone is attached to
  90500. * @param result The vector3 that the world direction will be copied to
  90501. */
  90502. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90503. /**
  90504. * Get the euler rotation of the bone in local or world space
  90505. * @param space The space that the rotation should be in
  90506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90507. * @returns The euler rotation
  90508. */
  90509. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90510. /**
  90511. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  90512. * @param space The space that the rotation should be in
  90513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90514. * @param result The vector3 that the rotation should be copied to
  90515. */
  90516. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90517. /**
  90518. * Get the quaternion rotation of the bone in either local or world space
  90519. * @param space The space that the rotation should be in
  90520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90521. * @returns The quaternion rotation
  90522. */
  90523. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  90524. /**
  90525. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  90526. * @param space The space that the rotation should be in
  90527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90528. * @param result The quaternion that the rotation should be copied to
  90529. */
  90530. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  90531. /**
  90532. * Get the rotation matrix of the bone in local or world space
  90533. * @param space The space that the rotation should be in
  90534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90535. * @returns The rotation matrix
  90536. */
  90537. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  90538. /**
  90539. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  90540. * @param space The space that the rotation should be in
  90541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90542. * @param result The quaternion that the rotation should be copied to
  90543. */
  90544. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  90545. /**
  90546. * Get the world position of a point that is in the local space of the bone
  90547. * @param position The local position
  90548. * @param mesh The mesh that this bone is attached to
  90549. * @returns The world position
  90550. */
  90551. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90552. /**
  90553. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  90554. * @param position The local position
  90555. * @param mesh The mesh that this bone is attached to
  90556. * @param result The vector3 that the world position should be copied to
  90557. */
  90558. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90559. /**
  90560. * Get the local position of a point that is in world space
  90561. * @param position The world position
  90562. * @param mesh The mesh that this bone is attached to
  90563. * @returns The local position
  90564. */
  90565. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90566. /**
  90567. * Get the local position of a point that is in world space and copy it to the result param
  90568. * @param position The world position
  90569. * @param mesh The mesh that this bone is attached to
  90570. * @param result The vector3 that the local position should be copied to
  90571. */
  90572. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90573. }
  90574. }
  90575. declare module BABYLON {
  90576. /**
  90577. * Defines a runtime animation
  90578. */
  90579. export class RuntimeAnimation {
  90580. private _events;
  90581. /**
  90582. * The current frame of the runtime animation
  90583. */
  90584. private _currentFrame;
  90585. /**
  90586. * The animation used by the runtime animation
  90587. */
  90588. private _animation;
  90589. /**
  90590. * The target of the runtime animation
  90591. */
  90592. private _target;
  90593. /**
  90594. * The initiating animatable
  90595. */
  90596. private _host;
  90597. /**
  90598. * The original value of the runtime animation
  90599. */
  90600. private _originalValue;
  90601. /**
  90602. * The original blend value of the runtime animation
  90603. */
  90604. private _originalBlendValue;
  90605. /**
  90606. * The offsets cache of the runtime animation
  90607. */
  90608. private _offsetsCache;
  90609. /**
  90610. * The high limits cache of the runtime animation
  90611. */
  90612. private _highLimitsCache;
  90613. /**
  90614. * Specifies if the runtime animation has been stopped
  90615. */
  90616. private _stopped;
  90617. /**
  90618. * The blending factor of the runtime animation
  90619. */
  90620. private _blendingFactor;
  90621. /**
  90622. * The BabylonJS scene
  90623. */
  90624. private _scene;
  90625. /**
  90626. * The current value of the runtime animation
  90627. */
  90628. private _currentValue;
  90629. /** @hidden */
  90630. _animationState: _IAnimationState;
  90631. /**
  90632. * The active target of the runtime animation
  90633. */
  90634. private _activeTargets;
  90635. private _currentActiveTarget;
  90636. private _directTarget;
  90637. /**
  90638. * The target path of the runtime animation
  90639. */
  90640. private _targetPath;
  90641. /**
  90642. * The weight of the runtime animation
  90643. */
  90644. private _weight;
  90645. /**
  90646. * The ratio offset of the runtime animation
  90647. */
  90648. private _ratioOffset;
  90649. /**
  90650. * The previous delay of the runtime animation
  90651. */
  90652. private _previousDelay;
  90653. /**
  90654. * The previous ratio of the runtime animation
  90655. */
  90656. private _previousRatio;
  90657. private _enableBlending;
  90658. private _keys;
  90659. private _minFrame;
  90660. private _maxFrame;
  90661. private _minValue;
  90662. private _maxValue;
  90663. private _targetIsArray;
  90664. /**
  90665. * Gets the current frame of the runtime animation
  90666. */
  90667. get currentFrame(): number;
  90668. /**
  90669. * Gets the weight of the runtime animation
  90670. */
  90671. get weight(): number;
  90672. /**
  90673. * Gets the current value of the runtime animation
  90674. */
  90675. get currentValue(): any;
  90676. /**
  90677. * Gets the target path of the runtime animation
  90678. */
  90679. get targetPath(): string;
  90680. /**
  90681. * Gets the actual target of the runtime animation
  90682. */
  90683. get target(): any;
  90684. /**
  90685. * Gets the additive state of the runtime animation
  90686. */
  90687. get isAdditive(): boolean;
  90688. /** @hidden */
  90689. _onLoop: () => void;
  90690. /**
  90691. * Create a new RuntimeAnimation object
  90692. * @param target defines the target of the animation
  90693. * @param animation defines the source animation object
  90694. * @param scene defines the hosting scene
  90695. * @param host defines the initiating Animatable
  90696. */
  90697. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  90698. private _preparePath;
  90699. /**
  90700. * Gets the animation from the runtime animation
  90701. */
  90702. get animation(): Animation;
  90703. /**
  90704. * Resets the runtime animation to the beginning
  90705. * @param restoreOriginal defines whether to restore the target property to the original value
  90706. */
  90707. reset(restoreOriginal?: boolean): void;
  90708. /**
  90709. * Specifies if the runtime animation is stopped
  90710. * @returns Boolean specifying if the runtime animation is stopped
  90711. */
  90712. isStopped(): boolean;
  90713. /**
  90714. * Disposes of the runtime animation
  90715. */
  90716. dispose(): void;
  90717. /**
  90718. * Apply the interpolated value to the target
  90719. * @param currentValue defines the value computed by the animation
  90720. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  90721. */
  90722. setValue(currentValue: any, weight: number): void;
  90723. private _getOriginalValues;
  90724. private _setValue;
  90725. /**
  90726. * Gets the loop pmode of the runtime animation
  90727. * @returns Loop Mode
  90728. */
  90729. private _getCorrectLoopMode;
  90730. /**
  90731. * Move the current animation to a given frame
  90732. * @param frame defines the frame to move to
  90733. */
  90734. goToFrame(frame: number): void;
  90735. /**
  90736. * @hidden Internal use only
  90737. */
  90738. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  90739. /**
  90740. * Execute the current animation
  90741. * @param delay defines the delay to add to the current frame
  90742. * @param from defines the lower bound of the animation range
  90743. * @param to defines the upper bound of the animation range
  90744. * @param loop defines if the current animation must loop
  90745. * @param speedRatio defines the current speed ratio
  90746. * @param weight defines the weight of the animation (default is -1 so no weight)
  90747. * @param onLoop optional callback called when animation loops
  90748. * @returns a boolean indicating if the animation is running
  90749. */
  90750. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  90751. }
  90752. }
  90753. declare module BABYLON {
  90754. /**
  90755. * Class used to store an actual running animation
  90756. */
  90757. export class Animatable {
  90758. /** defines the target object */
  90759. target: any;
  90760. /** defines the starting frame number (default is 0) */
  90761. fromFrame: number;
  90762. /** defines the ending frame number (default is 100) */
  90763. toFrame: number;
  90764. /** defines if the animation must loop (default is false) */
  90765. loopAnimation: boolean;
  90766. /** defines a callback to call when animation ends if it is not looping */
  90767. onAnimationEnd?: (() => void) | null | undefined;
  90768. /** defines a callback to call when animation loops */
  90769. onAnimationLoop?: (() => void) | null | undefined;
  90770. /** defines whether the animation should be evaluated additively */
  90771. isAdditive: boolean;
  90772. private _localDelayOffset;
  90773. private _pausedDelay;
  90774. private _runtimeAnimations;
  90775. private _paused;
  90776. private _scene;
  90777. private _speedRatio;
  90778. private _weight;
  90779. private _syncRoot;
  90780. /**
  90781. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  90782. * This will only apply for non looping animation (default is true)
  90783. */
  90784. disposeOnEnd: boolean;
  90785. /**
  90786. * Gets a boolean indicating if the animation has started
  90787. */
  90788. animationStarted: boolean;
  90789. /**
  90790. * Observer raised when the animation ends
  90791. */
  90792. onAnimationEndObservable: Observable<Animatable>;
  90793. /**
  90794. * Observer raised when the animation loops
  90795. */
  90796. onAnimationLoopObservable: Observable<Animatable>;
  90797. /**
  90798. * Gets the root Animatable used to synchronize and normalize animations
  90799. */
  90800. get syncRoot(): Nullable<Animatable>;
  90801. /**
  90802. * Gets the current frame of the first RuntimeAnimation
  90803. * Used to synchronize Animatables
  90804. */
  90805. get masterFrame(): number;
  90806. /**
  90807. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  90808. */
  90809. get weight(): number;
  90810. set weight(value: number);
  90811. /**
  90812. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  90813. */
  90814. get speedRatio(): number;
  90815. set speedRatio(value: number);
  90816. /**
  90817. * Creates a new Animatable
  90818. * @param scene defines the hosting scene
  90819. * @param target defines the target object
  90820. * @param fromFrame defines the starting frame number (default is 0)
  90821. * @param toFrame defines the ending frame number (default is 100)
  90822. * @param loopAnimation defines if the animation must loop (default is false)
  90823. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  90824. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  90825. * @param animations defines a group of animation to add to the new Animatable
  90826. * @param onAnimationLoop defines a callback to call when animation loops
  90827. * @param isAdditive defines whether the animation should be evaluated additively
  90828. */
  90829. constructor(scene: Scene,
  90830. /** defines the target object */
  90831. target: any,
  90832. /** defines the starting frame number (default is 0) */
  90833. fromFrame?: number,
  90834. /** defines the ending frame number (default is 100) */
  90835. toFrame?: number,
  90836. /** defines if the animation must loop (default is false) */
  90837. loopAnimation?: boolean, speedRatio?: number,
  90838. /** defines a callback to call when animation ends if it is not looping */
  90839. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  90840. /** defines a callback to call when animation loops */
  90841. onAnimationLoop?: (() => void) | null | undefined,
  90842. /** defines whether the animation should be evaluated additively */
  90843. isAdditive?: boolean);
  90844. /**
  90845. * Synchronize and normalize current Animatable with a source Animatable
  90846. * This is useful when using animation weights and when animations are not of the same length
  90847. * @param root defines the root Animatable to synchronize with
  90848. * @returns the current Animatable
  90849. */
  90850. syncWith(root: Animatable): Animatable;
  90851. /**
  90852. * Gets the list of runtime animations
  90853. * @returns an array of RuntimeAnimation
  90854. */
  90855. getAnimations(): RuntimeAnimation[];
  90856. /**
  90857. * Adds more animations to the current animatable
  90858. * @param target defines the target of the animations
  90859. * @param animations defines the new animations to add
  90860. */
  90861. appendAnimations(target: any, animations: Animation[]): void;
  90862. /**
  90863. * Gets the source animation for a specific property
  90864. * @param property defines the propertyu to look for
  90865. * @returns null or the source animation for the given property
  90866. */
  90867. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  90868. /**
  90869. * Gets the runtime animation for a specific property
  90870. * @param property defines the propertyu to look for
  90871. * @returns null or the runtime animation for the given property
  90872. */
  90873. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  90874. /**
  90875. * Resets the animatable to its original state
  90876. */
  90877. reset(): void;
  90878. /**
  90879. * Allows the animatable to blend with current running animations
  90880. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90881. * @param blendingSpeed defines the blending speed to use
  90882. */
  90883. enableBlending(blendingSpeed: number): void;
  90884. /**
  90885. * Disable animation blending
  90886. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90887. */
  90888. disableBlending(): void;
  90889. /**
  90890. * Jump directly to a given frame
  90891. * @param frame defines the frame to jump to
  90892. */
  90893. goToFrame(frame: number): void;
  90894. /**
  90895. * Pause the animation
  90896. */
  90897. pause(): void;
  90898. /**
  90899. * Restart the animation
  90900. */
  90901. restart(): void;
  90902. private _raiseOnAnimationEnd;
  90903. /**
  90904. * Stop and delete the current animation
  90905. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  90906. * @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)
  90907. */
  90908. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  90909. /**
  90910. * Wait asynchronously for the animation to end
  90911. * @returns a promise which will be fullfilled when the animation ends
  90912. */
  90913. waitAsync(): Promise<Animatable>;
  90914. /** @hidden */
  90915. _animate(delay: number): boolean;
  90916. }
  90917. interface Scene {
  90918. /** @hidden */
  90919. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  90920. /** @hidden */
  90921. _processLateAnimationBindingsForMatrices(holder: {
  90922. totalWeight: number;
  90923. totalAdditiveWeight: number;
  90924. animations: RuntimeAnimation[];
  90925. additiveAnimations: RuntimeAnimation[];
  90926. originalValue: Matrix;
  90927. }): any;
  90928. /** @hidden */
  90929. _processLateAnimationBindingsForQuaternions(holder: {
  90930. totalWeight: number;
  90931. totalAdditiveWeight: number;
  90932. animations: RuntimeAnimation[];
  90933. additiveAnimations: RuntimeAnimation[];
  90934. originalValue: Quaternion;
  90935. }, refQuaternion: Quaternion): Quaternion;
  90936. /** @hidden */
  90937. _processLateAnimationBindings(): void;
  90938. /**
  90939. * Will start the animation sequence of a given target
  90940. * @param target defines the target
  90941. * @param from defines from which frame should animation start
  90942. * @param to defines until which frame should animation run.
  90943. * @param weight defines the weight to apply to the animation (1.0 by default)
  90944. * @param loop defines if the animation loops
  90945. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90946. * @param onAnimationEnd defines the function to be executed when the animation ends
  90947. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90948. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90949. * @param onAnimationLoop defines the callback to call when an animation loops
  90950. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90951. * @returns the animatable object created for this animation
  90952. */
  90953. 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;
  90954. /**
  90955. * Will start the animation sequence of a given target
  90956. * @param target defines the target
  90957. * @param from defines from which frame should animation start
  90958. * @param to defines until which frame should animation run.
  90959. * @param loop defines if the animation loops
  90960. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90961. * @param onAnimationEnd defines the function to be executed when the animation ends
  90962. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90963. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90964. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  90965. * @param onAnimationLoop defines the callback to call when an animation loops
  90966. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90967. * @returns the animatable object created for this animation
  90968. */
  90969. 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;
  90970. /**
  90971. * Will start the animation sequence of a given target and its hierarchy
  90972. * @param target defines the target
  90973. * @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.
  90974. * @param from defines from which frame should animation start
  90975. * @param to defines until which frame should animation run.
  90976. * @param loop defines if the animation loops
  90977. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90978. * @param onAnimationEnd defines the function to be executed when the animation ends
  90979. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90980. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90981. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90982. * @param onAnimationLoop defines the callback to call when an animation loops
  90983. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90984. * @returns the list of created animatables
  90985. */
  90986. 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[];
  90987. /**
  90988. * Begin a new animation on a given node
  90989. * @param target defines the target where the animation will take place
  90990. * @param animations defines the list of animations to start
  90991. * @param from defines the initial value
  90992. * @param to defines the final value
  90993. * @param loop defines if you want animation to loop (off by default)
  90994. * @param speedRatio defines the speed ratio to apply to all animations
  90995. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90996. * @param onAnimationLoop defines the callback to call when an animation loops
  90997. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90998. * @returns the list of created animatables
  90999. */
  91000. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  91001. /**
  91002. * Begin a new animation on a given node and its hierarchy
  91003. * @param target defines the root node where the animation will take place
  91004. * @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.
  91005. * @param animations defines the list of animations to start
  91006. * @param from defines the initial value
  91007. * @param to defines the final value
  91008. * @param loop defines if you want animation to loop (off by default)
  91009. * @param speedRatio defines the speed ratio to apply to all animations
  91010. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91011. * @param onAnimationLoop defines the callback to call when an animation loops
  91012. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  91013. * @returns the list of animatables created for all nodes
  91014. */
  91015. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  91016. /**
  91017. * Gets the animatable associated with a specific target
  91018. * @param target defines the target of the animatable
  91019. * @returns the required animatable if found
  91020. */
  91021. getAnimatableByTarget(target: any): Nullable<Animatable>;
  91022. /**
  91023. * Gets all animatables associated with a given target
  91024. * @param target defines the target to look animatables for
  91025. * @returns an array of Animatables
  91026. */
  91027. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  91028. /**
  91029. * Stops and removes all animations that have been applied to the scene
  91030. */
  91031. stopAllAnimations(): void;
  91032. /**
  91033. * Gets the current delta time used by animation engine
  91034. */
  91035. deltaTime: number;
  91036. }
  91037. interface Bone {
  91038. /**
  91039. * Copy an animation range from another bone
  91040. * @param source defines the source bone
  91041. * @param rangeName defines the range name to copy
  91042. * @param frameOffset defines the frame offset
  91043. * @param rescaleAsRequired defines if rescaling must be applied if required
  91044. * @param skelDimensionsRatio defines the scaling ratio
  91045. * @returns true if operation was successful
  91046. */
  91047. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  91048. }
  91049. }
  91050. declare module BABYLON {
  91051. /**
  91052. * Class used to handle skinning animations
  91053. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91054. */
  91055. export class Skeleton implements IAnimatable {
  91056. /** defines the skeleton name */
  91057. name: string;
  91058. /** defines the skeleton Id */
  91059. id: string;
  91060. /**
  91061. * Defines the list of child bones
  91062. */
  91063. bones: Bone[];
  91064. /**
  91065. * Defines an estimate of the dimension of the skeleton at rest
  91066. */
  91067. dimensionsAtRest: Vector3;
  91068. /**
  91069. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  91070. */
  91071. needInitialSkinMatrix: boolean;
  91072. /**
  91073. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  91074. */
  91075. overrideMesh: Nullable<AbstractMesh>;
  91076. /**
  91077. * Gets the list of animations attached to this skeleton
  91078. */
  91079. animations: Array<Animation>;
  91080. private _scene;
  91081. private _isDirty;
  91082. private _transformMatrices;
  91083. private _transformMatrixTexture;
  91084. private _meshesWithPoseMatrix;
  91085. private _animatables;
  91086. private _identity;
  91087. private _synchronizedWithMesh;
  91088. private _ranges;
  91089. private _lastAbsoluteTransformsUpdateId;
  91090. private _canUseTextureForBones;
  91091. private _uniqueId;
  91092. /** @hidden */
  91093. _numBonesWithLinkedTransformNode: number;
  91094. /** @hidden */
  91095. _hasWaitingData: Nullable<boolean>;
  91096. /**
  91097. * Specifies if the skeleton should be serialized
  91098. */
  91099. doNotSerialize: boolean;
  91100. private _useTextureToStoreBoneMatrices;
  91101. /**
  91102. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  91103. * Please note that this option is not available if the hardware does not support it
  91104. */
  91105. get useTextureToStoreBoneMatrices(): boolean;
  91106. set useTextureToStoreBoneMatrices(value: boolean);
  91107. private _animationPropertiesOverride;
  91108. /**
  91109. * Gets or sets the animation properties override
  91110. */
  91111. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  91112. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  91113. /**
  91114. * List of inspectable custom properties (used by the Inspector)
  91115. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91116. */
  91117. inspectableCustomProperties: IInspectable[];
  91118. /**
  91119. * An observable triggered before computing the skeleton's matrices
  91120. */
  91121. onBeforeComputeObservable: Observable<Skeleton>;
  91122. /**
  91123. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  91124. */
  91125. get isUsingTextureForMatrices(): boolean;
  91126. /**
  91127. * Gets the unique ID of this skeleton
  91128. */
  91129. get uniqueId(): number;
  91130. /**
  91131. * Creates a new skeleton
  91132. * @param name defines the skeleton name
  91133. * @param id defines the skeleton Id
  91134. * @param scene defines the hosting scene
  91135. */
  91136. constructor(
  91137. /** defines the skeleton name */
  91138. name: string,
  91139. /** defines the skeleton Id */
  91140. id: string, scene: Scene);
  91141. /**
  91142. * Gets the current object class name.
  91143. * @return the class name
  91144. */
  91145. getClassName(): string;
  91146. /**
  91147. * Returns an array containing the root bones
  91148. * @returns an array containing the root bones
  91149. */
  91150. getChildren(): Array<Bone>;
  91151. /**
  91152. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  91153. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  91154. * @returns a Float32Array containing matrices data
  91155. */
  91156. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  91157. /**
  91158. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  91159. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  91160. * @returns a raw texture containing the data
  91161. */
  91162. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  91163. /**
  91164. * Gets the current hosting scene
  91165. * @returns a scene object
  91166. */
  91167. getScene(): Scene;
  91168. /**
  91169. * Gets a string representing the current skeleton data
  91170. * @param fullDetails defines a boolean indicating if we want a verbose version
  91171. * @returns a string representing the current skeleton data
  91172. */
  91173. toString(fullDetails?: boolean): string;
  91174. /**
  91175. * Get bone's index searching by name
  91176. * @param name defines bone's name to search for
  91177. * @return the indice of the bone. Returns -1 if not found
  91178. */
  91179. getBoneIndexByName(name: string): number;
  91180. /**
  91181. * Creater a new animation range
  91182. * @param name defines the name of the range
  91183. * @param from defines the start key
  91184. * @param to defines the end key
  91185. */
  91186. createAnimationRange(name: string, from: number, to: number): void;
  91187. /**
  91188. * Delete a specific animation range
  91189. * @param name defines the name of the range
  91190. * @param deleteFrames defines if frames must be removed as well
  91191. */
  91192. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91193. /**
  91194. * Gets a specific animation range
  91195. * @param name defines the name of the range to look for
  91196. * @returns the requested animation range or null if not found
  91197. */
  91198. getAnimationRange(name: string): Nullable<AnimationRange>;
  91199. /**
  91200. * Gets the list of all animation ranges defined on this skeleton
  91201. * @returns an array
  91202. */
  91203. getAnimationRanges(): Nullable<AnimationRange>[];
  91204. /**
  91205. * Copy animation range from a source skeleton.
  91206. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  91207. * @param source defines the source skeleton
  91208. * @param name defines the name of the range to copy
  91209. * @param rescaleAsRequired defines if rescaling must be applied if required
  91210. * @returns true if operation was successful
  91211. */
  91212. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  91213. /**
  91214. * Forces the skeleton to go to rest pose
  91215. */
  91216. returnToRest(): void;
  91217. private _getHighestAnimationFrame;
  91218. /**
  91219. * Begin a specific animation range
  91220. * @param name defines the name of the range to start
  91221. * @param loop defines if looping must be turned on (false by default)
  91222. * @param speedRatio defines the speed ratio to apply (1 by default)
  91223. * @param onAnimationEnd defines a callback which will be called when animation will end
  91224. * @returns a new animatable
  91225. */
  91226. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91227. /**
  91228. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  91229. * @param skeleton defines the Skeleton containing the animation range to convert
  91230. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  91231. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  91232. * @returns the original skeleton
  91233. */
  91234. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  91235. /** @hidden */
  91236. _markAsDirty(): void;
  91237. /** @hidden */
  91238. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  91239. /** @hidden */
  91240. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  91241. private _computeTransformMatrices;
  91242. /**
  91243. * Build all resources required to render a skeleton
  91244. */
  91245. prepare(): void;
  91246. /**
  91247. * Gets the list of animatables currently running for this skeleton
  91248. * @returns an array of animatables
  91249. */
  91250. getAnimatables(): IAnimatable[];
  91251. /**
  91252. * Clone the current skeleton
  91253. * @param name defines the name of the new skeleton
  91254. * @param id defines the id of the new skeleton
  91255. * @returns the new skeleton
  91256. */
  91257. clone(name: string, id?: string): Skeleton;
  91258. /**
  91259. * Enable animation blending for this skeleton
  91260. * @param blendingSpeed defines the blending speed to apply
  91261. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  91262. */
  91263. enableBlending(blendingSpeed?: number): void;
  91264. /**
  91265. * Releases all resources associated with the current skeleton
  91266. */
  91267. dispose(): void;
  91268. /**
  91269. * Serialize the skeleton in a JSON object
  91270. * @returns a JSON object
  91271. */
  91272. serialize(): any;
  91273. /**
  91274. * Creates a new skeleton from serialized data
  91275. * @param parsedSkeleton defines the serialized data
  91276. * @param scene defines the hosting scene
  91277. * @returns a new skeleton
  91278. */
  91279. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  91280. /**
  91281. * Compute all node absolute transforms
  91282. * @param forceUpdate defines if computation must be done even if cache is up to date
  91283. */
  91284. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  91285. /**
  91286. * Gets the root pose matrix
  91287. * @returns a matrix
  91288. */
  91289. getPoseMatrix(): Nullable<Matrix>;
  91290. /**
  91291. * Sorts bones per internal index
  91292. */
  91293. sortBones(): void;
  91294. private _sortBones;
  91295. }
  91296. }
  91297. declare module BABYLON {
  91298. /**
  91299. * Creates an instance based on a source mesh.
  91300. */
  91301. export class InstancedMesh extends AbstractMesh {
  91302. private _sourceMesh;
  91303. private _currentLOD;
  91304. /** @hidden */
  91305. _indexInSourceMeshInstanceArray: number;
  91306. constructor(name: string, source: Mesh);
  91307. /**
  91308. * Returns the string "InstancedMesh".
  91309. */
  91310. getClassName(): string;
  91311. /** Gets the list of lights affecting that mesh */
  91312. get lightSources(): Light[];
  91313. _resyncLightSources(): void;
  91314. _resyncLightSource(light: Light): void;
  91315. _removeLightSource(light: Light, dispose: boolean): void;
  91316. /**
  91317. * If the source mesh receives shadows
  91318. */
  91319. get receiveShadows(): boolean;
  91320. /**
  91321. * The material of the source mesh
  91322. */
  91323. get material(): Nullable<Material>;
  91324. /**
  91325. * Visibility of the source mesh
  91326. */
  91327. get visibility(): number;
  91328. /**
  91329. * Skeleton of the source mesh
  91330. */
  91331. get skeleton(): Nullable<Skeleton>;
  91332. /**
  91333. * Rendering ground id of the source mesh
  91334. */
  91335. get renderingGroupId(): number;
  91336. set renderingGroupId(value: number);
  91337. /**
  91338. * Returns the total number of vertices (integer).
  91339. */
  91340. getTotalVertices(): number;
  91341. /**
  91342. * Returns a positive integer : the total number of indices in this mesh geometry.
  91343. * @returns the numner of indices or zero if the mesh has no geometry.
  91344. */
  91345. getTotalIndices(): number;
  91346. /**
  91347. * The source mesh of the instance
  91348. */
  91349. get sourceMesh(): Mesh;
  91350. /**
  91351. * Is this node ready to be used/rendered
  91352. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91353. * @return {boolean} is it ready
  91354. */
  91355. isReady(completeCheck?: boolean): boolean;
  91356. /**
  91357. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91358. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91359. * @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.
  91360. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91361. */
  91362. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91363. /**
  91364. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91365. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91366. * The `data` are either a numeric array either a Float32Array.
  91367. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91368. * 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).
  91369. * Note that a new underlying VertexBuffer object is created each call.
  91370. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91371. *
  91372. * Possible `kind` values :
  91373. * - VertexBuffer.PositionKind
  91374. * - VertexBuffer.UVKind
  91375. * - VertexBuffer.UV2Kind
  91376. * - VertexBuffer.UV3Kind
  91377. * - VertexBuffer.UV4Kind
  91378. * - VertexBuffer.UV5Kind
  91379. * - VertexBuffer.UV6Kind
  91380. * - VertexBuffer.ColorKind
  91381. * - VertexBuffer.MatricesIndicesKind
  91382. * - VertexBuffer.MatricesIndicesExtraKind
  91383. * - VertexBuffer.MatricesWeightsKind
  91384. * - VertexBuffer.MatricesWeightsExtraKind
  91385. *
  91386. * Returns the Mesh.
  91387. */
  91388. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91389. /**
  91390. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91391. * If the mesh has no geometry, it is simply returned as it is.
  91392. * The `data` are either a numeric array either a Float32Array.
  91393. * No new underlying VertexBuffer object is created.
  91394. * 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.
  91395. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91396. *
  91397. * Possible `kind` values :
  91398. * - VertexBuffer.PositionKind
  91399. * - VertexBuffer.UVKind
  91400. * - VertexBuffer.UV2Kind
  91401. * - VertexBuffer.UV3Kind
  91402. * - VertexBuffer.UV4Kind
  91403. * - VertexBuffer.UV5Kind
  91404. * - VertexBuffer.UV6Kind
  91405. * - VertexBuffer.ColorKind
  91406. * - VertexBuffer.MatricesIndicesKind
  91407. * - VertexBuffer.MatricesIndicesExtraKind
  91408. * - VertexBuffer.MatricesWeightsKind
  91409. * - VertexBuffer.MatricesWeightsExtraKind
  91410. *
  91411. * Returns the Mesh.
  91412. */
  91413. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91414. /**
  91415. * Sets the mesh indices.
  91416. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91417. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91418. * This method creates a new index buffer each call.
  91419. * Returns the Mesh.
  91420. */
  91421. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91422. /**
  91423. * Boolean : True if the mesh owns the requested kind of data.
  91424. */
  91425. isVerticesDataPresent(kind: string): boolean;
  91426. /**
  91427. * Returns an array of indices (IndicesArray).
  91428. */
  91429. getIndices(): Nullable<IndicesArray>;
  91430. get _positions(): Nullable<Vector3[]>;
  91431. /**
  91432. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91433. * This means the mesh underlying bounding box and sphere are recomputed.
  91434. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91435. * @returns the current mesh
  91436. */
  91437. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91438. /** @hidden */
  91439. _preActivate(): InstancedMesh;
  91440. /** @hidden */
  91441. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91442. /** @hidden */
  91443. _postActivate(): void;
  91444. getWorldMatrix(): Matrix;
  91445. get isAnInstance(): boolean;
  91446. /**
  91447. * Returns the current associated LOD AbstractMesh.
  91448. */
  91449. getLOD(camera: Camera): AbstractMesh;
  91450. /** @hidden */
  91451. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91452. /** @hidden */
  91453. _syncSubMeshes(): InstancedMesh;
  91454. /** @hidden */
  91455. _generatePointsArray(): boolean;
  91456. /**
  91457. * Creates a new InstancedMesh from the current mesh.
  91458. * - name (string) : the cloned mesh name
  91459. * - newParent (optional Node) : the optional Node to parent the clone to.
  91460. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91461. *
  91462. * Returns the clone.
  91463. */
  91464. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91465. /**
  91466. * Disposes the InstancedMesh.
  91467. * Returns nothing.
  91468. */
  91469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91470. }
  91471. interface Mesh {
  91472. /**
  91473. * Register a custom buffer that will be instanced
  91474. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91475. * @param kind defines the buffer kind
  91476. * @param stride defines the stride in floats
  91477. */
  91478. registerInstancedBuffer(kind: string, stride: number): void;
  91479. /** @hidden */
  91480. _userInstancedBuffersStorage: {
  91481. data: {
  91482. [key: string]: Float32Array;
  91483. };
  91484. sizes: {
  91485. [key: string]: number;
  91486. };
  91487. vertexBuffers: {
  91488. [key: string]: Nullable<VertexBuffer>;
  91489. };
  91490. strides: {
  91491. [key: string]: number;
  91492. };
  91493. };
  91494. }
  91495. interface AbstractMesh {
  91496. /**
  91497. * Object used to store instanced buffers defined by user
  91498. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91499. */
  91500. instancedBuffers: {
  91501. [key: string]: any;
  91502. };
  91503. }
  91504. }
  91505. declare module BABYLON {
  91506. /**
  91507. * Defines the options associated with the creation of a shader material.
  91508. */
  91509. export interface IShaderMaterialOptions {
  91510. /**
  91511. * Does the material work in alpha blend mode
  91512. */
  91513. needAlphaBlending: boolean;
  91514. /**
  91515. * Does the material work in alpha test mode
  91516. */
  91517. needAlphaTesting: boolean;
  91518. /**
  91519. * The list of attribute names used in the shader
  91520. */
  91521. attributes: string[];
  91522. /**
  91523. * The list of unifrom names used in the shader
  91524. */
  91525. uniforms: string[];
  91526. /**
  91527. * The list of UBO names used in the shader
  91528. */
  91529. uniformBuffers: string[];
  91530. /**
  91531. * The list of sampler names used in the shader
  91532. */
  91533. samplers: string[];
  91534. /**
  91535. * The list of defines used in the shader
  91536. */
  91537. defines: string[];
  91538. }
  91539. /**
  91540. * 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.
  91541. *
  91542. * This returned material effects how the mesh will look based on the code in the shaders.
  91543. *
  91544. * @see http://doc.babylonjs.com/how_to/shader_material
  91545. */
  91546. export class ShaderMaterial extends Material {
  91547. private _shaderPath;
  91548. private _options;
  91549. private _textures;
  91550. private _textureArrays;
  91551. private _floats;
  91552. private _ints;
  91553. private _floatsArrays;
  91554. private _colors3;
  91555. private _colors3Arrays;
  91556. private _colors4;
  91557. private _colors4Arrays;
  91558. private _vectors2;
  91559. private _vectors3;
  91560. private _vectors4;
  91561. private _matrices;
  91562. private _matrixArrays;
  91563. private _matrices3x3;
  91564. private _matrices2x2;
  91565. private _vectors2Arrays;
  91566. private _vectors3Arrays;
  91567. private _vectors4Arrays;
  91568. private _cachedWorldViewMatrix;
  91569. private _cachedWorldViewProjectionMatrix;
  91570. private _renderId;
  91571. private _multiview;
  91572. private _cachedDefines;
  91573. /**
  91574. * Instantiate a new shader material.
  91575. * 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.
  91576. * This returned material effects how the mesh will look based on the code in the shaders.
  91577. * @see http://doc.babylonjs.com/how_to/shader_material
  91578. * @param name Define the name of the material in the scene
  91579. * @param scene Define the scene the material belongs to
  91580. * @param shaderPath Defines the route to the shader code in one of three ways:
  91581. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91582. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91583. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91584. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  91585. * @param options Define the options used to create the shader
  91586. */
  91587. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  91588. /**
  91589. * Gets the shader path used to define the shader code
  91590. * It can be modified to trigger a new compilation
  91591. */
  91592. get shaderPath(): any;
  91593. /**
  91594. * Sets the shader path used to define the shader code
  91595. * It can be modified to trigger a new compilation
  91596. */
  91597. set shaderPath(shaderPath: any);
  91598. /**
  91599. * Gets the options used to compile the shader.
  91600. * They can be modified to trigger a new compilation
  91601. */
  91602. get options(): IShaderMaterialOptions;
  91603. /**
  91604. * Gets the current class name of the material e.g. "ShaderMaterial"
  91605. * Mainly use in serialization.
  91606. * @returns the class name
  91607. */
  91608. getClassName(): string;
  91609. /**
  91610. * Specifies if the material will require alpha blending
  91611. * @returns a boolean specifying if alpha blending is needed
  91612. */
  91613. needAlphaBlending(): boolean;
  91614. /**
  91615. * Specifies if this material should be rendered in alpha test mode
  91616. * @returns a boolean specifying if an alpha test is needed.
  91617. */
  91618. needAlphaTesting(): boolean;
  91619. private _checkUniform;
  91620. /**
  91621. * Set a texture in the shader.
  91622. * @param name Define the name of the uniform samplers as defined in the shader
  91623. * @param texture Define the texture to bind to this sampler
  91624. * @return the material itself allowing "fluent" like uniform updates
  91625. */
  91626. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  91627. /**
  91628. * Set a texture array in the shader.
  91629. * @param name Define the name of the uniform sampler array as defined in the shader
  91630. * @param textures Define the list of textures to bind to this sampler
  91631. * @return the material itself allowing "fluent" like uniform updates
  91632. */
  91633. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  91634. /**
  91635. * Set a float in the shader.
  91636. * @param name Define the name of the uniform as defined in the shader
  91637. * @param value Define the value to give to the uniform
  91638. * @return the material itself allowing "fluent" like uniform updates
  91639. */
  91640. setFloat(name: string, value: number): ShaderMaterial;
  91641. /**
  91642. * Set a int in the shader.
  91643. * @param name Define the name of the uniform as defined in the shader
  91644. * @param value Define the value to give to the uniform
  91645. * @return the material itself allowing "fluent" like uniform updates
  91646. */
  91647. setInt(name: string, value: number): ShaderMaterial;
  91648. /**
  91649. * Set an array of floats in the shader.
  91650. * @param name Define the name of the uniform as defined in the shader
  91651. * @param value Define the value to give to the uniform
  91652. * @return the material itself allowing "fluent" like uniform updates
  91653. */
  91654. setFloats(name: string, value: number[]): ShaderMaterial;
  91655. /**
  91656. * Set a vec3 in the shader from a Color3.
  91657. * @param name Define the name of the uniform as defined in the shader
  91658. * @param value Define the value to give to the uniform
  91659. * @return the material itself allowing "fluent" like uniform updates
  91660. */
  91661. setColor3(name: string, value: Color3): ShaderMaterial;
  91662. /**
  91663. * Set a vec3 array in the shader from a Color3 array.
  91664. * @param name Define the name of the uniform as defined in the shader
  91665. * @param value Define the value to give to the uniform
  91666. * @return the material itself allowing "fluent" like uniform updates
  91667. */
  91668. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  91669. /**
  91670. * Set a vec4 in the shader from a Color4.
  91671. * @param name Define the name of the uniform as defined in the shader
  91672. * @param value Define the value to give to the uniform
  91673. * @return the material itself allowing "fluent" like uniform updates
  91674. */
  91675. setColor4(name: string, value: Color4): ShaderMaterial;
  91676. /**
  91677. * Set a vec4 array in the shader from a Color4 array.
  91678. * @param name Define the name of the uniform as defined in the shader
  91679. * @param value Define the value to give to the uniform
  91680. * @return the material itself allowing "fluent" like uniform updates
  91681. */
  91682. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  91683. /**
  91684. * Set a vec2 in the shader from a Vector2.
  91685. * @param name Define the name of the uniform as defined in the shader
  91686. * @param value Define the value to give to the uniform
  91687. * @return the material itself allowing "fluent" like uniform updates
  91688. */
  91689. setVector2(name: string, value: Vector2): ShaderMaterial;
  91690. /**
  91691. * Set a vec3 in the shader from a Vector3.
  91692. * @param name Define the name of the uniform as defined in the shader
  91693. * @param value Define the value to give to the uniform
  91694. * @return the material itself allowing "fluent" like uniform updates
  91695. */
  91696. setVector3(name: string, value: Vector3): ShaderMaterial;
  91697. /**
  91698. * Set a vec4 in the shader from a Vector4.
  91699. * @param name Define the name of the uniform as defined in the shader
  91700. * @param value Define the value to give to the uniform
  91701. * @return the material itself allowing "fluent" like uniform updates
  91702. */
  91703. setVector4(name: string, value: Vector4): ShaderMaterial;
  91704. /**
  91705. * Set a mat4 in the shader from a Matrix.
  91706. * @param name Define the name of the uniform as defined in the shader
  91707. * @param value Define the value to give to the uniform
  91708. * @return the material itself allowing "fluent" like uniform updates
  91709. */
  91710. setMatrix(name: string, value: Matrix): ShaderMaterial;
  91711. /**
  91712. * Set a float32Array in the shader from a matrix array.
  91713. * @param name Define the name of the uniform as defined in the shader
  91714. * @param value Define the value to give to the uniform
  91715. * @return the material itself allowing "fluent" like uniform updates
  91716. */
  91717. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  91718. /**
  91719. * Set a mat3 in the shader from a Float32Array.
  91720. * @param name Define the name of the uniform as defined in the shader
  91721. * @param value Define the value to give to the uniform
  91722. * @return the material itself allowing "fluent" like uniform updates
  91723. */
  91724. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  91725. /**
  91726. * Set a mat2 in the shader from a Float32Array.
  91727. * @param name Define the name of the uniform as defined in the shader
  91728. * @param value Define the value to give to the uniform
  91729. * @return the material itself allowing "fluent" like uniform updates
  91730. */
  91731. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  91732. /**
  91733. * Set a vec2 array in the shader from a number array.
  91734. * @param name Define the name of the uniform as defined in the shader
  91735. * @param value Define the value to give to the uniform
  91736. * @return the material itself allowing "fluent" like uniform updates
  91737. */
  91738. setArray2(name: string, value: number[]): ShaderMaterial;
  91739. /**
  91740. * Set a vec3 array in the shader from a number array.
  91741. * @param name Define the name of the uniform as defined in the shader
  91742. * @param value Define the value to give to the uniform
  91743. * @return the material itself allowing "fluent" like uniform updates
  91744. */
  91745. setArray3(name: string, value: number[]): ShaderMaterial;
  91746. /**
  91747. * Set a vec4 array in the shader from a number array.
  91748. * @param name Define the name of the uniform as defined in the shader
  91749. * @param value Define the value to give to the uniform
  91750. * @return the material itself allowing "fluent" like uniform updates
  91751. */
  91752. setArray4(name: string, value: number[]): ShaderMaterial;
  91753. private _checkCache;
  91754. /**
  91755. * Specifies that the submesh is ready to be used
  91756. * @param mesh defines the mesh to check
  91757. * @param subMesh defines which submesh to check
  91758. * @param useInstances specifies that instances should be used
  91759. * @returns a boolean indicating that the submesh is ready or not
  91760. */
  91761. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91762. /**
  91763. * Checks if the material is ready to render the requested mesh
  91764. * @param mesh Define the mesh to render
  91765. * @param useInstances Define whether or not the material is used with instances
  91766. * @returns true if ready, otherwise false
  91767. */
  91768. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91769. /**
  91770. * Binds the world matrix to the material
  91771. * @param world defines the world transformation matrix
  91772. * @param effectOverride - If provided, use this effect instead of internal effect
  91773. */
  91774. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  91775. /**
  91776. * Binds the submesh to this material by preparing the effect and shader to draw
  91777. * @param world defines the world transformation matrix
  91778. * @param mesh defines the mesh containing the submesh
  91779. * @param subMesh defines the submesh to bind the material to
  91780. */
  91781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91782. /**
  91783. * Binds the material to the mesh
  91784. * @param world defines the world transformation matrix
  91785. * @param mesh defines the mesh to bind the material to
  91786. * @param effectOverride - If provided, use this effect instead of internal effect
  91787. */
  91788. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  91789. protected _afterBind(mesh?: Mesh): void;
  91790. /**
  91791. * Gets the active textures from the material
  91792. * @returns an array of textures
  91793. */
  91794. getActiveTextures(): BaseTexture[];
  91795. /**
  91796. * Specifies if the material uses a texture
  91797. * @param texture defines the texture to check against the material
  91798. * @returns a boolean specifying if the material uses the texture
  91799. */
  91800. hasTexture(texture: BaseTexture): boolean;
  91801. /**
  91802. * Makes a duplicate of the material, and gives it a new name
  91803. * @param name defines the new name for the duplicated material
  91804. * @returns the cloned material
  91805. */
  91806. clone(name: string): ShaderMaterial;
  91807. /**
  91808. * Disposes the material
  91809. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91810. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91811. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91812. */
  91813. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91814. /**
  91815. * Serializes this material in a JSON representation
  91816. * @returns the serialized material object
  91817. */
  91818. serialize(): any;
  91819. /**
  91820. * Creates a shader material from parsed shader material data
  91821. * @param source defines the JSON represnetation of the material
  91822. * @param scene defines the hosting scene
  91823. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91824. * @returns a new material
  91825. */
  91826. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91827. }
  91828. }
  91829. declare module BABYLON {
  91830. /** @hidden */
  91831. export var colorPixelShader: {
  91832. name: string;
  91833. shader: string;
  91834. };
  91835. }
  91836. declare module BABYLON {
  91837. /** @hidden */
  91838. export var colorVertexShader: {
  91839. name: string;
  91840. shader: string;
  91841. };
  91842. }
  91843. declare module BABYLON {
  91844. /**
  91845. * Line mesh
  91846. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91847. */
  91848. export class LinesMesh extends Mesh {
  91849. /**
  91850. * If vertex color should be applied to the mesh
  91851. */
  91852. readonly useVertexColor?: boolean | undefined;
  91853. /**
  91854. * If vertex alpha should be applied to the mesh
  91855. */
  91856. readonly useVertexAlpha?: boolean | undefined;
  91857. /**
  91858. * Color of the line (Default: White)
  91859. */
  91860. color: Color3;
  91861. /**
  91862. * Alpha of the line (Default: 1)
  91863. */
  91864. alpha: number;
  91865. /**
  91866. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91867. * This margin is expressed in world space coordinates, so its value may vary.
  91868. * Default value is 0.1
  91869. */
  91870. intersectionThreshold: number;
  91871. private _colorShader;
  91872. private color4;
  91873. /**
  91874. * Creates a new LinesMesh
  91875. * @param name defines the name
  91876. * @param scene defines the hosting scene
  91877. * @param parent defines the parent mesh if any
  91878. * @param source defines the optional source LinesMesh used to clone data from
  91879. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91880. * When false, achieved by calling a clone(), also passing False.
  91881. * This will make creation of children, recursive.
  91882. * @param useVertexColor defines if this LinesMesh supports vertex color
  91883. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91884. */
  91885. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91886. /**
  91887. * If vertex color should be applied to the mesh
  91888. */
  91889. useVertexColor?: boolean | undefined,
  91890. /**
  91891. * If vertex alpha should be applied to the mesh
  91892. */
  91893. useVertexAlpha?: boolean | undefined);
  91894. private _addClipPlaneDefine;
  91895. private _removeClipPlaneDefine;
  91896. isReady(): boolean;
  91897. /**
  91898. * Returns the string "LineMesh"
  91899. */
  91900. getClassName(): string;
  91901. /**
  91902. * @hidden
  91903. */
  91904. get material(): Material;
  91905. /**
  91906. * @hidden
  91907. */
  91908. set material(value: Material);
  91909. /**
  91910. * @hidden
  91911. */
  91912. get checkCollisions(): boolean;
  91913. /** @hidden */
  91914. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91915. /** @hidden */
  91916. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91917. /**
  91918. * Disposes of the line mesh
  91919. * @param doNotRecurse If children should be disposed
  91920. */
  91921. dispose(doNotRecurse?: boolean): void;
  91922. /**
  91923. * Returns a new LineMesh object cloned from the current one.
  91924. */
  91925. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  91926. /**
  91927. * Creates a new InstancedLinesMesh object from the mesh model.
  91928. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91929. * @param name defines the name of the new instance
  91930. * @returns a new InstancedLinesMesh
  91931. */
  91932. createInstance(name: string): InstancedLinesMesh;
  91933. }
  91934. /**
  91935. * Creates an instance based on a source LinesMesh
  91936. */
  91937. export class InstancedLinesMesh extends InstancedMesh {
  91938. /**
  91939. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91940. * This margin is expressed in world space coordinates, so its value may vary.
  91941. * Initilized with the intersectionThreshold value of the source LinesMesh
  91942. */
  91943. intersectionThreshold: number;
  91944. constructor(name: string, source: LinesMesh);
  91945. /**
  91946. * Returns the string "InstancedLinesMesh".
  91947. */
  91948. getClassName(): string;
  91949. }
  91950. }
  91951. declare module BABYLON {
  91952. /** @hidden */
  91953. export var linePixelShader: {
  91954. name: string;
  91955. shader: string;
  91956. };
  91957. }
  91958. declare module BABYLON {
  91959. /** @hidden */
  91960. export var lineVertexShader: {
  91961. name: string;
  91962. shader: string;
  91963. };
  91964. }
  91965. declare module BABYLON {
  91966. interface AbstractMesh {
  91967. /**
  91968. * Gets the edgesRenderer associated with the mesh
  91969. */
  91970. edgesRenderer: Nullable<EdgesRenderer>;
  91971. }
  91972. interface LinesMesh {
  91973. /**
  91974. * Enables the edge rendering mode on the mesh.
  91975. * This mode makes the mesh edges visible
  91976. * @param epsilon defines the maximal distance between two angles to detect a face
  91977. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91978. * @returns the currentAbstractMesh
  91979. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91980. */
  91981. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91982. }
  91983. interface InstancedLinesMesh {
  91984. /**
  91985. * Enables the edge rendering mode on the mesh.
  91986. * This mode makes the mesh edges visible
  91987. * @param epsilon defines the maximal distance between two angles to detect a face
  91988. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91989. * @returns the current InstancedLinesMesh
  91990. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91991. */
  91992. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91993. }
  91994. /**
  91995. * Defines the minimum contract an Edges renderer should follow.
  91996. */
  91997. export interface IEdgesRenderer extends IDisposable {
  91998. /**
  91999. * Gets or sets a boolean indicating if the edgesRenderer is active
  92000. */
  92001. isEnabled: boolean;
  92002. /**
  92003. * Renders the edges of the attached mesh,
  92004. */
  92005. render(): void;
  92006. /**
  92007. * Checks wether or not the edges renderer is ready to render.
  92008. * @return true if ready, otherwise false.
  92009. */
  92010. isReady(): boolean;
  92011. }
  92012. /**
  92013. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  92014. */
  92015. export class EdgesRenderer implements IEdgesRenderer {
  92016. /**
  92017. * Define the size of the edges with an orthographic camera
  92018. */
  92019. edgesWidthScalerForOrthographic: number;
  92020. /**
  92021. * Define the size of the edges with a perspective camera
  92022. */
  92023. edgesWidthScalerForPerspective: number;
  92024. protected _source: AbstractMesh;
  92025. protected _linesPositions: number[];
  92026. protected _linesNormals: number[];
  92027. protected _linesIndices: number[];
  92028. protected _epsilon: number;
  92029. protected _indicesCount: number;
  92030. protected _lineShader: ShaderMaterial;
  92031. protected _ib: DataBuffer;
  92032. protected _buffers: {
  92033. [key: string]: Nullable<VertexBuffer>;
  92034. };
  92035. protected _checkVerticesInsteadOfIndices: boolean;
  92036. private _meshRebuildObserver;
  92037. private _meshDisposeObserver;
  92038. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  92039. isEnabled: boolean;
  92040. /**
  92041. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  92042. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  92043. * @param source Mesh used to create edges
  92044. * @param epsilon sum of angles in adjacency to check for edge
  92045. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  92046. * @param generateEdgesLines - should generate Lines or only prepare resources.
  92047. */
  92048. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  92049. protected _prepareRessources(): void;
  92050. /** @hidden */
  92051. _rebuild(): void;
  92052. /**
  92053. * Releases the required resources for the edges renderer
  92054. */
  92055. dispose(): void;
  92056. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92057. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92058. /**
  92059. * Checks if the pair of p0 and p1 is en edge
  92060. * @param faceIndex
  92061. * @param edge
  92062. * @param faceNormals
  92063. * @param p0
  92064. * @param p1
  92065. * @private
  92066. */
  92067. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92068. /**
  92069. * push line into the position, normal and index buffer
  92070. * @protected
  92071. */
  92072. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92073. /**
  92074. * Generates lines edges from adjacencjes
  92075. * @private
  92076. */
  92077. _generateEdgesLines(): void;
  92078. /**
  92079. * Checks wether or not the edges renderer is ready to render.
  92080. * @return true if ready, otherwise false.
  92081. */
  92082. isReady(): boolean;
  92083. /**
  92084. * Renders the edges of the attached mesh,
  92085. */
  92086. render(): void;
  92087. }
  92088. /**
  92089. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92090. */
  92091. export class LineEdgesRenderer extends EdgesRenderer {
  92092. /**
  92093. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92094. * @param source LineMesh used to generate edges
  92095. * @param epsilon not important (specified angle for edge detection)
  92096. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92097. */
  92098. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92099. /**
  92100. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92101. */
  92102. _generateEdgesLines(): void;
  92103. }
  92104. }
  92105. declare module BABYLON {
  92106. /**
  92107. * This represents the object necessary to create a rendering group.
  92108. * This is exclusively used and created by the rendering manager.
  92109. * To modify the behavior, you use the available helpers in your scene or meshes.
  92110. * @hidden
  92111. */
  92112. export class RenderingGroup {
  92113. index: number;
  92114. private static _zeroVector;
  92115. private _scene;
  92116. private _opaqueSubMeshes;
  92117. private _transparentSubMeshes;
  92118. private _alphaTestSubMeshes;
  92119. private _depthOnlySubMeshes;
  92120. private _particleSystems;
  92121. private _spriteManagers;
  92122. private _opaqueSortCompareFn;
  92123. private _alphaTestSortCompareFn;
  92124. private _transparentSortCompareFn;
  92125. private _renderOpaque;
  92126. private _renderAlphaTest;
  92127. private _renderTransparent;
  92128. /** @hidden */
  92129. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92130. onBeforeTransparentRendering: () => void;
  92131. /**
  92132. * Set the opaque sort comparison function.
  92133. * If null the sub meshes will be render in the order they were created
  92134. */
  92135. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92136. /**
  92137. * Set the alpha test sort comparison function.
  92138. * If null the sub meshes will be render in the order they were created
  92139. */
  92140. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92141. /**
  92142. * Set the transparent sort comparison function.
  92143. * If null the sub meshes will be render in the order they were created
  92144. */
  92145. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92146. /**
  92147. * Creates a new rendering group.
  92148. * @param index The rendering group index
  92149. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92150. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92151. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92152. */
  92153. 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>);
  92154. /**
  92155. * Render all the sub meshes contained in the group.
  92156. * @param customRenderFunction Used to override the default render behaviour of the group.
  92157. * @returns true if rendered some submeshes.
  92158. */
  92159. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92160. /**
  92161. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92162. * @param subMeshes The submeshes to render
  92163. */
  92164. private renderOpaqueSorted;
  92165. /**
  92166. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92167. * @param subMeshes The submeshes to render
  92168. */
  92169. private renderAlphaTestSorted;
  92170. /**
  92171. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92172. * @param subMeshes The submeshes to render
  92173. */
  92174. private renderTransparentSorted;
  92175. /**
  92176. * Renders the submeshes in a specified order.
  92177. * @param subMeshes The submeshes to sort before render
  92178. * @param sortCompareFn The comparison function use to sort
  92179. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92180. * @param transparent Specifies to activate blending if true
  92181. */
  92182. private static renderSorted;
  92183. /**
  92184. * Renders the submeshes in the order they were dispatched (no sort applied).
  92185. * @param subMeshes The submeshes to render
  92186. */
  92187. private static renderUnsorted;
  92188. /**
  92189. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92190. * are rendered back to front if in the same alpha index.
  92191. *
  92192. * @param a The first submesh
  92193. * @param b The second submesh
  92194. * @returns The result of the comparison
  92195. */
  92196. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92197. /**
  92198. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92199. * are rendered back to front.
  92200. *
  92201. * @param a The first submesh
  92202. * @param b The second submesh
  92203. * @returns The result of the comparison
  92204. */
  92205. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92206. /**
  92207. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92208. * are rendered front to back (prevent overdraw).
  92209. *
  92210. * @param a The first submesh
  92211. * @param b The second submesh
  92212. * @returns The result of the comparison
  92213. */
  92214. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  92215. /**
  92216. * Resets the different lists of submeshes to prepare a new frame.
  92217. */
  92218. prepare(): void;
  92219. dispose(): void;
  92220. /**
  92221. * Inserts the submesh in its correct queue depending on its material.
  92222. * @param subMesh The submesh to dispatch
  92223. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92224. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92225. */
  92226. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92227. dispatchSprites(spriteManager: ISpriteManager): void;
  92228. dispatchParticles(particleSystem: IParticleSystem): void;
  92229. private _renderParticles;
  92230. private _renderSprites;
  92231. }
  92232. }
  92233. declare module BABYLON {
  92234. /**
  92235. * Interface describing the different options available in the rendering manager
  92236. * regarding Auto Clear between groups.
  92237. */
  92238. export interface IRenderingManagerAutoClearSetup {
  92239. /**
  92240. * Defines whether or not autoclear is enable.
  92241. */
  92242. autoClear: boolean;
  92243. /**
  92244. * Defines whether or not to autoclear the depth buffer.
  92245. */
  92246. depth: boolean;
  92247. /**
  92248. * Defines whether or not to autoclear the stencil buffer.
  92249. */
  92250. stencil: boolean;
  92251. }
  92252. /**
  92253. * This class is used by the onRenderingGroupObservable
  92254. */
  92255. export class RenderingGroupInfo {
  92256. /**
  92257. * The Scene that being rendered
  92258. */
  92259. scene: Scene;
  92260. /**
  92261. * The camera currently used for the rendering pass
  92262. */
  92263. camera: Nullable<Camera>;
  92264. /**
  92265. * The ID of the renderingGroup being processed
  92266. */
  92267. renderingGroupId: number;
  92268. }
  92269. /**
  92270. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92271. * It is enable to manage the different groups as well as the different necessary sort functions.
  92272. * This should not be used directly aside of the few static configurations
  92273. */
  92274. export class RenderingManager {
  92275. /**
  92276. * The max id used for rendering groups (not included)
  92277. */
  92278. static MAX_RENDERINGGROUPS: number;
  92279. /**
  92280. * The min id used for rendering groups (included)
  92281. */
  92282. static MIN_RENDERINGGROUPS: number;
  92283. /**
  92284. * Used to globally prevent autoclearing scenes.
  92285. */
  92286. static AUTOCLEAR: boolean;
  92287. /**
  92288. * @hidden
  92289. */
  92290. _useSceneAutoClearSetup: boolean;
  92291. private _scene;
  92292. private _renderingGroups;
  92293. private _depthStencilBufferAlreadyCleaned;
  92294. private _autoClearDepthStencil;
  92295. private _customOpaqueSortCompareFn;
  92296. private _customAlphaTestSortCompareFn;
  92297. private _customTransparentSortCompareFn;
  92298. private _renderingGroupInfo;
  92299. /**
  92300. * Instantiates a new rendering group for a particular scene
  92301. * @param scene Defines the scene the groups belongs to
  92302. */
  92303. constructor(scene: Scene);
  92304. private _clearDepthStencilBuffer;
  92305. /**
  92306. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92307. * @hidden
  92308. */
  92309. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92310. /**
  92311. * Resets the different information of the group to prepare a new frame
  92312. * @hidden
  92313. */
  92314. reset(): void;
  92315. /**
  92316. * Dispose and release the group and its associated resources.
  92317. * @hidden
  92318. */
  92319. dispose(): void;
  92320. /**
  92321. * Clear the info related to rendering groups preventing retention points during dispose.
  92322. */
  92323. freeRenderingGroups(): void;
  92324. private _prepareRenderingGroup;
  92325. /**
  92326. * Add a sprite manager to the rendering manager in order to render it this frame.
  92327. * @param spriteManager Define the sprite manager to render
  92328. */
  92329. dispatchSprites(spriteManager: ISpriteManager): void;
  92330. /**
  92331. * Add a particle system to the rendering manager in order to render it this frame.
  92332. * @param particleSystem Define the particle system to render
  92333. */
  92334. dispatchParticles(particleSystem: IParticleSystem): void;
  92335. /**
  92336. * Add a submesh to the manager in order to render it this frame
  92337. * @param subMesh The submesh to dispatch
  92338. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92339. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92340. */
  92341. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92342. /**
  92343. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92344. * This allowed control for front to back rendering or reversly depending of the special needs.
  92345. *
  92346. * @param renderingGroupId The rendering group id corresponding to its index
  92347. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92348. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92349. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92350. */
  92351. 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;
  92352. /**
  92353. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92354. *
  92355. * @param renderingGroupId The rendering group id corresponding to its index
  92356. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92357. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92358. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92359. */
  92360. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92361. /**
  92362. * Gets the current auto clear configuration for one rendering group of the rendering
  92363. * manager.
  92364. * @param index the rendering group index to get the information for
  92365. * @returns The auto clear setup for the requested rendering group
  92366. */
  92367. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92368. }
  92369. }
  92370. declare module BABYLON {
  92371. /**
  92372. * Defines the options associated with the creation of a custom shader for a shadow generator.
  92373. */
  92374. export interface ICustomShaderOptions {
  92375. /**
  92376. * Gets or sets the custom shader name to use
  92377. */
  92378. shaderName: string;
  92379. /**
  92380. * The list of attribute names used in the shader
  92381. */
  92382. attributes?: string[];
  92383. /**
  92384. * The list of unifrom names used in the shader
  92385. */
  92386. uniforms?: string[];
  92387. /**
  92388. * The list of sampler names used in the shader
  92389. */
  92390. samplers?: string[];
  92391. /**
  92392. * The list of defines used in the shader
  92393. */
  92394. defines?: string[];
  92395. }
  92396. /**
  92397. * Interface to implement to create a shadow generator compatible with BJS.
  92398. */
  92399. export interface IShadowGenerator {
  92400. /**
  92401. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92402. * @returns The render target texture if present otherwise, null
  92403. */
  92404. getShadowMap(): Nullable<RenderTargetTexture>;
  92405. /**
  92406. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92407. * @param subMesh The submesh we want to render in the shadow map
  92408. * @param useInstances Defines wether will draw in the map using instances
  92409. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  92410. * @returns true if ready otherwise, false
  92411. */
  92412. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  92413. /**
  92414. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92415. * @param defines Defines of the material we want to update
  92416. * @param lightIndex Index of the light in the enabled light list of the material
  92417. */
  92418. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  92419. /**
  92420. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92421. * defined in the generator but impacting the effect).
  92422. * It implies the unifroms available on the materials are the standard BJS ones.
  92423. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92424. * @param effect The effect we are binfing the information for
  92425. */
  92426. bindShadowLight(lightIndex: string, effect: Effect): void;
  92427. /**
  92428. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92429. * (eq to shadow prjection matrix * light transform matrix)
  92430. * @returns The transform matrix used to create the shadow map
  92431. */
  92432. getTransformMatrix(): Matrix;
  92433. /**
  92434. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92435. * Cube and 2D textures for instance.
  92436. */
  92437. recreateShadowMap(): void;
  92438. /**
  92439. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92440. * @param onCompiled Callback triggered at the and of the effects compilation
  92441. * @param options Sets of optional options forcing the compilation with different modes
  92442. */
  92443. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92444. useInstances: boolean;
  92445. }>): void;
  92446. /**
  92447. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92448. * @param options Sets of optional options forcing the compilation with different modes
  92449. * @returns A promise that resolves when the compilation completes
  92450. */
  92451. forceCompilationAsync(options?: Partial<{
  92452. useInstances: boolean;
  92453. }>): Promise<void>;
  92454. /**
  92455. * Serializes the shadow generator setup to a json object.
  92456. * @returns The serialized JSON object
  92457. */
  92458. serialize(): any;
  92459. /**
  92460. * Disposes the Shadow map and related Textures and effects.
  92461. */
  92462. dispose(): void;
  92463. }
  92464. /**
  92465. * Default implementation IShadowGenerator.
  92466. * This is the main object responsible of generating shadows in the framework.
  92467. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  92468. */
  92469. export class ShadowGenerator implements IShadowGenerator {
  92470. /**
  92471. * Name of the shadow generator class
  92472. */
  92473. static CLASSNAME: string;
  92474. /**
  92475. * Shadow generator mode None: no filtering applied.
  92476. */
  92477. static readonly FILTER_NONE: number;
  92478. /**
  92479. * Shadow generator mode ESM: Exponential Shadow Mapping.
  92480. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92481. */
  92482. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  92483. /**
  92484. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  92485. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  92486. */
  92487. static readonly FILTER_POISSONSAMPLING: number;
  92488. /**
  92489. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  92490. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92491. */
  92492. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  92493. /**
  92494. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  92495. * edge artifacts on steep falloff.
  92496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92497. */
  92498. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  92499. /**
  92500. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  92501. * edge artifacts on steep falloff.
  92502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92503. */
  92504. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  92505. /**
  92506. * Shadow generator mode PCF: Percentage Closer Filtering
  92507. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92508. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  92509. */
  92510. static readonly FILTER_PCF: number;
  92511. /**
  92512. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  92513. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92514. * Contact Hardening
  92515. */
  92516. static readonly FILTER_PCSS: number;
  92517. /**
  92518. * Reserved for PCF and PCSS
  92519. * Highest Quality.
  92520. *
  92521. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  92522. *
  92523. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  92524. */
  92525. static readonly QUALITY_HIGH: number;
  92526. /**
  92527. * Reserved for PCF and PCSS
  92528. * Good tradeoff for quality/perf cross devices
  92529. *
  92530. * Execute PCF on a 3*3 kernel.
  92531. *
  92532. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  92533. */
  92534. static readonly QUALITY_MEDIUM: number;
  92535. /**
  92536. * Reserved for PCF and PCSS
  92537. * The lowest quality but the fastest.
  92538. *
  92539. * Execute PCF on a 1*1 kernel.
  92540. *
  92541. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  92542. */
  92543. static readonly QUALITY_LOW: number;
  92544. /** Gets or sets the custom shader name to use */
  92545. customShaderOptions: ICustomShaderOptions;
  92546. /**
  92547. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  92548. */
  92549. onBeforeShadowMapRenderObservable: Observable<Effect>;
  92550. /**
  92551. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  92552. */
  92553. onAfterShadowMapRenderObservable: Observable<Effect>;
  92554. /**
  92555. * Observable triggered before a mesh is rendered in the shadow map.
  92556. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  92557. */
  92558. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  92559. /**
  92560. * Observable triggered after a mesh is rendered in the shadow map.
  92561. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  92562. */
  92563. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  92564. protected _bias: number;
  92565. /**
  92566. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  92567. */
  92568. get bias(): number;
  92569. /**
  92570. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  92571. */
  92572. set bias(bias: number);
  92573. protected _normalBias: number;
  92574. /**
  92575. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92576. */
  92577. get normalBias(): number;
  92578. /**
  92579. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92580. */
  92581. set normalBias(normalBias: number);
  92582. protected _blurBoxOffset: number;
  92583. /**
  92584. * Gets the blur box offset: offset applied during the blur pass.
  92585. * Only useful if useKernelBlur = false
  92586. */
  92587. get blurBoxOffset(): number;
  92588. /**
  92589. * Sets the blur box offset: offset applied during the blur pass.
  92590. * Only useful if useKernelBlur = false
  92591. */
  92592. set blurBoxOffset(value: number);
  92593. protected _blurScale: number;
  92594. /**
  92595. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  92596. * 2 means half of the size.
  92597. */
  92598. get blurScale(): number;
  92599. /**
  92600. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  92601. * 2 means half of the size.
  92602. */
  92603. set blurScale(value: number);
  92604. protected _blurKernel: number;
  92605. /**
  92606. * Gets the blur kernel: kernel size of the blur pass.
  92607. * Only useful if useKernelBlur = true
  92608. */
  92609. get blurKernel(): number;
  92610. /**
  92611. * Sets the blur kernel: kernel size of the blur pass.
  92612. * Only useful if useKernelBlur = true
  92613. */
  92614. set blurKernel(value: number);
  92615. protected _useKernelBlur: boolean;
  92616. /**
  92617. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  92618. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92619. */
  92620. get useKernelBlur(): boolean;
  92621. /**
  92622. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  92623. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92624. */
  92625. set useKernelBlur(value: boolean);
  92626. protected _depthScale: number;
  92627. /**
  92628. * Gets the depth scale used in ESM mode.
  92629. */
  92630. get depthScale(): number;
  92631. /**
  92632. * Sets the depth scale used in ESM mode.
  92633. * This can override the scale stored on the light.
  92634. */
  92635. set depthScale(value: number);
  92636. protected _validateFilter(filter: number): number;
  92637. protected _filter: number;
  92638. /**
  92639. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  92640. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92641. */
  92642. get filter(): number;
  92643. /**
  92644. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  92645. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92646. */
  92647. set filter(value: number);
  92648. /**
  92649. * Gets if the current filter is set to Poisson Sampling.
  92650. */
  92651. get usePoissonSampling(): boolean;
  92652. /**
  92653. * Sets the current filter to Poisson Sampling.
  92654. */
  92655. set usePoissonSampling(value: boolean);
  92656. /**
  92657. * Gets if the current filter is set to ESM.
  92658. */
  92659. get useExponentialShadowMap(): boolean;
  92660. /**
  92661. * Sets the current filter is to ESM.
  92662. */
  92663. set useExponentialShadowMap(value: boolean);
  92664. /**
  92665. * Gets if the current filter is set to filtered ESM.
  92666. */
  92667. get useBlurExponentialShadowMap(): boolean;
  92668. /**
  92669. * Gets if the current filter is set to filtered ESM.
  92670. */
  92671. set useBlurExponentialShadowMap(value: boolean);
  92672. /**
  92673. * Gets if the current filter is set to "close ESM" (using the inverse of the
  92674. * exponential to prevent steep falloff artifacts).
  92675. */
  92676. get useCloseExponentialShadowMap(): boolean;
  92677. /**
  92678. * Sets the current filter to "close ESM" (using the inverse of the
  92679. * exponential to prevent steep falloff artifacts).
  92680. */
  92681. set useCloseExponentialShadowMap(value: boolean);
  92682. /**
  92683. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  92684. * exponential to prevent steep falloff artifacts).
  92685. */
  92686. get useBlurCloseExponentialShadowMap(): boolean;
  92687. /**
  92688. * Sets the current filter to filtered "close ESM" (using the inverse of the
  92689. * exponential to prevent steep falloff artifacts).
  92690. */
  92691. set useBlurCloseExponentialShadowMap(value: boolean);
  92692. /**
  92693. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  92694. */
  92695. get usePercentageCloserFiltering(): boolean;
  92696. /**
  92697. * Sets the current filter to "PCF" (percentage closer filtering).
  92698. */
  92699. set usePercentageCloserFiltering(value: boolean);
  92700. protected _filteringQuality: number;
  92701. /**
  92702. * Gets the PCF or PCSS Quality.
  92703. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92704. */
  92705. get filteringQuality(): number;
  92706. /**
  92707. * Sets the PCF or PCSS Quality.
  92708. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92709. */
  92710. set filteringQuality(filteringQuality: number);
  92711. /**
  92712. * Gets if the current filter is set to "PCSS" (contact hardening).
  92713. */
  92714. get useContactHardeningShadow(): boolean;
  92715. /**
  92716. * Sets the current filter to "PCSS" (contact hardening).
  92717. */
  92718. set useContactHardeningShadow(value: boolean);
  92719. protected _contactHardeningLightSizeUVRatio: number;
  92720. /**
  92721. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92722. * Using a ratio helps keeping shape stability independently of the map size.
  92723. *
  92724. * It does not account for the light projection as it was having too much
  92725. * instability during the light setup or during light position changes.
  92726. *
  92727. * Only valid if useContactHardeningShadow is true.
  92728. */
  92729. get contactHardeningLightSizeUVRatio(): number;
  92730. /**
  92731. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92732. * Using a ratio helps keeping shape stability independently of the map size.
  92733. *
  92734. * It does not account for the light projection as it was having too much
  92735. * instability during the light setup or during light position changes.
  92736. *
  92737. * Only valid if useContactHardeningShadow is true.
  92738. */
  92739. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  92740. protected _darkness: number;
  92741. /** Gets or sets the actual darkness of a shadow */
  92742. get darkness(): number;
  92743. set darkness(value: number);
  92744. /**
  92745. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  92746. * 0 means strongest and 1 would means no shadow.
  92747. * @returns the darkness.
  92748. */
  92749. getDarkness(): number;
  92750. /**
  92751. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  92752. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  92753. * @returns the shadow generator allowing fluent coding.
  92754. */
  92755. setDarkness(darkness: number): ShadowGenerator;
  92756. protected _transparencyShadow: boolean;
  92757. /** Gets or sets the ability to have transparent shadow */
  92758. get transparencyShadow(): boolean;
  92759. set transparencyShadow(value: boolean);
  92760. /**
  92761. * Sets the ability to have transparent shadow (boolean).
  92762. * @param transparent True if transparent else False
  92763. * @returns the shadow generator allowing fluent coding
  92764. */
  92765. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  92766. /**
  92767. * Enables or disables shadows with varying strength based on the transparency
  92768. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  92769. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  92770. * mesh.visibility * alphaTexture.a
  92771. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  92772. */
  92773. enableSoftTransparentShadow: boolean;
  92774. protected _shadowMap: Nullable<RenderTargetTexture>;
  92775. protected _shadowMap2: Nullable<RenderTargetTexture>;
  92776. /**
  92777. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92778. * @returns The render target texture if present otherwise, null
  92779. */
  92780. getShadowMap(): Nullable<RenderTargetTexture>;
  92781. /**
  92782. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  92783. * @returns The render target texture if the shadow map is present otherwise, null
  92784. */
  92785. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  92786. /**
  92787. * Gets the class name of that object
  92788. * @returns "ShadowGenerator"
  92789. */
  92790. getClassName(): string;
  92791. /**
  92792. * Helper function to add a mesh and its descendants to the list of shadow casters.
  92793. * @param mesh Mesh to add
  92794. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  92795. * @returns the Shadow Generator itself
  92796. */
  92797. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92798. /**
  92799. * Helper function to remove a mesh and its descendants from the list of shadow casters
  92800. * @param mesh Mesh to remove
  92801. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  92802. * @returns the Shadow Generator itself
  92803. */
  92804. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92805. /**
  92806. * Controls the extent to which the shadows fade out at the edge of the frustum
  92807. */
  92808. frustumEdgeFalloff: number;
  92809. protected _light: IShadowLight;
  92810. /**
  92811. * Returns the associated light object.
  92812. * @returns the light generating the shadow
  92813. */
  92814. getLight(): IShadowLight;
  92815. /**
  92816. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  92817. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  92818. * It might on the other hand introduce peter panning.
  92819. */
  92820. forceBackFacesOnly: boolean;
  92821. protected _scene: Scene;
  92822. protected _lightDirection: Vector3;
  92823. protected _effect: Effect;
  92824. protected _viewMatrix: Matrix;
  92825. protected _projectionMatrix: Matrix;
  92826. protected _transformMatrix: Matrix;
  92827. protected _cachedPosition: Vector3;
  92828. protected _cachedDirection: Vector3;
  92829. protected _cachedDefines: string;
  92830. protected _currentRenderID: number;
  92831. protected _boxBlurPostprocess: Nullable<PostProcess>;
  92832. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  92833. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  92834. protected _blurPostProcesses: PostProcess[];
  92835. protected _mapSize: number;
  92836. protected _currentFaceIndex: number;
  92837. protected _currentFaceIndexCache: number;
  92838. protected _textureType: number;
  92839. protected _defaultTextureMatrix: Matrix;
  92840. protected _storedUniqueId: Nullable<number>;
  92841. /** @hidden */
  92842. static _SceneComponentInitialization: (scene: Scene) => void;
  92843. /**
  92844. * Creates a ShadowGenerator object.
  92845. * A ShadowGenerator is the required tool to use the shadows.
  92846. * Each light casting shadows needs to use its own ShadowGenerator.
  92847. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  92848. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  92849. * @param light The light object generating the shadows.
  92850. * @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.
  92851. */
  92852. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  92853. protected _initializeGenerator(): void;
  92854. protected _createTargetRenderTexture(): void;
  92855. protected _initializeShadowMap(): void;
  92856. protected _initializeBlurRTTAndPostProcesses(): void;
  92857. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  92858. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  92859. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  92860. protected _applyFilterValues(): void;
  92861. /**
  92862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92863. * @param onCompiled Callback triggered at the and of the effects compilation
  92864. * @param options Sets of optional options forcing the compilation with different modes
  92865. */
  92866. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92867. useInstances: boolean;
  92868. }>): void;
  92869. /**
  92870. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92871. * @param options Sets of optional options forcing the compilation with different modes
  92872. * @returns A promise that resolves when the compilation completes
  92873. */
  92874. forceCompilationAsync(options?: Partial<{
  92875. useInstances: boolean;
  92876. }>): Promise<void>;
  92877. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  92878. private _prepareShadowDefines;
  92879. /**
  92880. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92881. * @param subMesh The submesh we want to render in the shadow map
  92882. * @param useInstances Defines wether will draw in the map using instances
  92883. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  92884. * @returns true if ready otherwise, false
  92885. */
  92886. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  92887. /**
  92888. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92889. * @param defines Defines of the material we want to update
  92890. * @param lightIndex Index of the light in the enabled light list of the material
  92891. */
  92892. prepareDefines(defines: any, lightIndex: number): void;
  92893. /**
  92894. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92895. * defined in the generator but impacting the effect).
  92896. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92897. * @param effect The effect we are binfing the information for
  92898. */
  92899. bindShadowLight(lightIndex: string, effect: Effect): void;
  92900. /**
  92901. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92902. * (eq to shadow prjection matrix * light transform matrix)
  92903. * @returns The transform matrix used to create the shadow map
  92904. */
  92905. getTransformMatrix(): Matrix;
  92906. /**
  92907. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92908. * Cube and 2D textures for instance.
  92909. */
  92910. recreateShadowMap(): void;
  92911. protected _disposeBlurPostProcesses(): void;
  92912. protected _disposeRTTandPostProcesses(): void;
  92913. /**
  92914. * Disposes the ShadowGenerator.
  92915. * Returns nothing.
  92916. */
  92917. dispose(): void;
  92918. /**
  92919. * Serializes the shadow generator setup to a json object.
  92920. * @returns The serialized JSON object
  92921. */
  92922. serialize(): any;
  92923. /**
  92924. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  92925. * @param parsedShadowGenerator The JSON object to parse
  92926. * @param scene The scene to create the shadow map for
  92927. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  92928. * @returns The parsed shadow generator
  92929. */
  92930. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  92931. }
  92932. }
  92933. declare module BABYLON {
  92934. /**
  92935. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  92936. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  92937. * 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.
  92938. */
  92939. export abstract class Light extends Node {
  92940. /**
  92941. * Falloff Default: light is falling off following the material specification:
  92942. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  92943. */
  92944. static readonly FALLOFF_DEFAULT: number;
  92945. /**
  92946. * Falloff Physical: light is falling off following the inverse squared distance law.
  92947. */
  92948. static readonly FALLOFF_PHYSICAL: number;
  92949. /**
  92950. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  92951. * to enhance interoperability with other engines.
  92952. */
  92953. static readonly FALLOFF_GLTF: number;
  92954. /**
  92955. * Falloff Standard: light is falling off like in the standard material
  92956. * to enhance interoperability with other materials.
  92957. */
  92958. static readonly FALLOFF_STANDARD: number;
  92959. /**
  92960. * If every light affecting the material is in this lightmapMode,
  92961. * material.lightmapTexture adds or multiplies
  92962. * (depends on material.useLightmapAsShadowmap)
  92963. * after every other light calculations.
  92964. */
  92965. static readonly LIGHTMAP_DEFAULT: number;
  92966. /**
  92967. * material.lightmapTexture as only diffuse lighting from this light
  92968. * adds only specular lighting from this light
  92969. * adds dynamic shadows
  92970. */
  92971. static readonly LIGHTMAP_SPECULAR: number;
  92972. /**
  92973. * material.lightmapTexture as only lighting
  92974. * no light calculation from this light
  92975. * only adds dynamic shadows from this light
  92976. */
  92977. static readonly LIGHTMAP_SHADOWSONLY: number;
  92978. /**
  92979. * Each light type uses the default quantity according to its type:
  92980. * point/spot lights use luminous intensity
  92981. * directional lights use illuminance
  92982. */
  92983. static readonly INTENSITYMODE_AUTOMATIC: number;
  92984. /**
  92985. * lumen (lm)
  92986. */
  92987. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  92988. /**
  92989. * candela (lm/sr)
  92990. */
  92991. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  92992. /**
  92993. * lux (lm/m^2)
  92994. */
  92995. static readonly INTENSITYMODE_ILLUMINANCE: number;
  92996. /**
  92997. * nit (cd/m^2)
  92998. */
  92999. static readonly INTENSITYMODE_LUMINANCE: number;
  93000. /**
  93001. * Light type const id of the point light.
  93002. */
  93003. static readonly LIGHTTYPEID_POINTLIGHT: number;
  93004. /**
  93005. * Light type const id of the directional light.
  93006. */
  93007. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  93008. /**
  93009. * Light type const id of the spot light.
  93010. */
  93011. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  93012. /**
  93013. * Light type const id of the hemispheric light.
  93014. */
  93015. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  93016. /**
  93017. * Diffuse gives the basic color to an object.
  93018. */
  93019. diffuse: Color3;
  93020. /**
  93021. * Specular produces a highlight color on an object.
  93022. * Note: This is note affecting PBR materials.
  93023. */
  93024. specular: Color3;
  93025. /**
  93026. * Defines the falloff type for this light. This lets overrriding how punctual light are
  93027. * falling off base on range or angle.
  93028. * This can be set to any values in Light.FALLOFF_x.
  93029. *
  93030. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  93031. * other types of materials.
  93032. */
  93033. falloffType: number;
  93034. /**
  93035. * Strength of the light.
  93036. * Note: By default it is define in the framework own unit.
  93037. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  93038. */
  93039. intensity: number;
  93040. private _range;
  93041. protected _inverseSquaredRange: number;
  93042. /**
  93043. * Defines how far from the source the light is impacting in scene units.
  93044. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93045. */
  93046. get range(): number;
  93047. /**
  93048. * Defines how far from the source the light is impacting in scene units.
  93049. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93050. */
  93051. set range(value: number);
  93052. /**
  93053. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  93054. * of light.
  93055. */
  93056. private _photometricScale;
  93057. private _intensityMode;
  93058. /**
  93059. * Gets the photometric scale used to interpret the intensity.
  93060. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93061. */
  93062. get intensityMode(): number;
  93063. /**
  93064. * Sets the photometric scale used to interpret the intensity.
  93065. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93066. */
  93067. set intensityMode(value: number);
  93068. private _radius;
  93069. /**
  93070. * Gets the light radius used by PBR Materials to simulate soft area lights.
  93071. */
  93072. get radius(): number;
  93073. /**
  93074. * sets the light radius used by PBR Materials to simulate soft area lights.
  93075. */
  93076. set radius(value: number);
  93077. private _renderPriority;
  93078. /**
  93079. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  93080. * exceeding the number allowed of the materials.
  93081. */
  93082. renderPriority: number;
  93083. private _shadowEnabled;
  93084. /**
  93085. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93086. * the current shadow generator.
  93087. */
  93088. get shadowEnabled(): boolean;
  93089. /**
  93090. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93091. * the current shadow generator.
  93092. */
  93093. set shadowEnabled(value: boolean);
  93094. private _includedOnlyMeshes;
  93095. /**
  93096. * Gets the only meshes impacted by this light.
  93097. */
  93098. get includedOnlyMeshes(): AbstractMesh[];
  93099. /**
  93100. * Sets the only meshes impacted by this light.
  93101. */
  93102. set includedOnlyMeshes(value: AbstractMesh[]);
  93103. private _excludedMeshes;
  93104. /**
  93105. * Gets the meshes not impacted by this light.
  93106. */
  93107. get excludedMeshes(): AbstractMesh[];
  93108. /**
  93109. * Sets the meshes not impacted by this light.
  93110. */
  93111. set excludedMeshes(value: AbstractMesh[]);
  93112. private _excludeWithLayerMask;
  93113. /**
  93114. * Gets the layer id use to find what meshes are not impacted by the light.
  93115. * Inactive if 0
  93116. */
  93117. get excludeWithLayerMask(): number;
  93118. /**
  93119. * Sets the layer id use to find what meshes are not impacted by the light.
  93120. * Inactive if 0
  93121. */
  93122. set excludeWithLayerMask(value: number);
  93123. private _includeOnlyWithLayerMask;
  93124. /**
  93125. * Gets the layer id use to find what meshes are impacted by the light.
  93126. * Inactive if 0
  93127. */
  93128. get includeOnlyWithLayerMask(): number;
  93129. /**
  93130. * Sets the layer id use to find what meshes are impacted by the light.
  93131. * Inactive if 0
  93132. */
  93133. set includeOnlyWithLayerMask(value: number);
  93134. private _lightmapMode;
  93135. /**
  93136. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93137. */
  93138. get lightmapMode(): number;
  93139. /**
  93140. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93141. */
  93142. set lightmapMode(value: number);
  93143. /**
  93144. * Shadow generator associted to the light.
  93145. * @hidden Internal use only.
  93146. */
  93147. _shadowGenerator: Nullable<IShadowGenerator>;
  93148. /**
  93149. * @hidden Internal use only.
  93150. */
  93151. _excludedMeshesIds: string[];
  93152. /**
  93153. * @hidden Internal use only.
  93154. */
  93155. _includedOnlyMeshesIds: string[];
  93156. /**
  93157. * The current light unifom buffer.
  93158. * @hidden Internal use only.
  93159. */
  93160. _uniformBuffer: UniformBuffer;
  93161. /** @hidden */
  93162. _renderId: number;
  93163. /**
  93164. * Creates a Light object in the scene.
  93165. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93166. * @param name The firendly name of the light
  93167. * @param scene The scene the light belongs too
  93168. */
  93169. constructor(name: string, scene: Scene);
  93170. protected abstract _buildUniformLayout(): void;
  93171. /**
  93172. * Sets the passed Effect "effect" with the Light information.
  93173. * @param effect The effect to update
  93174. * @param lightIndex The index of the light in the effect to update
  93175. * @returns The light
  93176. */
  93177. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  93178. /**
  93179. * Sets the passed Effect "effect" with the Light textures.
  93180. * @param effect The effect to update
  93181. * @param lightIndex The index of the light in the effect to update
  93182. * @returns The light
  93183. */
  93184. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  93185. /**
  93186. * Binds the lights information from the scene to the effect for the given mesh.
  93187. * @param lightIndex Light index
  93188. * @param scene The scene where the light belongs to
  93189. * @param effect The effect we are binding the data to
  93190. * @param useSpecular Defines if specular is supported
  93191. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  93192. */
  93193. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  93194. /**
  93195. * Sets the passed Effect "effect" with the Light information.
  93196. * @param effect The effect to update
  93197. * @param lightDataUniformName The uniform used to store light data (position or direction)
  93198. * @returns The light
  93199. */
  93200. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  93201. /**
  93202. * Returns the string "Light".
  93203. * @returns the class name
  93204. */
  93205. getClassName(): string;
  93206. /** @hidden */
  93207. readonly _isLight: boolean;
  93208. /**
  93209. * Converts the light information to a readable string for debug purpose.
  93210. * @param fullDetails Supports for multiple levels of logging within scene loading
  93211. * @returns the human readable light info
  93212. */
  93213. toString(fullDetails?: boolean): string;
  93214. /** @hidden */
  93215. protected _syncParentEnabledState(): void;
  93216. /**
  93217. * Set the enabled state of this node.
  93218. * @param value - the new enabled state
  93219. */
  93220. setEnabled(value: boolean): void;
  93221. /**
  93222. * Returns the Light associated shadow generator if any.
  93223. * @return the associated shadow generator.
  93224. */
  93225. getShadowGenerator(): Nullable<IShadowGenerator>;
  93226. /**
  93227. * Returns a Vector3, the absolute light position in the World.
  93228. * @returns the world space position of the light
  93229. */
  93230. getAbsolutePosition(): Vector3;
  93231. /**
  93232. * Specifies if the light will affect the passed mesh.
  93233. * @param mesh The mesh to test against the light
  93234. * @return true the mesh is affected otherwise, false.
  93235. */
  93236. canAffectMesh(mesh: AbstractMesh): boolean;
  93237. /**
  93238. * Sort function to order lights for rendering.
  93239. * @param a First Light object to compare to second.
  93240. * @param b Second Light object to compare first.
  93241. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  93242. */
  93243. static CompareLightsPriority(a: Light, b: Light): number;
  93244. /**
  93245. * Releases resources associated with this node.
  93246. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93247. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93248. */
  93249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93250. /**
  93251. * Returns the light type ID (integer).
  93252. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93253. */
  93254. getTypeID(): number;
  93255. /**
  93256. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  93257. * @returns the scaled intensity in intensity mode unit
  93258. */
  93259. getScaledIntensity(): number;
  93260. /**
  93261. * Returns a new Light object, named "name", from the current one.
  93262. * @param name The name of the cloned light
  93263. * @param newParent The parent of this light, if it has one
  93264. * @returns the new created light
  93265. */
  93266. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  93267. /**
  93268. * Serializes the current light into a Serialization object.
  93269. * @returns the serialized object.
  93270. */
  93271. serialize(): any;
  93272. /**
  93273. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  93274. * This new light is named "name" and added to the passed scene.
  93275. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  93276. * @param name The friendly name of the light
  93277. * @param scene The scene the new light will belong to
  93278. * @returns the constructor function
  93279. */
  93280. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  93281. /**
  93282. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  93283. * @param parsedLight The JSON representation of the light
  93284. * @param scene The scene to create the parsed light in
  93285. * @returns the created light after parsing
  93286. */
  93287. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  93288. private _hookArrayForExcluded;
  93289. private _hookArrayForIncludedOnly;
  93290. private _resyncMeshes;
  93291. /**
  93292. * Forces the meshes to update their light related information in their rendering used effects
  93293. * @hidden Internal Use Only
  93294. */
  93295. _markMeshesAsLightDirty(): void;
  93296. /**
  93297. * Recomputes the cached photometric scale if needed.
  93298. */
  93299. private _computePhotometricScale;
  93300. /**
  93301. * Returns the Photometric Scale according to the light type and intensity mode.
  93302. */
  93303. private _getPhotometricScale;
  93304. /**
  93305. * Reorder the light in the scene according to their defined priority.
  93306. * @hidden Internal Use Only
  93307. */
  93308. _reorderLightsInScene(): void;
  93309. /**
  93310. * Prepares the list of defines specific to the light type.
  93311. * @param defines the list of defines
  93312. * @param lightIndex defines the index of the light for the effect
  93313. */
  93314. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93315. }
  93316. }
  93317. declare module BABYLON {
  93318. /**
  93319. * Interface used to define Action
  93320. */
  93321. export interface IAction {
  93322. /**
  93323. * Trigger for the action
  93324. */
  93325. trigger: number;
  93326. /** Options of the trigger */
  93327. triggerOptions: any;
  93328. /**
  93329. * Gets the trigger parameters
  93330. * @returns the trigger parameters
  93331. */
  93332. getTriggerParameter(): any;
  93333. /**
  93334. * Internal only - executes current action event
  93335. * @hidden
  93336. */
  93337. _executeCurrent(evt?: ActionEvent): void;
  93338. /**
  93339. * Serialize placeholder for child classes
  93340. * @param parent of child
  93341. * @returns the serialized object
  93342. */
  93343. serialize(parent: any): any;
  93344. /**
  93345. * Internal only
  93346. * @hidden
  93347. */
  93348. _prepare(): void;
  93349. /**
  93350. * Internal only - manager for action
  93351. * @hidden
  93352. */
  93353. _actionManager: AbstractActionManager;
  93354. /**
  93355. * Adds action to chain of actions, may be a DoNothingAction
  93356. * @param action defines the next action to execute
  93357. * @returns The action passed in
  93358. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93359. */
  93360. then(action: IAction): IAction;
  93361. }
  93362. /**
  93363. * The action to be carried out following a trigger
  93364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  93365. */
  93366. export class Action implements IAction {
  93367. /** the trigger, with or without parameters, for the action */
  93368. triggerOptions: any;
  93369. /**
  93370. * Trigger for the action
  93371. */
  93372. trigger: number;
  93373. /**
  93374. * Internal only - manager for action
  93375. * @hidden
  93376. */
  93377. _actionManager: ActionManager;
  93378. private _nextActiveAction;
  93379. private _child;
  93380. private _condition?;
  93381. private _triggerParameter;
  93382. /**
  93383. * An event triggered prior to action being executed.
  93384. */
  93385. onBeforeExecuteObservable: Observable<Action>;
  93386. /**
  93387. * Creates a new Action
  93388. * @param triggerOptions the trigger, with or without parameters, for the action
  93389. * @param condition an optional determinant of action
  93390. */
  93391. constructor(
  93392. /** the trigger, with or without parameters, for the action */
  93393. triggerOptions: any, condition?: Condition);
  93394. /**
  93395. * Internal only
  93396. * @hidden
  93397. */
  93398. _prepare(): void;
  93399. /**
  93400. * Gets the trigger parameters
  93401. * @returns the trigger parameters
  93402. */
  93403. getTriggerParameter(): any;
  93404. /**
  93405. * Internal only - executes current action event
  93406. * @hidden
  93407. */
  93408. _executeCurrent(evt?: ActionEvent): void;
  93409. /**
  93410. * Execute placeholder for child classes
  93411. * @param evt optional action event
  93412. */
  93413. execute(evt?: ActionEvent): void;
  93414. /**
  93415. * Skips to next active action
  93416. */
  93417. skipToNextActiveAction(): void;
  93418. /**
  93419. * Adds action to chain of actions, may be a DoNothingAction
  93420. * @param action defines the next action to execute
  93421. * @returns The action passed in
  93422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93423. */
  93424. then(action: Action): Action;
  93425. /**
  93426. * Internal only
  93427. * @hidden
  93428. */
  93429. _getProperty(propertyPath: string): string;
  93430. /**
  93431. * Internal only
  93432. * @hidden
  93433. */
  93434. _getEffectiveTarget(target: any, propertyPath: string): any;
  93435. /**
  93436. * Serialize placeholder for child classes
  93437. * @param parent of child
  93438. * @returns the serialized object
  93439. */
  93440. serialize(parent: any): any;
  93441. /**
  93442. * Internal only called by serialize
  93443. * @hidden
  93444. */
  93445. protected _serialize(serializedAction: any, parent?: any): any;
  93446. /**
  93447. * Internal only
  93448. * @hidden
  93449. */
  93450. static _SerializeValueAsString: (value: any) => string;
  93451. /**
  93452. * Internal only
  93453. * @hidden
  93454. */
  93455. static _GetTargetProperty: (target: Node | Scene) => {
  93456. name: string;
  93457. targetType: string;
  93458. value: string;
  93459. };
  93460. }
  93461. }
  93462. declare module BABYLON {
  93463. /**
  93464. * A Condition applied to an Action
  93465. */
  93466. export class Condition {
  93467. /**
  93468. * Internal only - manager for action
  93469. * @hidden
  93470. */
  93471. _actionManager: ActionManager;
  93472. /**
  93473. * Internal only
  93474. * @hidden
  93475. */
  93476. _evaluationId: number;
  93477. /**
  93478. * Internal only
  93479. * @hidden
  93480. */
  93481. _currentResult: boolean;
  93482. /**
  93483. * Creates a new Condition
  93484. * @param actionManager the manager of the action the condition is applied to
  93485. */
  93486. constructor(actionManager: ActionManager);
  93487. /**
  93488. * Check if the current condition is valid
  93489. * @returns a boolean
  93490. */
  93491. isValid(): boolean;
  93492. /**
  93493. * Internal only
  93494. * @hidden
  93495. */
  93496. _getProperty(propertyPath: string): string;
  93497. /**
  93498. * Internal only
  93499. * @hidden
  93500. */
  93501. _getEffectiveTarget(target: any, propertyPath: string): any;
  93502. /**
  93503. * Serialize placeholder for child classes
  93504. * @returns the serialized object
  93505. */
  93506. serialize(): any;
  93507. /**
  93508. * Internal only
  93509. * @hidden
  93510. */
  93511. protected _serialize(serializedCondition: any): any;
  93512. }
  93513. /**
  93514. * Defines specific conditional operators as extensions of Condition
  93515. */
  93516. export class ValueCondition extends Condition {
  93517. /** path to specify the property of the target the conditional operator uses */
  93518. propertyPath: string;
  93519. /** the value compared by the conditional operator against the current value of the property */
  93520. value: any;
  93521. /** the conditional operator, default ValueCondition.IsEqual */
  93522. operator: number;
  93523. /**
  93524. * Internal only
  93525. * @hidden
  93526. */
  93527. private static _IsEqual;
  93528. /**
  93529. * Internal only
  93530. * @hidden
  93531. */
  93532. private static _IsDifferent;
  93533. /**
  93534. * Internal only
  93535. * @hidden
  93536. */
  93537. private static _IsGreater;
  93538. /**
  93539. * Internal only
  93540. * @hidden
  93541. */
  93542. private static _IsLesser;
  93543. /**
  93544. * returns the number for IsEqual
  93545. */
  93546. static get IsEqual(): number;
  93547. /**
  93548. * Returns the number for IsDifferent
  93549. */
  93550. static get IsDifferent(): number;
  93551. /**
  93552. * Returns the number for IsGreater
  93553. */
  93554. static get IsGreater(): number;
  93555. /**
  93556. * Returns the number for IsLesser
  93557. */
  93558. static get IsLesser(): number;
  93559. /**
  93560. * Internal only The action manager for the condition
  93561. * @hidden
  93562. */
  93563. _actionManager: ActionManager;
  93564. /**
  93565. * Internal only
  93566. * @hidden
  93567. */
  93568. private _target;
  93569. /**
  93570. * Internal only
  93571. * @hidden
  93572. */
  93573. private _effectiveTarget;
  93574. /**
  93575. * Internal only
  93576. * @hidden
  93577. */
  93578. private _property;
  93579. /**
  93580. * Creates a new ValueCondition
  93581. * @param actionManager manager for the action the condition applies to
  93582. * @param target for the action
  93583. * @param propertyPath path to specify the property of the target the conditional operator uses
  93584. * @param value the value compared by the conditional operator against the current value of the property
  93585. * @param operator the conditional operator, default ValueCondition.IsEqual
  93586. */
  93587. constructor(actionManager: ActionManager, target: any,
  93588. /** path to specify the property of the target the conditional operator uses */
  93589. propertyPath: string,
  93590. /** the value compared by the conditional operator against the current value of the property */
  93591. value: any,
  93592. /** the conditional operator, default ValueCondition.IsEqual */
  93593. operator?: number);
  93594. /**
  93595. * Compares the given value with the property value for the specified conditional operator
  93596. * @returns the result of the comparison
  93597. */
  93598. isValid(): boolean;
  93599. /**
  93600. * Serialize the ValueCondition into a JSON compatible object
  93601. * @returns serialization object
  93602. */
  93603. serialize(): any;
  93604. /**
  93605. * Gets the name of the conditional operator for the ValueCondition
  93606. * @param operator the conditional operator
  93607. * @returns the name
  93608. */
  93609. static GetOperatorName(operator: number): string;
  93610. }
  93611. /**
  93612. * Defines a predicate condition as an extension of Condition
  93613. */
  93614. export class PredicateCondition extends Condition {
  93615. /** defines the predicate function used to validate the condition */
  93616. predicate: () => boolean;
  93617. /**
  93618. * Internal only - manager for action
  93619. * @hidden
  93620. */
  93621. _actionManager: ActionManager;
  93622. /**
  93623. * Creates a new PredicateCondition
  93624. * @param actionManager manager for the action the condition applies to
  93625. * @param predicate defines the predicate function used to validate the condition
  93626. */
  93627. constructor(actionManager: ActionManager,
  93628. /** defines the predicate function used to validate the condition */
  93629. predicate: () => boolean);
  93630. /**
  93631. * @returns the validity of the predicate condition
  93632. */
  93633. isValid(): boolean;
  93634. }
  93635. /**
  93636. * Defines a state condition as an extension of Condition
  93637. */
  93638. export class StateCondition extends Condition {
  93639. /** Value to compare with target state */
  93640. value: string;
  93641. /**
  93642. * Internal only - manager for action
  93643. * @hidden
  93644. */
  93645. _actionManager: ActionManager;
  93646. /**
  93647. * Internal only
  93648. * @hidden
  93649. */
  93650. private _target;
  93651. /**
  93652. * Creates a new StateCondition
  93653. * @param actionManager manager for the action the condition applies to
  93654. * @param target of the condition
  93655. * @param value to compare with target state
  93656. */
  93657. constructor(actionManager: ActionManager, target: any,
  93658. /** Value to compare with target state */
  93659. value: string);
  93660. /**
  93661. * Gets a boolean indicating if the current condition is met
  93662. * @returns the validity of the state
  93663. */
  93664. isValid(): boolean;
  93665. /**
  93666. * Serialize the StateCondition into a JSON compatible object
  93667. * @returns serialization object
  93668. */
  93669. serialize(): any;
  93670. }
  93671. }
  93672. declare module BABYLON {
  93673. /**
  93674. * This defines an action responsible to toggle a boolean once triggered.
  93675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93676. */
  93677. export class SwitchBooleanAction extends Action {
  93678. /**
  93679. * The path to the boolean property in the target object
  93680. */
  93681. propertyPath: string;
  93682. private _target;
  93683. private _effectiveTarget;
  93684. private _property;
  93685. /**
  93686. * Instantiate the action
  93687. * @param triggerOptions defines the trigger options
  93688. * @param target defines the object containing the boolean
  93689. * @param propertyPath defines the path to the boolean property in the target object
  93690. * @param condition defines the trigger related conditions
  93691. */
  93692. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  93693. /** @hidden */
  93694. _prepare(): void;
  93695. /**
  93696. * Execute the action toggle the boolean value.
  93697. */
  93698. execute(): void;
  93699. /**
  93700. * Serializes the actions and its related information.
  93701. * @param parent defines the object to serialize in
  93702. * @returns the serialized object
  93703. */
  93704. serialize(parent: any): any;
  93705. }
  93706. /**
  93707. * This defines an action responsible to set a the state field of the target
  93708. * to a desired value once triggered.
  93709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93710. */
  93711. export class SetStateAction extends Action {
  93712. /**
  93713. * The value to store in the state field.
  93714. */
  93715. value: string;
  93716. private _target;
  93717. /**
  93718. * Instantiate the action
  93719. * @param triggerOptions defines the trigger options
  93720. * @param target defines the object containing the state property
  93721. * @param value defines the value to store in the state field
  93722. * @param condition defines the trigger related conditions
  93723. */
  93724. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  93725. /**
  93726. * Execute the action and store the value on the target state property.
  93727. */
  93728. execute(): void;
  93729. /**
  93730. * Serializes the actions and its related information.
  93731. * @param parent defines the object to serialize in
  93732. * @returns the serialized object
  93733. */
  93734. serialize(parent: any): any;
  93735. }
  93736. /**
  93737. * This defines an action responsible to set a property of the target
  93738. * to a desired value once triggered.
  93739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93740. */
  93741. export class SetValueAction extends Action {
  93742. /**
  93743. * The path of the property to set in the target.
  93744. */
  93745. propertyPath: string;
  93746. /**
  93747. * The value to set in the property
  93748. */
  93749. value: any;
  93750. private _target;
  93751. private _effectiveTarget;
  93752. private _property;
  93753. /**
  93754. * Instantiate the action
  93755. * @param triggerOptions defines the trigger options
  93756. * @param target defines the object containing the property
  93757. * @param propertyPath defines the path of the property to set in the target
  93758. * @param value defines the value to set in the property
  93759. * @param condition defines the trigger related conditions
  93760. */
  93761. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93762. /** @hidden */
  93763. _prepare(): void;
  93764. /**
  93765. * Execute the action and set the targetted property to the desired value.
  93766. */
  93767. execute(): void;
  93768. /**
  93769. * Serializes the actions and its related information.
  93770. * @param parent defines the object to serialize in
  93771. * @returns the serialized object
  93772. */
  93773. serialize(parent: any): any;
  93774. }
  93775. /**
  93776. * This defines an action responsible to increment the target value
  93777. * to a desired value once triggered.
  93778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93779. */
  93780. export class IncrementValueAction extends Action {
  93781. /**
  93782. * The path of the property to increment in the target.
  93783. */
  93784. propertyPath: string;
  93785. /**
  93786. * The value we should increment the property by.
  93787. */
  93788. value: any;
  93789. private _target;
  93790. private _effectiveTarget;
  93791. private _property;
  93792. /**
  93793. * Instantiate the action
  93794. * @param triggerOptions defines the trigger options
  93795. * @param target defines the object containing the property
  93796. * @param propertyPath defines the path of the property to increment in the target
  93797. * @param value defines the value value we should increment the property by
  93798. * @param condition defines the trigger related conditions
  93799. */
  93800. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93801. /** @hidden */
  93802. _prepare(): void;
  93803. /**
  93804. * Execute the action and increment the target of the value amount.
  93805. */
  93806. execute(): void;
  93807. /**
  93808. * Serializes the actions and its related information.
  93809. * @param parent defines the object to serialize in
  93810. * @returns the serialized object
  93811. */
  93812. serialize(parent: any): any;
  93813. }
  93814. /**
  93815. * This defines an action responsible to start an animation once triggered.
  93816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93817. */
  93818. export class PlayAnimationAction extends Action {
  93819. /**
  93820. * Where the animation should start (animation frame)
  93821. */
  93822. from: number;
  93823. /**
  93824. * Where the animation should stop (animation frame)
  93825. */
  93826. to: number;
  93827. /**
  93828. * Define if the animation should loop or stop after the first play.
  93829. */
  93830. loop?: boolean;
  93831. private _target;
  93832. /**
  93833. * Instantiate the action
  93834. * @param triggerOptions defines the trigger options
  93835. * @param target defines the target animation or animation name
  93836. * @param from defines from where the animation should start (animation frame)
  93837. * @param end defines where the animation should stop (animation frame)
  93838. * @param loop defines if the animation should loop or stop after the first play
  93839. * @param condition defines the trigger related conditions
  93840. */
  93841. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  93842. /** @hidden */
  93843. _prepare(): void;
  93844. /**
  93845. * Execute the action and play the animation.
  93846. */
  93847. execute(): void;
  93848. /**
  93849. * Serializes the actions and its related information.
  93850. * @param parent defines the object to serialize in
  93851. * @returns the serialized object
  93852. */
  93853. serialize(parent: any): any;
  93854. }
  93855. /**
  93856. * This defines an action responsible to stop an animation once triggered.
  93857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93858. */
  93859. export class StopAnimationAction extends Action {
  93860. private _target;
  93861. /**
  93862. * Instantiate the action
  93863. * @param triggerOptions defines the trigger options
  93864. * @param target defines the target animation or animation name
  93865. * @param condition defines the trigger related conditions
  93866. */
  93867. constructor(triggerOptions: any, target: any, condition?: Condition);
  93868. /** @hidden */
  93869. _prepare(): void;
  93870. /**
  93871. * Execute the action and stop the animation.
  93872. */
  93873. execute(): void;
  93874. /**
  93875. * Serializes the actions and its related information.
  93876. * @param parent defines the object to serialize in
  93877. * @returns the serialized object
  93878. */
  93879. serialize(parent: any): any;
  93880. }
  93881. /**
  93882. * This defines an action responsible that does nothing once triggered.
  93883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93884. */
  93885. export class DoNothingAction extends Action {
  93886. /**
  93887. * Instantiate the action
  93888. * @param triggerOptions defines the trigger options
  93889. * @param condition defines the trigger related conditions
  93890. */
  93891. constructor(triggerOptions?: any, condition?: Condition);
  93892. /**
  93893. * Execute the action and do nothing.
  93894. */
  93895. execute(): void;
  93896. /**
  93897. * Serializes the actions and its related information.
  93898. * @param parent defines the object to serialize in
  93899. * @returns the serialized object
  93900. */
  93901. serialize(parent: any): any;
  93902. }
  93903. /**
  93904. * This defines an action responsible to trigger several actions once triggered.
  93905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93906. */
  93907. export class CombineAction extends Action {
  93908. /**
  93909. * The list of aggregated animations to run.
  93910. */
  93911. children: Action[];
  93912. /**
  93913. * Instantiate the action
  93914. * @param triggerOptions defines the trigger options
  93915. * @param children defines the list of aggregated animations to run
  93916. * @param condition defines the trigger related conditions
  93917. */
  93918. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  93919. /** @hidden */
  93920. _prepare(): void;
  93921. /**
  93922. * Execute the action and executes all the aggregated actions.
  93923. */
  93924. execute(evt: ActionEvent): void;
  93925. /**
  93926. * Serializes the actions and its related information.
  93927. * @param parent defines the object to serialize in
  93928. * @returns the serialized object
  93929. */
  93930. serialize(parent: any): any;
  93931. }
  93932. /**
  93933. * This defines an action responsible to run code (external event) once triggered.
  93934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93935. */
  93936. export class ExecuteCodeAction extends Action {
  93937. /**
  93938. * The callback function to run.
  93939. */
  93940. func: (evt: ActionEvent) => void;
  93941. /**
  93942. * Instantiate the action
  93943. * @param triggerOptions defines the trigger options
  93944. * @param func defines the callback function to run
  93945. * @param condition defines the trigger related conditions
  93946. */
  93947. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  93948. /**
  93949. * Execute the action and run the attached code.
  93950. */
  93951. execute(evt: ActionEvent): void;
  93952. }
  93953. /**
  93954. * This defines an action responsible to set the parent property of the target once triggered.
  93955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93956. */
  93957. export class SetParentAction extends Action {
  93958. private _parent;
  93959. private _target;
  93960. /**
  93961. * Instantiate the action
  93962. * @param triggerOptions defines the trigger options
  93963. * @param target defines the target containing the parent property
  93964. * @param parent defines from where the animation should start (animation frame)
  93965. * @param condition defines the trigger related conditions
  93966. */
  93967. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  93968. /** @hidden */
  93969. _prepare(): void;
  93970. /**
  93971. * Execute the action and set the parent property.
  93972. */
  93973. execute(): void;
  93974. /**
  93975. * Serializes the actions and its related information.
  93976. * @param parent defines the object to serialize in
  93977. * @returns the serialized object
  93978. */
  93979. serialize(parent: any): any;
  93980. }
  93981. }
  93982. declare module BABYLON {
  93983. /**
  93984. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  93985. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  93986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93987. */
  93988. export class ActionManager extends AbstractActionManager {
  93989. /**
  93990. * Nothing
  93991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93992. */
  93993. static readonly NothingTrigger: number;
  93994. /**
  93995. * On pick
  93996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93997. */
  93998. static readonly OnPickTrigger: number;
  93999. /**
  94000. * On left pick
  94001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94002. */
  94003. static readonly OnLeftPickTrigger: number;
  94004. /**
  94005. * On right pick
  94006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94007. */
  94008. static readonly OnRightPickTrigger: number;
  94009. /**
  94010. * On center pick
  94011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94012. */
  94013. static readonly OnCenterPickTrigger: number;
  94014. /**
  94015. * On pick down
  94016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94017. */
  94018. static readonly OnPickDownTrigger: number;
  94019. /**
  94020. * On double pick
  94021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94022. */
  94023. static readonly OnDoublePickTrigger: number;
  94024. /**
  94025. * On pick up
  94026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94027. */
  94028. static readonly OnPickUpTrigger: number;
  94029. /**
  94030. * On pick out.
  94031. * This trigger will only be raised if you also declared a OnPickDown
  94032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94033. */
  94034. static readonly OnPickOutTrigger: number;
  94035. /**
  94036. * On long press
  94037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94038. */
  94039. static readonly OnLongPressTrigger: number;
  94040. /**
  94041. * On pointer over
  94042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94043. */
  94044. static readonly OnPointerOverTrigger: number;
  94045. /**
  94046. * On pointer out
  94047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94048. */
  94049. static readonly OnPointerOutTrigger: number;
  94050. /**
  94051. * On every frame
  94052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94053. */
  94054. static readonly OnEveryFrameTrigger: number;
  94055. /**
  94056. * On intersection enter
  94057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94058. */
  94059. static readonly OnIntersectionEnterTrigger: number;
  94060. /**
  94061. * On intersection exit
  94062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94063. */
  94064. static readonly OnIntersectionExitTrigger: number;
  94065. /**
  94066. * On key down
  94067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94068. */
  94069. static readonly OnKeyDownTrigger: number;
  94070. /**
  94071. * On key up
  94072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94073. */
  94074. static readonly OnKeyUpTrigger: number;
  94075. private _scene;
  94076. /**
  94077. * Creates a new action manager
  94078. * @param scene defines the hosting scene
  94079. */
  94080. constructor(scene: Scene);
  94081. /**
  94082. * Releases all associated resources
  94083. */
  94084. dispose(): void;
  94085. /**
  94086. * Gets hosting scene
  94087. * @returns the hosting scene
  94088. */
  94089. getScene(): Scene;
  94090. /**
  94091. * Does this action manager handles actions of any of the given triggers
  94092. * @param triggers defines the triggers to be tested
  94093. * @return a boolean indicating whether one (or more) of the triggers is handled
  94094. */
  94095. hasSpecificTriggers(triggers: number[]): boolean;
  94096. /**
  94097. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94098. * speed.
  94099. * @param triggerA defines the trigger to be tested
  94100. * @param triggerB defines the trigger to be tested
  94101. * @return a boolean indicating whether one (or more) of the triggers is handled
  94102. */
  94103. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94104. /**
  94105. * Does this action manager handles actions of a given trigger
  94106. * @param trigger defines the trigger to be tested
  94107. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94108. * @return whether the trigger is handled
  94109. */
  94110. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94111. /**
  94112. * Does this action manager has pointer triggers
  94113. */
  94114. get hasPointerTriggers(): boolean;
  94115. /**
  94116. * Does this action manager has pick triggers
  94117. */
  94118. get hasPickTriggers(): boolean;
  94119. /**
  94120. * Registers an action to this action manager
  94121. * @param action defines the action to be registered
  94122. * @return the action amended (prepared) after registration
  94123. */
  94124. registerAction(action: IAction): Nullable<IAction>;
  94125. /**
  94126. * Unregisters an action to this action manager
  94127. * @param action defines the action to be unregistered
  94128. * @return a boolean indicating whether the action has been unregistered
  94129. */
  94130. unregisterAction(action: IAction): Boolean;
  94131. /**
  94132. * Process a specific trigger
  94133. * @param trigger defines the trigger to process
  94134. * @param evt defines the event details to be processed
  94135. */
  94136. processTrigger(trigger: number, evt?: IActionEvent): void;
  94137. /** @hidden */
  94138. _getEffectiveTarget(target: any, propertyPath: string): any;
  94139. /** @hidden */
  94140. _getProperty(propertyPath: string): string;
  94141. /**
  94142. * Serialize this manager to a JSON object
  94143. * @param name defines the property name to store this manager
  94144. * @returns a JSON representation of this manager
  94145. */
  94146. serialize(name: string): any;
  94147. /**
  94148. * Creates a new ActionManager from a JSON data
  94149. * @param parsedActions defines the JSON data to read from
  94150. * @param object defines the hosting mesh
  94151. * @param scene defines the hosting scene
  94152. */
  94153. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  94154. /**
  94155. * Get a trigger name by index
  94156. * @param trigger defines the trigger index
  94157. * @returns a trigger name
  94158. */
  94159. static GetTriggerName(trigger: number): string;
  94160. }
  94161. }
  94162. declare module BABYLON {
  94163. /**
  94164. * Class used to represent a sprite
  94165. * @see http://doc.babylonjs.com/babylon101/sprites
  94166. */
  94167. export class Sprite {
  94168. /** defines the name */
  94169. name: string;
  94170. /** Gets or sets the current world position */
  94171. position: Vector3;
  94172. /** Gets or sets the main color */
  94173. color: Color4;
  94174. /** Gets or sets the width */
  94175. width: number;
  94176. /** Gets or sets the height */
  94177. height: number;
  94178. /** Gets or sets rotation angle */
  94179. angle: number;
  94180. /** Gets or sets the cell index in the sprite sheet */
  94181. cellIndex: number;
  94182. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  94183. cellRef: string;
  94184. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  94185. invertU: number;
  94186. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  94187. invertV: number;
  94188. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  94189. disposeWhenFinishedAnimating: boolean;
  94190. /** Gets the list of attached animations */
  94191. animations: Animation[];
  94192. /** Gets or sets a boolean indicating if the sprite can be picked */
  94193. isPickable: boolean;
  94194. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  94195. useAlphaForPicking: boolean;
  94196. /** @hidden */
  94197. _xOffset: number;
  94198. /** @hidden */
  94199. _yOffset: number;
  94200. /** @hidden */
  94201. _xSize: number;
  94202. /** @hidden */
  94203. _ySize: number;
  94204. /**
  94205. * Gets or sets the associated action manager
  94206. */
  94207. actionManager: Nullable<ActionManager>;
  94208. /**
  94209. * An event triggered when the control has been disposed
  94210. */
  94211. onDisposeObservable: Observable<Sprite>;
  94212. private _animationStarted;
  94213. private _loopAnimation;
  94214. private _fromIndex;
  94215. private _toIndex;
  94216. private _delay;
  94217. private _direction;
  94218. private _manager;
  94219. private _time;
  94220. private _onAnimationEnd;
  94221. /**
  94222. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  94223. */
  94224. isVisible: boolean;
  94225. /**
  94226. * Gets or sets the sprite size
  94227. */
  94228. get size(): number;
  94229. set size(value: number);
  94230. /**
  94231. * Gets or sets the unique id of the sprite
  94232. */
  94233. uniqueId: number;
  94234. /**
  94235. * Creates a new Sprite
  94236. * @param name defines the name
  94237. * @param manager defines the manager
  94238. */
  94239. constructor(
  94240. /** defines the name */
  94241. name: string, manager: ISpriteManager);
  94242. /**
  94243. * Returns the string "Sprite"
  94244. * @returns "Sprite"
  94245. */
  94246. getClassName(): string;
  94247. /**
  94248. * Starts an animation
  94249. * @param from defines the initial key
  94250. * @param to defines the end key
  94251. * @param loop defines if the animation must loop
  94252. * @param delay defines the start delay (in ms)
  94253. * @param onAnimationEnd defines a callback to call when animation ends
  94254. */
  94255. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  94256. /** Stops current animation (if any) */
  94257. stopAnimation(): void;
  94258. /** @hidden */
  94259. _animate(deltaTime: number): void;
  94260. /** Release associated resources */
  94261. dispose(): void;
  94262. }
  94263. }
  94264. declare module BABYLON {
  94265. /**
  94266. * Information about the result of picking within a scene
  94267. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  94268. */
  94269. export class PickingInfo {
  94270. /** @hidden */
  94271. _pickingUnavailable: boolean;
  94272. /**
  94273. * If the pick collided with an object
  94274. */
  94275. hit: boolean;
  94276. /**
  94277. * Distance away where the pick collided
  94278. */
  94279. distance: number;
  94280. /**
  94281. * The location of pick collision
  94282. */
  94283. pickedPoint: Nullable<Vector3>;
  94284. /**
  94285. * The mesh corresponding the the pick collision
  94286. */
  94287. pickedMesh: Nullable<AbstractMesh>;
  94288. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  94289. bu: number;
  94290. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  94291. bv: number;
  94292. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  94293. faceId: number;
  94294. /** Id of the the submesh that was picked */
  94295. subMeshId: number;
  94296. /** If a sprite was picked, this will be the sprite the pick collided with */
  94297. pickedSprite: Nullable<Sprite>;
  94298. /**
  94299. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  94300. */
  94301. originMesh: Nullable<AbstractMesh>;
  94302. /**
  94303. * The ray that was used to perform the picking.
  94304. */
  94305. ray: Nullable<Ray>;
  94306. /**
  94307. * Gets the normal correspodning to the face the pick collided with
  94308. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  94309. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  94310. * @returns The normal correspodning to the face the pick collided with
  94311. */
  94312. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  94313. /**
  94314. * Gets the texture coordinates of where the pick occured
  94315. * @returns the vector containing the coordnates of the texture
  94316. */
  94317. getTextureCoordinates(): Nullable<Vector2>;
  94318. }
  94319. }
  94320. declare module BABYLON {
  94321. /**
  94322. * Gather the list of pointer event types as constants.
  94323. */
  94324. export class PointerEventTypes {
  94325. /**
  94326. * 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.
  94327. */
  94328. static readonly POINTERDOWN: number;
  94329. /**
  94330. * The pointerup event is fired when a pointer is no longer active.
  94331. */
  94332. static readonly POINTERUP: number;
  94333. /**
  94334. * The pointermove event is fired when a pointer changes coordinates.
  94335. */
  94336. static readonly POINTERMOVE: number;
  94337. /**
  94338. * The pointerwheel event is fired when a mouse wheel has been rotated.
  94339. */
  94340. static readonly POINTERWHEEL: number;
  94341. /**
  94342. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  94343. */
  94344. static readonly POINTERPICK: number;
  94345. /**
  94346. * The pointertap event is fired when a the object has been touched and released without drag.
  94347. */
  94348. static readonly POINTERTAP: number;
  94349. /**
  94350. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  94351. */
  94352. static readonly POINTERDOUBLETAP: number;
  94353. }
  94354. /**
  94355. * Base class of pointer info types.
  94356. */
  94357. export class PointerInfoBase {
  94358. /**
  94359. * Defines the type of event (PointerEventTypes)
  94360. */
  94361. type: number;
  94362. /**
  94363. * Defines the related dom event
  94364. */
  94365. event: PointerEvent | MouseWheelEvent;
  94366. /**
  94367. * Instantiates the base class of pointers info.
  94368. * @param type Defines the type of event (PointerEventTypes)
  94369. * @param event Defines the related dom event
  94370. */
  94371. constructor(
  94372. /**
  94373. * Defines the type of event (PointerEventTypes)
  94374. */
  94375. type: number,
  94376. /**
  94377. * Defines the related dom event
  94378. */
  94379. event: PointerEvent | MouseWheelEvent);
  94380. }
  94381. /**
  94382. * This class is used to store pointer related info for the onPrePointerObservable event.
  94383. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  94384. */
  94385. export class PointerInfoPre extends PointerInfoBase {
  94386. /**
  94387. * Ray from a pointer if availible (eg. 6dof controller)
  94388. */
  94389. ray: Nullable<Ray>;
  94390. /**
  94391. * Defines the local position of the pointer on the canvas.
  94392. */
  94393. localPosition: Vector2;
  94394. /**
  94395. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  94396. */
  94397. skipOnPointerObservable: boolean;
  94398. /**
  94399. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  94400. * @param type Defines the type of event (PointerEventTypes)
  94401. * @param event Defines the related dom event
  94402. * @param localX Defines the local x coordinates of the pointer when the event occured
  94403. * @param localY Defines the local y coordinates of the pointer when the event occured
  94404. */
  94405. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  94406. }
  94407. /**
  94408. * This type contains all the data related to a pointer event in Babylon.js.
  94409. * 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.
  94410. */
  94411. export class PointerInfo extends PointerInfoBase {
  94412. /**
  94413. * Defines the picking info associated to the info (if any)\
  94414. */
  94415. pickInfo: Nullable<PickingInfo>;
  94416. /**
  94417. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  94418. * @param type Defines the type of event (PointerEventTypes)
  94419. * @param event Defines the related dom event
  94420. * @param pickInfo Defines the picking info associated to the info (if any)\
  94421. */
  94422. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  94423. /**
  94424. * Defines the picking info associated to the info (if any)\
  94425. */
  94426. pickInfo: Nullable<PickingInfo>);
  94427. }
  94428. /**
  94429. * Data relating to a touch event on the screen.
  94430. */
  94431. export interface PointerTouch {
  94432. /**
  94433. * X coordinate of touch.
  94434. */
  94435. x: number;
  94436. /**
  94437. * Y coordinate of touch.
  94438. */
  94439. y: number;
  94440. /**
  94441. * Id of touch. Unique for each finger.
  94442. */
  94443. pointerId: number;
  94444. /**
  94445. * Event type passed from DOM.
  94446. */
  94447. type: any;
  94448. }
  94449. }
  94450. declare module BABYLON {
  94451. /**
  94452. * Manage the mouse inputs to control the movement of a free camera.
  94453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94454. */
  94455. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  94456. /**
  94457. * Define if touch is enabled in the mouse input
  94458. */
  94459. touchEnabled: boolean;
  94460. /**
  94461. * Defines the camera the input is attached to.
  94462. */
  94463. camera: FreeCamera;
  94464. /**
  94465. * Defines the buttons associated with the input to handle camera move.
  94466. */
  94467. buttons: number[];
  94468. /**
  94469. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  94470. */
  94471. angularSensibility: number;
  94472. private _pointerInput;
  94473. private _onMouseMove;
  94474. private _observer;
  94475. private previousPosition;
  94476. /**
  94477. * Observable for when a pointer move event occurs containing the move offset
  94478. */
  94479. onPointerMovedObservable: Observable<{
  94480. offsetX: number;
  94481. offsetY: number;
  94482. }>;
  94483. /**
  94484. * @hidden
  94485. * If the camera should be rotated automatically based on pointer movement
  94486. */
  94487. _allowCameraRotation: boolean;
  94488. /**
  94489. * Manage the mouse inputs to control the movement of a free camera.
  94490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94491. * @param touchEnabled Defines if touch is enabled or not
  94492. */
  94493. constructor(
  94494. /**
  94495. * Define if touch is enabled in the mouse input
  94496. */
  94497. touchEnabled?: boolean);
  94498. /**
  94499. * Attach the input controls to a specific dom element to get the input from.
  94500. * @param element Defines the element the controls should be listened from
  94501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94502. */
  94503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94504. /**
  94505. * Called on JS contextmenu event.
  94506. * Override this method to provide functionality.
  94507. */
  94508. protected onContextMenu(evt: PointerEvent): void;
  94509. /**
  94510. * Detach the current controls from the specified dom element.
  94511. * @param element Defines the element to stop listening the inputs from
  94512. */
  94513. detachControl(element: Nullable<HTMLElement>): void;
  94514. /**
  94515. * Gets the class name of the current intput.
  94516. * @returns the class name
  94517. */
  94518. getClassName(): string;
  94519. /**
  94520. * Get the friendly name associated with the input class.
  94521. * @returns the input friendly name
  94522. */
  94523. getSimpleName(): string;
  94524. }
  94525. }
  94526. declare module BABYLON {
  94527. /**
  94528. * Manage the touch inputs to control the movement of a free camera.
  94529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94530. */
  94531. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  94532. /**
  94533. * Defines the camera the input is attached to.
  94534. */
  94535. camera: FreeCamera;
  94536. /**
  94537. * Defines the touch sensibility for rotation.
  94538. * The higher the faster.
  94539. */
  94540. touchAngularSensibility: number;
  94541. /**
  94542. * Defines the touch sensibility for move.
  94543. * The higher the faster.
  94544. */
  94545. touchMoveSensibility: number;
  94546. private _offsetX;
  94547. private _offsetY;
  94548. private _pointerPressed;
  94549. private _pointerInput;
  94550. private _observer;
  94551. private _onLostFocus;
  94552. /**
  94553. * Attach the input controls to a specific dom element to get the input from.
  94554. * @param element Defines the element the controls should be listened from
  94555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94556. */
  94557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94558. /**
  94559. * Detach the current controls from the specified dom element.
  94560. * @param element Defines the element to stop listening the inputs from
  94561. */
  94562. detachControl(element: Nullable<HTMLElement>): void;
  94563. /**
  94564. * Update the current camera state depending on the inputs that have been used this frame.
  94565. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94566. */
  94567. checkInputs(): void;
  94568. /**
  94569. * Gets the class name of the current intput.
  94570. * @returns the class name
  94571. */
  94572. getClassName(): string;
  94573. /**
  94574. * Get the friendly name associated with the input class.
  94575. * @returns the input friendly name
  94576. */
  94577. getSimpleName(): string;
  94578. }
  94579. }
  94580. declare module BABYLON {
  94581. /**
  94582. * Default Inputs manager for the FreeCamera.
  94583. * It groups all the default supported inputs for ease of use.
  94584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94585. */
  94586. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  94587. /**
  94588. * @hidden
  94589. */
  94590. _mouseInput: Nullable<FreeCameraMouseInput>;
  94591. /**
  94592. * Instantiates a new FreeCameraInputsManager.
  94593. * @param camera Defines the camera the inputs belong to
  94594. */
  94595. constructor(camera: FreeCamera);
  94596. /**
  94597. * Add keyboard input support to the input manager.
  94598. * @returns the current input manager
  94599. */
  94600. addKeyboard(): FreeCameraInputsManager;
  94601. /**
  94602. * Add mouse input support to the input manager.
  94603. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  94604. * @returns the current input manager
  94605. */
  94606. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  94607. /**
  94608. * Removes the mouse input support from the manager
  94609. * @returns the current input manager
  94610. */
  94611. removeMouse(): FreeCameraInputsManager;
  94612. /**
  94613. * Add touch input support to the input manager.
  94614. * @returns the current input manager
  94615. */
  94616. addTouch(): FreeCameraInputsManager;
  94617. /**
  94618. * Remove all attached input methods from a camera
  94619. */
  94620. clear(): void;
  94621. }
  94622. }
  94623. declare module BABYLON {
  94624. /**
  94625. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94626. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  94627. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94628. */
  94629. export class FreeCamera extends TargetCamera {
  94630. /**
  94631. * Define the collision ellipsoid of the camera.
  94632. * This is helpful to simulate a camera body like the player body around the camera
  94633. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94634. */
  94635. ellipsoid: Vector3;
  94636. /**
  94637. * Define an offset for the position of the ellipsoid around the camera.
  94638. * This can be helpful to determine the center of the body near the gravity center of the body
  94639. * instead of its head.
  94640. */
  94641. ellipsoidOffset: Vector3;
  94642. /**
  94643. * Enable or disable collisions of the camera with the rest of the scene objects.
  94644. */
  94645. checkCollisions: boolean;
  94646. /**
  94647. * Enable or disable gravity on the camera.
  94648. */
  94649. applyGravity: boolean;
  94650. /**
  94651. * Define the input manager associated to the camera.
  94652. */
  94653. inputs: FreeCameraInputsManager;
  94654. /**
  94655. * Gets the input sensibility for a mouse input. (default is 2000.0)
  94656. * Higher values reduce sensitivity.
  94657. */
  94658. get angularSensibility(): number;
  94659. /**
  94660. * Sets the input sensibility for a mouse input. (default is 2000.0)
  94661. * Higher values reduce sensitivity.
  94662. */
  94663. set angularSensibility(value: number);
  94664. /**
  94665. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94666. */
  94667. get keysUp(): number[];
  94668. set keysUp(value: number[]);
  94669. /**
  94670. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94671. */
  94672. get keysUpward(): number[];
  94673. set keysUpward(value: number[]);
  94674. /**
  94675. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94676. */
  94677. get keysDown(): number[];
  94678. set keysDown(value: number[]);
  94679. /**
  94680. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94681. */
  94682. get keysDownward(): number[];
  94683. set keysDownward(value: number[]);
  94684. /**
  94685. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94686. */
  94687. get keysLeft(): number[];
  94688. set keysLeft(value: number[]);
  94689. /**
  94690. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94691. */
  94692. get keysRight(): number[];
  94693. set keysRight(value: number[]);
  94694. /**
  94695. * Event raised when the camera collide with a mesh in the scene.
  94696. */
  94697. onCollide: (collidedMesh: AbstractMesh) => void;
  94698. private _collider;
  94699. private _needMoveForGravity;
  94700. private _oldPosition;
  94701. private _diffPosition;
  94702. private _newPosition;
  94703. /** @hidden */
  94704. _localDirection: Vector3;
  94705. /** @hidden */
  94706. _transformedDirection: Vector3;
  94707. /**
  94708. * Instantiates a Free Camera.
  94709. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94710. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  94711. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94712. * @param name Define the name of the camera in the scene
  94713. * @param position Define the start position of the camera in the scene
  94714. * @param scene Define the scene the camera belongs to
  94715. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94716. */
  94717. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94718. /**
  94719. * Attached controls to the current camera.
  94720. * @param element Defines the element the controls should be listened from
  94721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94722. */
  94723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94724. /**
  94725. * Detach the current controls from the camera.
  94726. * The camera will stop reacting to inputs.
  94727. * @param element Defines the element to stop listening the inputs from
  94728. */
  94729. detachControl(element: HTMLElement): void;
  94730. private _collisionMask;
  94731. /**
  94732. * Define a collision mask to limit the list of object the camera can collide with
  94733. */
  94734. get collisionMask(): number;
  94735. set collisionMask(mask: number);
  94736. /** @hidden */
  94737. _collideWithWorld(displacement: Vector3): void;
  94738. private _onCollisionPositionChange;
  94739. /** @hidden */
  94740. _checkInputs(): void;
  94741. /** @hidden */
  94742. _decideIfNeedsToMove(): boolean;
  94743. /** @hidden */
  94744. _updatePosition(): void;
  94745. /**
  94746. * Destroy the camera and release the current resources hold by it.
  94747. */
  94748. dispose(): void;
  94749. /**
  94750. * Gets the current object class name.
  94751. * @return the class name
  94752. */
  94753. getClassName(): string;
  94754. }
  94755. }
  94756. declare module BABYLON {
  94757. /**
  94758. * Represents a gamepad control stick position
  94759. */
  94760. export class StickValues {
  94761. /**
  94762. * The x component of the control stick
  94763. */
  94764. x: number;
  94765. /**
  94766. * The y component of the control stick
  94767. */
  94768. y: number;
  94769. /**
  94770. * Initializes the gamepad x and y control stick values
  94771. * @param x The x component of the gamepad control stick value
  94772. * @param y The y component of the gamepad control stick value
  94773. */
  94774. constructor(
  94775. /**
  94776. * The x component of the control stick
  94777. */
  94778. x: number,
  94779. /**
  94780. * The y component of the control stick
  94781. */
  94782. y: number);
  94783. }
  94784. /**
  94785. * An interface which manages callbacks for gamepad button changes
  94786. */
  94787. export interface GamepadButtonChanges {
  94788. /**
  94789. * Called when a gamepad has been changed
  94790. */
  94791. changed: boolean;
  94792. /**
  94793. * Called when a gamepad press event has been triggered
  94794. */
  94795. pressChanged: boolean;
  94796. /**
  94797. * Called when a touch event has been triggered
  94798. */
  94799. touchChanged: boolean;
  94800. /**
  94801. * Called when a value has changed
  94802. */
  94803. valueChanged: boolean;
  94804. }
  94805. /**
  94806. * Represents a gamepad
  94807. */
  94808. export class Gamepad {
  94809. /**
  94810. * The id of the gamepad
  94811. */
  94812. id: string;
  94813. /**
  94814. * The index of the gamepad
  94815. */
  94816. index: number;
  94817. /**
  94818. * The browser gamepad
  94819. */
  94820. browserGamepad: any;
  94821. /**
  94822. * Specifies what type of gamepad this represents
  94823. */
  94824. type: number;
  94825. private _leftStick;
  94826. private _rightStick;
  94827. /** @hidden */
  94828. _isConnected: boolean;
  94829. private _leftStickAxisX;
  94830. private _leftStickAxisY;
  94831. private _rightStickAxisX;
  94832. private _rightStickAxisY;
  94833. /**
  94834. * Triggered when the left control stick has been changed
  94835. */
  94836. private _onleftstickchanged;
  94837. /**
  94838. * Triggered when the right control stick has been changed
  94839. */
  94840. private _onrightstickchanged;
  94841. /**
  94842. * Represents a gamepad controller
  94843. */
  94844. static GAMEPAD: number;
  94845. /**
  94846. * Represents a generic controller
  94847. */
  94848. static GENERIC: number;
  94849. /**
  94850. * Represents an XBox controller
  94851. */
  94852. static XBOX: number;
  94853. /**
  94854. * Represents a pose-enabled controller
  94855. */
  94856. static POSE_ENABLED: number;
  94857. /**
  94858. * Represents an Dual Shock controller
  94859. */
  94860. static DUALSHOCK: number;
  94861. /**
  94862. * Specifies whether the left control stick should be Y-inverted
  94863. */
  94864. protected _invertLeftStickY: boolean;
  94865. /**
  94866. * Specifies if the gamepad has been connected
  94867. */
  94868. get isConnected(): boolean;
  94869. /**
  94870. * Initializes the gamepad
  94871. * @param id The id of the gamepad
  94872. * @param index The index of the gamepad
  94873. * @param browserGamepad The browser gamepad
  94874. * @param leftStickX The x component of the left joystick
  94875. * @param leftStickY The y component of the left joystick
  94876. * @param rightStickX The x component of the right joystick
  94877. * @param rightStickY The y component of the right joystick
  94878. */
  94879. constructor(
  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, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  94892. /**
  94893. * Callback triggered when the left joystick has changed
  94894. * @param callback
  94895. */
  94896. onleftstickchanged(callback: (values: StickValues) => void): void;
  94897. /**
  94898. * Callback triggered when the right joystick has changed
  94899. * @param callback
  94900. */
  94901. onrightstickchanged(callback: (values: StickValues) => void): void;
  94902. /**
  94903. * Gets the left joystick
  94904. */
  94905. get leftStick(): StickValues;
  94906. /**
  94907. * Sets the left joystick values
  94908. */
  94909. set leftStick(newValues: StickValues);
  94910. /**
  94911. * Gets the right joystick
  94912. */
  94913. get rightStick(): StickValues;
  94914. /**
  94915. * Sets the right joystick value
  94916. */
  94917. set rightStick(newValues: StickValues);
  94918. /**
  94919. * Updates the gamepad joystick positions
  94920. */
  94921. update(): void;
  94922. /**
  94923. * Disposes the gamepad
  94924. */
  94925. dispose(): void;
  94926. }
  94927. /**
  94928. * Represents a generic gamepad
  94929. */
  94930. export class GenericPad extends Gamepad {
  94931. private _buttons;
  94932. private _onbuttondown;
  94933. private _onbuttonup;
  94934. /**
  94935. * Observable triggered when a button has been pressed
  94936. */
  94937. onButtonDownObservable: Observable<number>;
  94938. /**
  94939. * Observable triggered when a button has been released
  94940. */
  94941. onButtonUpObservable: Observable<number>;
  94942. /**
  94943. * Callback triggered when a button has been pressed
  94944. * @param callback Called when a button has been pressed
  94945. */
  94946. onbuttondown(callback: (buttonPressed: number) => void): void;
  94947. /**
  94948. * Callback triggered when a button has been released
  94949. * @param callback Called when a button has been released
  94950. */
  94951. onbuttonup(callback: (buttonReleased: number) => void): void;
  94952. /**
  94953. * Initializes the generic gamepad
  94954. * @param id The id of the generic gamepad
  94955. * @param index The index of the generic gamepad
  94956. * @param browserGamepad The browser gamepad
  94957. */
  94958. constructor(id: string, index: number, browserGamepad: any);
  94959. private _setButtonValue;
  94960. /**
  94961. * Updates the generic gamepad
  94962. */
  94963. update(): void;
  94964. /**
  94965. * Disposes the generic gamepad
  94966. */
  94967. dispose(): void;
  94968. }
  94969. }
  94970. declare module BABYLON {
  94971. /**
  94972. * Defines the types of pose enabled controllers that are supported
  94973. */
  94974. export enum PoseEnabledControllerType {
  94975. /**
  94976. * HTC Vive
  94977. */
  94978. VIVE = 0,
  94979. /**
  94980. * Oculus Rift
  94981. */
  94982. OCULUS = 1,
  94983. /**
  94984. * Windows mixed reality
  94985. */
  94986. WINDOWS = 2,
  94987. /**
  94988. * Samsung gear VR
  94989. */
  94990. GEAR_VR = 3,
  94991. /**
  94992. * Google Daydream
  94993. */
  94994. DAYDREAM = 4,
  94995. /**
  94996. * Generic
  94997. */
  94998. GENERIC = 5
  94999. }
  95000. /**
  95001. * Defines the MutableGamepadButton interface for the state of a gamepad button
  95002. */
  95003. export interface MutableGamepadButton {
  95004. /**
  95005. * Value of the button/trigger
  95006. */
  95007. value: number;
  95008. /**
  95009. * If the button/trigger is currently touched
  95010. */
  95011. touched: boolean;
  95012. /**
  95013. * If the button/trigger is currently pressed
  95014. */
  95015. pressed: boolean;
  95016. }
  95017. /**
  95018. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  95019. * @hidden
  95020. */
  95021. export interface ExtendedGamepadButton extends GamepadButton {
  95022. /**
  95023. * If the button/trigger is currently pressed
  95024. */
  95025. readonly pressed: boolean;
  95026. /**
  95027. * If the button/trigger is currently touched
  95028. */
  95029. readonly touched: boolean;
  95030. /**
  95031. * Value of the button/trigger
  95032. */
  95033. readonly value: number;
  95034. }
  95035. /** @hidden */
  95036. export interface _GamePadFactory {
  95037. /**
  95038. * Returns whether or not the current gamepad can be created for this type of controller.
  95039. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  95040. * @returns true if it can be created, otherwise false
  95041. */
  95042. canCreate(gamepadInfo: any): boolean;
  95043. /**
  95044. * Creates a new instance of the Gamepad.
  95045. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  95046. * @returns the new gamepad instance
  95047. */
  95048. create(gamepadInfo: any): Gamepad;
  95049. }
  95050. /**
  95051. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  95052. */
  95053. export class PoseEnabledControllerHelper {
  95054. /** @hidden */
  95055. static _ControllerFactories: _GamePadFactory[];
  95056. /** @hidden */
  95057. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  95058. /**
  95059. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  95060. * @param vrGamepad the gamepad to initialized
  95061. * @returns a vr controller of the type the gamepad identified as
  95062. */
  95063. static InitiateController(vrGamepad: any): Gamepad;
  95064. }
  95065. /**
  95066. * Defines the PoseEnabledController object that contains state of a vr capable controller
  95067. */
  95068. export class PoseEnabledController extends Gamepad implements PoseControlled {
  95069. /**
  95070. * If the controller is used in a webXR session
  95071. */
  95072. isXR: boolean;
  95073. private _deviceRoomPosition;
  95074. private _deviceRoomRotationQuaternion;
  95075. /**
  95076. * The device position in babylon space
  95077. */
  95078. devicePosition: Vector3;
  95079. /**
  95080. * The device rotation in babylon space
  95081. */
  95082. deviceRotationQuaternion: Quaternion;
  95083. /**
  95084. * The scale factor of the device in babylon space
  95085. */
  95086. deviceScaleFactor: number;
  95087. /**
  95088. * (Likely devicePosition should be used instead) The device position in its room space
  95089. */
  95090. position: Vector3;
  95091. /**
  95092. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  95093. */
  95094. rotationQuaternion: Quaternion;
  95095. /**
  95096. * The type of controller (Eg. Windows mixed reality)
  95097. */
  95098. controllerType: PoseEnabledControllerType;
  95099. protected _calculatedPosition: Vector3;
  95100. private _calculatedRotation;
  95101. /**
  95102. * The raw pose from the device
  95103. */
  95104. rawPose: DevicePose;
  95105. private _trackPosition;
  95106. private _maxRotationDistFromHeadset;
  95107. private _draggedRoomRotation;
  95108. /**
  95109. * @hidden
  95110. */
  95111. _disableTrackPosition(fixedPosition: Vector3): void;
  95112. /**
  95113. * Internal, the mesh attached to the controller
  95114. * @hidden
  95115. */
  95116. _mesh: Nullable<AbstractMesh>;
  95117. private _poseControlledCamera;
  95118. private _leftHandSystemQuaternion;
  95119. /**
  95120. * Internal, matrix used to convert room space to babylon space
  95121. * @hidden
  95122. */
  95123. _deviceToWorld: Matrix;
  95124. /**
  95125. * Node to be used when casting a ray from the controller
  95126. * @hidden
  95127. */
  95128. _pointingPoseNode: Nullable<TransformNode>;
  95129. /**
  95130. * Name of the child mesh that can be used to cast a ray from the controller
  95131. */
  95132. static readonly POINTING_POSE: string;
  95133. /**
  95134. * Creates a new PoseEnabledController from a gamepad
  95135. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  95136. */
  95137. constructor(browserGamepad: any);
  95138. private _workingMatrix;
  95139. /**
  95140. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  95141. */
  95142. update(): void;
  95143. /**
  95144. * Updates only the pose device and mesh without doing any button event checking
  95145. */
  95146. protected _updatePoseAndMesh(): void;
  95147. /**
  95148. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  95149. * @param poseData raw pose fromthe device
  95150. */
  95151. updateFromDevice(poseData: DevicePose): void;
  95152. /**
  95153. * @hidden
  95154. */
  95155. _meshAttachedObservable: Observable<AbstractMesh>;
  95156. /**
  95157. * Attaches a mesh to the controller
  95158. * @param mesh the mesh to be attached
  95159. */
  95160. attachToMesh(mesh: AbstractMesh): void;
  95161. /**
  95162. * Attaches the controllers mesh to a camera
  95163. * @param camera the camera the mesh should be attached to
  95164. */
  95165. attachToPoseControlledCamera(camera: TargetCamera): void;
  95166. /**
  95167. * Disposes of the controller
  95168. */
  95169. dispose(): void;
  95170. /**
  95171. * The mesh that is attached to the controller
  95172. */
  95173. get mesh(): Nullable<AbstractMesh>;
  95174. /**
  95175. * Gets the ray of the controller in the direction the controller is pointing
  95176. * @param length the length the resulting ray should be
  95177. * @returns a ray in the direction the controller is pointing
  95178. */
  95179. getForwardRay(length?: number): Ray;
  95180. }
  95181. }
  95182. declare module BABYLON {
  95183. /**
  95184. * Defines the WebVRController object that represents controllers tracked in 3D space
  95185. */
  95186. export abstract class WebVRController extends PoseEnabledController {
  95187. /**
  95188. * Internal, the default controller model for the controller
  95189. */
  95190. protected _defaultModel: Nullable<AbstractMesh>;
  95191. /**
  95192. * Fired when the trigger state has changed
  95193. */
  95194. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  95195. /**
  95196. * Fired when the main button state has changed
  95197. */
  95198. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  95199. /**
  95200. * Fired when the secondary button state has changed
  95201. */
  95202. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  95203. /**
  95204. * Fired when the pad state has changed
  95205. */
  95206. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  95207. /**
  95208. * Fired when controllers stick values have changed
  95209. */
  95210. onPadValuesChangedObservable: Observable<StickValues>;
  95211. /**
  95212. * Array of button availible on the controller
  95213. */
  95214. protected _buttons: Array<MutableGamepadButton>;
  95215. private _onButtonStateChange;
  95216. /**
  95217. * Fired when a controller button's state has changed
  95218. * @param callback the callback containing the button that was modified
  95219. */
  95220. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  95221. /**
  95222. * X and Y axis corresponding to the controllers joystick
  95223. */
  95224. pad: StickValues;
  95225. /**
  95226. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  95227. */
  95228. hand: string;
  95229. /**
  95230. * The default controller model for the controller
  95231. */
  95232. get defaultModel(): Nullable<AbstractMesh>;
  95233. /**
  95234. * Creates a new WebVRController from a gamepad
  95235. * @param vrGamepad the gamepad that the WebVRController should be created from
  95236. */
  95237. constructor(vrGamepad: any);
  95238. /**
  95239. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  95240. */
  95241. update(): void;
  95242. /**
  95243. * Function to be called when a button is modified
  95244. */
  95245. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  95246. /**
  95247. * Loads a mesh and attaches it to the controller
  95248. * @param scene the scene the mesh should be added to
  95249. * @param meshLoaded callback for when the mesh has been loaded
  95250. */
  95251. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  95252. private _setButtonValue;
  95253. private _changes;
  95254. private _checkChanges;
  95255. /**
  95256. * Disposes of th webVRCOntroller
  95257. */
  95258. dispose(): void;
  95259. }
  95260. }
  95261. declare module BABYLON {
  95262. /**
  95263. * The HemisphericLight simulates the ambient environment light,
  95264. * so the passed direction is the light reflection direction, not the incoming direction.
  95265. */
  95266. export class HemisphericLight extends Light {
  95267. /**
  95268. * The groundColor is the light in the opposite direction to the one specified during creation.
  95269. * 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.
  95270. */
  95271. groundColor: Color3;
  95272. /**
  95273. * The light reflection direction, not the incoming direction.
  95274. */
  95275. direction: Vector3;
  95276. /**
  95277. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  95278. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  95279. * The HemisphericLight can't cast shadows.
  95280. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95281. * @param name The friendly name of the light
  95282. * @param direction The direction of the light reflection
  95283. * @param scene The scene the light belongs to
  95284. */
  95285. constructor(name: string, direction: Vector3, scene: Scene);
  95286. protected _buildUniformLayout(): void;
  95287. /**
  95288. * Returns the string "HemisphericLight".
  95289. * @return The class name
  95290. */
  95291. getClassName(): string;
  95292. /**
  95293. * Sets the HemisphericLight direction towards the passed target (Vector3).
  95294. * Returns the updated direction.
  95295. * @param target The target the direction should point to
  95296. * @return The computed direction
  95297. */
  95298. setDirectionToTarget(target: Vector3): Vector3;
  95299. /**
  95300. * Returns the shadow generator associated to the light.
  95301. * @returns Always null for hemispheric lights because it does not support shadows.
  95302. */
  95303. getShadowGenerator(): Nullable<IShadowGenerator>;
  95304. /**
  95305. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  95306. * @param effect The effect to update
  95307. * @param lightIndex The index of the light in the effect to update
  95308. * @returns The hemispheric light
  95309. */
  95310. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  95311. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  95312. /**
  95313. * Computes the world matrix of the node
  95314. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95315. * @param useWasUpdatedFlag defines a reserved property
  95316. * @returns the world matrix
  95317. */
  95318. computeWorldMatrix(): Matrix;
  95319. /**
  95320. * Returns the integer 3.
  95321. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95322. */
  95323. getTypeID(): number;
  95324. /**
  95325. * Prepares the list of defines specific to the light type.
  95326. * @param defines the list of defines
  95327. * @param lightIndex defines the index of the light for the effect
  95328. */
  95329. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95330. }
  95331. }
  95332. declare module BABYLON {
  95333. /** @hidden */
  95334. export var vrMultiviewToSingleviewPixelShader: {
  95335. name: string;
  95336. shader: string;
  95337. };
  95338. }
  95339. declare module BABYLON {
  95340. /**
  95341. * Renders to multiple views with a single draw call
  95342. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  95343. */
  95344. export class MultiviewRenderTarget extends RenderTargetTexture {
  95345. /**
  95346. * Creates a multiview render target
  95347. * @param scene scene used with the render target
  95348. * @param size the size of the render target (used for each view)
  95349. */
  95350. constructor(scene: Scene, size?: number | {
  95351. width: number;
  95352. height: number;
  95353. } | {
  95354. ratio: number;
  95355. });
  95356. /**
  95357. * @hidden
  95358. * @param faceIndex the face index, if its a cube texture
  95359. */
  95360. _bindFrameBuffer(faceIndex?: number): void;
  95361. /**
  95362. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95363. * @returns the view count
  95364. */
  95365. getViewCount(): number;
  95366. }
  95367. }
  95368. declare module BABYLON {
  95369. /**
  95370. * Represents a camera frustum
  95371. */
  95372. export class Frustum {
  95373. /**
  95374. * Gets the planes representing the frustum
  95375. * @param transform matrix to be applied to the returned planes
  95376. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  95377. */
  95378. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  95379. /**
  95380. * Gets the near frustum plane transformed by the transform matrix
  95381. * @param transform transformation matrix to be applied to the resulting frustum plane
  95382. * @param frustumPlane the resuling frustum plane
  95383. */
  95384. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95385. /**
  95386. * Gets the far frustum plane transformed by the transform matrix
  95387. * @param transform transformation matrix to be applied to the resulting frustum plane
  95388. * @param frustumPlane the resuling frustum plane
  95389. */
  95390. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95391. /**
  95392. * Gets the left frustum plane transformed by the transform matrix
  95393. * @param transform transformation matrix to be applied to the resulting frustum plane
  95394. * @param frustumPlane the resuling frustum plane
  95395. */
  95396. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95397. /**
  95398. * Gets the right frustum plane transformed by the transform matrix
  95399. * @param transform transformation matrix to be applied to the resulting frustum plane
  95400. * @param frustumPlane the resuling frustum plane
  95401. */
  95402. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95403. /**
  95404. * Gets the top frustum plane transformed by the transform matrix
  95405. * @param transform transformation matrix to be applied to the resulting frustum plane
  95406. * @param frustumPlane the resuling frustum plane
  95407. */
  95408. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95409. /**
  95410. * Gets the bottom frustum plane transformed by the transform matrix
  95411. * @param transform transformation matrix to be applied to the resulting frustum plane
  95412. * @param frustumPlane the resuling frustum plane
  95413. */
  95414. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95415. /**
  95416. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  95417. * @param transform transformation matrix to be applied to the resulting frustum planes
  95418. * @param frustumPlanes the resuling frustum planes
  95419. */
  95420. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  95421. }
  95422. }
  95423. declare module BABYLON {
  95424. interface Engine {
  95425. /**
  95426. * Creates a new multiview render target
  95427. * @param width defines the width of the texture
  95428. * @param height defines the height of the texture
  95429. * @returns the created multiview texture
  95430. */
  95431. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  95432. /**
  95433. * Binds a multiview framebuffer to be drawn to
  95434. * @param multiviewTexture texture to bind
  95435. */
  95436. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  95437. }
  95438. interface Camera {
  95439. /**
  95440. * @hidden
  95441. * 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)
  95442. */
  95443. _useMultiviewToSingleView: boolean;
  95444. /**
  95445. * @hidden
  95446. * 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)
  95447. */
  95448. _multiviewTexture: Nullable<RenderTargetTexture>;
  95449. /**
  95450. * @hidden
  95451. * ensures the multiview texture of the camera exists and has the specified width/height
  95452. * @param width height to set on the multiview texture
  95453. * @param height width to set on the multiview texture
  95454. */
  95455. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  95456. }
  95457. interface Scene {
  95458. /** @hidden */
  95459. _transformMatrixR: Matrix;
  95460. /** @hidden */
  95461. _multiviewSceneUbo: Nullable<UniformBuffer>;
  95462. /** @hidden */
  95463. _createMultiviewUbo(): void;
  95464. /** @hidden */
  95465. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  95466. /** @hidden */
  95467. _renderMultiviewToSingleView(camera: Camera): void;
  95468. }
  95469. }
  95470. declare module BABYLON {
  95471. /**
  95472. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  95473. * This will not be used for webXR as it supports displaying texture arrays directly
  95474. */
  95475. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  95476. /**
  95477. * Initializes a VRMultiviewToSingleview
  95478. * @param name name of the post process
  95479. * @param camera camera to be applied to
  95480. * @param scaleFactor scaling factor to the size of the output texture
  95481. */
  95482. constructor(name: string, camera: Camera, scaleFactor: number);
  95483. }
  95484. }
  95485. declare module BABYLON {
  95486. /**
  95487. * Interface used to define additional presentation attributes
  95488. */
  95489. export interface IVRPresentationAttributes {
  95490. /**
  95491. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  95492. */
  95493. highRefreshRate: boolean;
  95494. /**
  95495. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  95496. */
  95497. foveationLevel: number;
  95498. }
  95499. interface Engine {
  95500. /** @hidden */
  95501. _vrDisplay: any;
  95502. /** @hidden */
  95503. _vrSupported: boolean;
  95504. /** @hidden */
  95505. _oldSize: Size;
  95506. /** @hidden */
  95507. _oldHardwareScaleFactor: number;
  95508. /** @hidden */
  95509. _vrExclusivePointerMode: boolean;
  95510. /** @hidden */
  95511. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  95512. /** @hidden */
  95513. _onVRDisplayPointerRestricted: () => void;
  95514. /** @hidden */
  95515. _onVRDisplayPointerUnrestricted: () => void;
  95516. /** @hidden */
  95517. _onVrDisplayConnect: Nullable<(display: any) => void>;
  95518. /** @hidden */
  95519. _onVrDisplayDisconnect: Nullable<() => void>;
  95520. /** @hidden */
  95521. _onVrDisplayPresentChange: Nullable<() => void>;
  95522. /**
  95523. * Observable signaled when VR display mode changes
  95524. */
  95525. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  95526. /**
  95527. * Observable signaled when VR request present is complete
  95528. */
  95529. onVRRequestPresentComplete: Observable<boolean>;
  95530. /**
  95531. * Observable signaled when VR request present starts
  95532. */
  95533. onVRRequestPresentStart: Observable<Engine>;
  95534. /**
  95535. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  95536. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  95537. */
  95538. isInVRExclusivePointerMode: boolean;
  95539. /**
  95540. * Gets a boolean indicating if a webVR device was detected
  95541. * @returns true if a webVR device was detected
  95542. */
  95543. isVRDevicePresent(): boolean;
  95544. /**
  95545. * Gets the current webVR device
  95546. * @returns the current webVR device (or null)
  95547. */
  95548. getVRDevice(): any;
  95549. /**
  95550. * Initializes a webVR display and starts listening to display change events
  95551. * The onVRDisplayChangedObservable will be notified upon these changes
  95552. * @returns A promise containing a VRDisplay and if vr is supported
  95553. */
  95554. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  95555. /** @hidden */
  95556. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  95557. /**
  95558. * Gets or sets the presentation attributes used to configure VR rendering
  95559. */
  95560. vrPresentationAttributes?: IVRPresentationAttributes;
  95561. /**
  95562. * Call this function to switch to webVR mode
  95563. * Will do nothing if webVR is not supported or if there is no webVR device
  95564. * @param options the webvr options provided to the camera. mainly used for multiview
  95565. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95566. */
  95567. enableVR(options: WebVROptions): void;
  95568. /** @hidden */
  95569. _onVRFullScreenTriggered(): void;
  95570. }
  95571. }
  95572. declare module BABYLON {
  95573. /**
  95574. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  95575. * IMPORTANT!! The data is right-hand data.
  95576. * @export
  95577. * @interface DevicePose
  95578. */
  95579. export interface DevicePose {
  95580. /**
  95581. * The position of the device, values in array are [x,y,z].
  95582. */
  95583. readonly position: Nullable<Float32Array>;
  95584. /**
  95585. * The linearVelocity of the device, values in array are [x,y,z].
  95586. */
  95587. readonly linearVelocity: Nullable<Float32Array>;
  95588. /**
  95589. * The linearAcceleration of the device, values in array are [x,y,z].
  95590. */
  95591. readonly linearAcceleration: Nullable<Float32Array>;
  95592. /**
  95593. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  95594. */
  95595. readonly orientation: Nullable<Float32Array>;
  95596. /**
  95597. * The angularVelocity of the device, values in array are [x,y,z].
  95598. */
  95599. readonly angularVelocity: Nullable<Float32Array>;
  95600. /**
  95601. * The angularAcceleration of the device, values in array are [x,y,z].
  95602. */
  95603. readonly angularAcceleration: Nullable<Float32Array>;
  95604. }
  95605. /**
  95606. * Interface representing a pose controlled object in Babylon.
  95607. * A pose controlled object has both regular pose values as well as pose values
  95608. * from an external device such as a VR head mounted display
  95609. */
  95610. export interface PoseControlled {
  95611. /**
  95612. * The position of the object in babylon space.
  95613. */
  95614. position: Vector3;
  95615. /**
  95616. * The rotation quaternion of the object in babylon space.
  95617. */
  95618. rotationQuaternion: Quaternion;
  95619. /**
  95620. * The position of the device in babylon space.
  95621. */
  95622. devicePosition?: Vector3;
  95623. /**
  95624. * The rotation quaternion of the device in babylon space.
  95625. */
  95626. deviceRotationQuaternion: Quaternion;
  95627. /**
  95628. * The raw pose coming from the device.
  95629. */
  95630. rawPose: Nullable<DevicePose>;
  95631. /**
  95632. * The scale of the device to be used when translating from device space to babylon space.
  95633. */
  95634. deviceScaleFactor: number;
  95635. /**
  95636. * Updates the poseControlled values based on the input device pose.
  95637. * @param poseData the pose data to update the object with
  95638. */
  95639. updateFromDevice(poseData: DevicePose): void;
  95640. }
  95641. /**
  95642. * Set of options to customize the webVRCamera
  95643. */
  95644. export interface WebVROptions {
  95645. /**
  95646. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  95647. */
  95648. trackPosition?: boolean;
  95649. /**
  95650. * Sets the scale of the vrDevice in babylon space. (default: 1)
  95651. */
  95652. positionScale?: number;
  95653. /**
  95654. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  95655. */
  95656. displayName?: string;
  95657. /**
  95658. * Should the native controller meshes be initialized. (default: true)
  95659. */
  95660. controllerMeshes?: boolean;
  95661. /**
  95662. * Creating a default HemiLight only on controllers. (default: true)
  95663. */
  95664. defaultLightingOnControllers?: boolean;
  95665. /**
  95666. * If you don't want to use the default VR button of the helper. (default: false)
  95667. */
  95668. useCustomVRButton?: boolean;
  95669. /**
  95670. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  95671. */
  95672. customVRButton?: HTMLButtonElement;
  95673. /**
  95674. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  95675. */
  95676. rayLength?: number;
  95677. /**
  95678. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  95679. */
  95680. defaultHeight?: number;
  95681. /**
  95682. * If multiview should be used if availible (default: false)
  95683. */
  95684. useMultiview?: boolean;
  95685. }
  95686. /**
  95687. * This represents a WebVR camera.
  95688. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  95689. * @example http://doc.babylonjs.com/how_to/webvr_camera
  95690. */
  95691. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  95692. private webVROptions;
  95693. /**
  95694. * @hidden
  95695. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  95696. */
  95697. _vrDevice: any;
  95698. /**
  95699. * The rawPose of the vrDevice.
  95700. */
  95701. rawPose: Nullable<DevicePose>;
  95702. private _onVREnabled;
  95703. private _specsVersion;
  95704. private _attached;
  95705. private _frameData;
  95706. protected _descendants: Array<Node>;
  95707. private _deviceRoomPosition;
  95708. /** @hidden */
  95709. _deviceRoomRotationQuaternion: Quaternion;
  95710. private _standingMatrix;
  95711. /**
  95712. * Represents device position in babylon space.
  95713. */
  95714. devicePosition: Vector3;
  95715. /**
  95716. * Represents device rotation in babylon space.
  95717. */
  95718. deviceRotationQuaternion: Quaternion;
  95719. /**
  95720. * The scale of the device to be used when translating from device space to babylon space.
  95721. */
  95722. deviceScaleFactor: number;
  95723. private _deviceToWorld;
  95724. private _worldToDevice;
  95725. /**
  95726. * References to the webVR controllers for the vrDevice.
  95727. */
  95728. controllers: Array<WebVRController>;
  95729. /**
  95730. * Emits an event when a controller is attached.
  95731. */
  95732. onControllersAttachedObservable: Observable<WebVRController[]>;
  95733. /**
  95734. * Emits an event when a controller's mesh has been loaded;
  95735. */
  95736. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95737. /**
  95738. * Emits an event when the HMD's pose has been updated.
  95739. */
  95740. onPoseUpdatedFromDeviceObservable: Observable<any>;
  95741. private _poseSet;
  95742. /**
  95743. * If the rig cameras be used as parent instead of this camera.
  95744. */
  95745. rigParenting: boolean;
  95746. private _lightOnControllers;
  95747. private _defaultHeight?;
  95748. /**
  95749. * Instantiates a WebVRFreeCamera.
  95750. * @param name The name of the WebVRFreeCamera
  95751. * @param position The starting anchor position for the camera
  95752. * @param scene The scene the camera belongs to
  95753. * @param webVROptions a set of customizable options for the webVRCamera
  95754. */
  95755. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  95756. /**
  95757. * Gets the device distance from the ground in meters.
  95758. * @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.
  95759. */
  95760. deviceDistanceToRoomGround(): number;
  95761. /**
  95762. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95763. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  95764. */
  95765. useStandingMatrix(callback?: (bool: boolean) => void): void;
  95766. /**
  95767. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95768. * @returns A promise with a boolean set to if the standing matrix is supported.
  95769. */
  95770. useStandingMatrixAsync(): Promise<boolean>;
  95771. /**
  95772. * Disposes the camera
  95773. */
  95774. dispose(): void;
  95775. /**
  95776. * Gets a vrController by name.
  95777. * @param name The name of the controller to retreive
  95778. * @returns the controller matching the name specified or null if not found
  95779. */
  95780. getControllerByName(name: string): Nullable<WebVRController>;
  95781. private _leftController;
  95782. /**
  95783. * The controller corresponding to the users left hand.
  95784. */
  95785. get leftController(): Nullable<WebVRController>;
  95786. private _rightController;
  95787. /**
  95788. * The controller corresponding to the users right hand.
  95789. */
  95790. get rightController(): Nullable<WebVRController>;
  95791. /**
  95792. * Casts a ray forward from the vrCamera's gaze.
  95793. * @param length Length of the ray (default: 100)
  95794. * @returns the ray corresponding to the gaze
  95795. */
  95796. getForwardRay(length?: number): Ray;
  95797. /**
  95798. * @hidden
  95799. * Updates the camera based on device's frame data
  95800. */
  95801. _checkInputs(): void;
  95802. /**
  95803. * Updates the poseControlled values based on the input device pose.
  95804. * @param poseData Pose coming from the device
  95805. */
  95806. updateFromDevice(poseData: DevicePose): void;
  95807. private _htmlElementAttached;
  95808. private _detachIfAttached;
  95809. /**
  95810. * WebVR's attach control will start broadcasting frames to the device.
  95811. * Note that in certain browsers (chrome for example) this function must be called
  95812. * within a user-interaction callback. Example:
  95813. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  95814. *
  95815. * @param element html element to attach the vrDevice to
  95816. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  95817. */
  95818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95819. /**
  95820. * Detaches the camera from the html element and disables VR
  95821. *
  95822. * @param element html element to detach from
  95823. */
  95824. detachControl(element: HTMLElement): void;
  95825. /**
  95826. * @returns the name of this class
  95827. */
  95828. getClassName(): string;
  95829. /**
  95830. * Calls resetPose on the vrDisplay
  95831. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  95832. */
  95833. resetToCurrentRotation(): void;
  95834. /**
  95835. * @hidden
  95836. * Updates the rig cameras (left and right eye)
  95837. */
  95838. _updateRigCameras(): void;
  95839. private _workingVector;
  95840. private _oneVector;
  95841. private _workingMatrix;
  95842. private updateCacheCalled;
  95843. private _correctPositionIfNotTrackPosition;
  95844. /**
  95845. * @hidden
  95846. * Updates the cached values of the camera
  95847. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  95848. */
  95849. _updateCache(ignoreParentClass?: boolean): void;
  95850. /**
  95851. * @hidden
  95852. * Get current device position in babylon world
  95853. */
  95854. _computeDevicePosition(): void;
  95855. /**
  95856. * Updates the current device position and rotation in the babylon world
  95857. */
  95858. update(): void;
  95859. /**
  95860. * @hidden
  95861. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  95862. * @returns an identity matrix
  95863. */
  95864. _getViewMatrix(): Matrix;
  95865. private _tmpMatrix;
  95866. /**
  95867. * This function is called by the two RIG cameras.
  95868. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  95869. * @hidden
  95870. */
  95871. _getWebVRViewMatrix(): Matrix;
  95872. /** @hidden */
  95873. _getWebVRProjectionMatrix(): Matrix;
  95874. private _onGamepadConnectedObserver;
  95875. private _onGamepadDisconnectedObserver;
  95876. private _updateCacheWhenTrackingDisabledObserver;
  95877. /**
  95878. * Initializes the controllers and their meshes
  95879. */
  95880. initControllers(): void;
  95881. }
  95882. }
  95883. declare module BABYLON {
  95884. /**
  95885. * Size options for a post process
  95886. */
  95887. export type PostProcessOptions = {
  95888. width: number;
  95889. height: number;
  95890. };
  95891. /**
  95892. * PostProcess can be used to apply a shader to a texture after it has been rendered
  95893. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  95894. */
  95895. export class PostProcess {
  95896. /** Name of the PostProcess. */
  95897. name: string;
  95898. /**
  95899. * Gets or sets the unique id of the post process
  95900. */
  95901. uniqueId: number;
  95902. /**
  95903. * Width of the texture to apply the post process on
  95904. */
  95905. width: number;
  95906. /**
  95907. * Height of the texture to apply the post process on
  95908. */
  95909. height: number;
  95910. /**
  95911. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  95912. * @hidden
  95913. */
  95914. _outputTexture: Nullable<InternalTexture>;
  95915. /**
  95916. * Sampling mode used by the shader
  95917. * See https://doc.babylonjs.com/classes/3.1/texture
  95918. */
  95919. renderTargetSamplingMode: number;
  95920. /**
  95921. * Clear color to use when screen clearing
  95922. */
  95923. clearColor: Color4;
  95924. /**
  95925. * If the buffer needs to be cleared before applying the post process. (default: true)
  95926. * Should be set to false if shader will overwrite all previous pixels.
  95927. */
  95928. autoClear: boolean;
  95929. /**
  95930. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  95931. */
  95932. alphaMode: number;
  95933. /**
  95934. * Sets the setAlphaBlendConstants of the babylon engine
  95935. */
  95936. alphaConstants: Color4;
  95937. /**
  95938. * Animations to be used for the post processing
  95939. */
  95940. animations: Animation[];
  95941. /**
  95942. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  95943. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  95944. */
  95945. enablePixelPerfectMode: boolean;
  95946. /**
  95947. * Force the postprocess to be applied without taking in account viewport
  95948. */
  95949. forceFullscreenViewport: boolean;
  95950. /**
  95951. * List of inspectable custom properties (used by the Inspector)
  95952. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95953. */
  95954. inspectableCustomProperties: IInspectable[];
  95955. /**
  95956. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  95957. *
  95958. * | Value | Type | Description |
  95959. * | ----- | ----------------------------------- | ----------- |
  95960. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  95961. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  95962. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  95963. *
  95964. */
  95965. scaleMode: number;
  95966. /**
  95967. * Force textures to be a power of two (default: false)
  95968. */
  95969. alwaysForcePOT: boolean;
  95970. private _samples;
  95971. /**
  95972. * Number of sample textures (default: 1)
  95973. */
  95974. get samples(): number;
  95975. set samples(n: number);
  95976. /**
  95977. * Modify the scale of the post process to be the same as the viewport (default: false)
  95978. */
  95979. adaptScaleToCurrentViewport: boolean;
  95980. private _camera;
  95981. private _scene;
  95982. private _engine;
  95983. private _options;
  95984. private _reusable;
  95985. private _textureType;
  95986. private _textureFormat;
  95987. /**
  95988. * Smart array of input and output textures for the post process.
  95989. * @hidden
  95990. */
  95991. _textures: SmartArray<InternalTexture>;
  95992. /**
  95993. * The index in _textures that corresponds to the output texture.
  95994. * @hidden
  95995. */
  95996. _currentRenderTextureInd: number;
  95997. private _effect;
  95998. private _samplers;
  95999. private _fragmentUrl;
  96000. private _vertexUrl;
  96001. private _parameters;
  96002. private _scaleRatio;
  96003. protected _indexParameters: any;
  96004. private _shareOutputWithPostProcess;
  96005. private _texelSize;
  96006. private _forcedOutputTexture;
  96007. /**
  96008. * Returns the fragment url or shader name used in the post process.
  96009. * @returns the fragment url or name in the shader store.
  96010. */
  96011. getEffectName(): string;
  96012. /**
  96013. * An event triggered when the postprocess is activated.
  96014. */
  96015. onActivateObservable: Observable<Camera>;
  96016. private _onActivateObserver;
  96017. /**
  96018. * A function that is added to the onActivateObservable
  96019. */
  96020. set onActivate(callback: Nullable<(camera: Camera) => void>);
  96021. /**
  96022. * An event triggered when the postprocess changes its size.
  96023. */
  96024. onSizeChangedObservable: Observable<PostProcess>;
  96025. private _onSizeChangedObserver;
  96026. /**
  96027. * A function that is added to the onSizeChangedObservable
  96028. */
  96029. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  96030. /**
  96031. * An event triggered when the postprocess applies its effect.
  96032. */
  96033. onApplyObservable: Observable<Effect>;
  96034. private _onApplyObserver;
  96035. /**
  96036. * A function that is added to the onApplyObservable
  96037. */
  96038. set onApply(callback: (effect: Effect) => void);
  96039. /**
  96040. * An event triggered before rendering the postprocess
  96041. */
  96042. onBeforeRenderObservable: Observable<Effect>;
  96043. private _onBeforeRenderObserver;
  96044. /**
  96045. * A function that is added to the onBeforeRenderObservable
  96046. */
  96047. set onBeforeRender(callback: (effect: Effect) => void);
  96048. /**
  96049. * An event triggered after rendering the postprocess
  96050. */
  96051. onAfterRenderObservable: Observable<Effect>;
  96052. private _onAfterRenderObserver;
  96053. /**
  96054. * A function that is added to the onAfterRenderObservable
  96055. */
  96056. set onAfterRender(callback: (efect: Effect) => void);
  96057. /**
  96058. * 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
  96059. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  96060. */
  96061. get inputTexture(): InternalTexture;
  96062. set inputTexture(value: InternalTexture);
  96063. /**
  96064. * Gets the camera which post process is applied to.
  96065. * @returns The camera the post process is applied to.
  96066. */
  96067. getCamera(): Camera;
  96068. /**
  96069. * Gets the texel size of the postprocess.
  96070. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  96071. */
  96072. get texelSize(): Vector2;
  96073. /**
  96074. * Creates a new instance PostProcess
  96075. * @param name The name of the PostProcess.
  96076. * @param fragmentUrl The url of the fragment shader to be used.
  96077. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  96078. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  96079. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  96080. * @param camera The camera to apply the render pass to.
  96081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96082. * @param engine The engine which the post process will be applied. (default: current engine)
  96083. * @param reusable If the post process can be reused on the same frame. (default: false)
  96084. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  96085. * @param textureType Type of textures used when performing the post process. (default: 0)
  96086. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  96087. * @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
  96088. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  96089. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  96090. */
  96091. constructor(
  96092. /** Name of the PostProcess. */
  96093. 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);
  96094. /**
  96095. * Gets a string idenfifying the name of the class
  96096. * @returns "PostProcess" string
  96097. */
  96098. getClassName(): string;
  96099. /**
  96100. * Gets the engine which this post process belongs to.
  96101. * @returns The engine the post process was enabled with.
  96102. */
  96103. getEngine(): Engine;
  96104. /**
  96105. * The effect that is created when initializing the post process.
  96106. * @returns The created effect corresponding the the postprocess.
  96107. */
  96108. getEffect(): Effect;
  96109. /**
  96110. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  96111. * @param postProcess The post process to share the output with.
  96112. * @returns This post process.
  96113. */
  96114. shareOutputWith(postProcess: PostProcess): PostProcess;
  96115. /**
  96116. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  96117. * This should be called if the post process that shares output with this post process is disabled/disposed.
  96118. */
  96119. useOwnOutput(): void;
  96120. /**
  96121. * Updates the effect with the current post process compile time values and recompiles the shader.
  96122. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  96123. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96124. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96125. * @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
  96126. * @param onCompiled Called when the shader has been compiled.
  96127. * @param onError Called if there is an error when compiling a shader.
  96128. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  96129. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  96130. */
  96131. 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;
  96132. /**
  96133. * The post process is reusable if it can be used multiple times within one frame.
  96134. * @returns If the post process is reusable
  96135. */
  96136. isReusable(): boolean;
  96137. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  96138. markTextureDirty(): void;
  96139. /**
  96140. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  96141. * 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.
  96142. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  96143. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  96144. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  96145. * @returns The target texture that was bound to be written to.
  96146. */
  96147. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  96148. /**
  96149. * If the post process is supported.
  96150. */
  96151. get isSupported(): boolean;
  96152. /**
  96153. * The aspect ratio of the output texture.
  96154. */
  96155. get aspectRatio(): number;
  96156. /**
  96157. * Get a value indicating if the post-process is ready to be used
  96158. * @returns true if the post-process is ready (shader is compiled)
  96159. */
  96160. isReady(): boolean;
  96161. /**
  96162. * Binds all textures and uniforms to the shader, this will be run on every pass.
  96163. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  96164. */
  96165. apply(): Nullable<Effect>;
  96166. private _disposeTextures;
  96167. /**
  96168. * Disposes the post process.
  96169. * @param camera The camera to dispose the post process on.
  96170. */
  96171. dispose(camera?: Camera): void;
  96172. }
  96173. }
  96174. declare module BABYLON {
  96175. /** @hidden */
  96176. export var kernelBlurVaryingDeclaration: {
  96177. name: string;
  96178. shader: string;
  96179. };
  96180. }
  96181. declare module BABYLON {
  96182. /** @hidden */
  96183. export var kernelBlurFragment: {
  96184. name: string;
  96185. shader: string;
  96186. };
  96187. }
  96188. declare module BABYLON {
  96189. /** @hidden */
  96190. export var kernelBlurFragment2: {
  96191. name: string;
  96192. shader: string;
  96193. };
  96194. }
  96195. declare module BABYLON {
  96196. /** @hidden */
  96197. export var kernelBlurPixelShader: {
  96198. name: string;
  96199. shader: string;
  96200. };
  96201. }
  96202. declare module BABYLON {
  96203. /** @hidden */
  96204. export var kernelBlurVertex: {
  96205. name: string;
  96206. shader: string;
  96207. };
  96208. }
  96209. declare module BABYLON {
  96210. /** @hidden */
  96211. export var kernelBlurVertexShader: {
  96212. name: string;
  96213. shader: string;
  96214. };
  96215. }
  96216. declare module BABYLON {
  96217. /**
  96218. * The Blur Post Process which blurs an image based on a kernel and direction.
  96219. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  96220. */
  96221. export class BlurPostProcess extends PostProcess {
  96222. /** The direction in which to blur the image. */
  96223. direction: Vector2;
  96224. private blockCompilation;
  96225. protected _kernel: number;
  96226. protected _idealKernel: number;
  96227. protected _packedFloat: boolean;
  96228. private _staticDefines;
  96229. /**
  96230. * Sets the length in pixels of the blur sample region
  96231. */
  96232. set kernel(v: number);
  96233. /**
  96234. * Gets the length in pixels of the blur sample region
  96235. */
  96236. get kernel(): number;
  96237. /**
  96238. * Sets wether or not the blur needs to unpack/repack floats
  96239. */
  96240. set packedFloat(v: boolean);
  96241. /**
  96242. * Gets wether or not the blur is unpacking/repacking floats
  96243. */
  96244. get packedFloat(): boolean;
  96245. /**
  96246. * Creates a new instance BlurPostProcess
  96247. * @param name The name of the effect.
  96248. * @param direction The direction in which to blur the image.
  96249. * @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.
  96250. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  96251. * @param camera The camera to apply the render pass to.
  96252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96253. * @param engine The engine which the post process will be applied. (default: current engine)
  96254. * @param reusable If the post process can be reused on the same frame. (default: false)
  96255. * @param textureType Type of textures used when performing the post process. (default: 0)
  96256. * @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)
  96257. */
  96258. constructor(name: string,
  96259. /** The direction in which to blur the image. */
  96260. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  96261. /**
  96262. * Updates the effect with the current post process compile time values and recompiles the shader.
  96263. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  96264. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96265. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96266. * @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
  96267. * @param onCompiled Called when the shader has been compiled.
  96268. * @param onError Called if there is an error when compiling a shader.
  96269. */
  96270. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96271. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96272. /**
  96273. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  96274. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  96275. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  96276. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  96277. * The gaps between physical kernels are compensated for in the weighting of the samples
  96278. * @param idealKernel Ideal blur kernel.
  96279. * @return Nearest best kernel.
  96280. */
  96281. protected _nearestBestKernel(idealKernel: number): number;
  96282. /**
  96283. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  96284. * @param x The point on the Gaussian distribution to sample.
  96285. * @return the value of the Gaussian function at x.
  96286. */
  96287. protected _gaussianWeight(x: number): number;
  96288. /**
  96289. * Generates a string that can be used as a floating point number in GLSL.
  96290. * @param x Value to print.
  96291. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  96292. * @return GLSL float string.
  96293. */
  96294. protected _glslFloat(x: number, decimalFigures?: number): string;
  96295. }
  96296. }
  96297. declare module BABYLON {
  96298. /**
  96299. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96300. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96301. * You can then easily use it as a reflectionTexture on a flat surface.
  96302. * In case the surface is not a plane, please consider relying on reflection probes.
  96303. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96304. */
  96305. export class MirrorTexture extends RenderTargetTexture {
  96306. private scene;
  96307. /**
  96308. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  96309. * 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.
  96310. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96311. */
  96312. mirrorPlane: Plane;
  96313. /**
  96314. * Define the blur ratio used to blur the reflection if needed.
  96315. */
  96316. set blurRatio(value: number);
  96317. get blurRatio(): number;
  96318. /**
  96319. * Define the adaptive blur kernel used to blur the reflection if needed.
  96320. * This will autocompute the closest best match for the `blurKernel`
  96321. */
  96322. set adaptiveBlurKernel(value: number);
  96323. /**
  96324. * Define the blur kernel used to blur the reflection if needed.
  96325. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96326. */
  96327. set blurKernel(value: number);
  96328. /**
  96329. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  96330. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96331. */
  96332. set blurKernelX(value: number);
  96333. get blurKernelX(): number;
  96334. /**
  96335. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  96336. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96337. */
  96338. set blurKernelY(value: number);
  96339. get blurKernelY(): number;
  96340. private _autoComputeBlurKernel;
  96341. protected _onRatioRescale(): void;
  96342. private _updateGammaSpace;
  96343. private _imageProcessingConfigChangeObserver;
  96344. private _transformMatrix;
  96345. private _mirrorMatrix;
  96346. private _savedViewMatrix;
  96347. private _blurX;
  96348. private _blurY;
  96349. private _adaptiveBlurKernel;
  96350. private _blurKernelX;
  96351. private _blurKernelY;
  96352. private _blurRatio;
  96353. /**
  96354. * Instantiates a Mirror Texture.
  96355. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96356. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96357. * You can then easily use it as a reflectionTexture on a flat surface.
  96358. * In case the surface is not a plane, please consider relying on reflection probes.
  96359. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96360. * @param name
  96361. * @param size
  96362. * @param scene
  96363. * @param generateMipMaps
  96364. * @param type
  96365. * @param samplingMode
  96366. * @param generateDepthBuffer
  96367. */
  96368. constructor(name: string, size: number | {
  96369. width: number;
  96370. height: number;
  96371. } | {
  96372. ratio: number;
  96373. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  96374. private _preparePostProcesses;
  96375. /**
  96376. * Clone the mirror texture.
  96377. * @returns the cloned texture
  96378. */
  96379. clone(): MirrorTexture;
  96380. /**
  96381. * Serialize the texture to a JSON representation you could use in Parse later on
  96382. * @returns the serialized JSON representation
  96383. */
  96384. serialize(): any;
  96385. /**
  96386. * Dispose the texture and release its associated resources.
  96387. */
  96388. dispose(): void;
  96389. }
  96390. }
  96391. declare module BABYLON {
  96392. /**
  96393. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96394. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96395. */
  96396. export class Texture extends BaseTexture {
  96397. /**
  96398. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  96399. */
  96400. static SerializeBuffers: boolean;
  96401. /** @hidden */
  96402. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  96403. /** @hidden */
  96404. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  96405. /** @hidden */
  96406. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  96407. /** nearest is mag = nearest and min = nearest and mip = linear */
  96408. static readonly NEAREST_SAMPLINGMODE: number;
  96409. /** nearest is mag = nearest and min = nearest and mip = linear */
  96410. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  96411. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96412. static readonly BILINEAR_SAMPLINGMODE: number;
  96413. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96414. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  96415. /** Trilinear is mag = linear and min = linear and mip = linear */
  96416. static readonly TRILINEAR_SAMPLINGMODE: number;
  96417. /** Trilinear is mag = linear and min = linear and mip = linear */
  96418. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  96419. /** mag = nearest and min = nearest and mip = nearest */
  96420. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  96421. /** mag = nearest and min = linear and mip = nearest */
  96422. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  96423. /** mag = nearest and min = linear and mip = linear */
  96424. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  96425. /** mag = nearest and min = linear and mip = none */
  96426. static readonly NEAREST_LINEAR: number;
  96427. /** mag = nearest and min = nearest and mip = none */
  96428. static readonly NEAREST_NEAREST: number;
  96429. /** mag = linear and min = nearest and mip = nearest */
  96430. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  96431. /** mag = linear and min = nearest and mip = linear */
  96432. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  96433. /** mag = linear and min = linear and mip = none */
  96434. static readonly LINEAR_LINEAR: number;
  96435. /** mag = linear and min = nearest and mip = none */
  96436. static readonly LINEAR_NEAREST: number;
  96437. /** Explicit coordinates mode */
  96438. static readonly EXPLICIT_MODE: number;
  96439. /** Spherical coordinates mode */
  96440. static readonly SPHERICAL_MODE: number;
  96441. /** Planar coordinates mode */
  96442. static readonly PLANAR_MODE: number;
  96443. /** Cubic coordinates mode */
  96444. static readonly CUBIC_MODE: number;
  96445. /** Projection coordinates mode */
  96446. static readonly PROJECTION_MODE: number;
  96447. /** Inverse Cubic coordinates mode */
  96448. static readonly SKYBOX_MODE: number;
  96449. /** Inverse Cubic coordinates mode */
  96450. static readonly INVCUBIC_MODE: number;
  96451. /** Equirectangular coordinates mode */
  96452. static readonly EQUIRECTANGULAR_MODE: number;
  96453. /** Equirectangular Fixed coordinates mode */
  96454. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  96455. /** Equirectangular Fixed Mirrored coordinates mode */
  96456. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  96457. /** Texture is not repeating outside of 0..1 UVs */
  96458. static readonly CLAMP_ADDRESSMODE: number;
  96459. /** Texture is repeating outside of 0..1 UVs */
  96460. static readonly WRAP_ADDRESSMODE: number;
  96461. /** Texture is repeating and mirrored */
  96462. static readonly MIRROR_ADDRESSMODE: number;
  96463. /**
  96464. * 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
  96465. */
  96466. static UseSerializedUrlIfAny: boolean;
  96467. /**
  96468. * Define the url of the texture.
  96469. */
  96470. url: Nullable<string>;
  96471. /**
  96472. * Define an offset on the texture to offset the u coordinates of the UVs
  96473. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96474. */
  96475. uOffset: number;
  96476. /**
  96477. * Define an offset on the texture to offset the v coordinates of the UVs
  96478. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96479. */
  96480. vOffset: number;
  96481. /**
  96482. * Define an offset on the texture to scale the u coordinates of the UVs
  96483. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96484. */
  96485. uScale: number;
  96486. /**
  96487. * Define an offset on the texture to scale the v coordinates of the UVs
  96488. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96489. */
  96490. vScale: number;
  96491. /**
  96492. * Define an offset on the texture to rotate around the u coordinates of the UVs
  96493. * @see http://doc.babylonjs.com/how_to/more_materials
  96494. */
  96495. uAng: number;
  96496. /**
  96497. * Define an offset on the texture to rotate around the v coordinates of the UVs
  96498. * @see http://doc.babylonjs.com/how_to/more_materials
  96499. */
  96500. vAng: number;
  96501. /**
  96502. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  96503. * @see http://doc.babylonjs.com/how_to/more_materials
  96504. */
  96505. wAng: number;
  96506. /**
  96507. * Defines the center of rotation (U)
  96508. */
  96509. uRotationCenter: number;
  96510. /**
  96511. * Defines the center of rotation (V)
  96512. */
  96513. vRotationCenter: number;
  96514. /**
  96515. * Defines the center of rotation (W)
  96516. */
  96517. wRotationCenter: number;
  96518. /**
  96519. * Are mip maps generated for this texture or not.
  96520. */
  96521. get noMipmap(): boolean;
  96522. /**
  96523. * List of inspectable custom properties (used by the Inspector)
  96524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96525. */
  96526. inspectableCustomProperties: Nullable<IInspectable[]>;
  96527. private _noMipmap;
  96528. /** @hidden */
  96529. _invertY: boolean;
  96530. private _rowGenerationMatrix;
  96531. private _cachedTextureMatrix;
  96532. private _projectionModeMatrix;
  96533. private _t0;
  96534. private _t1;
  96535. private _t2;
  96536. private _cachedUOffset;
  96537. private _cachedVOffset;
  96538. private _cachedUScale;
  96539. private _cachedVScale;
  96540. private _cachedUAng;
  96541. private _cachedVAng;
  96542. private _cachedWAng;
  96543. private _cachedProjectionMatrixId;
  96544. private _cachedCoordinatesMode;
  96545. /** @hidden */
  96546. protected _initialSamplingMode: number;
  96547. /** @hidden */
  96548. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  96549. private _deleteBuffer;
  96550. protected _format: Nullable<number>;
  96551. private _delayedOnLoad;
  96552. private _delayedOnError;
  96553. private _mimeType?;
  96554. /**
  96555. * Observable triggered once the texture has been loaded.
  96556. */
  96557. onLoadObservable: Observable<Texture>;
  96558. protected _isBlocking: boolean;
  96559. /**
  96560. * Is the texture preventing material to render while loading.
  96561. * If false, a default texture will be used instead of the loading one during the preparation step.
  96562. */
  96563. set isBlocking(value: boolean);
  96564. get isBlocking(): boolean;
  96565. /**
  96566. * Get the current sampling mode associated with the texture.
  96567. */
  96568. get samplingMode(): number;
  96569. /**
  96570. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  96571. */
  96572. get invertY(): boolean;
  96573. /**
  96574. * Instantiates a new texture.
  96575. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96576. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96577. * @param url defines the url of the picture to load as a texture
  96578. * @param sceneOrEngine defines the scene or engine the texture will belong to
  96579. * @param noMipmap defines if the texture will require mip maps or not
  96580. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  96581. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96582. * @param onLoad defines a callback triggered when the texture has been loaded
  96583. * @param onError defines a callback triggered when an error occurred during the loading session
  96584. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  96585. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  96586. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96587. * @param mimeType defines an optional mime type information
  96588. */
  96589. 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);
  96590. /**
  96591. * Update the url (and optional buffer) of this texture if url was null during construction.
  96592. * @param url the url of the texture
  96593. * @param buffer the buffer of the texture (defaults to null)
  96594. * @param onLoad callback called when the texture is loaded (defaults to null)
  96595. */
  96596. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  96597. /**
  96598. * Finish the loading sequence of a texture flagged as delayed load.
  96599. * @hidden
  96600. */
  96601. delayLoad(): void;
  96602. private _prepareRowForTextureGeneration;
  96603. /**
  96604. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  96605. * @returns the transform matrix of the texture.
  96606. */
  96607. getTextureMatrix(uBase?: number): Matrix;
  96608. /**
  96609. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  96610. * @returns The reflection texture transform
  96611. */
  96612. getReflectionTextureMatrix(): Matrix;
  96613. /**
  96614. * Clones the texture.
  96615. * @returns the cloned texture
  96616. */
  96617. clone(): Texture;
  96618. /**
  96619. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96620. * @returns The JSON representation of the texture
  96621. */
  96622. serialize(): any;
  96623. /**
  96624. * Get the current class name of the texture useful for serialization or dynamic coding.
  96625. * @returns "Texture"
  96626. */
  96627. getClassName(): string;
  96628. /**
  96629. * Dispose the texture and release its associated resources.
  96630. */
  96631. dispose(): void;
  96632. /**
  96633. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  96634. * @param parsedTexture Define the JSON representation of the texture
  96635. * @param scene Define the scene the parsed texture should be instantiated in
  96636. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  96637. * @returns The parsed texture if successful
  96638. */
  96639. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  96640. /**
  96641. * Creates a texture from its base 64 representation.
  96642. * @param data Define the base64 payload without the data: prefix
  96643. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96644. * @param scene Define the scene the texture should belong to
  96645. * @param noMipmap Forces the texture to not create mip map information if true
  96646. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96647. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96648. * @param onLoad define a callback triggered when the texture has been loaded
  96649. * @param onError define a callback triggered when an error occurred during the loading session
  96650. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96651. * @returns the created texture
  96652. */
  96653. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  96654. /**
  96655. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  96656. * @param data Define the base64 payload without the data: prefix
  96657. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96658. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  96659. * @param scene Define the scene the texture should belong to
  96660. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  96661. * @param noMipmap Forces the texture to not create mip map information if true
  96662. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96663. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96664. * @param onLoad define a callback triggered when the texture has been loaded
  96665. * @param onError define a callback triggered when an error occurred during the loading session
  96666. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96667. * @returns the created texture
  96668. */
  96669. 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;
  96670. }
  96671. }
  96672. declare module BABYLON {
  96673. /**
  96674. * PostProcessManager is used to manage one or more post processes or post process pipelines
  96675. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  96676. */
  96677. export class PostProcessManager {
  96678. private _scene;
  96679. private _indexBuffer;
  96680. private _vertexBuffers;
  96681. /**
  96682. * Creates a new instance PostProcess
  96683. * @param scene The scene that the post process is associated with.
  96684. */
  96685. constructor(scene: Scene);
  96686. private _prepareBuffers;
  96687. private _buildIndexBuffer;
  96688. /**
  96689. * Rebuilds the vertex buffers of the manager.
  96690. * @hidden
  96691. */
  96692. _rebuild(): void;
  96693. /**
  96694. * Prepares a frame to be run through a post process.
  96695. * @param sourceTexture The input texture to the post procesess. (default: null)
  96696. * @param postProcesses An array of post processes to be run. (default: null)
  96697. * @returns True if the post processes were able to be run.
  96698. * @hidden
  96699. */
  96700. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  96701. /**
  96702. * Manually render a set of post processes to a texture.
  96703. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  96704. * @param postProcesses An array of post processes to be run.
  96705. * @param targetTexture The target texture to render to.
  96706. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  96707. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  96708. * @param lodLevel defines which lod of the texture to render to
  96709. */
  96710. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  96711. /**
  96712. * Finalize the result of the output of the postprocesses.
  96713. * @param doNotPresent If true the result will not be displayed to the screen.
  96714. * @param targetTexture The target texture to render to.
  96715. * @param faceIndex The index of the face to bind the target texture to.
  96716. * @param postProcesses The array of post processes to render.
  96717. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  96718. * @hidden
  96719. */
  96720. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  96721. /**
  96722. * Disposes of the post process manager.
  96723. */
  96724. dispose(): void;
  96725. }
  96726. }
  96727. declare module BABYLON {
  96728. /**
  96729. * This Helps creating a texture that will be created from a camera in your scene.
  96730. * It is basically a dynamic texture that could be used to create special effects for instance.
  96731. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  96732. */
  96733. export class RenderTargetTexture extends Texture {
  96734. isCube: boolean;
  96735. /**
  96736. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  96737. */
  96738. static readonly REFRESHRATE_RENDER_ONCE: number;
  96739. /**
  96740. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  96741. */
  96742. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  96743. /**
  96744. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  96745. * the central point of your effect and can save a lot of performances.
  96746. */
  96747. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  96748. /**
  96749. * Use this predicate to dynamically define the list of mesh you want to render.
  96750. * If set, the renderList property will be overwritten.
  96751. */
  96752. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  96753. private _renderList;
  96754. /**
  96755. * Use this list to define the list of mesh you want to render.
  96756. */
  96757. get renderList(): Nullable<Array<AbstractMesh>>;
  96758. set renderList(value: Nullable<Array<AbstractMesh>>);
  96759. /**
  96760. * Use this function to overload the renderList array at rendering time.
  96761. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  96762. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  96763. * the cube (if the RTT is a cube, else layerOrFace=0).
  96764. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  96765. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  96766. * hold dummy elements!
  96767. */
  96768. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  96769. private _hookArray;
  96770. /**
  96771. * Define if particles should be rendered in your texture.
  96772. */
  96773. renderParticles: boolean;
  96774. /**
  96775. * Define if sprites should be rendered in your texture.
  96776. */
  96777. renderSprites: boolean;
  96778. /**
  96779. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  96780. */
  96781. coordinatesMode: number;
  96782. /**
  96783. * Define the camera used to render the texture.
  96784. */
  96785. activeCamera: Nullable<Camera>;
  96786. /**
  96787. * Override the mesh isReady function with your own one.
  96788. */
  96789. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  96790. /**
  96791. * Override the render function of the texture with your own one.
  96792. */
  96793. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  96794. /**
  96795. * Define if camera post processes should be use while rendering the texture.
  96796. */
  96797. useCameraPostProcesses: boolean;
  96798. /**
  96799. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  96800. */
  96801. ignoreCameraViewport: boolean;
  96802. private _postProcessManager;
  96803. private _postProcesses;
  96804. private _resizeObserver;
  96805. /**
  96806. * An event triggered when the texture is unbind.
  96807. */
  96808. onBeforeBindObservable: Observable<RenderTargetTexture>;
  96809. /**
  96810. * An event triggered when the texture is unbind.
  96811. */
  96812. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  96813. private _onAfterUnbindObserver;
  96814. /**
  96815. * Set a after unbind callback in the texture.
  96816. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  96817. */
  96818. set onAfterUnbind(callback: () => void);
  96819. /**
  96820. * An event triggered before rendering the texture
  96821. */
  96822. onBeforeRenderObservable: Observable<number>;
  96823. private _onBeforeRenderObserver;
  96824. /**
  96825. * Set a before render callback in the texture.
  96826. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  96827. */
  96828. set onBeforeRender(callback: (faceIndex: number) => void);
  96829. /**
  96830. * An event triggered after rendering the texture
  96831. */
  96832. onAfterRenderObservable: Observable<number>;
  96833. private _onAfterRenderObserver;
  96834. /**
  96835. * Set a after render callback in the texture.
  96836. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  96837. */
  96838. set onAfterRender(callback: (faceIndex: number) => void);
  96839. /**
  96840. * An event triggered after the texture clear
  96841. */
  96842. onClearObservable: Observable<Engine>;
  96843. private _onClearObserver;
  96844. /**
  96845. * Set a clear callback in the texture.
  96846. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  96847. */
  96848. set onClear(callback: (Engine: Engine) => void);
  96849. /**
  96850. * An event triggered when the texture is resized.
  96851. */
  96852. onResizeObservable: Observable<RenderTargetTexture>;
  96853. /**
  96854. * Define the clear color of the Render Target if it should be different from the scene.
  96855. */
  96856. clearColor: Color4;
  96857. protected _size: number | {
  96858. width: number;
  96859. height: number;
  96860. layers?: number;
  96861. };
  96862. protected _initialSizeParameter: number | {
  96863. width: number;
  96864. height: number;
  96865. } | {
  96866. ratio: number;
  96867. };
  96868. protected _sizeRatio: Nullable<number>;
  96869. /** @hidden */
  96870. _generateMipMaps: boolean;
  96871. protected _renderingManager: RenderingManager;
  96872. /** @hidden */
  96873. _waitingRenderList: string[];
  96874. protected _doNotChangeAspectRatio: boolean;
  96875. protected _currentRefreshId: number;
  96876. protected _refreshRate: number;
  96877. protected _textureMatrix: Matrix;
  96878. protected _samples: number;
  96879. protected _renderTargetOptions: RenderTargetCreationOptions;
  96880. /**
  96881. * Gets render target creation options that were used.
  96882. */
  96883. get renderTargetOptions(): RenderTargetCreationOptions;
  96884. protected _onRatioRescale(): void;
  96885. /**
  96886. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  96887. * It must define where the camera used to render the texture is set
  96888. */
  96889. boundingBoxPosition: Vector3;
  96890. private _boundingBoxSize;
  96891. /**
  96892. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  96893. * When defined, the cubemap will switch to local mode
  96894. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96895. * @example https://www.babylonjs-playground.com/#RNASML
  96896. */
  96897. set boundingBoxSize(value: Vector3);
  96898. get boundingBoxSize(): Vector3;
  96899. /**
  96900. * In case the RTT has been created with a depth texture, get the associated
  96901. * depth texture.
  96902. * Otherwise, return null.
  96903. */
  96904. get depthStencilTexture(): Nullable<InternalTexture>;
  96905. /**
  96906. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  96907. * or used a shadow, depth texture...
  96908. * @param name The friendly name of the texture
  96909. * @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)
  96910. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  96911. * @param generateMipMaps True if mip maps need to be generated after render.
  96912. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  96913. * @param type The type of the buffer in the RTT (int, half float, float...)
  96914. * @param isCube True if a cube texture needs to be created
  96915. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  96916. * @param generateDepthBuffer True to generate a depth buffer
  96917. * @param generateStencilBuffer True to generate a stencil buffer
  96918. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  96919. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  96920. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96921. */
  96922. constructor(name: string, size: number | {
  96923. width: number;
  96924. height: number;
  96925. layers?: number;
  96926. } | {
  96927. ratio: number;
  96928. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  96929. /**
  96930. * Creates a depth stencil texture.
  96931. * This is only available in WebGL 2 or with the depth texture extension available.
  96932. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  96933. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  96934. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  96935. */
  96936. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  96937. private _processSizeParameter;
  96938. /**
  96939. * Define the number of samples to use in case of MSAA.
  96940. * It defaults to one meaning no MSAA has been enabled.
  96941. */
  96942. get samples(): number;
  96943. set samples(value: number);
  96944. /**
  96945. * Resets the refresh counter of the texture and start bak from scratch.
  96946. * Could be useful to regenerate the texture if it is setup to render only once.
  96947. */
  96948. resetRefreshCounter(): void;
  96949. /**
  96950. * Define the refresh rate of the texture or the rendering frequency.
  96951. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  96952. */
  96953. get refreshRate(): number;
  96954. set refreshRate(value: number);
  96955. /**
  96956. * Adds a post process to the render target rendering passes.
  96957. * @param postProcess define the post process to add
  96958. */
  96959. addPostProcess(postProcess: PostProcess): void;
  96960. /**
  96961. * Clear all the post processes attached to the render target
  96962. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  96963. */
  96964. clearPostProcesses(dispose?: boolean): void;
  96965. /**
  96966. * Remove one of the post process from the list of attached post processes to the texture
  96967. * @param postProcess define the post process to remove from the list
  96968. */
  96969. removePostProcess(postProcess: PostProcess): void;
  96970. /** @hidden */
  96971. _shouldRender(): boolean;
  96972. /**
  96973. * Gets the actual render size of the texture.
  96974. * @returns the width of the render size
  96975. */
  96976. getRenderSize(): number;
  96977. /**
  96978. * Gets the actual render width of the texture.
  96979. * @returns the width of the render size
  96980. */
  96981. getRenderWidth(): number;
  96982. /**
  96983. * Gets the actual render height of the texture.
  96984. * @returns the height of the render size
  96985. */
  96986. getRenderHeight(): number;
  96987. /**
  96988. * Gets the actual number of layers of the texture.
  96989. * @returns the number of layers
  96990. */
  96991. getRenderLayers(): number;
  96992. /**
  96993. * Get if the texture can be rescaled or not.
  96994. */
  96995. get canRescale(): boolean;
  96996. /**
  96997. * Resize the texture using a ratio.
  96998. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  96999. */
  97000. scale(ratio: number): void;
  97001. /**
  97002. * Get the texture reflection matrix used to rotate/transform the reflection.
  97003. * @returns the reflection matrix
  97004. */
  97005. getReflectionTextureMatrix(): Matrix;
  97006. /**
  97007. * Resize the texture to a new desired size.
  97008. * Be carrefull as it will recreate all the data in the new texture.
  97009. * @param size Define the new size. It can be:
  97010. * - a number for squared texture,
  97011. * - an object containing { width: number, height: number }
  97012. * - or an object containing a ratio { ratio: number }
  97013. */
  97014. resize(size: number | {
  97015. width: number;
  97016. height: number;
  97017. } | {
  97018. ratio: number;
  97019. }): void;
  97020. private _defaultRenderListPrepared;
  97021. /**
  97022. * Renders all the objects from the render list into the texture.
  97023. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  97024. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  97025. */
  97026. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  97027. private _bestReflectionRenderTargetDimension;
  97028. private _prepareRenderingManager;
  97029. /**
  97030. * @hidden
  97031. * @param faceIndex face index to bind to if this is a cubetexture
  97032. * @param layer defines the index of the texture to bind in the array
  97033. */
  97034. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  97035. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  97036. private renderToTarget;
  97037. /**
  97038. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97039. * This allowed control for front to back rendering or reversly depending of the special needs.
  97040. *
  97041. * @param renderingGroupId The rendering group id corresponding to its index
  97042. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97043. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97044. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97045. */
  97046. 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;
  97047. /**
  97048. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97049. *
  97050. * @param renderingGroupId The rendering group id corresponding to its index
  97051. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97052. */
  97053. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  97054. /**
  97055. * Clones the texture.
  97056. * @returns the cloned texture
  97057. */
  97058. clone(): RenderTargetTexture;
  97059. /**
  97060. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  97061. * @returns The JSON representation of the texture
  97062. */
  97063. serialize(): any;
  97064. /**
  97065. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  97066. */
  97067. disposeFramebufferObjects(): void;
  97068. /**
  97069. * Dispose the texture and release its associated resources.
  97070. */
  97071. dispose(): void;
  97072. /** @hidden */
  97073. _rebuild(): void;
  97074. /**
  97075. * Clear the info related to rendering groups preventing retention point in material dispose.
  97076. */
  97077. freeRenderingGroups(): void;
  97078. /**
  97079. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97080. * @returns the view count
  97081. */
  97082. getViewCount(): number;
  97083. }
  97084. }
  97085. declare module BABYLON {
  97086. /**
  97087. * Class used to manipulate GUIDs
  97088. */
  97089. export class GUID {
  97090. /**
  97091. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97092. * Be aware Math.random() could cause collisions, but:
  97093. * "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"
  97094. * @returns a pseudo random id
  97095. */
  97096. static RandomId(): string;
  97097. }
  97098. }
  97099. declare module BABYLON {
  97100. /**
  97101. * Options to be used when creating a shadow depth material
  97102. */
  97103. export interface IIOptionShadowDepthMaterial {
  97104. /** Variables in the vertex shader code that need to have their names remapped.
  97105. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  97106. * "var_name" should be either: worldPos or vNormalW
  97107. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  97108. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  97109. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  97110. */
  97111. remappedVariables?: string[];
  97112. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  97113. standalone?: boolean;
  97114. }
  97115. /**
  97116. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  97117. */
  97118. export class ShadowDepthWrapper {
  97119. private _scene;
  97120. private _options?;
  97121. private _baseMaterial;
  97122. private _onEffectCreatedObserver;
  97123. private _subMeshToEffect;
  97124. private _subMeshToDepthEffect;
  97125. private _meshes;
  97126. /** @hidden */
  97127. _matriceNames: any;
  97128. /** Gets the standalone status of the wrapper */
  97129. get standalone(): boolean;
  97130. /** Gets the base material the wrapper is built upon */
  97131. get baseMaterial(): Material;
  97132. /**
  97133. * Instantiate a new shadow depth wrapper.
  97134. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  97135. * generate the shadow depth map. For more information, please refer to the documentation:
  97136. * https://doc.babylonjs.com/babylon101/shadows
  97137. * @param baseMaterial Material to wrap
  97138. * @param scene Define the scene the material belongs to
  97139. * @param options Options used to create the wrapper
  97140. */
  97141. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  97142. /**
  97143. * Gets the effect to use to generate the depth map
  97144. * @param subMesh subMesh to get the effect for
  97145. * @param shadowGenerator shadow generator to get the effect for
  97146. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  97147. */
  97148. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  97149. /**
  97150. * Specifies that the submesh is ready to be used for depth rendering
  97151. * @param subMesh submesh to check
  97152. * @param defines the list of defines to take into account when checking the effect
  97153. * @param shadowGenerator combined with subMesh, it defines the effect to check
  97154. * @param useInstances specifies that instances should be used
  97155. * @returns a boolean indicating that the submesh is ready or not
  97156. */
  97157. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  97158. /**
  97159. * Disposes the resources
  97160. */
  97161. dispose(): void;
  97162. private _makeEffect;
  97163. }
  97164. }
  97165. declare module BABYLON {
  97166. /**
  97167. * Options for compiling materials.
  97168. */
  97169. export interface IMaterialCompilationOptions {
  97170. /**
  97171. * Defines whether clip planes are enabled.
  97172. */
  97173. clipPlane: boolean;
  97174. /**
  97175. * Defines whether instances are enabled.
  97176. */
  97177. useInstances: boolean;
  97178. }
  97179. /**
  97180. * Base class for the main features of a material in Babylon.js
  97181. */
  97182. export class Material implements IAnimatable {
  97183. /**
  97184. * Returns the triangle fill mode
  97185. */
  97186. static readonly TriangleFillMode: number;
  97187. /**
  97188. * Returns the wireframe mode
  97189. */
  97190. static readonly WireFrameFillMode: number;
  97191. /**
  97192. * Returns the point fill mode
  97193. */
  97194. static readonly PointFillMode: number;
  97195. /**
  97196. * Returns the point list draw mode
  97197. */
  97198. static readonly PointListDrawMode: number;
  97199. /**
  97200. * Returns the line list draw mode
  97201. */
  97202. static readonly LineListDrawMode: number;
  97203. /**
  97204. * Returns the line loop draw mode
  97205. */
  97206. static readonly LineLoopDrawMode: number;
  97207. /**
  97208. * Returns the line strip draw mode
  97209. */
  97210. static readonly LineStripDrawMode: number;
  97211. /**
  97212. * Returns the triangle strip draw mode
  97213. */
  97214. static readonly TriangleStripDrawMode: number;
  97215. /**
  97216. * Returns the triangle fan draw mode
  97217. */
  97218. static readonly TriangleFanDrawMode: number;
  97219. /**
  97220. * Stores the clock-wise side orientation
  97221. */
  97222. static readonly ClockWiseSideOrientation: number;
  97223. /**
  97224. * Stores the counter clock-wise side orientation
  97225. */
  97226. static readonly CounterClockWiseSideOrientation: number;
  97227. /**
  97228. * The dirty texture flag value
  97229. */
  97230. static readonly TextureDirtyFlag: number;
  97231. /**
  97232. * The dirty light flag value
  97233. */
  97234. static readonly LightDirtyFlag: number;
  97235. /**
  97236. * The dirty fresnel flag value
  97237. */
  97238. static readonly FresnelDirtyFlag: number;
  97239. /**
  97240. * The dirty attribute flag value
  97241. */
  97242. static readonly AttributesDirtyFlag: number;
  97243. /**
  97244. * The dirty misc flag value
  97245. */
  97246. static readonly MiscDirtyFlag: number;
  97247. /**
  97248. * The all dirty flag value
  97249. */
  97250. static readonly AllDirtyFlag: number;
  97251. /**
  97252. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  97253. */
  97254. static readonly MATERIAL_OPAQUE: number;
  97255. /**
  97256. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  97257. */
  97258. static readonly MATERIAL_ALPHATEST: number;
  97259. /**
  97260. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97261. */
  97262. static readonly MATERIAL_ALPHABLEND: number;
  97263. /**
  97264. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97265. * They are also discarded below the alpha cutoff threshold to improve performances.
  97266. */
  97267. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  97268. /**
  97269. * Custom callback helping to override the default shader used in the material.
  97270. */
  97271. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  97272. /**
  97273. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  97274. */
  97275. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  97276. /**
  97277. * The ID of the material
  97278. */
  97279. id: string;
  97280. /**
  97281. * Gets or sets the unique id of the material
  97282. */
  97283. uniqueId: number;
  97284. /**
  97285. * The name of the material
  97286. */
  97287. name: string;
  97288. /**
  97289. * Gets or sets user defined metadata
  97290. */
  97291. metadata: any;
  97292. /**
  97293. * For internal use only. Please do not use.
  97294. */
  97295. reservedDataStore: any;
  97296. /**
  97297. * Specifies if the ready state should be checked on each call
  97298. */
  97299. checkReadyOnEveryCall: boolean;
  97300. /**
  97301. * Specifies if the ready state should be checked once
  97302. */
  97303. checkReadyOnlyOnce: boolean;
  97304. /**
  97305. * The state of the material
  97306. */
  97307. state: string;
  97308. /**
  97309. * The alpha value of the material
  97310. */
  97311. protected _alpha: number;
  97312. /**
  97313. * List of inspectable custom properties (used by the Inspector)
  97314. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97315. */
  97316. inspectableCustomProperties: IInspectable[];
  97317. /**
  97318. * Sets the alpha value of the material
  97319. */
  97320. set alpha(value: number);
  97321. /**
  97322. * Gets the alpha value of the material
  97323. */
  97324. get alpha(): number;
  97325. /**
  97326. * Specifies if back face culling is enabled
  97327. */
  97328. protected _backFaceCulling: boolean;
  97329. /**
  97330. * Sets the back-face culling state
  97331. */
  97332. set backFaceCulling(value: boolean);
  97333. /**
  97334. * Gets the back-face culling state
  97335. */
  97336. get backFaceCulling(): boolean;
  97337. /**
  97338. * Stores the value for side orientation
  97339. */
  97340. sideOrientation: number;
  97341. /**
  97342. * Callback triggered when the material is compiled
  97343. */
  97344. onCompiled: Nullable<(effect: Effect) => void>;
  97345. /**
  97346. * Callback triggered when an error occurs
  97347. */
  97348. onError: Nullable<(effect: Effect, errors: string) => void>;
  97349. /**
  97350. * Callback triggered to get the render target textures
  97351. */
  97352. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  97353. /**
  97354. * Gets a boolean indicating that current material needs to register RTT
  97355. */
  97356. get hasRenderTargetTextures(): boolean;
  97357. /**
  97358. * Specifies if the material should be serialized
  97359. */
  97360. doNotSerialize: boolean;
  97361. /**
  97362. * @hidden
  97363. */
  97364. _storeEffectOnSubMeshes: boolean;
  97365. /**
  97366. * Stores the animations for the material
  97367. */
  97368. animations: Nullable<Array<Animation>>;
  97369. /**
  97370. * An event triggered when the material is disposed
  97371. */
  97372. onDisposeObservable: Observable<Material>;
  97373. /**
  97374. * An observer which watches for dispose events
  97375. */
  97376. private _onDisposeObserver;
  97377. private _onUnBindObservable;
  97378. /**
  97379. * Called during a dispose event
  97380. */
  97381. set onDispose(callback: () => void);
  97382. private _onBindObservable;
  97383. /**
  97384. * An event triggered when the material is bound
  97385. */
  97386. get onBindObservable(): Observable<AbstractMesh>;
  97387. /**
  97388. * An observer which watches for bind events
  97389. */
  97390. private _onBindObserver;
  97391. /**
  97392. * Called during a bind event
  97393. */
  97394. set onBind(callback: (Mesh: AbstractMesh) => void);
  97395. /**
  97396. * An event triggered when the material is unbound
  97397. */
  97398. get onUnBindObservable(): Observable<Material>;
  97399. protected _onEffectCreatedObservable: Nullable<Observable<{
  97400. effect: Effect;
  97401. subMesh: Nullable<SubMesh>;
  97402. }>>;
  97403. /**
  97404. * An event triggered when the effect is (re)created
  97405. */
  97406. get onEffectCreatedObservable(): Observable<{
  97407. effect: Effect;
  97408. subMesh: Nullable<SubMesh>;
  97409. }>;
  97410. /**
  97411. * Stores the value of the alpha mode
  97412. */
  97413. private _alphaMode;
  97414. /**
  97415. * Sets the value of the alpha mode.
  97416. *
  97417. * | Value | Type | Description |
  97418. * | --- | --- | --- |
  97419. * | 0 | ALPHA_DISABLE | |
  97420. * | 1 | ALPHA_ADD | |
  97421. * | 2 | ALPHA_COMBINE | |
  97422. * | 3 | ALPHA_SUBTRACT | |
  97423. * | 4 | ALPHA_MULTIPLY | |
  97424. * | 5 | ALPHA_MAXIMIZED | |
  97425. * | 6 | ALPHA_ONEONE | |
  97426. * | 7 | ALPHA_PREMULTIPLIED | |
  97427. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  97428. * | 9 | ALPHA_INTERPOLATE | |
  97429. * | 10 | ALPHA_SCREENMODE | |
  97430. *
  97431. */
  97432. set alphaMode(value: number);
  97433. /**
  97434. * Gets the value of the alpha mode
  97435. */
  97436. get alphaMode(): number;
  97437. /**
  97438. * Stores the state of the need depth pre-pass value
  97439. */
  97440. private _needDepthPrePass;
  97441. /**
  97442. * Sets the need depth pre-pass value
  97443. */
  97444. set needDepthPrePass(value: boolean);
  97445. /**
  97446. * Gets the depth pre-pass value
  97447. */
  97448. get needDepthPrePass(): boolean;
  97449. /**
  97450. * Specifies if depth writing should be disabled
  97451. */
  97452. disableDepthWrite: boolean;
  97453. /**
  97454. * Specifies if color writing should be disabled
  97455. */
  97456. disableColorWrite: boolean;
  97457. /**
  97458. * Specifies if depth writing should be forced
  97459. */
  97460. forceDepthWrite: boolean;
  97461. /**
  97462. * Specifies the depth function that should be used. 0 means the default engine function
  97463. */
  97464. depthFunction: number;
  97465. /**
  97466. * Specifies if there should be a separate pass for culling
  97467. */
  97468. separateCullingPass: boolean;
  97469. /**
  97470. * Stores the state specifing if fog should be enabled
  97471. */
  97472. private _fogEnabled;
  97473. /**
  97474. * Sets the state for enabling fog
  97475. */
  97476. set fogEnabled(value: boolean);
  97477. /**
  97478. * Gets the value of the fog enabled state
  97479. */
  97480. get fogEnabled(): boolean;
  97481. /**
  97482. * Stores the size of points
  97483. */
  97484. pointSize: number;
  97485. /**
  97486. * Stores the z offset value
  97487. */
  97488. zOffset: number;
  97489. get wireframe(): boolean;
  97490. /**
  97491. * Sets the state of wireframe mode
  97492. */
  97493. set wireframe(value: boolean);
  97494. /**
  97495. * Gets the value specifying if point clouds are enabled
  97496. */
  97497. get pointsCloud(): boolean;
  97498. /**
  97499. * Sets the state of point cloud mode
  97500. */
  97501. set pointsCloud(value: boolean);
  97502. /**
  97503. * Gets the material fill mode
  97504. */
  97505. get fillMode(): number;
  97506. /**
  97507. * Sets the material fill mode
  97508. */
  97509. set fillMode(value: number);
  97510. /**
  97511. * @hidden
  97512. * Stores the effects for the material
  97513. */
  97514. _effect: Nullable<Effect>;
  97515. /**
  97516. * Specifies if uniform buffers should be used
  97517. */
  97518. private _useUBO;
  97519. /**
  97520. * Stores a reference to the scene
  97521. */
  97522. private _scene;
  97523. /**
  97524. * Stores the fill mode state
  97525. */
  97526. private _fillMode;
  97527. /**
  97528. * Specifies if the depth write state should be cached
  97529. */
  97530. private _cachedDepthWriteState;
  97531. /**
  97532. * Specifies if the color write state should be cached
  97533. */
  97534. private _cachedColorWriteState;
  97535. /**
  97536. * Specifies if the depth function state should be cached
  97537. */
  97538. private _cachedDepthFunctionState;
  97539. /**
  97540. * Stores the uniform buffer
  97541. */
  97542. protected _uniformBuffer: UniformBuffer;
  97543. /** @hidden */
  97544. _indexInSceneMaterialArray: number;
  97545. /** @hidden */
  97546. meshMap: Nullable<{
  97547. [id: string]: AbstractMesh | undefined;
  97548. }>;
  97549. /**
  97550. * Creates a material instance
  97551. * @param name defines the name of the material
  97552. * @param scene defines the scene to reference
  97553. * @param doNotAdd specifies if the material should be added to the scene
  97554. */
  97555. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  97556. /**
  97557. * Returns a string representation of the current material
  97558. * @param fullDetails defines a boolean indicating which levels of logging is desired
  97559. * @returns a string with material information
  97560. */
  97561. toString(fullDetails?: boolean): string;
  97562. /**
  97563. * Gets the class name of the material
  97564. * @returns a string with the class name of the material
  97565. */
  97566. getClassName(): string;
  97567. /**
  97568. * Specifies if updates for the material been locked
  97569. */
  97570. get isFrozen(): boolean;
  97571. /**
  97572. * Locks updates for the material
  97573. */
  97574. freeze(): void;
  97575. /**
  97576. * Unlocks updates for the material
  97577. */
  97578. unfreeze(): void;
  97579. /**
  97580. * Specifies if the material is ready to be used
  97581. * @param mesh defines the mesh to check
  97582. * @param useInstances specifies if instances should be used
  97583. * @returns a boolean indicating if the material is ready to be used
  97584. */
  97585. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97586. /**
  97587. * Specifies that the submesh is ready to be used
  97588. * @param mesh defines the mesh to check
  97589. * @param subMesh defines which submesh to check
  97590. * @param useInstances specifies that instances should be used
  97591. * @returns a boolean indicating that the submesh is ready or not
  97592. */
  97593. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97594. /**
  97595. * Returns the material effect
  97596. * @returns the effect associated with the material
  97597. */
  97598. getEffect(): Nullable<Effect>;
  97599. /**
  97600. * Returns the current scene
  97601. * @returns a Scene
  97602. */
  97603. getScene(): Scene;
  97604. /**
  97605. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  97606. */
  97607. protected _forceAlphaTest: boolean;
  97608. /**
  97609. * The transparency mode of the material.
  97610. */
  97611. protected _transparencyMode: Nullable<number>;
  97612. /**
  97613. * Gets the current transparency mode.
  97614. */
  97615. get transparencyMode(): Nullable<number>;
  97616. /**
  97617. * Sets the transparency mode of the material.
  97618. *
  97619. * | Value | Type | Description |
  97620. * | ----- | ----------------------------------- | ----------- |
  97621. * | 0 | OPAQUE | |
  97622. * | 1 | ALPHATEST | |
  97623. * | 2 | ALPHABLEND | |
  97624. * | 3 | ALPHATESTANDBLEND | |
  97625. *
  97626. */
  97627. set transparencyMode(value: Nullable<number>);
  97628. /**
  97629. * Returns true if alpha blending should be disabled.
  97630. */
  97631. protected get _disableAlphaBlending(): boolean;
  97632. /**
  97633. * Specifies whether or not this material should be rendered in alpha blend mode.
  97634. * @returns a boolean specifying if alpha blending is needed
  97635. */
  97636. needAlphaBlending(): boolean;
  97637. /**
  97638. * Specifies if the mesh will require alpha blending
  97639. * @param mesh defines the mesh to check
  97640. * @returns a boolean specifying if alpha blending is needed for the mesh
  97641. */
  97642. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  97643. /**
  97644. * Specifies whether or not this material should be rendered in alpha test mode.
  97645. * @returns a boolean specifying if an alpha test is needed.
  97646. */
  97647. needAlphaTesting(): boolean;
  97648. /**
  97649. * Specifies if material alpha testing should be turned on for the mesh
  97650. * @param mesh defines the mesh to check
  97651. */
  97652. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  97653. /**
  97654. * Gets the texture used for the alpha test
  97655. * @returns the texture to use for alpha testing
  97656. */
  97657. getAlphaTestTexture(): Nullable<BaseTexture>;
  97658. /**
  97659. * Marks the material to indicate that it needs to be re-calculated
  97660. */
  97661. markDirty(): void;
  97662. /** @hidden */
  97663. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  97664. /**
  97665. * Binds the material to the mesh
  97666. * @param world defines the world transformation matrix
  97667. * @param mesh defines the mesh to bind the material to
  97668. */
  97669. bind(world: Matrix, mesh?: Mesh): void;
  97670. /**
  97671. * Binds the submesh to the material
  97672. * @param world defines the world transformation matrix
  97673. * @param mesh defines the mesh containing the submesh
  97674. * @param subMesh defines the submesh to bind the material to
  97675. */
  97676. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97677. /**
  97678. * Binds the world matrix to the material
  97679. * @param world defines the world transformation matrix
  97680. */
  97681. bindOnlyWorldMatrix(world: Matrix): void;
  97682. /**
  97683. * Binds the scene's uniform buffer to the effect.
  97684. * @param effect defines the effect to bind to the scene uniform buffer
  97685. * @param sceneUbo defines the uniform buffer storing scene data
  97686. */
  97687. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  97688. /**
  97689. * Binds the view matrix to the effect
  97690. * @param effect defines the effect to bind the view matrix to
  97691. */
  97692. bindView(effect: Effect): void;
  97693. /**
  97694. * Binds the view projection matrix to the effect
  97695. * @param effect defines the effect to bind the view projection matrix to
  97696. */
  97697. bindViewProjection(effect: Effect): void;
  97698. /**
  97699. * Processes to execute after binding the material to a mesh
  97700. * @param mesh defines the rendered mesh
  97701. */
  97702. protected _afterBind(mesh?: Mesh): void;
  97703. /**
  97704. * Unbinds the material from the mesh
  97705. */
  97706. unbind(): void;
  97707. /**
  97708. * Gets the active textures from the material
  97709. * @returns an array of textures
  97710. */
  97711. getActiveTextures(): BaseTexture[];
  97712. /**
  97713. * Specifies if the material uses a texture
  97714. * @param texture defines the texture to check against the material
  97715. * @returns a boolean specifying if the material uses the texture
  97716. */
  97717. hasTexture(texture: BaseTexture): boolean;
  97718. /**
  97719. * Makes a duplicate of the material, and gives it a new name
  97720. * @param name defines the new name for the duplicated material
  97721. * @returns the cloned material
  97722. */
  97723. clone(name: string): Nullable<Material>;
  97724. /**
  97725. * Gets the meshes bound to the material
  97726. * @returns an array of meshes bound to the material
  97727. */
  97728. getBindedMeshes(): AbstractMesh[];
  97729. /**
  97730. * Force shader compilation
  97731. * @param mesh defines the mesh associated with this material
  97732. * @param onCompiled defines a function to execute once the material is compiled
  97733. * @param options defines the options to configure the compilation
  97734. * @param onError defines a function to execute if the material fails compiling
  97735. */
  97736. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  97737. /**
  97738. * Force shader compilation
  97739. * @param mesh defines the mesh that will use this material
  97740. * @param options defines additional options for compiling the shaders
  97741. * @returns a promise that resolves when the compilation completes
  97742. */
  97743. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  97744. private static readonly _AllDirtyCallBack;
  97745. private static readonly _ImageProcessingDirtyCallBack;
  97746. private static readonly _TextureDirtyCallBack;
  97747. private static readonly _FresnelDirtyCallBack;
  97748. private static readonly _MiscDirtyCallBack;
  97749. private static readonly _LightsDirtyCallBack;
  97750. private static readonly _AttributeDirtyCallBack;
  97751. private static _FresnelAndMiscDirtyCallBack;
  97752. private static _TextureAndMiscDirtyCallBack;
  97753. private static readonly _DirtyCallbackArray;
  97754. private static readonly _RunDirtyCallBacks;
  97755. /**
  97756. * Marks a define in the material to indicate that it needs to be re-computed
  97757. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  97758. */
  97759. markAsDirty(flag: number): void;
  97760. /**
  97761. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  97762. * @param func defines a function which checks material defines against the submeshes
  97763. */
  97764. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  97765. /**
  97766. * Indicates that we need to re-calculated for all submeshes
  97767. */
  97768. protected _markAllSubMeshesAsAllDirty(): void;
  97769. /**
  97770. * Indicates that image processing needs to be re-calculated for all submeshes
  97771. */
  97772. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  97773. /**
  97774. * Indicates that textures need to be re-calculated for all submeshes
  97775. */
  97776. protected _markAllSubMeshesAsTexturesDirty(): void;
  97777. /**
  97778. * Indicates that fresnel needs to be re-calculated for all submeshes
  97779. */
  97780. protected _markAllSubMeshesAsFresnelDirty(): void;
  97781. /**
  97782. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  97783. */
  97784. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  97785. /**
  97786. * Indicates that lights need to be re-calculated for all submeshes
  97787. */
  97788. protected _markAllSubMeshesAsLightsDirty(): void;
  97789. /**
  97790. * Indicates that attributes need to be re-calculated for all submeshes
  97791. */
  97792. protected _markAllSubMeshesAsAttributesDirty(): void;
  97793. /**
  97794. * Indicates that misc needs to be re-calculated for all submeshes
  97795. */
  97796. protected _markAllSubMeshesAsMiscDirty(): void;
  97797. /**
  97798. * Indicates that textures and misc need to be re-calculated for all submeshes
  97799. */
  97800. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  97801. /**
  97802. * Disposes the material
  97803. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97804. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97805. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97806. */
  97807. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97808. /** @hidden */
  97809. private releaseVertexArrayObject;
  97810. /**
  97811. * Serializes this material
  97812. * @returns the serialized material object
  97813. */
  97814. serialize(): any;
  97815. /**
  97816. * Creates a material from parsed material data
  97817. * @param parsedMaterial defines parsed material data
  97818. * @param scene defines the hosting scene
  97819. * @param rootUrl defines the root URL to use to load textures
  97820. * @returns a new material
  97821. */
  97822. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  97823. }
  97824. }
  97825. declare module BABYLON {
  97826. /**
  97827. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97828. * separate meshes. This can be use to improve performances.
  97829. * @see http://doc.babylonjs.com/how_to/multi_materials
  97830. */
  97831. export class MultiMaterial extends Material {
  97832. private _subMaterials;
  97833. /**
  97834. * Gets or Sets the list of Materials used within the multi material.
  97835. * They need to be ordered according to the submeshes order in the associated mesh
  97836. */
  97837. get subMaterials(): Nullable<Material>[];
  97838. set subMaterials(value: Nullable<Material>[]);
  97839. /**
  97840. * Function used to align with Node.getChildren()
  97841. * @returns the list of Materials used within the multi material
  97842. */
  97843. getChildren(): Nullable<Material>[];
  97844. /**
  97845. * Instantiates a new Multi Material
  97846. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97847. * separate meshes. This can be use to improve performances.
  97848. * @see http://doc.babylonjs.com/how_to/multi_materials
  97849. * @param name Define the name in the scene
  97850. * @param scene Define the scene the material belongs to
  97851. */
  97852. constructor(name: string, scene: Scene);
  97853. private _hookArray;
  97854. /**
  97855. * Get one of the submaterial by its index in the submaterials array
  97856. * @param index The index to look the sub material at
  97857. * @returns The Material if the index has been defined
  97858. */
  97859. getSubMaterial(index: number): Nullable<Material>;
  97860. /**
  97861. * Get the list of active textures for the whole sub materials list.
  97862. * @returns All the textures that will be used during the rendering
  97863. */
  97864. getActiveTextures(): BaseTexture[];
  97865. /**
  97866. * Gets the current class name of the material e.g. "MultiMaterial"
  97867. * Mainly use in serialization.
  97868. * @returns the class name
  97869. */
  97870. getClassName(): string;
  97871. /**
  97872. * Checks if the material is ready to render the requested sub mesh
  97873. * @param mesh Define the mesh the submesh belongs to
  97874. * @param subMesh Define the sub mesh to look readyness for
  97875. * @param useInstances Define whether or not the material is used with instances
  97876. * @returns true if ready, otherwise false
  97877. */
  97878. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97879. /**
  97880. * Clones the current material and its related sub materials
  97881. * @param name Define the name of the newly cloned material
  97882. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  97883. * @returns the cloned material
  97884. */
  97885. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  97886. /**
  97887. * Serializes the materials into a JSON representation.
  97888. * @returns the JSON representation
  97889. */
  97890. serialize(): any;
  97891. /**
  97892. * Dispose the material and release its associated resources
  97893. * @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)
  97894. * @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)
  97895. * @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)
  97896. */
  97897. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  97898. /**
  97899. * Creates a MultiMaterial from parsed MultiMaterial data.
  97900. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  97901. * @param scene defines the hosting scene
  97902. * @returns a new MultiMaterial
  97903. */
  97904. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  97905. }
  97906. }
  97907. declare module BABYLON {
  97908. /**
  97909. * Base class for submeshes
  97910. */
  97911. export class BaseSubMesh {
  97912. /** @hidden */
  97913. _materialDefines: Nullable<MaterialDefines>;
  97914. /** @hidden */
  97915. _materialEffect: Nullable<Effect>;
  97916. /** @hidden */
  97917. _effectOverride: Nullable<Effect>;
  97918. /**
  97919. * Gets material defines used by the effect associated to the sub mesh
  97920. */
  97921. get materialDefines(): Nullable<MaterialDefines>;
  97922. /**
  97923. * Sets material defines used by the effect associated to the sub mesh
  97924. */
  97925. set materialDefines(defines: Nullable<MaterialDefines>);
  97926. /**
  97927. * Gets associated effect
  97928. */
  97929. get effect(): Nullable<Effect>;
  97930. /**
  97931. * Sets associated effect (effect used to render this submesh)
  97932. * @param effect defines the effect to associate with
  97933. * @param defines defines the set of defines used to compile this effect
  97934. */
  97935. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  97936. }
  97937. /**
  97938. * Defines a subdivision inside a mesh
  97939. */
  97940. export class SubMesh extends BaseSubMesh implements ICullable {
  97941. /** the material index to use */
  97942. materialIndex: number;
  97943. /** vertex index start */
  97944. verticesStart: number;
  97945. /** vertices count */
  97946. verticesCount: number;
  97947. /** index start */
  97948. indexStart: number;
  97949. /** indices count */
  97950. indexCount: number;
  97951. /** @hidden */
  97952. _linesIndexCount: number;
  97953. private _mesh;
  97954. private _renderingMesh;
  97955. private _boundingInfo;
  97956. private _linesIndexBuffer;
  97957. /** @hidden */
  97958. _lastColliderWorldVertices: Nullable<Vector3[]>;
  97959. /** @hidden */
  97960. _trianglePlanes: Plane[];
  97961. /** @hidden */
  97962. _lastColliderTransformMatrix: Nullable<Matrix>;
  97963. /** @hidden */
  97964. _renderId: number;
  97965. /** @hidden */
  97966. _alphaIndex: number;
  97967. /** @hidden */
  97968. _distanceToCamera: number;
  97969. /** @hidden */
  97970. _id: number;
  97971. private _currentMaterial;
  97972. /**
  97973. * Add a new submesh to a mesh
  97974. * @param materialIndex defines the material index to use
  97975. * @param verticesStart defines vertex index start
  97976. * @param verticesCount defines vertices count
  97977. * @param indexStart defines index start
  97978. * @param indexCount defines indices count
  97979. * @param mesh defines the parent mesh
  97980. * @param renderingMesh defines an optional rendering mesh
  97981. * @param createBoundingBox defines if bounding box should be created for this submesh
  97982. * @returns the new submesh
  97983. */
  97984. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  97985. /**
  97986. * Creates a new submesh
  97987. * @param materialIndex defines the material index to use
  97988. * @param verticesStart defines vertex index start
  97989. * @param verticesCount defines vertices count
  97990. * @param indexStart defines index start
  97991. * @param indexCount defines indices count
  97992. * @param mesh defines the parent mesh
  97993. * @param renderingMesh defines an optional rendering mesh
  97994. * @param createBoundingBox defines if bounding box should be created for this submesh
  97995. */
  97996. constructor(
  97997. /** the material index to use */
  97998. materialIndex: number,
  97999. /** vertex index start */
  98000. verticesStart: number,
  98001. /** vertices count */
  98002. verticesCount: number,
  98003. /** index start */
  98004. indexStart: number,
  98005. /** indices count */
  98006. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  98007. /**
  98008. * Returns true if this submesh covers the entire parent mesh
  98009. * @ignorenaming
  98010. */
  98011. get IsGlobal(): boolean;
  98012. /**
  98013. * Returns the submesh BoudingInfo object
  98014. * @returns current bounding info (or mesh's one if the submesh is global)
  98015. */
  98016. getBoundingInfo(): BoundingInfo;
  98017. /**
  98018. * Sets the submesh BoundingInfo
  98019. * @param boundingInfo defines the new bounding info to use
  98020. * @returns the SubMesh
  98021. */
  98022. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  98023. /**
  98024. * Returns the mesh of the current submesh
  98025. * @return the parent mesh
  98026. */
  98027. getMesh(): AbstractMesh;
  98028. /**
  98029. * Returns the rendering mesh of the submesh
  98030. * @returns the rendering mesh (could be different from parent mesh)
  98031. */
  98032. getRenderingMesh(): Mesh;
  98033. /**
  98034. * Returns the submesh material
  98035. * @returns null or the current material
  98036. */
  98037. getMaterial(): Nullable<Material>;
  98038. /**
  98039. * Sets a new updated BoundingInfo object to the submesh
  98040. * @param data defines an optional position array to use to determine the bounding info
  98041. * @returns the SubMesh
  98042. */
  98043. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  98044. /** @hidden */
  98045. _checkCollision(collider: Collider): boolean;
  98046. /**
  98047. * Updates the submesh BoundingInfo
  98048. * @param world defines the world matrix to use to update the bounding info
  98049. * @returns the submesh
  98050. */
  98051. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  98052. /**
  98053. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  98054. * @param frustumPlanes defines the frustum planes
  98055. * @returns true if the submesh is intersecting with the frustum
  98056. */
  98057. isInFrustum(frustumPlanes: Plane[]): boolean;
  98058. /**
  98059. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  98060. * @param frustumPlanes defines the frustum planes
  98061. * @returns true if the submesh is inside the frustum
  98062. */
  98063. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98064. /**
  98065. * Renders the submesh
  98066. * @param enableAlphaMode defines if alpha needs to be used
  98067. * @returns the submesh
  98068. */
  98069. render(enableAlphaMode: boolean): SubMesh;
  98070. /**
  98071. * @hidden
  98072. */
  98073. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  98074. /**
  98075. * Checks if the submesh intersects with a ray
  98076. * @param ray defines the ray to test
  98077. * @returns true is the passed ray intersects the submesh bounding box
  98078. */
  98079. canIntersects(ray: Ray): boolean;
  98080. /**
  98081. * Intersects current submesh with a ray
  98082. * @param ray defines the ray to test
  98083. * @param positions defines mesh's positions array
  98084. * @param indices defines mesh's indices array
  98085. * @param fastCheck defines if the first intersection will be used (and not the closest)
  98086. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98087. * @returns intersection info or null if no intersection
  98088. */
  98089. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  98090. /** @hidden */
  98091. private _intersectLines;
  98092. /** @hidden */
  98093. private _intersectUnIndexedLines;
  98094. /** @hidden */
  98095. private _intersectTriangles;
  98096. /** @hidden */
  98097. private _intersectUnIndexedTriangles;
  98098. /** @hidden */
  98099. _rebuild(): void;
  98100. /**
  98101. * Creates a new submesh from the passed mesh
  98102. * @param newMesh defines the new hosting mesh
  98103. * @param newRenderingMesh defines an optional rendering mesh
  98104. * @returns the new submesh
  98105. */
  98106. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  98107. /**
  98108. * Release associated resources
  98109. */
  98110. dispose(): void;
  98111. /**
  98112. * Gets the class name
  98113. * @returns the string "SubMesh".
  98114. */
  98115. getClassName(): string;
  98116. /**
  98117. * Creates a new submesh from indices data
  98118. * @param materialIndex the index of the main mesh material
  98119. * @param startIndex the index where to start the copy in the mesh indices array
  98120. * @param indexCount the number of indices to copy then from the startIndex
  98121. * @param mesh the main mesh to create the submesh from
  98122. * @param renderingMesh the optional rendering mesh
  98123. * @returns a new submesh
  98124. */
  98125. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  98126. }
  98127. }
  98128. declare module BABYLON {
  98129. /**
  98130. * Class used to represent data loading progression
  98131. */
  98132. export class SceneLoaderFlags {
  98133. private static _ForceFullSceneLoadingForIncremental;
  98134. private static _ShowLoadingScreen;
  98135. private static _CleanBoneMatrixWeights;
  98136. private static _loggingLevel;
  98137. /**
  98138. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98139. */
  98140. static get ForceFullSceneLoadingForIncremental(): boolean;
  98141. static set ForceFullSceneLoadingForIncremental(value: boolean);
  98142. /**
  98143. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98144. */
  98145. static get ShowLoadingScreen(): boolean;
  98146. static set ShowLoadingScreen(value: boolean);
  98147. /**
  98148. * Defines the current logging level (while loading the scene)
  98149. * @ignorenaming
  98150. */
  98151. static get loggingLevel(): number;
  98152. static set loggingLevel(value: number);
  98153. /**
  98154. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98155. */
  98156. static get CleanBoneMatrixWeights(): boolean;
  98157. static set CleanBoneMatrixWeights(value: boolean);
  98158. }
  98159. }
  98160. declare module BABYLON {
  98161. /**
  98162. * Class used to store geometry data (vertex buffers + index buffer)
  98163. */
  98164. export class Geometry implements IGetSetVerticesData {
  98165. /**
  98166. * Gets or sets the ID of the geometry
  98167. */
  98168. id: string;
  98169. /**
  98170. * Gets or sets the unique ID of the geometry
  98171. */
  98172. uniqueId: number;
  98173. /**
  98174. * Gets the delay loading state of the geometry (none by default which means not delayed)
  98175. */
  98176. delayLoadState: number;
  98177. /**
  98178. * Gets the file containing the data to load when running in delay load state
  98179. */
  98180. delayLoadingFile: Nullable<string>;
  98181. /**
  98182. * Callback called when the geometry is updated
  98183. */
  98184. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  98185. private _scene;
  98186. private _engine;
  98187. private _meshes;
  98188. private _totalVertices;
  98189. /** @hidden */
  98190. _indices: IndicesArray;
  98191. /** @hidden */
  98192. _vertexBuffers: {
  98193. [key: string]: VertexBuffer;
  98194. };
  98195. private _isDisposed;
  98196. private _extend;
  98197. private _boundingBias;
  98198. /** @hidden */
  98199. _delayInfo: Array<string>;
  98200. private _indexBuffer;
  98201. private _indexBufferIsUpdatable;
  98202. /** @hidden */
  98203. _boundingInfo: Nullable<BoundingInfo>;
  98204. /** @hidden */
  98205. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  98206. /** @hidden */
  98207. _softwareSkinningFrameId: number;
  98208. private _vertexArrayObjects;
  98209. private _updatable;
  98210. /** @hidden */
  98211. _positions: Nullable<Vector3[]>;
  98212. /**
  98213. * 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
  98214. */
  98215. get boundingBias(): Vector2;
  98216. /**
  98217. * 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
  98218. */
  98219. set boundingBias(value: Vector2);
  98220. /**
  98221. * Static function used to attach a new empty geometry to a mesh
  98222. * @param mesh defines the mesh to attach the geometry to
  98223. * @returns the new Geometry
  98224. */
  98225. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  98226. /** Get the list of meshes using this geometry */
  98227. get meshes(): Mesh[];
  98228. /**
  98229. * Creates a new geometry
  98230. * @param id defines the unique ID
  98231. * @param scene defines the hosting scene
  98232. * @param vertexData defines the VertexData used to get geometry data
  98233. * @param updatable defines if geometry must be updatable (false by default)
  98234. * @param mesh defines the mesh that will be associated with the geometry
  98235. */
  98236. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  98237. /**
  98238. * Gets the current extend of the geometry
  98239. */
  98240. get extend(): {
  98241. minimum: Vector3;
  98242. maximum: Vector3;
  98243. };
  98244. /**
  98245. * Gets the hosting scene
  98246. * @returns the hosting Scene
  98247. */
  98248. getScene(): Scene;
  98249. /**
  98250. * Gets the hosting engine
  98251. * @returns the hosting Engine
  98252. */
  98253. getEngine(): Engine;
  98254. /**
  98255. * Defines if the geometry is ready to use
  98256. * @returns true if the geometry is ready to be used
  98257. */
  98258. isReady(): boolean;
  98259. /**
  98260. * Gets a value indicating that the geometry should not be serialized
  98261. */
  98262. get doNotSerialize(): boolean;
  98263. /** @hidden */
  98264. _rebuild(): void;
  98265. /**
  98266. * Affects all geometry data in one call
  98267. * @param vertexData defines the geometry data
  98268. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  98269. */
  98270. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  98271. /**
  98272. * Set specific vertex data
  98273. * @param kind defines the data kind (Position, normal, etc...)
  98274. * @param data defines the vertex data to use
  98275. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98276. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98277. */
  98278. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  98279. /**
  98280. * Removes a specific vertex data
  98281. * @param kind defines the data kind (Position, normal, etc...)
  98282. */
  98283. removeVerticesData(kind: string): void;
  98284. /**
  98285. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  98286. * @param buffer defines the vertex buffer to use
  98287. * @param totalVertices defines the total number of vertices for position kind (could be null)
  98288. */
  98289. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  98290. /**
  98291. * Update a specific vertex buffer
  98292. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  98293. * It will do nothing if the buffer is not updatable
  98294. * @param kind defines the data kind (Position, normal, etc...)
  98295. * @param data defines the data to use
  98296. * @param offset defines the offset in the target buffer where to store the data
  98297. * @param useBytes set to true if the offset is in bytes
  98298. */
  98299. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  98300. /**
  98301. * Update a specific vertex buffer
  98302. * This function will create a new buffer if the current one is not updatable
  98303. * @param kind defines the data kind (Position, normal, etc...)
  98304. * @param data defines the data to use
  98305. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  98306. */
  98307. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  98308. private _updateBoundingInfo;
  98309. /** @hidden */
  98310. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  98311. /**
  98312. * Gets total number of vertices
  98313. * @returns the total number of vertices
  98314. */
  98315. getTotalVertices(): number;
  98316. /**
  98317. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98318. * @param kind defines the data kind (Position, normal, etc...)
  98319. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98320. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98321. * @returns a float array containing vertex data
  98322. */
  98323. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98324. /**
  98325. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  98326. * @param kind defines the data kind (Position, normal, etc...)
  98327. * @returns true if the vertex buffer with the specified kind is updatable
  98328. */
  98329. isVertexBufferUpdatable(kind: string): boolean;
  98330. /**
  98331. * Gets a specific vertex buffer
  98332. * @param kind defines the data kind (Position, normal, etc...)
  98333. * @returns a VertexBuffer
  98334. */
  98335. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98336. /**
  98337. * Returns all vertex buffers
  98338. * @return an object holding all vertex buffers indexed by kind
  98339. */
  98340. getVertexBuffers(): Nullable<{
  98341. [key: string]: VertexBuffer;
  98342. }>;
  98343. /**
  98344. * Gets a boolean indicating if specific vertex buffer is present
  98345. * @param kind defines the data kind (Position, normal, etc...)
  98346. * @returns true if data is present
  98347. */
  98348. isVerticesDataPresent(kind: string): boolean;
  98349. /**
  98350. * Gets a list of all attached data kinds (Position, normal, etc...)
  98351. * @returns a list of string containing all kinds
  98352. */
  98353. getVerticesDataKinds(): string[];
  98354. /**
  98355. * Update index buffer
  98356. * @param indices defines the indices to store in the index buffer
  98357. * @param offset defines the offset in the target buffer where to store the data
  98358. * @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)
  98359. */
  98360. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  98361. /**
  98362. * Creates a new index buffer
  98363. * @param indices defines the indices to store in the index buffer
  98364. * @param totalVertices defines the total number of vertices (could be null)
  98365. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98366. */
  98367. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  98368. /**
  98369. * Return the total number of indices
  98370. * @returns the total number of indices
  98371. */
  98372. getTotalIndices(): number;
  98373. /**
  98374. * Gets the index buffer array
  98375. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98376. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98377. * @returns the index buffer array
  98378. */
  98379. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98380. /**
  98381. * Gets the index buffer
  98382. * @return the index buffer
  98383. */
  98384. getIndexBuffer(): Nullable<DataBuffer>;
  98385. /** @hidden */
  98386. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  98387. /**
  98388. * Release the associated resources for a specific mesh
  98389. * @param mesh defines the source mesh
  98390. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  98391. */
  98392. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  98393. /**
  98394. * Apply current geometry to a given mesh
  98395. * @param mesh defines the mesh to apply geometry to
  98396. */
  98397. applyToMesh(mesh: Mesh): void;
  98398. private _updateExtend;
  98399. private _applyToMesh;
  98400. private notifyUpdate;
  98401. /**
  98402. * Load the geometry if it was flagged as delay loaded
  98403. * @param scene defines the hosting scene
  98404. * @param onLoaded defines a callback called when the geometry is loaded
  98405. */
  98406. load(scene: Scene, onLoaded?: () => void): void;
  98407. private _queueLoad;
  98408. /**
  98409. * Invert the geometry to move from a right handed system to a left handed one.
  98410. */
  98411. toLeftHanded(): void;
  98412. /** @hidden */
  98413. _resetPointsArrayCache(): void;
  98414. /** @hidden */
  98415. _generatePointsArray(): boolean;
  98416. /**
  98417. * Gets a value indicating if the geometry is disposed
  98418. * @returns true if the geometry was disposed
  98419. */
  98420. isDisposed(): boolean;
  98421. private _disposeVertexArrayObjects;
  98422. /**
  98423. * Free all associated resources
  98424. */
  98425. dispose(): void;
  98426. /**
  98427. * Clone the current geometry into a new geometry
  98428. * @param id defines the unique ID of the new geometry
  98429. * @returns a new geometry object
  98430. */
  98431. copy(id: string): Geometry;
  98432. /**
  98433. * Serialize the current geometry info (and not the vertices data) into a JSON object
  98434. * @return a JSON representation of the current geometry data (without the vertices data)
  98435. */
  98436. serialize(): any;
  98437. private toNumberArray;
  98438. /**
  98439. * Serialize all vertices data into a JSON oject
  98440. * @returns a JSON representation of the current geometry data
  98441. */
  98442. serializeVerticeData(): any;
  98443. /**
  98444. * Extracts a clone of a mesh geometry
  98445. * @param mesh defines the source mesh
  98446. * @param id defines the unique ID of the new geometry object
  98447. * @returns the new geometry object
  98448. */
  98449. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  98450. /**
  98451. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  98452. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98453. * Be aware Math.random() could cause collisions, but:
  98454. * "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"
  98455. * @returns a string containing a new GUID
  98456. */
  98457. static RandomId(): string;
  98458. /** @hidden */
  98459. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  98460. private static _CleanMatricesWeights;
  98461. /**
  98462. * Create a new geometry from persisted data (Using .babylon file format)
  98463. * @param parsedVertexData defines the persisted data
  98464. * @param scene defines the hosting scene
  98465. * @param rootUrl defines the root url to use to load assets (like delayed data)
  98466. * @returns the new geometry object
  98467. */
  98468. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  98469. }
  98470. }
  98471. declare module BABYLON {
  98472. /**
  98473. * Define an interface for all classes that will get and set the data on vertices
  98474. */
  98475. export interface IGetSetVerticesData {
  98476. /**
  98477. * Gets a boolean indicating if specific vertex data is present
  98478. * @param kind defines the vertex data kind to use
  98479. * @returns true is data kind is present
  98480. */
  98481. isVerticesDataPresent(kind: string): boolean;
  98482. /**
  98483. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98484. * @param kind defines the data kind (Position, normal, etc...)
  98485. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98486. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98487. * @returns a float array containing vertex data
  98488. */
  98489. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98490. /**
  98491. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98492. * @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.
  98493. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98494. * @returns the indices array or an empty array if the mesh has no geometry
  98495. */
  98496. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98497. /**
  98498. * Set specific vertex data
  98499. * @param kind defines the data kind (Position, normal, etc...)
  98500. * @param data defines the vertex data to use
  98501. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98502. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98503. */
  98504. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  98505. /**
  98506. * Update a specific associated vertex buffer
  98507. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98508. * - VertexBuffer.PositionKind
  98509. * - VertexBuffer.UVKind
  98510. * - VertexBuffer.UV2Kind
  98511. * - VertexBuffer.UV3Kind
  98512. * - VertexBuffer.UV4Kind
  98513. * - VertexBuffer.UV5Kind
  98514. * - VertexBuffer.UV6Kind
  98515. * - VertexBuffer.ColorKind
  98516. * - VertexBuffer.MatricesIndicesKind
  98517. * - VertexBuffer.MatricesIndicesExtraKind
  98518. * - VertexBuffer.MatricesWeightsKind
  98519. * - VertexBuffer.MatricesWeightsExtraKind
  98520. * @param data defines the data source
  98521. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98522. * @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)
  98523. */
  98524. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  98525. /**
  98526. * Creates a new index buffer
  98527. * @param indices defines the indices to store in the index buffer
  98528. * @param totalVertices defines the total number of vertices (could be null)
  98529. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98530. */
  98531. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  98532. }
  98533. /**
  98534. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  98535. */
  98536. export class VertexData {
  98537. /**
  98538. * Mesh side orientation : usually the external or front surface
  98539. */
  98540. static readonly FRONTSIDE: number;
  98541. /**
  98542. * Mesh side orientation : usually the internal or back surface
  98543. */
  98544. static readonly BACKSIDE: number;
  98545. /**
  98546. * Mesh side orientation : both internal and external or front and back surfaces
  98547. */
  98548. static readonly DOUBLESIDE: number;
  98549. /**
  98550. * Mesh side orientation : by default, `FRONTSIDE`
  98551. */
  98552. static readonly DEFAULTSIDE: number;
  98553. /**
  98554. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  98555. */
  98556. positions: Nullable<FloatArray>;
  98557. /**
  98558. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  98559. */
  98560. normals: Nullable<FloatArray>;
  98561. /**
  98562. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  98563. */
  98564. tangents: Nullable<FloatArray>;
  98565. /**
  98566. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98567. */
  98568. uvs: Nullable<FloatArray>;
  98569. /**
  98570. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98571. */
  98572. uvs2: Nullable<FloatArray>;
  98573. /**
  98574. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98575. */
  98576. uvs3: Nullable<FloatArray>;
  98577. /**
  98578. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98579. */
  98580. uvs4: Nullable<FloatArray>;
  98581. /**
  98582. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98583. */
  98584. uvs5: Nullable<FloatArray>;
  98585. /**
  98586. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98587. */
  98588. uvs6: Nullable<FloatArray>;
  98589. /**
  98590. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  98591. */
  98592. colors: Nullable<FloatArray>;
  98593. /**
  98594. * 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).
  98595. */
  98596. matricesIndices: Nullable<FloatArray>;
  98597. /**
  98598. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  98599. */
  98600. matricesWeights: Nullable<FloatArray>;
  98601. /**
  98602. * An array extending the number of possible indices
  98603. */
  98604. matricesIndicesExtra: Nullable<FloatArray>;
  98605. /**
  98606. * An array extending the number of possible weights when the number of indices is extended
  98607. */
  98608. matricesWeightsExtra: Nullable<FloatArray>;
  98609. /**
  98610. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  98611. */
  98612. indices: Nullable<IndicesArray>;
  98613. /**
  98614. * Uses the passed data array to set the set the values for the specified kind of data
  98615. * @param data a linear array of floating numbers
  98616. * @param kind the type of data that is being set, eg positions, colors etc
  98617. */
  98618. set(data: FloatArray, kind: string): void;
  98619. /**
  98620. * Associates the vertexData to the passed Mesh.
  98621. * Sets it as updatable or not (default `false`)
  98622. * @param mesh the mesh the vertexData is applied to
  98623. * @param updatable when used and having the value true allows new data to update the vertexData
  98624. * @returns the VertexData
  98625. */
  98626. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  98627. /**
  98628. * Associates the vertexData to the passed Geometry.
  98629. * Sets it as updatable or not (default `false`)
  98630. * @param geometry the geometry the vertexData is applied to
  98631. * @param updatable when used and having the value true allows new data to update the vertexData
  98632. * @returns VertexData
  98633. */
  98634. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  98635. /**
  98636. * Updates the associated mesh
  98637. * @param mesh the mesh to be updated
  98638. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98639. * @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
  98640. * @returns VertexData
  98641. */
  98642. updateMesh(mesh: Mesh): VertexData;
  98643. /**
  98644. * Updates the associated geometry
  98645. * @param geometry the geometry to be updated
  98646. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98647. * @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
  98648. * @returns VertexData.
  98649. */
  98650. updateGeometry(geometry: Geometry): VertexData;
  98651. private _applyTo;
  98652. private _update;
  98653. /**
  98654. * Transforms each position and each normal of the vertexData according to the passed Matrix
  98655. * @param matrix the transforming matrix
  98656. * @returns the VertexData
  98657. */
  98658. transform(matrix: Matrix): VertexData;
  98659. /**
  98660. * Merges the passed VertexData into the current one
  98661. * @param other the VertexData to be merged into the current one
  98662. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  98663. * @returns the modified VertexData
  98664. */
  98665. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  98666. private _mergeElement;
  98667. private _validate;
  98668. /**
  98669. * Serializes the VertexData
  98670. * @returns a serialized object
  98671. */
  98672. serialize(): any;
  98673. /**
  98674. * Extracts the vertexData from a mesh
  98675. * @param mesh the mesh from which to extract the VertexData
  98676. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  98677. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98678. * @returns the object VertexData associated to the passed mesh
  98679. */
  98680. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98681. /**
  98682. * Extracts the vertexData from the geometry
  98683. * @param geometry the geometry from which to extract the VertexData
  98684. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  98685. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98686. * @returns the object VertexData associated to the passed mesh
  98687. */
  98688. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98689. private static _ExtractFrom;
  98690. /**
  98691. * Creates the VertexData for a Ribbon
  98692. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  98693. * * pathArray array of paths, each of which an array of successive Vector3
  98694. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  98695. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  98696. * * 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
  98697. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98698. * * 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)
  98699. * * 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)
  98700. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  98701. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  98702. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  98703. * @returns the VertexData of the ribbon
  98704. */
  98705. static CreateRibbon(options: {
  98706. pathArray: Vector3[][];
  98707. closeArray?: boolean;
  98708. closePath?: boolean;
  98709. offset?: number;
  98710. sideOrientation?: number;
  98711. frontUVs?: Vector4;
  98712. backUVs?: Vector4;
  98713. invertUV?: boolean;
  98714. uvs?: Vector2[];
  98715. colors?: Color4[];
  98716. }): VertexData;
  98717. /**
  98718. * Creates the VertexData for a box
  98719. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98720. * * size sets the width, height and depth of the box to the value of size, optional default 1
  98721. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  98722. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  98723. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  98724. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98725. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98727. * * 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)
  98728. * * 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)
  98729. * @returns the VertexData of the box
  98730. */
  98731. static CreateBox(options: {
  98732. size?: number;
  98733. width?: number;
  98734. height?: number;
  98735. depth?: number;
  98736. faceUV?: Vector4[];
  98737. faceColors?: Color4[];
  98738. sideOrientation?: number;
  98739. frontUVs?: Vector4;
  98740. backUVs?: Vector4;
  98741. }): VertexData;
  98742. /**
  98743. * Creates the VertexData for a tiled box
  98744. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98745. * * faceTiles sets the pattern, tile size and number of tiles for a face
  98746. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98747. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98749. * @returns the VertexData of the box
  98750. */
  98751. static CreateTiledBox(options: {
  98752. pattern?: number;
  98753. width?: number;
  98754. height?: number;
  98755. depth?: number;
  98756. tileSize?: number;
  98757. tileWidth?: number;
  98758. tileHeight?: number;
  98759. alignHorizontal?: number;
  98760. alignVertical?: number;
  98761. faceUV?: Vector4[];
  98762. faceColors?: Color4[];
  98763. sideOrientation?: number;
  98764. }): VertexData;
  98765. /**
  98766. * Creates the VertexData for a tiled plane
  98767. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98768. * * pattern a limited pattern arrangement depending on the number
  98769. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  98770. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  98771. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  98772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98773. * * 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)
  98774. * * 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)
  98775. * @returns the VertexData of the tiled plane
  98776. */
  98777. static CreateTiledPlane(options: {
  98778. pattern?: number;
  98779. tileSize?: number;
  98780. tileWidth?: number;
  98781. tileHeight?: number;
  98782. size?: number;
  98783. width?: number;
  98784. height?: number;
  98785. alignHorizontal?: number;
  98786. alignVertical?: number;
  98787. sideOrientation?: number;
  98788. frontUVs?: Vector4;
  98789. backUVs?: Vector4;
  98790. }): VertexData;
  98791. /**
  98792. * Creates the VertexData for an ellipsoid, defaults to a sphere
  98793. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98794. * * segments sets the number of horizontal strips optional, default 32
  98795. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  98796. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  98797. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  98798. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  98799. * * 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
  98800. * * 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
  98801. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98802. * * 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)
  98803. * * 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)
  98804. * @returns the VertexData of the ellipsoid
  98805. */
  98806. static CreateSphere(options: {
  98807. segments?: number;
  98808. diameter?: number;
  98809. diameterX?: number;
  98810. diameterY?: number;
  98811. diameterZ?: number;
  98812. arc?: number;
  98813. slice?: number;
  98814. sideOrientation?: number;
  98815. frontUVs?: Vector4;
  98816. backUVs?: Vector4;
  98817. }): VertexData;
  98818. /**
  98819. * Creates the VertexData for a cylinder, cone or prism
  98820. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98821. * * height sets the height (y direction) of the cylinder, optional, default 2
  98822. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  98823. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  98824. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  98825. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98826. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  98827. * * 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
  98828. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98829. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98830. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  98831. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  98832. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98833. * * 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)
  98834. * * 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)
  98835. * @returns the VertexData of the cylinder, cone or prism
  98836. */
  98837. static CreateCylinder(options: {
  98838. height?: number;
  98839. diameterTop?: number;
  98840. diameterBottom?: number;
  98841. diameter?: number;
  98842. tessellation?: number;
  98843. subdivisions?: number;
  98844. arc?: number;
  98845. faceColors?: Color4[];
  98846. faceUV?: Vector4[];
  98847. hasRings?: boolean;
  98848. enclose?: boolean;
  98849. sideOrientation?: number;
  98850. frontUVs?: Vector4;
  98851. backUVs?: Vector4;
  98852. }): VertexData;
  98853. /**
  98854. * Creates the VertexData for a torus
  98855. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98856. * * diameter the diameter of the torus, optional default 1
  98857. * * thickness the diameter of the tube forming the torus, optional default 0.5
  98858. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98859. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98860. * * 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)
  98861. * * 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)
  98862. * @returns the VertexData of the torus
  98863. */
  98864. static CreateTorus(options: {
  98865. diameter?: number;
  98866. thickness?: number;
  98867. tessellation?: number;
  98868. sideOrientation?: number;
  98869. frontUVs?: Vector4;
  98870. backUVs?: Vector4;
  98871. }): VertexData;
  98872. /**
  98873. * Creates the VertexData of the LineSystem
  98874. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  98875. * - lines an array of lines, each line being an array of successive Vector3
  98876. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  98877. * @returns the VertexData of the LineSystem
  98878. */
  98879. static CreateLineSystem(options: {
  98880. lines: Vector3[][];
  98881. colors?: Nullable<Color4[][]>;
  98882. }): VertexData;
  98883. /**
  98884. * Create the VertexData for a DashedLines
  98885. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  98886. * - points an array successive Vector3
  98887. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  98888. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  98889. * - dashNb the intended total number of dashes, optional, default 200
  98890. * @returns the VertexData for the DashedLines
  98891. */
  98892. static CreateDashedLines(options: {
  98893. points: Vector3[];
  98894. dashSize?: number;
  98895. gapSize?: number;
  98896. dashNb?: number;
  98897. }): VertexData;
  98898. /**
  98899. * Creates the VertexData for a Ground
  98900. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98901. * - width the width (x direction) of the ground, optional, default 1
  98902. * - height the height (z direction) of the ground, optional, default 1
  98903. * - subdivisions the number of subdivisions per side, optional, default 1
  98904. * @returns the VertexData of the Ground
  98905. */
  98906. static CreateGround(options: {
  98907. width?: number;
  98908. height?: number;
  98909. subdivisions?: number;
  98910. subdivisionsX?: number;
  98911. subdivisionsY?: number;
  98912. }): VertexData;
  98913. /**
  98914. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  98915. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98916. * * xmin the ground minimum X coordinate, optional, default -1
  98917. * * zmin the ground minimum Z coordinate, optional, default -1
  98918. * * xmax the ground maximum X coordinate, optional, default 1
  98919. * * zmax the ground maximum Z coordinate, optional, default 1
  98920. * * 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}
  98921. * * 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}
  98922. * @returns the VertexData of the TiledGround
  98923. */
  98924. static CreateTiledGround(options: {
  98925. xmin: number;
  98926. zmin: number;
  98927. xmax: number;
  98928. zmax: number;
  98929. subdivisions?: {
  98930. w: number;
  98931. h: number;
  98932. };
  98933. precision?: {
  98934. w: number;
  98935. h: number;
  98936. };
  98937. }): VertexData;
  98938. /**
  98939. * Creates the VertexData of the Ground designed from a heightmap
  98940. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  98941. * * width the width (x direction) of the ground
  98942. * * height the height (z direction) of the ground
  98943. * * subdivisions the number of subdivisions per side
  98944. * * minHeight the minimum altitude on the ground, optional, default 0
  98945. * * maxHeight the maximum altitude on the ground, optional default 1
  98946. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  98947. * * buffer the array holding the image color data
  98948. * * bufferWidth the width of image
  98949. * * bufferHeight the height of image
  98950. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  98951. * @returns the VertexData of the Ground designed from a heightmap
  98952. */
  98953. static CreateGroundFromHeightMap(options: {
  98954. width: number;
  98955. height: number;
  98956. subdivisions: number;
  98957. minHeight: number;
  98958. maxHeight: number;
  98959. colorFilter: Color3;
  98960. buffer: Uint8Array;
  98961. bufferWidth: number;
  98962. bufferHeight: number;
  98963. alphaFilter: number;
  98964. }): VertexData;
  98965. /**
  98966. * Creates the VertexData for a Plane
  98967. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  98968. * * size sets the width and height of the plane to the value of size, optional default 1
  98969. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  98970. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  98971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98972. * * 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)
  98973. * * 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)
  98974. * @returns the VertexData of the box
  98975. */
  98976. static CreatePlane(options: {
  98977. size?: number;
  98978. width?: number;
  98979. height?: number;
  98980. sideOrientation?: number;
  98981. frontUVs?: Vector4;
  98982. backUVs?: Vector4;
  98983. }): VertexData;
  98984. /**
  98985. * Creates the VertexData of the Disc or regular Polygon
  98986. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  98987. * * radius the radius of the disc, optional default 0.5
  98988. * * tessellation the number of polygon sides, optional, default 64
  98989. * * 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
  98990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98991. * * 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)
  98992. * * 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)
  98993. * @returns the VertexData of the box
  98994. */
  98995. static CreateDisc(options: {
  98996. radius?: number;
  98997. tessellation?: number;
  98998. arc?: number;
  98999. sideOrientation?: number;
  99000. frontUVs?: Vector4;
  99001. backUVs?: Vector4;
  99002. }): VertexData;
  99003. /**
  99004. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  99005. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  99006. * @param polygon a mesh built from polygonTriangulation.build()
  99007. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99008. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  99009. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  99010. * @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)
  99011. * @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)
  99012. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  99013. * @returns the VertexData of the Polygon
  99014. */
  99015. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  99016. /**
  99017. * Creates the VertexData of the IcoSphere
  99018. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  99019. * * radius the radius of the IcoSphere, optional default 1
  99020. * * radiusX allows stretching in the x direction, optional, default radius
  99021. * * radiusY allows stretching in the y direction, optional, default radius
  99022. * * radiusZ allows stretching in the z direction, optional, default radius
  99023. * * flat when true creates a flat shaded mesh, optional, default true
  99024. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  99025. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99026. * * 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)
  99027. * * 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)
  99028. * @returns the VertexData of the IcoSphere
  99029. */
  99030. static CreateIcoSphere(options: {
  99031. radius?: number;
  99032. radiusX?: number;
  99033. radiusY?: number;
  99034. radiusZ?: number;
  99035. flat?: boolean;
  99036. subdivisions?: number;
  99037. sideOrientation?: number;
  99038. frontUVs?: Vector4;
  99039. backUVs?: Vector4;
  99040. }): VertexData;
  99041. /**
  99042. * Creates the VertexData for a Polyhedron
  99043. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  99044. * * type provided types are:
  99045. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  99046. * * 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)
  99047. * * size the size of the IcoSphere, optional default 1
  99048. * * sizeX allows stretching in the x direction, optional, default size
  99049. * * sizeY allows stretching in the y direction, optional, default size
  99050. * * sizeZ allows stretching in the z direction, optional, default size
  99051. * * 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
  99052. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  99053. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  99054. * * flat when true creates a flat shaded mesh, optional, default true
  99055. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  99056. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99057. * * 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)
  99058. * * 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)
  99059. * @returns the VertexData of the Polyhedron
  99060. */
  99061. static CreatePolyhedron(options: {
  99062. type?: number;
  99063. size?: number;
  99064. sizeX?: number;
  99065. sizeY?: number;
  99066. sizeZ?: number;
  99067. custom?: any;
  99068. faceUV?: Vector4[];
  99069. faceColors?: Color4[];
  99070. flat?: boolean;
  99071. sideOrientation?: number;
  99072. frontUVs?: Vector4;
  99073. backUVs?: Vector4;
  99074. }): VertexData;
  99075. /**
  99076. * Creates the VertexData for a TorusKnot
  99077. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  99078. * * radius the radius of the torus knot, optional, default 2
  99079. * * tube the thickness of the tube, optional, default 0.5
  99080. * * radialSegments the number of sides on each tube segments, optional, default 32
  99081. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  99082. * * p the number of windings around the z axis, optional, default 2
  99083. * * q the number of windings around the x axis, optional, default 3
  99084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99085. * * 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)
  99086. * * 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)
  99087. * @returns the VertexData of the Torus Knot
  99088. */
  99089. static CreateTorusKnot(options: {
  99090. radius?: number;
  99091. tube?: number;
  99092. radialSegments?: number;
  99093. tubularSegments?: number;
  99094. p?: number;
  99095. q?: number;
  99096. sideOrientation?: number;
  99097. frontUVs?: Vector4;
  99098. backUVs?: Vector4;
  99099. }): VertexData;
  99100. /**
  99101. * Compute normals for given positions and indices
  99102. * @param positions an array of vertex positions, [...., x, y, z, ......]
  99103. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  99104. * @param normals an array of vertex normals, [...., x, y, z, ......]
  99105. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  99106. * * facetNormals : optional array of facet normals (vector3)
  99107. * * facetPositions : optional array of facet positions (vector3)
  99108. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  99109. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  99110. * * bInfo : optional bounding info, required for facetPartitioning computation
  99111. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  99112. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  99113. * * useRightHandedSystem: optional boolean to for right handed system computation
  99114. * * depthSort : optional boolean to enable the facet depth sort computation
  99115. * * distanceTo : optional Vector3 to compute the facet depth from this location
  99116. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  99117. */
  99118. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  99119. facetNormals?: any;
  99120. facetPositions?: any;
  99121. facetPartitioning?: any;
  99122. ratio?: number;
  99123. bInfo?: any;
  99124. bbSize?: Vector3;
  99125. subDiv?: any;
  99126. useRightHandedSystem?: boolean;
  99127. depthSort?: boolean;
  99128. distanceTo?: Vector3;
  99129. depthSortedFacets?: any;
  99130. }): void;
  99131. /** @hidden */
  99132. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  99133. /**
  99134. * Applies VertexData created from the imported parameters to the geometry
  99135. * @param parsedVertexData the parsed data from an imported file
  99136. * @param geometry the geometry to apply the VertexData to
  99137. */
  99138. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  99139. }
  99140. }
  99141. declare module BABYLON {
  99142. /**
  99143. * Defines a target to use with MorphTargetManager
  99144. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99145. */
  99146. export class MorphTarget implements IAnimatable {
  99147. /** defines the name of the target */
  99148. name: string;
  99149. /**
  99150. * Gets or sets the list of animations
  99151. */
  99152. animations: Animation[];
  99153. private _scene;
  99154. private _positions;
  99155. private _normals;
  99156. private _tangents;
  99157. private _uvs;
  99158. private _influence;
  99159. private _uniqueId;
  99160. /**
  99161. * Observable raised when the influence changes
  99162. */
  99163. onInfluenceChanged: Observable<boolean>;
  99164. /** @hidden */
  99165. _onDataLayoutChanged: Observable<void>;
  99166. /**
  99167. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  99168. */
  99169. get influence(): number;
  99170. set influence(influence: number);
  99171. /**
  99172. * Gets or sets the id of the morph Target
  99173. */
  99174. id: string;
  99175. private _animationPropertiesOverride;
  99176. /**
  99177. * Gets or sets the animation properties override
  99178. */
  99179. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99180. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99181. /**
  99182. * Creates a new MorphTarget
  99183. * @param name defines the name of the target
  99184. * @param influence defines the influence to use
  99185. * @param scene defines the scene the morphtarget belongs to
  99186. */
  99187. constructor(
  99188. /** defines the name of the target */
  99189. name: string, influence?: number, scene?: Nullable<Scene>);
  99190. /**
  99191. * Gets the unique ID of this manager
  99192. */
  99193. get uniqueId(): number;
  99194. /**
  99195. * Gets a boolean defining if the target contains position data
  99196. */
  99197. get hasPositions(): boolean;
  99198. /**
  99199. * Gets a boolean defining if the target contains normal data
  99200. */
  99201. get hasNormals(): boolean;
  99202. /**
  99203. * Gets a boolean defining if the target contains tangent data
  99204. */
  99205. get hasTangents(): boolean;
  99206. /**
  99207. * Gets a boolean defining if the target contains texture coordinates data
  99208. */
  99209. get hasUVs(): boolean;
  99210. /**
  99211. * Affects position data to this target
  99212. * @param data defines the position data to use
  99213. */
  99214. setPositions(data: Nullable<FloatArray>): void;
  99215. /**
  99216. * Gets the position data stored in this target
  99217. * @returns a FloatArray containing the position data (or null if not present)
  99218. */
  99219. getPositions(): Nullable<FloatArray>;
  99220. /**
  99221. * Affects normal data to this target
  99222. * @param data defines the normal data to use
  99223. */
  99224. setNormals(data: Nullable<FloatArray>): void;
  99225. /**
  99226. * Gets the normal data stored in this target
  99227. * @returns a FloatArray containing the normal data (or null if not present)
  99228. */
  99229. getNormals(): Nullable<FloatArray>;
  99230. /**
  99231. * Affects tangent data to this target
  99232. * @param data defines the tangent data to use
  99233. */
  99234. setTangents(data: Nullable<FloatArray>): void;
  99235. /**
  99236. * Gets the tangent data stored in this target
  99237. * @returns a FloatArray containing the tangent data (or null if not present)
  99238. */
  99239. getTangents(): Nullable<FloatArray>;
  99240. /**
  99241. * Affects texture coordinates data to this target
  99242. * @param data defines the texture coordinates data to use
  99243. */
  99244. setUVs(data: Nullable<FloatArray>): void;
  99245. /**
  99246. * Gets the texture coordinates data stored in this target
  99247. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  99248. */
  99249. getUVs(): Nullable<FloatArray>;
  99250. /**
  99251. * Clone the current target
  99252. * @returns a new MorphTarget
  99253. */
  99254. clone(): MorphTarget;
  99255. /**
  99256. * Serializes the current target into a Serialization object
  99257. * @returns the serialized object
  99258. */
  99259. serialize(): any;
  99260. /**
  99261. * Returns the string "MorphTarget"
  99262. * @returns "MorphTarget"
  99263. */
  99264. getClassName(): string;
  99265. /**
  99266. * Creates a new target from serialized data
  99267. * @param serializationObject defines the serialized data to use
  99268. * @returns a new MorphTarget
  99269. */
  99270. static Parse(serializationObject: any): MorphTarget;
  99271. /**
  99272. * Creates a MorphTarget from mesh data
  99273. * @param mesh defines the source mesh
  99274. * @param name defines the name to use for the new target
  99275. * @param influence defines the influence to attach to the target
  99276. * @returns a new MorphTarget
  99277. */
  99278. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  99279. }
  99280. }
  99281. declare module BABYLON {
  99282. /**
  99283. * This class is used to deform meshes using morphing between different targets
  99284. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99285. */
  99286. export class MorphTargetManager {
  99287. private _targets;
  99288. private _targetInfluenceChangedObservers;
  99289. private _targetDataLayoutChangedObservers;
  99290. private _activeTargets;
  99291. private _scene;
  99292. private _influences;
  99293. private _supportsNormals;
  99294. private _supportsTangents;
  99295. private _supportsUVs;
  99296. private _vertexCount;
  99297. private _uniqueId;
  99298. private _tempInfluences;
  99299. /**
  99300. * Gets or sets a boolean indicating if normals must be morphed
  99301. */
  99302. enableNormalMorphing: boolean;
  99303. /**
  99304. * Gets or sets a boolean indicating if tangents must be morphed
  99305. */
  99306. enableTangentMorphing: boolean;
  99307. /**
  99308. * Gets or sets a boolean indicating if UV must be morphed
  99309. */
  99310. enableUVMorphing: boolean;
  99311. /**
  99312. * Creates a new MorphTargetManager
  99313. * @param scene defines the current scene
  99314. */
  99315. constructor(scene?: Nullable<Scene>);
  99316. /**
  99317. * Gets the unique ID of this manager
  99318. */
  99319. get uniqueId(): number;
  99320. /**
  99321. * Gets the number of vertices handled by this manager
  99322. */
  99323. get vertexCount(): number;
  99324. /**
  99325. * Gets a boolean indicating if this manager supports morphing of normals
  99326. */
  99327. get supportsNormals(): boolean;
  99328. /**
  99329. * Gets a boolean indicating if this manager supports morphing of tangents
  99330. */
  99331. get supportsTangents(): boolean;
  99332. /**
  99333. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  99334. */
  99335. get supportsUVs(): boolean;
  99336. /**
  99337. * Gets the number of targets stored in this manager
  99338. */
  99339. get numTargets(): number;
  99340. /**
  99341. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99342. */
  99343. get numInfluencers(): number;
  99344. /**
  99345. * Gets the list of influences (one per target)
  99346. */
  99347. get influences(): Float32Array;
  99348. /**
  99349. * Gets the active target at specified index. An active target is a target with an influence > 0
  99350. * @param index defines the index to check
  99351. * @returns the requested target
  99352. */
  99353. getActiveTarget(index: number): MorphTarget;
  99354. /**
  99355. * Gets the target at specified index
  99356. * @param index defines the index to check
  99357. * @returns the requested target
  99358. */
  99359. getTarget(index: number): MorphTarget;
  99360. /**
  99361. * Add a new target to this manager
  99362. * @param target defines the target to add
  99363. */
  99364. addTarget(target: MorphTarget): void;
  99365. /**
  99366. * Removes a target from the manager
  99367. * @param target defines the target to remove
  99368. */
  99369. removeTarget(target: MorphTarget): void;
  99370. /**
  99371. * Clone the current manager
  99372. * @returns a new MorphTargetManager
  99373. */
  99374. clone(): MorphTargetManager;
  99375. /**
  99376. * Serializes the current manager into a Serialization object
  99377. * @returns the serialized object
  99378. */
  99379. serialize(): any;
  99380. private _syncActiveTargets;
  99381. /**
  99382. * Syncrhonize the targets with all the meshes using this morph target manager
  99383. */
  99384. synchronize(): void;
  99385. /**
  99386. * Creates a new MorphTargetManager from serialized data
  99387. * @param serializationObject defines the serialized data
  99388. * @param scene defines the hosting scene
  99389. * @returns the new MorphTargetManager
  99390. */
  99391. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  99392. }
  99393. }
  99394. declare module BABYLON {
  99395. /**
  99396. * Class used to represent a specific level of detail of a mesh
  99397. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  99398. */
  99399. export class MeshLODLevel {
  99400. /** Defines the distance where this level should start being displayed */
  99401. distance: number;
  99402. /** Defines the mesh to use to render this level */
  99403. mesh: Nullable<Mesh>;
  99404. /**
  99405. * Creates a new LOD level
  99406. * @param distance defines the distance where this level should star being displayed
  99407. * @param mesh defines the mesh to use to render this level
  99408. */
  99409. constructor(
  99410. /** Defines the distance where this level should start being displayed */
  99411. distance: number,
  99412. /** Defines the mesh to use to render this level */
  99413. mesh: Nullable<Mesh>);
  99414. }
  99415. }
  99416. declare module BABYLON {
  99417. /**
  99418. * Mesh representing the gorund
  99419. */
  99420. export class GroundMesh extends Mesh {
  99421. /** If octree should be generated */
  99422. generateOctree: boolean;
  99423. private _heightQuads;
  99424. /** @hidden */
  99425. _subdivisionsX: number;
  99426. /** @hidden */
  99427. _subdivisionsY: number;
  99428. /** @hidden */
  99429. _width: number;
  99430. /** @hidden */
  99431. _height: number;
  99432. /** @hidden */
  99433. _minX: number;
  99434. /** @hidden */
  99435. _maxX: number;
  99436. /** @hidden */
  99437. _minZ: number;
  99438. /** @hidden */
  99439. _maxZ: number;
  99440. constructor(name: string, scene: Scene);
  99441. /**
  99442. * "GroundMesh"
  99443. * @returns "GroundMesh"
  99444. */
  99445. getClassName(): string;
  99446. /**
  99447. * The minimum of x and y subdivisions
  99448. */
  99449. get subdivisions(): number;
  99450. /**
  99451. * X subdivisions
  99452. */
  99453. get subdivisionsX(): number;
  99454. /**
  99455. * Y subdivisions
  99456. */
  99457. get subdivisionsY(): number;
  99458. /**
  99459. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  99460. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99461. * @param chunksCount the number of subdivisions for x and y
  99462. * @param octreeBlocksSize (Default: 32)
  99463. */
  99464. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  99465. /**
  99466. * Returns a height (y) value in the Worl system :
  99467. * the ground altitude at the coordinates (x, z) expressed in the World system.
  99468. * @param x x coordinate
  99469. * @param z z coordinate
  99470. * @returns the ground y position if (x, z) are outside the ground surface.
  99471. */
  99472. getHeightAtCoordinates(x: number, z: number): number;
  99473. /**
  99474. * Returns a normalized vector (Vector3) orthogonal to the ground
  99475. * at the ground coordinates (x, z) expressed in the World system.
  99476. * @param x x coordinate
  99477. * @param z z coordinate
  99478. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  99479. */
  99480. getNormalAtCoordinates(x: number, z: number): Vector3;
  99481. /**
  99482. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  99483. * at the ground coordinates (x, z) expressed in the World system.
  99484. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  99485. * @param x x coordinate
  99486. * @param z z coordinate
  99487. * @param ref vector to store the result
  99488. * @returns the GroundMesh.
  99489. */
  99490. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  99491. /**
  99492. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  99493. * if the ground has been updated.
  99494. * This can be used in the render loop.
  99495. * @returns the GroundMesh.
  99496. */
  99497. updateCoordinateHeights(): GroundMesh;
  99498. private _getFacetAt;
  99499. private _initHeightQuads;
  99500. private _computeHeightQuads;
  99501. /**
  99502. * Serializes this ground mesh
  99503. * @param serializationObject object to write serialization to
  99504. */
  99505. serialize(serializationObject: any): void;
  99506. /**
  99507. * Parses a serialized ground mesh
  99508. * @param parsedMesh the serialized mesh
  99509. * @param scene the scene to create the ground mesh in
  99510. * @returns the created ground mesh
  99511. */
  99512. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  99513. }
  99514. }
  99515. declare module BABYLON {
  99516. /**
  99517. * Interface for Physics-Joint data
  99518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99519. */
  99520. export interface PhysicsJointData {
  99521. /**
  99522. * The main pivot of the joint
  99523. */
  99524. mainPivot?: Vector3;
  99525. /**
  99526. * The connected pivot of the joint
  99527. */
  99528. connectedPivot?: Vector3;
  99529. /**
  99530. * The main axis of the joint
  99531. */
  99532. mainAxis?: Vector3;
  99533. /**
  99534. * The connected axis of the joint
  99535. */
  99536. connectedAxis?: Vector3;
  99537. /**
  99538. * The collision of the joint
  99539. */
  99540. collision?: boolean;
  99541. /**
  99542. * Native Oimo/Cannon/Energy data
  99543. */
  99544. nativeParams?: any;
  99545. }
  99546. /**
  99547. * This is a holder class for the physics joint created by the physics plugin
  99548. * It holds a set of functions to control the underlying joint
  99549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99550. */
  99551. export class PhysicsJoint {
  99552. /**
  99553. * The type of the physics joint
  99554. */
  99555. type: number;
  99556. /**
  99557. * The data for the physics joint
  99558. */
  99559. jointData: PhysicsJointData;
  99560. private _physicsJoint;
  99561. protected _physicsPlugin: IPhysicsEnginePlugin;
  99562. /**
  99563. * Initializes the physics joint
  99564. * @param type The type of the physics joint
  99565. * @param jointData The data for the physics joint
  99566. */
  99567. constructor(
  99568. /**
  99569. * The type of the physics joint
  99570. */
  99571. type: number,
  99572. /**
  99573. * The data for the physics joint
  99574. */
  99575. jointData: PhysicsJointData);
  99576. /**
  99577. * Gets the physics joint
  99578. */
  99579. get physicsJoint(): any;
  99580. /**
  99581. * Sets the physics joint
  99582. */
  99583. set physicsJoint(newJoint: any);
  99584. /**
  99585. * Sets the physics plugin
  99586. */
  99587. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  99588. /**
  99589. * Execute a function that is physics-plugin specific.
  99590. * @param {Function} func the function that will be executed.
  99591. * It accepts two parameters: the physics world and the physics joint
  99592. */
  99593. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  99594. /**
  99595. * Distance-Joint type
  99596. */
  99597. static DistanceJoint: number;
  99598. /**
  99599. * Hinge-Joint type
  99600. */
  99601. static HingeJoint: number;
  99602. /**
  99603. * Ball-and-Socket joint type
  99604. */
  99605. static BallAndSocketJoint: number;
  99606. /**
  99607. * Wheel-Joint type
  99608. */
  99609. static WheelJoint: number;
  99610. /**
  99611. * Slider-Joint type
  99612. */
  99613. static SliderJoint: number;
  99614. /**
  99615. * Prismatic-Joint type
  99616. */
  99617. static PrismaticJoint: number;
  99618. /**
  99619. * Universal-Joint type
  99620. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  99621. */
  99622. static UniversalJoint: number;
  99623. /**
  99624. * Hinge-Joint 2 type
  99625. */
  99626. static Hinge2Joint: number;
  99627. /**
  99628. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  99629. */
  99630. static PointToPointJoint: number;
  99631. /**
  99632. * Spring-Joint type
  99633. */
  99634. static SpringJoint: number;
  99635. /**
  99636. * Lock-Joint type
  99637. */
  99638. static LockJoint: number;
  99639. }
  99640. /**
  99641. * A class representing a physics distance joint
  99642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99643. */
  99644. export class DistanceJoint extends PhysicsJoint {
  99645. /**
  99646. *
  99647. * @param jointData The data for the Distance-Joint
  99648. */
  99649. constructor(jointData: DistanceJointData);
  99650. /**
  99651. * Update the predefined distance.
  99652. * @param maxDistance The maximum preferred distance
  99653. * @param minDistance The minimum preferred distance
  99654. */
  99655. updateDistance(maxDistance: number, minDistance?: number): void;
  99656. }
  99657. /**
  99658. * Represents a Motor-Enabled Joint
  99659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99660. */
  99661. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  99662. /**
  99663. * Initializes the Motor-Enabled Joint
  99664. * @param type The type of the joint
  99665. * @param jointData The physica joint data for the joint
  99666. */
  99667. constructor(type: number, jointData: PhysicsJointData);
  99668. /**
  99669. * Set the motor values.
  99670. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99671. * @param force the force to apply
  99672. * @param maxForce max force for this motor.
  99673. */
  99674. setMotor(force?: number, maxForce?: number): void;
  99675. /**
  99676. * Set the motor's limits.
  99677. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99678. * @param upperLimit The upper limit of the motor
  99679. * @param lowerLimit The lower limit of the motor
  99680. */
  99681. setLimit(upperLimit: number, lowerLimit?: number): void;
  99682. }
  99683. /**
  99684. * This class represents a single physics Hinge-Joint
  99685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99686. */
  99687. export class HingeJoint extends MotorEnabledJoint {
  99688. /**
  99689. * Initializes the Hinge-Joint
  99690. * @param jointData The joint data for the Hinge-Joint
  99691. */
  99692. constructor(jointData: PhysicsJointData);
  99693. /**
  99694. * Set the motor values.
  99695. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99696. * @param {number} force the force to apply
  99697. * @param {number} maxForce max force for this motor.
  99698. */
  99699. setMotor(force?: number, maxForce?: number): void;
  99700. /**
  99701. * Set the motor's limits.
  99702. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99703. * @param upperLimit The upper limit of the motor
  99704. * @param lowerLimit The lower limit of the motor
  99705. */
  99706. setLimit(upperLimit: number, lowerLimit?: number): void;
  99707. }
  99708. /**
  99709. * This class represents a dual hinge physics joint (same as wheel joint)
  99710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99711. */
  99712. export class Hinge2Joint extends MotorEnabledJoint {
  99713. /**
  99714. * Initializes the Hinge2-Joint
  99715. * @param jointData The joint data for the Hinge2-Joint
  99716. */
  99717. constructor(jointData: PhysicsJointData);
  99718. /**
  99719. * Set the motor values.
  99720. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99721. * @param {number} targetSpeed the speed the motor is to reach
  99722. * @param {number} maxForce max force for this motor.
  99723. * @param {motorIndex} the motor's index, 0 or 1.
  99724. */
  99725. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  99726. /**
  99727. * Set the motor limits.
  99728. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99729. * @param {number} upperLimit the upper limit
  99730. * @param {number} lowerLimit lower limit
  99731. * @param {motorIndex} the motor's index, 0 or 1.
  99732. */
  99733. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99734. }
  99735. /**
  99736. * Interface for a motor enabled joint
  99737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99738. */
  99739. export interface IMotorEnabledJoint {
  99740. /**
  99741. * Physics joint
  99742. */
  99743. physicsJoint: any;
  99744. /**
  99745. * Sets the motor of the motor-enabled joint
  99746. * @param force The force of the motor
  99747. * @param maxForce The maximum force of the motor
  99748. * @param motorIndex The index of the motor
  99749. */
  99750. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  99751. /**
  99752. * Sets the limit of the motor
  99753. * @param upperLimit The upper limit of the motor
  99754. * @param lowerLimit The lower limit of the motor
  99755. * @param motorIndex The index of the motor
  99756. */
  99757. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99758. }
  99759. /**
  99760. * Joint data for a Distance-Joint
  99761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99762. */
  99763. export interface DistanceJointData extends PhysicsJointData {
  99764. /**
  99765. * Max distance the 2 joint objects can be apart
  99766. */
  99767. maxDistance: number;
  99768. }
  99769. /**
  99770. * Joint data from a spring joint
  99771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99772. */
  99773. export interface SpringJointData extends PhysicsJointData {
  99774. /**
  99775. * Length of the spring
  99776. */
  99777. length: number;
  99778. /**
  99779. * Stiffness of the spring
  99780. */
  99781. stiffness: number;
  99782. /**
  99783. * Damping of the spring
  99784. */
  99785. damping: number;
  99786. /** this callback will be called when applying the force to the impostors. */
  99787. forceApplicationCallback: () => void;
  99788. }
  99789. }
  99790. declare module BABYLON {
  99791. /**
  99792. * Holds the data for the raycast result
  99793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99794. */
  99795. export class PhysicsRaycastResult {
  99796. private _hasHit;
  99797. private _hitDistance;
  99798. private _hitNormalWorld;
  99799. private _hitPointWorld;
  99800. private _rayFromWorld;
  99801. private _rayToWorld;
  99802. /**
  99803. * Gets if there was a hit
  99804. */
  99805. get hasHit(): boolean;
  99806. /**
  99807. * Gets the distance from the hit
  99808. */
  99809. get hitDistance(): number;
  99810. /**
  99811. * Gets the hit normal/direction in the world
  99812. */
  99813. get hitNormalWorld(): Vector3;
  99814. /**
  99815. * Gets the hit point in the world
  99816. */
  99817. get hitPointWorld(): Vector3;
  99818. /**
  99819. * Gets the ray "start point" of the ray in the world
  99820. */
  99821. get rayFromWorld(): Vector3;
  99822. /**
  99823. * Gets the ray "end point" of the ray in the world
  99824. */
  99825. get rayToWorld(): Vector3;
  99826. /**
  99827. * Sets the hit data (normal & point in world space)
  99828. * @param hitNormalWorld defines the normal in world space
  99829. * @param hitPointWorld defines the point in world space
  99830. */
  99831. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  99832. /**
  99833. * Sets the distance from the start point to the hit point
  99834. * @param distance
  99835. */
  99836. setHitDistance(distance: number): void;
  99837. /**
  99838. * Calculates the distance manually
  99839. */
  99840. calculateHitDistance(): void;
  99841. /**
  99842. * Resets all the values to default
  99843. * @param from The from point on world space
  99844. * @param to The to point on world space
  99845. */
  99846. reset(from?: Vector3, to?: Vector3): void;
  99847. }
  99848. /**
  99849. * Interface for the size containing width and height
  99850. */
  99851. interface IXYZ {
  99852. /**
  99853. * X
  99854. */
  99855. x: number;
  99856. /**
  99857. * Y
  99858. */
  99859. y: number;
  99860. /**
  99861. * Z
  99862. */
  99863. z: number;
  99864. }
  99865. }
  99866. declare module BABYLON {
  99867. /**
  99868. * Interface used to describe a physics joint
  99869. */
  99870. export interface PhysicsImpostorJoint {
  99871. /** Defines the main impostor to which the joint is linked */
  99872. mainImpostor: PhysicsImpostor;
  99873. /** Defines the impostor that is connected to the main impostor using this joint */
  99874. connectedImpostor: PhysicsImpostor;
  99875. /** Defines the joint itself */
  99876. joint: PhysicsJoint;
  99877. }
  99878. /** @hidden */
  99879. export interface IPhysicsEnginePlugin {
  99880. world: any;
  99881. name: string;
  99882. setGravity(gravity: Vector3): void;
  99883. setTimeStep(timeStep: number): void;
  99884. getTimeStep(): number;
  99885. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  99886. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99887. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99888. generatePhysicsBody(impostor: PhysicsImpostor): void;
  99889. removePhysicsBody(impostor: PhysicsImpostor): void;
  99890. generateJoint(joint: PhysicsImpostorJoint): void;
  99891. removeJoint(joint: PhysicsImpostorJoint): void;
  99892. isSupported(): boolean;
  99893. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  99894. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  99895. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99896. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99897. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99898. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99899. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  99900. getBodyMass(impostor: PhysicsImpostor): number;
  99901. getBodyFriction(impostor: PhysicsImpostor): number;
  99902. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  99903. getBodyRestitution(impostor: PhysicsImpostor): number;
  99904. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  99905. getBodyPressure?(impostor: PhysicsImpostor): number;
  99906. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  99907. getBodyStiffness?(impostor: PhysicsImpostor): number;
  99908. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  99909. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  99910. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  99911. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  99912. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  99913. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99914. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99915. sleepBody(impostor: PhysicsImpostor): void;
  99916. wakeUpBody(impostor: PhysicsImpostor): void;
  99917. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99918. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  99919. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  99920. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99921. getRadius(impostor: PhysicsImpostor): number;
  99922. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  99923. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  99924. dispose(): void;
  99925. }
  99926. /**
  99927. * Interface used to define a physics engine
  99928. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  99929. */
  99930. export interface IPhysicsEngine {
  99931. /**
  99932. * Gets the gravity vector used by the simulation
  99933. */
  99934. gravity: Vector3;
  99935. /**
  99936. * Sets the gravity vector used by the simulation
  99937. * @param gravity defines the gravity vector to use
  99938. */
  99939. setGravity(gravity: Vector3): void;
  99940. /**
  99941. * Set the time step of the physics engine.
  99942. * Default is 1/60.
  99943. * To slow it down, enter 1/600 for example.
  99944. * To speed it up, 1/30
  99945. * @param newTimeStep the new timestep to apply to this world.
  99946. */
  99947. setTimeStep(newTimeStep: number): void;
  99948. /**
  99949. * Get the time step of the physics engine.
  99950. * @returns the current time step
  99951. */
  99952. getTimeStep(): number;
  99953. /**
  99954. * Set the sub time step of the physics engine.
  99955. * Default is 0 meaning there is no sub steps
  99956. * To increase physics resolution precision, set a small value (like 1 ms)
  99957. * @param subTimeStep defines the new sub timestep used for physics resolution.
  99958. */
  99959. setSubTimeStep(subTimeStep: number): void;
  99960. /**
  99961. * Get the sub time step of the physics engine.
  99962. * @returns the current sub time step
  99963. */
  99964. getSubTimeStep(): number;
  99965. /**
  99966. * Release all resources
  99967. */
  99968. dispose(): void;
  99969. /**
  99970. * Gets the name of the current physics plugin
  99971. * @returns the name of the plugin
  99972. */
  99973. getPhysicsPluginName(): string;
  99974. /**
  99975. * Adding a new impostor for the impostor tracking.
  99976. * This will be done by the impostor itself.
  99977. * @param impostor the impostor to add
  99978. */
  99979. addImpostor(impostor: PhysicsImpostor): void;
  99980. /**
  99981. * Remove an impostor from the engine.
  99982. * This impostor and its mesh will not longer be updated by the physics engine.
  99983. * @param impostor the impostor to remove
  99984. */
  99985. removeImpostor(impostor: PhysicsImpostor): void;
  99986. /**
  99987. * Add a joint to the physics engine
  99988. * @param mainImpostor defines the main impostor to which the joint is added.
  99989. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  99990. * @param joint defines the joint that will connect both impostors.
  99991. */
  99992. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99993. /**
  99994. * Removes a joint from the simulation
  99995. * @param mainImpostor defines the impostor used with the joint
  99996. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  99997. * @param joint defines the joint to remove
  99998. */
  99999. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  100000. /**
  100001. * Gets the current plugin used to run the simulation
  100002. * @returns current plugin
  100003. */
  100004. getPhysicsPlugin(): IPhysicsEnginePlugin;
  100005. /**
  100006. * Gets the list of physic impostors
  100007. * @returns an array of PhysicsImpostor
  100008. */
  100009. getImpostors(): Array<PhysicsImpostor>;
  100010. /**
  100011. * Gets the impostor for a physics enabled object
  100012. * @param object defines the object impersonated by the impostor
  100013. * @returns the PhysicsImpostor or null if not found
  100014. */
  100015. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  100016. /**
  100017. * Gets the impostor for a physics body object
  100018. * @param body defines physics body used by the impostor
  100019. * @returns the PhysicsImpostor or null if not found
  100020. */
  100021. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  100022. /**
  100023. * Does a raycast in the physics world
  100024. * @param from when should the ray start?
  100025. * @param to when should the ray end?
  100026. * @returns PhysicsRaycastResult
  100027. */
  100028. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  100029. /**
  100030. * Called by the scene. No need to call it.
  100031. * @param delta defines the timespam between frames
  100032. */
  100033. _step(delta: number): void;
  100034. }
  100035. }
  100036. declare module BABYLON {
  100037. /**
  100038. * The interface for the physics imposter parameters
  100039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100040. */
  100041. export interface PhysicsImpostorParameters {
  100042. /**
  100043. * The mass of the physics imposter
  100044. */
  100045. mass: number;
  100046. /**
  100047. * The friction of the physics imposter
  100048. */
  100049. friction?: number;
  100050. /**
  100051. * The coefficient of restitution of the physics imposter
  100052. */
  100053. restitution?: number;
  100054. /**
  100055. * The native options of the physics imposter
  100056. */
  100057. nativeOptions?: any;
  100058. /**
  100059. * Specifies if the parent should be ignored
  100060. */
  100061. ignoreParent?: boolean;
  100062. /**
  100063. * Specifies if bi-directional transformations should be disabled
  100064. */
  100065. disableBidirectionalTransformation?: boolean;
  100066. /**
  100067. * The pressure inside the physics imposter, soft object only
  100068. */
  100069. pressure?: number;
  100070. /**
  100071. * The stiffness the physics imposter, soft object only
  100072. */
  100073. stiffness?: number;
  100074. /**
  100075. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  100076. */
  100077. velocityIterations?: number;
  100078. /**
  100079. * The number of iterations used in maintaining consistent vertex positions, soft object only
  100080. */
  100081. positionIterations?: number;
  100082. /**
  100083. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  100084. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  100085. * Add to fix multiple points
  100086. */
  100087. fixedPoints?: number;
  100088. /**
  100089. * The collision margin around a soft object
  100090. */
  100091. margin?: number;
  100092. /**
  100093. * The collision margin around a soft object
  100094. */
  100095. damping?: number;
  100096. /**
  100097. * The path for a rope based on an extrusion
  100098. */
  100099. path?: any;
  100100. /**
  100101. * The shape of an extrusion used for a rope based on an extrusion
  100102. */
  100103. shape?: any;
  100104. }
  100105. /**
  100106. * Interface for a physics-enabled object
  100107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100108. */
  100109. export interface IPhysicsEnabledObject {
  100110. /**
  100111. * The position of the physics-enabled object
  100112. */
  100113. position: Vector3;
  100114. /**
  100115. * The rotation of the physics-enabled object
  100116. */
  100117. rotationQuaternion: Nullable<Quaternion>;
  100118. /**
  100119. * The scale of the physics-enabled object
  100120. */
  100121. scaling: Vector3;
  100122. /**
  100123. * The rotation of the physics-enabled object
  100124. */
  100125. rotation?: Vector3;
  100126. /**
  100127. * The parent of the physics-enabled object
  100128. */
  100129. parent?: any;
  100130. /**
  100131. * The bounding info of the physics-enabled object
  100132. * @returns The bounding info of the physics-enabled object
  100133. */
  100134. getBoundingInfo(): BoundingInfo;
  100135. /**
  100136. * Computes the world matrix
  100137. * @param force Specifies if the world matrix should be computed by force
  100138. * @returns A world matrix
  100139. */
  100140. computeWorldMatrix(force: boolean): Matrix;
  100141. /**
  100142. * Gets the world matrix
  100143. * @returns A world matrix
  100144. */
  100145. getWorldMatrix?(): Matrix;
  100146. /**
  100147. * Gets the child meshes
  100148. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  100149. * @returns An array of abstract meshes
  100150. */
  100151. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  100152. /**
  100153. * Gets the vertex data
  100154. * @param kind The type of vertex data
  100155. * @returns A nullable array of numbers, or a float32 array
  100156. */
  100157. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  100158. /**
  100159. * Gets the indices from the mesh
  100160. * @returns A nullable array of index arrays
  100161. */
  100162. getIndices?(): Nullable<IndicesArray>;
  100163. /**
  100164. * Gets the scene from the mesh
  100165. * @returns the indices array or null
  100166. */
  100167. getScene?(): Scene;
  100168. /**
  100169. * Gets the absolute position from the mesh
  100170. * @returns the absolute position
  100171. */
  100172. getAbsolutePosition(): Vector3;
  100173. /**
  100174. * Gets the absolute pivot point from the mesh
  100175. * @returns the absolute pivot point
  100176. */
  100177. getAbsolutePivotPoint(): Vector3;
  100178. /**
  100179. * Rotates the mesh
  100180. * @param axis The axis of rotation
  100181. * @param amount The amount of rotation
  100182. * @param space The space of the rotation
  100183. * @returns The rotation transform node
  100184. */
  100185. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  100186. /**
  100187. * Translates the mesh
  100188. * @param axis The axis of translation
  100189. * @param distance The distance of translation
  100190. * @param space The space of the translation
  100191. * @returns The transform node
  100192. */
  100193. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  100194. /**
  100195. * Sets the absolute position of the mesh
  100196. * @param absolutePosition The absolute position of the mesh
  100197. * @returns The transform node
  100198. */
  100199. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  100200. /**
  100201. * Gets the class name of the mesh
  100202. * @returns The class name
  100203. */
  100204. getClassName(): string;
  100205. }
  100206. /**
  100207. * Represents a physics imposter
  100208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100209. */
  100210. export class PhysicsImpostor {
  100211. /**
  100212. * The physics-enabled object used as the physics imposter
  100213. */
  100214. object: IPhysicsEnabledObject;
  100215. /**
  100216. * The type of the physics imposter
  100217. */
  100218. type: number;
  100219. private _options;
  100220. private _scene?;
  100221. /**
  100222. * The default object size of the imposter
  100223. */
  100224. static DEFAULT_OBJECT_SIZE: Vector3;
  100225. /**
  100226. * The identity quaternion of the imposter
  100227. */
  100228. static IDENTITY_QUATERNION: Quaternion;
  100229. /** @hidden */
  100230. _pluginData: any;
  100231. private _physicsEngine;
  100232. private _physicsBody;
  100233. private _bodyUpdateRequired;
  100234. private _onBeforePhysicsStepCallbacks;
  100235. private _onAfterPhysicsStepCallbacks;
  100236. /** @hidden */
  100237. _onPhysicsCollideCallbacks: Array<{
  100238. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  100239. otherImpostors: Array<PhysicsImpostor>;
  100240. }>;
  100241. private _deltaPosition;
  100242. private _deltaRotation;
  100243. private _deltaRotationConjugated;
  100244. /** @hidden */
  100245. _isFromLine: boolean;
  100246. private _parent;
  100247. private _isDisposed;
  100248. private static _tmpVecs;
  100249. private static _tmpQuat;
  100250. /**
  100251. * Specifies if the physics imposter is disposed
  100252. */
  100253. get isDisposed(): boolean;
  100254. /**
  100255. * Gets the mass of the physics imposter
  100256. */
  100257. get mass(): number;
  100258. set mass(value: number);
  100259. /**
  100260. * Gets the coefficient of friction
  100261. */
  100262. get friction(): number;
  100263. /**
  100264. * Sets the coefficient of friction
  100265. */
  100266. set friction(value: number);
  100267. /**
  100268. * Gets the coefficient of restitution
  100269. */
  100270. get restitution(): number;
  100271. /**
  100272. * Sets the coefficient of restitution
  100273. */
  100274. set restitution(value: number);
  100275. /**
  100276. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  100277. */
  100278. get pressure(): number;
  100279. /**
  100280. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  100281. */
  100282. set pressure(value: number);
  100283. /**
  100284. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100285. */
  100286. get stiffness(): number;
  100287. /**
  100288. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100289. */
  100290. set stiffness(value: number);
  100291. /**
  100292. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100293. */
  100294. get velocityIterations(): number;
  100295. /**
  100296. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100297. */
  100298. set velocityIterations(value: number);
  100299. /**
  100300. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100301. */
  100302. get positionIterations(): number;
  100303. /**
  100304. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100305. */
  100306. set positionIterations(value: number);
  100307. /**
  100308. * The unique id of the physics imposter
  100309. * set by the physics engine when adding this impostor to the array
  100310. */
  100311. uniqueId: number;
  100312. /**
  100313. * @hidden
  100314. */
  100315. soft: boolean;
  100316. /**
  100317. * @hidden
  100318. */
  100319. segments: number;
  100320. private _joints;
  100321. /**
  100322. * Initializes the physics imposter
  100323. * @param object The physics-enabled object used as the physics imposter
  100324. * @param type The type of the physics imposter
  100325. * @param _options The options for the physics imposter
  100326. * @param _scene The Babylon scene
  100327. */
  100328. constructor(
  100329. /**
  100330. * The physics-enabled object used as the physics imposter
  100331. */
  100332. object: IPhysicsEnabledObject,
  100333. /**
  100334. * The type of the physics imposter
  100335. */
  100336. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  100337. /**
  100338. * This function will completly initialize this impostor.
  100339. * It will create a new body - but only if this mesh has no parent.
  100340. * If it has, this impostor will not be used other than to define the impostor
  100341. * of the child mesh.
  100342. * @hidden
  100343. */
  100344. _init(): void;
  100345. private _getPhysicsParent;
  100346. /**
  100347. * Should a new body be generated.
  100348. * @returns boolean specifying if body initialization is required
  100349. */
  100350. isBodyInitRequired(): boolean;
  100351. /**
  100352. * Sets the updated scaling
  100353. * @param updated Specifies if the scaling is updated
  100354. */
  100355. setScalingUpdated(): void;
  100356. /**
  100357. * Force a regeneration of this or the parent's impostor's body.
  100358. * Use under cautious - This will remove all joints already implemented.
  100359. */
  100360. forceUpdate(): void;
  100361. /**
  100362. * Gets the body that holds this impostor. Either its own, or its parent.
  100363. */
  100364. get physicsBody(): any;
  100365. /**
  100366. * Get the parent of the physics imposter
  100367. * @returns Physics imposter or null
  100368. */
  100369. get parent(): Nullable<PhysicsImpostor>;
  100370. /**
  100371. * Sets the parent of the physics imposter
  100372. */
  100373. set parent(value: Nullable<PhysicsImpostor>);
  100374. /**
  100375. * Set the physics body. Used mainly by the physics engine/plugin
  100376. */
  100377. set physicsBody(physicsBody: any);
  100378. /**
  100379. * Resets the update flags
  100380. */
  100381. resetUpdateFlags(): void;
  100382. /**
  100383. * Gets the object extend size
  100384. * @returns the object extend size
  100385. */
  100386. getObjectExtendSize(): Vector3;
  100387. /**
  100388. * Gets the object center
  100389. * @returns The object center
  100390. */
  100391. getObjectCenter(): Vector3;
  100392. /**
  100393. * Get a specific parameter from the options parameters
  100394. * @param paramName The object parameter name
  100395. * @returns The object parameter
  100396. */
  100397. getParam(paramName: string): any;
  100398. /**
  100399. * Sets a specific parameter in the options given to the physics plugin
  100400. * @param paramName The parameter name
  100401. * @param value The value of the parameter
  100402. */
  100403. setParam(paramName: string, value: number): void;
  100404. /**
  100405. * Specifically change the body's mass option. Won't recreate the physics body object
  100406. * @param mass The mass of the physics imposter
  100407. */
  100408. setMass(mass: number): void;
  100409. /**
  100410. * Gets the linear velocity
  100411. * @returns linear velocity or null
  100412. */
  100413. getLinearVelocity(): Nullable<Vector3>;
  100414. /**
  100415. * Sets the linear velocity
  100416. * @param velocity linear velocity or null
  100417. */
  100418. setLinearVelocity(velocity: Nullable<Vector3>): void;
  100419. /**
  100420. * Gets the angular velocity
  100421. * @returns angular velocity or null
  100422. */
  100423. getAngularVelocity(): Nullable<Vector3>;
  100424. /**
  100425. * Sets the angular velocity
  100426. * @param velocity The velocity or null
  100427. */
  100428. setAngularVelocity(velocity: Nullable<Vector3>): void;
  100429. /**
  100430. * Execute a function with the physics plugin native code
  100431. * Provide a function the will have two variables - the world object and the physics body object
  100432. * @param func The function to execute with the physics plugin native code
  100433. */
  100434. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  100435. /**
  100436. * Register a function that will be executed before the physics world is stepping forward
  100437. * @param func The function to execute before the physics world is stepped forward
  100438. */
  100439. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100440. /**
  100441. * Unregister a function that will be executed before the physics world is stepping forward
  100442. * @param func The function to execute before the physics world is stepped forward
  100443. */
  100444. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100445. /**
  100446. * Register a function that will be executed after the physics step
  100447. * @param func The function to execute after physics step
  100448. */
  100449. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100450. /**
  100451. * Unregisters a function that will be executed after the physics step
  100452. * @param func The function to execute after physics step
  100453. */
  100454. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100455. /**
  100456. * register a function that will be executed when this impostor collides against a different body
  100457. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  100458. * @param func Callback that is executed on collision
  100459. */
  100460. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  100461. /**
  100462. * Unregisters the physics imposter on contact
  100463. * @param collideAgainst The physics object to collide against
  100464. * @param func Callback to execute on collision
  100465. */
  100466. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  100467. private _tmpQuat;
  100468. private _tmpQuat2;
  100469. /**
  100470. * Get the parent rotation
  100471. * @returns The parent rotation
  100472. */
  100473. getParentsRotation(): Quaternion;
  100474. /**
  100475. * this function is executed by the physics engine.
  100476. */
  100477. beforeStep: () => void;
  100478. /**
  100479. * this function is executed by the physics engine
  100480. */
  100481. afterStep: () => void;
  100482. /**
  100483. * Legacy collision detection event support
  100484. */
  100485. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  100486. /**
  100487. * event and body object due to cannon's event-based architecture.
  100488. */
  100489. onCollide: (e: {
  100490. body: any;
  100491. }) => void;
  100492. /**
  100493. * Apply a force
  100494. * @param force The force to apply
  100495. * @param contactPoint The contact point for the force
  100496. * @returns The physics imposter
  100497. */
  100498. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100499. /**
  100500. * Apply an impulse
  100501. * @param force The impulse force
  100502. * @param contactPoint The contact point for the impulse force
  100503. * @returns The physics imposter
  100504. */
  100505. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100506. /**
  100507. * A help function to create a joint
  100508. * @param otherImpostor A physics imposter used to create a joint
  100509. * @param jointType The type of joint
  100510. * @param jointData The data for the joint
  100511. * @returns The physics imposter
  100512. */
  100513. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  100514. /**
  100515. * Add a joint to this impostor with a different impostor
  100516. * @param otherImpostor A physics imposter used to add a joint
  100517. * @param joint The joint to add
  100518. * @returns The physics imposter
  100519. */
  100520. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  100521. /**
  100522. * Add an anchor to a cloth impostor
  100523. * @param otherImpostor rigid impostor to anchor to
  100524. * @param width ratio across width from 0 to 1
  100525. * @param height ratio up height from 0 to 1
  100526. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  100527. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  100528. * @returns impostor the soft imposter
  100529. */
  100530. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100531. /**
  100532. * Add a hook to a rope impostor
  100533. * @param otherImpostor rigid impostor to anchor to
  100534. * @param length ratio across rope from 0 to 1
  100535. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  100536. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  100537. * @returns impostor the rope imposter
  100538. */
  100539. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100540. /**
  100541. * Will keep this body still, in a sleep mode.
  100542. * @returns the physics imposter
  100543. */
  100544. sleep(): PhysicsImpostor;
  100545. /**
  100546. * Wake the body up.
  100547. * @returns The physics imposter
  100548. */
  100549. wakeUp(): PhysicsImpostor;
  100550. /**
  100551. * Clones the physics imposter
  100552. * @param newObject The physics imposter clones to this physics-enabled object
  100553. * @returns A nullable physics imposter
  100554. */
  100555. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  100556. /**
  100557. * Disposes the physics imposter
  100558. */
  100559. dispose(): void;
  100560. /**
  100561. * Sets the delta position
  100562. * @param position The delta position amount
  100563. */
  100564. setDeltaPosition(position: Vector3): void;
  100565. /**
  100566. * Sets the delta rotation
  100567. * @param rotation The delta rotation amount
  100568. */
  100569. setDeltaRotation(rotation: Quaternion): void;
  100570. /**
  100571. * Gets the box size of the physics imposter and stores the result in the input parameter
  100572. * @param result Stores the box size
  100573. * @returns The physics imposter
  100574. */
  100575. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  100576. /**
  100577. * Gets the radius of the physics imposter
  100578. * @returns Radius of the physics imposter
  100579. */
  100580. getRadius(): number;
  100581. /**
  100582. * Sync a bone with this impostor
  100583. * @param bone The bone to sync to the impostor.
  100584. * @param boneMesh The mesh that the bone is influencing.
  100585. * @param jointPivot The pivot of the joint / bone in local space.
  100586. * @param distToJoint Optional distance from the impostor to the joint.
  100587. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100588. */
  100589. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  100590. /**
  100591. * Sync impostor to a bone
  100592. * @param bone The bone that the impostor will be synced to.
  100593. * @param boneMesh The mesh that the bone is influencing.
  100594. * @param jointPivot The pivot of the joint / bone in local space.
  100595. * @param distToJoint Optional distance from the impostor to the joint.
  100596. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100597. * @param boneAxis Optional vector3 axis the bone is aligned with
  100598. */
  100599. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  100600. /**
  100601. * No-Imposter type
  100602. */
  100603. static NoImpostor: number;
  100604. /**
  100605. * Sphere-Imposter type
  100606. */
  100607. static SphereImpostor: number;
  100608. /**
  100609. * Box-Imposter type
  100610. */
  100611. static BoxImpostor: number;
  100612. /**
  100613. * Plane-Imposter type
  100614. */
  100615. static PlaneImpostor: number;
  100616. /**
  100617. * Mesh-imposter type
  100618. */
  100619. static MeshImpostor: number;
  100620. /**
  100621. * Capsule-Impostor type (Ammo.js plugin only)
  100622. */
  100623. static CapsuleImpostor: number;
  100624. /**
  100625. * Cylinder-Imposter type
  100626. */
  100627. static CylinderImpostor: number;
  100628. /**
  100629. * Particle-Imposter type
  100630. */
  100631. static ParticleImpostor: number;
  100632. /**
  100633. * Heightmap-Imposter type
  100634. */
  100635. static HeightmapImpostor: number;
  100636. /**
  100637. * ConvexHull-Impostor type (Ammo.js plugin only)
  100638. */
  100639. static ConvexHullImpostor: number;
  100640. /**
  100641. * Custom-Imposter type (Ammo.js plugin only)
  100642. */
  100643. static CustomImpostor: number;
  100644. /**
  100645. * Rope-Imposter type
  100646. */
  100647. static RopeImpostor: number;
  100648. /**
  100649. * Cloth-Imposter type
  100650. */
  100651. static ClothImpostor: number;
  100652. /**
  100653. * Softbody-Imposter type
  100654. */
  100655. static SoftbodyImpostor: number;
  100656. }
  100657. }
  100658. declare module BABYLON {
  100659. /**
  100660. * @hidden
  100661. **/
  100662. export class _CreationDataStorage {
  100663. closePath?: boolean;
  100664. closeArray?: boolean;
  100665. idx: number[];
  100666. dashSize: number;
  100667. gapSize: number;
  100668. path3D: Path3D;
  100669. pathArray: Vector3[][];
  100670. arc: number;
  100671. radius: number;
  100672. cap: number;
  100673. tessellation: number;
  100674. }
  100675. /**
  100676. * @hidden
  100677. **/
  100678. class _InstanceDataStorage {
  100679. visibleInstances: any;
  100680. batchCache: _InstancesBatch;
  100681. instancesBufferSize: number;
  100682. instancesBuffer: Nullable<Buffer>;
  100683. instancesData: Float32Array;
  100684. overridenInstanceCount: number;
  100685. isFrozen: boolean;
  100686. previousBatch: Nullable<_InstancesBatch>;
  100687. hardwareInstancedRendering: boolean;
  100688. sideOrientation: number;
  100689. manualUpdate: boolean;
  100690. }
  100691. /**
  100692. * @hidden
  100693. **/
  100694. export class _InstancesBatch {
  100695. mustReturn: boolean;
  100696. visibleInstances: Nullable<InstancedMesh[]>[];
  100697. renderSelf: boolean[];
  100698. hardwareInstancedRendering: boolean[];
  100699. }
  100700. /**
  100701. * Class used to represent renderable models
  100702. */
  100703. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  100704. /**
  100705. * Mesh side orientation : usually the external or front surface
  100706. */
  100707. static readonly FRONTSIDE: number;
  100708. /**
  100709. * Mesh side orientation : usually the internal or back surface
  100710. */
  100711. static readonly BACKSIDE: number;
  100712. /**
  100713. * Mesh side orientation : both internal and external or front and back surfaces
  100714. */
  100715. static readonly DOUBLESIDE: number;
  100716. /**
  100717. * Mesh side orientation : by default, `FRONTSIDE`
  100718. */
  100719. static readonly DEFAULTSIDE: number;
  100720. /**
  100721. * Mesh cap setting : no cap
  100722. */
  100723. static readonly NO_CAP: number;
  100724. /**
  100725. * Mesh cap setting : one cap at the beginning of the mesh
  100726. */
  100727. static readonly CAP_START: number;
  100728. /**
  100729. * Mesh cap setting : one cap at the end of the mesh
  100730. */
  100731. static readonly CAP_END: number;
  100732. /**
  100733. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  100734. */
  100735. static readonly CAP_ALL: number;
  100736. /**
  100737. * Mesh pattern setting : no flip or rotate
  100738. */
  100739. static readonly NO_FLIP: number;
  100740. /**
  100741. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  100742. */
  100743. static readonly FLIP_TILE: number;
  100744. /**
  100745. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  100746. */
  100747. static readonly ROTATE_TILE: number;
  100748. /**
  100749. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  100750. */
  100751. static readonly FLIP_ROW: number;
  100752. /**
  100753. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  100754. */
  100755. static readonly ROTATE_ROW: number;
  100756. /**
  100757. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  100758. */
  100759. static readonly FLIP_N_ROTATE_TILE: number;
  100760. /**
  100761. * Mesh pattern setting : rotate pattern and rotate
  100762. */
  100763. static readonly FLIP_N_ROTATE_ROW: number;
  100764. /**
  100765. * Mesh tile positioning : part tiles same on left/right or top/bottom
  100766. */
  100767. static readonly CENTER: number;
  100768. /**
  100769. * Mesh tile positioning : part tiles on left
  100770. */
  100771. static readonly LEFT: number;
  100772. /**
  100773. * Mesh tile positioning : part tiles on right
  100774. */
  100775. static readonly RIGHT: number;
  100776. /**
  100777. * Mesh tile positioning : part tiles on top
  100778. */
  100779. static readonly TOP: number;
  100780. /**
  100781. * Mesh tile positioning : part tiles on bottom
  100782. */
  100783. static readonly BOTTOM: number;
  100784. /**
  100785. * Gets the default side orientation.
  100786. * @param orientation the orientation to value to attempt to get
  100787. * @returns the default orientation
  100788. * @hidden
  100789. */
  100790. static _GetDefaultSideOrientation(orientation?: number): number;
  100791. private _internalMeshDataInfo;
  100792. /**
  100793. * An event triggered before rendering the mesh
  100794. */
  100795. get onBeforeRenderObservable(): Observable<Mesh>;
  100796. /**
  100797. * An event triggered before binding the mesh
  100798. */
  100799. get onBeforeBindObservable(): Observable<Mesh>;
  100800. /**
  100801. * An event triggered after rendering the mesh
  100802. */
  100803. get onAfterRenderObservable(): Observable<Mesh>;
  100804. /**
  100805. * An event triggered before drawing the mesh
  100806. */
  100807. get onBeforeDrawObservable(): Observable<Mesh>;
  100808. private _onBeforeDrawObserver;
  100809. /**
  100810. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  100811. */
  100812. set onBeforeDraw(callback: () => void);
  100813. get hasInstances(): boolean;
  100814. /**
  100815. * Gets the delay loading state of the mesh (when delay loading is turned on)
  100816. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  100817. */
  100818. delayLoadState: number;
  100819. /**
  100820. * Gets the list of instances created from this mesh
  100821. * it is not supposed to be modified manually.
  100822. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  100823. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100824. */
  100825. instances: InstancedMesh[];
  100826. /**
  100827. * Gets the file containing delay loading data for this mesh
  100828. */
  100829. delayLoadingFile: string;
  100830. /** @hidden */
  100831. _binaryInfo: any;
  100832. /**
  100833. * User defined function used to change how LOD level selection is done
  100834. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  100835. */
  100836. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  100837. /**
  100838. * Gets or sets the morph target manager
  100839. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100840. */
  100841. get morphTargetManager(): Nullable<MorphTargetManager>;
  100842. set morphTargetManager(value: Nullable<MorphTargetManager>);
  100843. /** @hidden */
  100844. _creationDataStorage: Nullable<_CreationDataStorage>;
  100845. /** @hidden */
  100846. _geometry: Nullable<Geometry>;
  100847. /** @hidden */
  100848. _delayInfo: Array<string>;
  100849. /** @hidden */
  100850. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  100851. /** @hidden */
  100852. _instanceDataStorage: _InstanceDataStorage;
  100853. private _effectiveMaterial;
  100854. /** @hidden */
  100855. _shouldGenerateFlatShading: boolean;
  100856. /** @hidden */
  100857. _originalBuilderSideOrientation: number;
  100858. /**
  100859. * Use this property to change the original side orientation defined at construction time
  100860. */
  100861. overrideMaterialSideOrientation: Nullable<number>;
  100862. /**
  100863. * Gets the source mesh (the one used to clone this one from)
  100864. */
  100865. get source(): Nullable<Mesh>;
  100866. /**
  100867. * Gets or sets a boolean indicating that this mesh does not use index buffer
  100868. */
  100869. get isUnIndexed(): boolean;
  100870. set isUnIndexed(value: boolean);
  100871. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  100872. get worldMatrixInstancedBuffer(): Float32Array;
  100873. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  100874. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  100875. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  100876. /**
  100877. * @constructor
  100878. * @param name The value used by scene.getMeshByName() to do a lookup.
  100879. * @param scene The scene to add this mesh to.
  100880. * @param parent The parent of this mesh, if it has one
  100881. * @param source An optional Mesh from which geometry is shared, cloned.
  100882. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  100883. * When false, achieved by calling a clone(), also passing False.
  100884. * This will make creation of children, recursive.
  100885. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  100886. */
  100887. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  100888. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  100889. doNotInstantiate: boolean;
  100890. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  100891. /**
  100892. * Gets the class name
  100893. * @returns the string "Mesh".
  100894. */
  100895. getClassName(): string;
  100896. /** @hidden */
  100897. get _isMesh(): boolean;
  100898. /**
  100899. * Returns a description of this mesh
  100900. * @param fullDetails define if full details about this mesh must be used
  100901. * @returns a descriptive string representing this mesh
  100902. */
  100903. toString(fullDetails?: boolean): string;
  100904. /** @hidden */
  100905. _unBindEffect(): void;
  100906. /**
  100907. * Gets a boolean indicating if this mesh has LOD
  100908. */
  100909. get hasLODLevels(): boolean;
  100910. /**
  100911. * Gets the list of MeshLODLevel associated with the current mesh
  100912. * @returns an array of MeshLODLevel
  100913. */
  100914. getLODLevels(): MeshLODLevel[];
  100915. private _sortLODLevels;
  100916. /**
  100917. * Add a mesh as LOD level triggered at the given distance.
  100918. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100919. * @param distance The distance from the center of the object to show this level
  100920. * @param mesh The mesh to be added as LOD level (can be null)
  100921. * @return This mesh (for chaining)
  100922. */
  100923. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  100924. /**
  100925. * Returns the LOD level mesh at the passed distance or null if not found.
  100926. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100927. * @param distance The distance from the center of the object to show this level
  100928. * @returns a Mesh or `null`
  100929. */
  100930. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  100931. /**
  100932. * Remove a mesh from the LOD array
  100933. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100934. * @param mesh defines the mesh to be removed
  100935. * @return This mesh (for chaining)
  100936. */
  100937. removeLODLevel(mesh: Mesh): Mesh;
  100938. /**
  100939. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  100940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100941. * @param camera defines the camera to use to compute distance
  100942. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  100943. * @return This mesh (for chaining)
  100944. */
  100945. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  100946. /**
  100947. * Gets the mesh internal Geometry object
  100948. */
  100949. get geometry(): Nullable<Geometry>;
  100950. /**
  100951. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  100952. * @returns the total number of vertices
  100953. */
  100954. getTotalVertices(): number;
  100955. /**
  100956. * Returns the content of an associated vertex buffer
  100957. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100958. * - VertexBuffer.PositionKind
  100959. * - VertexBuffer.UVKind
  100960. * - VertexBuffer.UV2Kind
  100961. * - VertexBuffer.UV3Kind
  100962. * - VertexBuffer.UV4Kind
  100963. * - VertexBuffer.UV5Kind
  100964. * - VertexBuffer.UV6Kind
  100965. * - VertexBuffer.ColorKind
  100966. * - VertexBuffer.MatricesIndicesKind
  100967. * - VertexBuffer.MatricesIndicesExtraKind
  100968. * - VertexBuffer.MatricesWeightsKind
  100969. * - VertexBuffer.MatricesWeightsExtraKind
  100970. * @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
  100971. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  100972. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  100973. */
  100974. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  100975. /**
  100976. * Returns the mesh VertexBuffer object from the requested `kind`
  100977. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100978. * - VertexBuffer.PositionKind
  100979. * - VertexBuffer.NormalKind
  100980. * - VertexBuffer.UVKind
  100981. * - VertexBuffer.UV2Kind
  100982. * - VertexBuffer.UV3Kind
  100983. * - VertexBuffer.UV4Kind
  100984. * - VertexBuffer.UV5Kind
  100985. * - VertexBuffer.UV6Kind
  100986. * - VertexBuffer.ColorKind
  100987. * - VertexBuffer.MatricesIndicesKind
  100988. * - VertexBuffer.MatricesIndicesExtraKind
  100989. * - VertexBuffer.MatricesWeightsKind
  100990. * - VertexBuffer.MatricesWeightsExtraKind
  100991. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  100992. */
  100993. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  100994. /**
  100995. * Tests if a specific vertex buffer is associated with this mesh
  100996. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100997. * - VertexBuffer.PositionKind
  100998. * - VertexBuffer.NormalKind
  100999. * - VertexBuffer.UVKind
  101000. * - VertexBuffer.UV2Kind
  101001. * - VertexBuffer.UV3Kind
  101002. * - VertexBuffer.UV4Kind
  101003. * - VertexBuffer.UV5Kind
  101004. * - VertexBuffer.UV6Kind
  101005. * - VertexBuffer.ColorKind
  101006. * - VertexBuffer.MatricesIndicesKind
  101007. * - VertexBuffer.MatricesIndicesExtraKind
  101008. * - VertexBuffer.MatricesWeightsKind
  101009. * - VertexBuffer.MatricesWeightsExtraKind
  101010. * @returns a boolean
  101011. */
  101012. isVerticesDataPresent(kind: string): boolean;
  101013. /**
  101014. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  101015. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  101016. * - VertexBuffer.PositionKind
  101017. * - VertexBuffer.UVKind
  101018. * - VertexBuffer.UV2Kind
  101019. * - VertexBuffer.UV3Kind
  101020. * - VertexBuffer.UV4Kind
  101021. * - VertexBuffer.UV5Kind
  101022. * - VertexBuffer.UV6Kind
  101023. * - VertexBuffer.ColorKind
  101024. * - VertexBuffer.MatricesIndicesKind
  101025. * - VertexBuffer.MatricesIndicesExtraKind
  101026. * - VertexBuffer.MatricesWeightsKind
  101027. * - VertexBuffer.MatricesWeightsExtraKind
  101028. * @returns a boolean
  101029. */
  101030. isVertexBufferUpdatable(kind: string): boolean;
  101031. /**
  101032. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  101033. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  101034. * - VertexBuffer.PositionKind
  101035. * - VertexBuffer.NormalKind
  101036. * - VertexBuffer.UVKind
  101037. * - VertexBuffer.UV2Kind
  101038. * - VertexBuffer.UV3Kind
  101039. * - VertexBuffer.UV4Kind
  101040. * - VertexBuffer.UV5Kind
  101041. * - VertexBuffer.UV6Kind
  101042. * - VertexBuffer.ColorKind
  101043. * - VertexBuffer.MatricesIndicesKind
  101044. * - VertexBuffer.MatricesIndicesExtraKind
  101045. * - VertexBuffer.MatricesWeightsKind
  101046. * - VertexBuffer.MatricesWeightsExtraKind
  101047. * @returns an array of strings
  101048. */
  101049. getVerticesDataKinds(): string[];
  101050. /**
  101051. * Returns a positive integer : the total number of indices in this mesh geometry.
  101052. * @returns the numner of indices or zero if the mesh has no geometry.
  101053. */
  101054. getTotalIndices(): number;
  101055. /**
  101056. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  101057. * @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.
  101058. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101059. * @returns the indices array or an empty array if the mesh has no geometry
  101060. */
  101061. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  101062. get isBlocked(): boolean;
  101063. /**
  101064. * Determine if the current mesh is ready to be rendered
  101065. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101066. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  101067. * @returns true if all associated assets are ready (material, textures, shaders)
  101068. */
  101069. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  101070. /**
  101071. * 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.
  101072. */
  101073. get areNormalsFrozen(): boolean;
  101074. /**
  101075. * 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.
  101076. * @returns the current mesh
  101077. */
  101078. freezeNormals(): Mesh;
  101079. /**
  101080. * 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
  101081. * @returns the current mesh
  101082. */
  101083. unfreezeNormals(): Mesh;
  101084. /**
  101085. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  101086. */
  101087. set overridenInstanceCount(count: number);
  101088. /** @hidden */
  101089. _preActivate(): Mesh;
  101090. /** @hidden */
  101091. _preActivateForIntermediateRendering(renderId: number): Mesh;
  101092. /** @hidden */
  101093. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  101094. /**
  101095. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101096. * This means the mesh underlying bounding box and sphere are recomputed.
  101097. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101098. * @returns the current mesh
  101099. */
  101100. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  101101. /** @hidden */
  101102. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  101103. /**
  101104. * This function will subdivide the mesh into multiple submeshes
  101105. * @param count defines the expected number of submeshes
  101106. */
  101107. subdivide(count: number): void;
  101108. /**
  101109. * Copy a FloatArray into a specific associated vertex buffer
  101110. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101111. * - VertexBuffer.PositionKind
  101112. * - VertexBuffer.UVKind
  101113. * - VertexBuffer.UV2Kind
  101114. * - VertexBuffer.UV3Kind
  101115. * - VertexBuffer.UV4Kind
  101116. * - VertexBuffer.UV5Kind
  101117. * - VertexBuffer.UV6Kind
  101118. * - VertexBuffer.ColorKind
  101119. * - VertexBuffer.MatricesIndicesKind
  101120. * - VertexBuffer.MatricesIndicesExtraKind
  101121. * - VertexBuffer.MatricesWeightsKind
  101122. * - VertexBuffer.MatricesWeightsExtraKind
  101123. * @param data defines the data source
  101124. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  101125. * @param stride defines the data stride size (can be null)
  101126. * @returns the current mesh
  101127. */
  101128. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101129. /**
  101130. * Delete a vertex buffer associated with this mesh
  101131. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  101132. * - VertexBuffer.PositionKind
  101133. * - VertexBuffer.UVKind
  101134. * - VertexBuffer.UV2Kind
  101135. * - VertexBuffer.UV3Kind
  101136. * - VertexBuffer.UV4Kind
  101137. * - VertexBuffer.UV5Kind
  101138. * - VertexBuffer.UV6Kind
  101139. * - VertexBuffer.ColorKind
  101140. * - VertexBuffer.MatricesIndicesKind
  101141. * - VertexBuffer.MatricesIndicesExtraKind
  101142. * - VertexBuffer.MatricesWeightsKind
  101143. * - VertexBuffer.MatricesWeightsExtraKind
  101144. */
  101145. removeVerticesData(kind: string): void;
  101146. /**
  101147. * Flags an associated vertex buffer as updatable
  101148. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  101149. * - VertexBuffer.PositionKind
  101150. * - VertexBuffer.UVKind
  101151. * - VertexBuffer.UV2Kind
  101152. * - VertexBuffer.UV3Kind
  101153. * - VertexBuffer.UV4Kind
  101154. * - VertexBuffer.UV5Kind
  101155. * - VertexBuffer.UV6Kind
  101156. * - VertexBuffer.ColorKind
  101157. * - VertexBuffer.MatricesIndicesKind
  101158. * - VertexBuffer.MatricesIndicesExtraKind
  101159. * - VertexBuffer.MatricesWeightsKind
  101160. * - VertexBuffer.MatricesWeightsExtraKind
  101161. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  101162. */
  101163. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  101164. /**
  101165. * Sets the mesh global Vertex Buffer
  101166. * @param buffer defines the buffer to use
  101167. * @returns the current mesh
  101168. */
  101169. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  101170. /**
  101171. * Update a specific associated vertex buffer
  101172. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101173. * - VertexBuffer.PositionKind
  101174. * - VertexBuffer.UVKind
  101175. * - VertexBuffer.UV2Kind
  101176. * - VertexBuffer.UV3Kind
  101177. * - VertexBuffer.UV4Kind
  101178. * - VertexBuffer.UV5Kind
  101179. * - VertexBuffer.UV6Kind
  101180. * - VertexBuffer.ColorKind
  101181. * - VertexBuffer.MatricesIndicesKind
  101182. * - VertexBuffer.MatricesIndicesExtraKind
  101183. * - VertexBuffer.MatricesWeightsKind
  101184. * - VertexBuffer.MatricesWeightsExtraKind
  101185. * @param data defines the data source
  101186. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  101187. * @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)
  101188. * @returns the current mesh
  101189. */
  101190. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101191. /**
  101192. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  101193. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  101194. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  101195. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  101196. * @returns the current mesh
  101197. */
  101198. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  101199. /**
  101200. * Creates a un-shared specific occurence of the geometry for the mesh.
  101201. * @returns the current mesh
  101202. */
  101203. makeGeometryUnique(): Mesh;
  101204. /**
  101205. * Set the index buffer of this mesh
  101206. * @param indices defines the source data
  101207. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  101208. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  101209. * @returns the current mesh
  101210. */
  101211. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  101212. /**
  101213. * Update the current index buffer
  101214. * @param indices defines the source data
  101215. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101216. * @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)
  101217. * @returns the current mesh
  101218. */
  101219. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101220. /**
  101221. * Invert the geometry to move from a right handed system to a left handed one.
  101222. * @returns the current mesh
  101223. */
  101224. toLeftHanded(): Mesh;
  101225. /** @hidden */
  101226. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  101227. /** @hidden */
  101228. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  101229. /**
  101230. * Registers for this mesh a javascript function called just before the rendering process
  101231. * @param func defines the function to call before rendering this mesh
  101232. * @returns the current mesh
  101233. */
  101234. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  101235. /**
  101236. * Disposes a previously registered javascript function called before the rendering
  101237. * @param func defines the function to remove
  101238. * @returns the current mesh
  101239. */
  101240. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  101241. /**
  101242. * Registers for this mesh a javascript function called just after the rendering is complete
  101243. * @param func defines the function to call after rendering this mesh
  101244. * @returns the current mesh
  101245. */
  101246. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  101247. /**
  101248. * Disposes a previously registered javascript function called after the rendering.
  101249. * @param func defines the function to remove
  101250. * @returns the current mesh
  101251. */
  101252. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  101253. /** @hidden */
  101254. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  101255. /** @hidden */
  101256. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  101257. /** @hidden */
  101258. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  101259. /** @hidden */
  101260. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  101261. /** @hidden */
  101262. _rebuild(): void;
  101263. /** @hidden */
  101264. _freeze(): void;
  101265. /** @hidden */
  101266. _unFreeze(): void;
  101267. /**
  101268. * 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
  101269. * @param subMesh defines the subMesh to render
  101270. * @param enableAlphaMode defines if alpha mode can be changed
  101271. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  101272. * @returns the current mesh
  101273. */
  101274. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  101275. private _onBeforeDraw;
  101276. /**
  101277. * Renormalize the mesh and patch it up if there are no weights
  101278. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  101279. * However in the case of zero weights then we set just a single influence to 1.
  101280. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  101281. */
  101282. cleanMatrixWeights(): void;
  101283. private normalizeSkinFourWeights;
  101284. private normalizeSkinWeightsAndExtra;
  101285. /**
  101286. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  101287. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  101288. * the user know there was an issue with importing the mesh
  101289. * @returns a validation object with skinned, valid and report string
  101290. */
  101291. validateSkinning(): {
  101292. skinned: boolean;
  101293. valid: boolean;
  101294. report: string;
  101295. };
  101296. /** @hidden */
  101297. _checkDelayState(): Mesh;
  101298. private _queueLoad;
  101299. /**
  101300. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101301. * A mesh is in the frustum if its bounding box intersects the frustum
  101302. * @param frustumPlanes defines the frustum to test
  101303. * @returns true if the mesh is in the frustum planes
  101304. */
  101305. isInFrustum(frustumPlanes: Plane[]): boolean;
  101306. /**
  101307. * Sets the mesh material by the material or multiMaterial `id` property
  101308. * @param id is a string identifying the material or the multiMaterial
  101309. * @returns the current mesh
  101310. */
  101311. setMaterialByID(id: string): Mesh;
  101312. /**
  101313. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  101314. * @returns an array of IAnimatable
  101315. */
  101316. getAnimatables(): IAnimatable[];
  101317. /**
  101318. * Modifies the mesh geometry according to the passed transformation matrix.
  101319. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  101320. * The mesh normals are modified using the same transformation.
  101321. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101322. * @param transform defines the transform matrix to use
  101323. * @see http://doc.babylonjs.com/resources/baking_transformations
  101324. * @returns the current mesh
  101325. */
  101326. bakeTransformIntoVertices(transform: Matrix): Mesh;
  101327. /**
  101328. * Modifies the mesh geometry according to its own current World Matrix.
  101329. * The mesh World Matrix is then reset.
  101330. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  101331. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101332. * @see http://doc.babylonjs.com/resources/baking_transformations
  101333. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  101334. * @returns the current mesh
  101335. */
  101336. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  101337. /** @hidden */
  101338. get _positions(): Nullable<Vector3[]>;
  101339. /** @hidden */
  101340. _resetPointsArrayCache(): Mesh;
  101341. /** @hidden */
  101342. _generatePointsArray(): boolean;
  101343. /**
  101344. * Returns a new Mesh object generated from the current mesh properties.
  101345. * This method must not get confused with createInstance()
  101346. * @param name is a string, the name given to the new mesh
  101347. * @param newParent can be any Node object (default `null`)
  101348. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  101349. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  101350. * @returns a new mesh
  101351. */
  101352. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  101353. /**
  101354. * Releases resources associated with this mesh.
  101355. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101356. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101357. */
  101358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101359. /** @hidden */
  101360. _disposeInstanceSpecificData(): void;
  101361. /**
  101362. * Modifies the mesh geometry according to a displacement map.
  101363. * 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.
  101364. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101365. * @param url is a string, the URL from the image file is to be downloaded.
  101366. * @param minHeight is the lower limit of the displacement.
  101367. * @param maxHeight is the upper limit of the displacement.
  101368. * @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.
  101369. * @param uvOffset is an optional vector2 used to offset UV.
  101370. * @param uvScale is an optional vector2 used to scale UV.
  101371. * @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.
  101372. * @returns the Mesh.
  101373. */
  101374. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101375. /**
  101376. * Modifies the mesh geometry according to a displacementMap buffer.
  101377. * 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.
  101378. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101379. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  101380. * @param heightMapWidth is the width of the buffer image.
  101381. * @param heightMapHeight is the height of the buffer image.
  101382. * @param minHeight is the lower limit of the displacement.
  101383. * @param maxHeight is the upper limit of the displacement.
  101384. * @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.
  101385. * @param uvOffset is an optional vector2 used to offset UV.
  101386. * @param uvScale is an optional vector2 used to scale UV.
  101387. * @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.
  101388. * @returns the Mesh.
  101389. */
  101390. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101391. /**
  101392. * Modify the mesh to get a flat shading rendering.
  101393. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  101394. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  101395. * @returns current mesh
  101396. */
  101397. convertToFlatShadedMesh(): Mesh;
  101398. /**
  101399. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  101400. * In other words, more vertices, no more indices and a single bigger VBO.
  101401. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  101402. * @returns current mesh
  101403. */
  101404. convertToUnIndexedMesh(): Mesh;
  101405. /**
  101406. * Inverses facet orientations.
  101407. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101408. * @param flipNormals will also inverts the normals
  101409. * @returns current mesh
  101410. */
  101411. flipFaces(flipNormals?: boolean): Mesh;
  101412. /**
  101413. * Increase the number of facets and hence vertices in a mesh
  101414. * Vertex normals are interpolated from existing vertex normals
  101415. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101416. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  101417. */
  101418. increaseVertices(numberPerEdge: number): void;
  101419. /**
  101420. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  101421. * This will undo any application of covertToFlatShadedMesh
  101422. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101423. */
  101424. forceSharedVertices(): void;
  101425. /** @hidden */
  101426. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  101427. /** @hidden */
  101428. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  101429. /**
  101430. * Creates a new InstancedMesh object from the mesh model.
  101431. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  101432. * @param name defines the name of the new instance
  101433. * @returns a new InstancedMesh
  101434. */
  101435. createInstance(name: string): InstancedMesh;
  101436. /**
  101437. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  101438. * After this call, all the mesh instances have the same submeshes than the current mesh.
  101439. * @returns the current mesh
  101440. */
  101441. synchronizeInstances(): Mesh;
  101442. /**
  101443. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  101444. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  101445. * This should be used together with the simplification to avoid disappearing triangles.
  101446. * @param successCallback an optional success callback to be called after the optimization finished.
  101447. * @returns the current mesh
  101448. */
  101449. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  101450. /**
  101451. * Serialize current mesh
  101452. * @param serializationObject defines the object which will receive the serialization data
  101453. */
  101454. serialize(serializationObject: any): void;
  101455. /** @hidden */
  101456. _syncGeometryWithMorphTargetManager(): void;
  101457. /** @hidden */
  101458. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  101459. /**
  101460. * Returns a new Mesh object parsed from the source provided.
  101461. * @param parsedMesh is the source
  101462. * @param scene defines the hosting scene
  101463. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  101464. * @returns a new Mesh
  101465. */
  101466. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  101467. /**
  101468. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  101469. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101470. * @param name defines the name of the mesh to create
  101471. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  101472. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  101473. * @param closePath creates a seam between the first and the last points of each path of the path array
  101474. * @param offset is taken in account only if the `pathArray` is containing a single path
  101475. * @param scene defines the hosting scene
  101476. * @param updatable defines if the mesh must be flagged as updatable
  101477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101478. * @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)
  101479. * @returns a new Mesh
  101480. */
  101481. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101482. /**
  101483. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  101484. * @param name defines the name of the mesh to create
  101485. * @param radius sets the radius size (float) of the polygon (default 0.5)
  101486. * @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
  101487. * @param scene defines the hosting scene
  101488. * @param updatable defines if the mesh must be flagged as updatable
  101489. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101490. * @returns a new Mesh
  101491. */
  101492. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101493. /**
  101494. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  101495. * @param name defines the name of the mesh to create
  101496. * @param size sets the size (float) of each box side (default 1)
  101497. * @param scene defines the hosting scene
  101498. * @param updatable defines if the mesh must be flagged as updatable
  101499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101500. * @returns a new Mesh
  101501. */
  101502. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101503. /**
  101504. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  101505. * @param name defines the name of the mesh to create
  101506. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101507. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101508. * @param scene defines the hosting scene
  101509. * @param updatable defines if the mesh must be flagged as updatable
  101510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101511. * @returns a new Mesh
  101512. */
  101513. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101514. /**
  101515. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  101516. * @param name defines the name of the mesh to create
  101517. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101518. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101519. * @param scene defines the hosting scene
  101520. * @returns a new Mesh
  101521. */
  101522. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  101523. /**
  101524. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  101525. * @param name defines the name of the mesh to create
  101526. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  101527. * @param diameterTop set the top cap diameter (floats, default 1)
  101528. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  101529. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  101530. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  101531. * @param scene defines the hosting scene
  101532. * @param updatable defines if the mesh must be flagged as updatable
  101533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101534. * @returns a new Mesh
  101535. */
  101536. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  101537. /**
  101538. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  101539. * @param name defines the name of the mesh to create
  101540. * @param diameter sets the diameter size (float) of the torus (default 1)
  101541. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  101542. * @param tessellation sets the number of torus sides (postive integer, default 16)
  101543. * @param scene defines the hosting scene
  101544. * @param updatable defines if the mesh must be flagged as updatable
  101545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101546. * @returns a new Mesh
  101547. */
  101548. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101549. /**
  101550. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  101551. * @param name defines the name of the mesh to create
  101552. * @param radius sets the global radius size (float) of the torus knot (default 2)
  101553. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  101554. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  101555. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  101556. * @param p the number of windings on X axis (positive integers, default 2)
  101557. * @param q the number of windings on Y axis (positive integers, default 3)
  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 CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101564. /**
  101565. * Creates a line 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 points is an array successive Vector3
  101568. * @param scene defines the hosting scene
  101569. * @param updatable defines if the mesh must be flagged as updatable
  101570. * @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).
  101571. * @returns a new Mesh
  101572. */
  101573. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  101574. /**
  101575. * Creates a dashed line 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 points is an array successive Vector3
  101578. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  101579. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101580. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  101581. * @param scene defines the hosting scene
  101582. * @param updatable defines if the mesh must be flagged as updatable
  101583. * @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)
  101584. * @returns a new Mesh
  101585. */
  101586. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  101587. /**
  101588. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  101589. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  101590. * 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.
  101591. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101592. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101593. * Remember you can only change the shape positions, not their number when updating a polygon.
  101594. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  101595. * @param name defines the name of the mesh to create
  101596. * @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
  101597. * @param scene defines the hosting scene
  101598. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101599. * @param updatable defines if the mesh must be flagged as updatable
  101600. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101601. * @param earcutInjection can be used to inject your own earcut reference
  101602. * @returns a new Mesh
  101603. */
  101604. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101605. /**
  101606. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  101607. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  101608. * @param name defines the name of the mesh to create
  101609. * @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
  101610. * @param depth defines the height of extrusion
  101611. * @param scene defines the hosting scene
  101612. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101613. * @param updatable defines if the mesh must be flagged as updatable
  101614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101615. * @param earcutInjection can be used to inject your own earcut reference
  101616. * @returns a new Mesh
  101617. */
  101618. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101619. /**
  101620. * Creates an extruded shape mesh.
  101621. * 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
  101622. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101624. * @param name defines the name of the mesh to create
  101625. * @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
  101626. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101627. * @param scale is the value to scale the shape
  101628. * @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
  101629. * @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
  101630. * @param scene defines the hosting scene
  101631. * @param updatable defines if the mesh must be flagged as updatable
  101632. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101633. * @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)
  101634. * @returns a new Mesh
  101635. */
  101636. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101637. /**
  101638. * Creates an custom extruded shape mesh.
  101639. * The custom extrusion is a parametric shape.
  101640. * It has no predefined shape. Its final shape will depend on the input parameters.
  101641. * Please consider using the same method from the MeshBuilder class instead
  101642. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101643. * @param name defines the name of the mesh to create
  101644. * @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
  101645. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101646. * @param scaleFunction is a custom Javascript function called on each path point
  101647. * @param rotationFunction is a custom Javascript function called on each path point
  101648. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  101649. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  101650. * @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
  101651. * @param scene defines the hosting scene
  101652. * @param updatable defines if the mesh must be flagged as updatable
  101653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101654. * @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)
  101655. * @returns a new Mesh
  101656. */
  101657. 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;
  101658. /**
  101659. * Creates lathe mesh.
  101660. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  101661. * Please consider using the same method from the MeshBuilder class instead
  101662. * @param name defines the name of the mesh to create
  101663. * @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
  101664. * @param radius is the radius value of the lathe
  101665. * @param tessellation is the side number of the lathe.
  101666. * @param scene defines the hosting scene
  101667. * @param updatable defines if the mesh must be flagged as updatable
  101668. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101669. * @returns a new Mesh
  101670. */
  101671. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101672. /**
  101673. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  101674. * @param name defines the name of the mesh to create
  101675. * @param size sets the size (float) of both sides of the plane at once (default 1)
  101676. * @param scene defines the hosting scene
  101677. * @param updatable defines if the mesh must be flagged as updatable
  101678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101679. * @returns a new Mesh
  101680. */
  101681. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101682. /**
  101683. * Creates a ground mesh.
  101684. * Please consider using the same method from the MeshBuilder class instead
  101685. * @param name defines the name of the mesh to create
  101686. * @param width set the width of the ground
  101687. * @param height set the height of the ground
  101688. * @param subdivisions sets the number of subdivisions per side
  101689. * @param scene defines the hosting scene
  101690. * @param updatable defines if the mesh must be flagged as updatable
  101691. * @returns a new Mesh
  101692. */
  101693. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  101694. /**
  101695. * Creates a tiled ground mesh.
  101696. * Please consider using the same method from the MeshBuilder class instead
  101697. * @param name defines the name of the mesh to create
  101698. * @param xmin set the ground minimum X coordinate
  101699. * @param zmin set the ground minimum Y coordinate
  101700. * @param xmax set the ground maximum X coordinate
  101701. * @param zmax set the ground maximum Z coordinate
  101702. * @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
  101703. * @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
  101704. * @param scene defines the hosting scene
  101705. * @param updatable defines if the mesh must be flagged as updatable
  101706. * @returns a new Mesh
  101707. */
  101708. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  101709. w: number;
  101710. h: number;
  101711. }, precision: {
  101712. w: number;
  101713. h: number;
  101714. }, scene: Scene, updatable?: boolean): Mesh;
  101715. /**
  101716. * Creates a ground mesh from a height map.
  101717. * Please consider using the same method from the MeshBuilder class instead
  101718. * @see http://doc.babylonjs.com/babylon101/height_map
  101719. * @param name defines the name of the mesh to create
  101720. * @param url sets the URL of the height map image resource
  101721. * @param width set the ground width size
  101722. * @param height set the ground height size
  101723. * @param subdivisions sets the number of subdivision per side
  101724. * @param minHeight is the minimum altitude on the ground
  101725. * @param maxHeight is the maximum altitude on the ground
  101726. * @param scene defines the hosting scene
  101727. * @param updatable defines if the mesh must be flagged as updatable
  101728. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  101729. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101730. * @returns a new Mesh
  101731. */
  101732. 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;
  101733. /**
  101734. * Creates a tube mesh.
  101735. * The tube is a parametric shape.
  101736. * It has no predefined shape. Its final shape will depend on the input parameters.
  101737. * Please consider using the same method from the MeshBuilder class instead
  101738. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101739. * @param name defines the name of the mesh to create
  101740. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  101741. * @param radius sets the tube radius size
  101742. * @param tessellation is the number of sides on the tubular surface
  101743. * @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
  101744. * @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
  101745. * @param scene defines the hosting scene
  101746. * @param updatable defines if the mesh must be flagged as updatable
  101747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101748. * @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)
  101749. * @returns a new Mesh
  101750. */
  101751. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  101752. (i: number, distance: number): number;
  101753. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101754. /**
  101755. * Creates a polyhedron mesh.
  101756. * Please consider using the same method from the MeshBuilder class instead.
  101757. * * 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
  101758. * * The parameter `size` (positive float, default 1) sets the polygon size
  101759. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101760. * * 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`
  101761. * * 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
  101762. * * 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)`)
  101763. * * 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
  101764. * * 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
  101765. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101766. * * 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
  101767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101768. * @param name defines the name of the mesh to create
  101769. * @param options defines the options used to create the mesh
  101770. * @param scene defines the hosting scene
  101771. * @returns a new Mesh
  101772. */
  101773. static CreatePolyhedron(name: string, options: {
  101774. type?: number;
  101775. size?: number;
  101776. sizeX?: number;
  101777. sizeY?: number;
  101778. sizeZ?: number;
  101779. custom?: any;
  101780. faceUV?: Vector4[];
  101781. faceColors?: Color4[];
  101782. updatable?: boolean;
  101783. sideOrientation?: number;
  101784. }, scene: Scene): Mesh;
  101785. /**
  101786. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  101787. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  101788. * * 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`)
  101789. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  101790. * * 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
  101791. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101792. * * 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
  101793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101794. * @param name defines the name of the mesh
  101795. * @param options defines the options used to create the mesh
  101796. * @param scene defines the hosting scene
  101797. * @returns a new Mesh
  101798. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  101799. */
  101800. static CreateIcoSphere(name: string, options: {
  101801. radius?: number;
  101802. flat?: boolean;
  101803. subdivisions?: number;
  101804. sideOrientation?: number;
  101805. updatable?: boolean;
  101806. }, scene: Scene): Mesh;
  101807. /**
  101808. * Creates a decal mesh.
  101809. * Please consider using the same method from the MeshBuilder class instead.
  101810. * A decal is a mesh usually applied as a model onto the surface of another mesh
  101811. * @param name defines the name of the mesh
  101812. * @param sourceMesh defines the mesh receiving the decal
  101813. * @param position sets the position of the decal in world coordinates
  101814. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  101815. * @param size sets the decal scaling
  101816. * @param angle sets the angle to rotate the decal
  101817. * @returns a new Mesh
  101818. */
  101819. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  101820. /**
  101821. * Prepare internal position array for software CPU skinning
  101822. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  101823. */
  101824. setPositionsForCPUSkinning(): Float32Array;
  101825. /**
  101826. * Prepare internal normal array for software CPU skinning
  101827. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  101828. */
  101829. setNormalsForCPUSkinning(): Float32Array;
  101830. /**
  101831. * Updates the vertex buffer by applying transformation from the bones
  101832. * @param skeleton defines the skeleton to apply to current mesh
  101833. * @returns the current mesh
  101834. */
  101835. applySkeleton(skeleton: Skeleton): Mesh;
  101836. /**
  101837. * 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
  101838. * @param meshes defines the list of meshes to scan
  101839. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  101840. */
  101841. static MinMax(meshes: AbstractMesh[]): {
  101842. min: Vector3;
  101843. max: Vector3;
  101844. };
  101845. /**
  101846. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  101847. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  101848. * @returns a vector3
  101849. */
  101850. static Center(meshesOrMinMaxVector: {
  101851. min: Vector3;
  101852. max: Vector3;
  101853. } | AbstractMesh[]): Vector3;
  101854. /**
  101855. * Merge the array of meshes into a single mesh for performance reasons.
  101856. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  101857. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  101858. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  101859. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  101860. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  101861. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  101862. * @returns a new mesh
  101863. */
  101864. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  101865. /** @hidden */
  101866. addInstance(instance: InstancedMesh): void;
  101867. /** @hidden */
  101868. removeInstance(instance: InstancedMesh): void;
  101869. }
  101870. }
  101871. declare module BABYLON {
  101872. /**
  101873. * This is the base class of all the camera used in the application.
  101874. * @see http://doc.babylonjs.com/features/cameras
  101875. */
  101876. export class Camera extends Node {
  101877. /** @hidden */
  101878. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  101879. /**
  101880. * This is the default projection mode used by the cameras.
  101881. * It helps recreating a feeling of perspective and better appreciate depth.
  101882. * This is the best way to simulate real life cameras.
  101883. */
  101884. static readonly PERSPECTIVE_CAMERA: number;
  101885. /**
  101886. * This helps creating camera with an orthographic mode.
  101887. * 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.
  101888. */
  101889. static readonly ORTHOGRAPHIC_CAMERA: number;
  101890. /**
  101891. * This is the default FOV mode for perspective cameras.
  101892. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  101893. */
  101894. static readonly FOVMODE_VERTICAL_FIXED: number;
  101895. /**
  101896. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  101897. */
  101898. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  101899. /**
  101900. * This specifies ther is no need for a camera rig.
  101901. * Basically only one eye is rendered corresponding to the camera.
  101902. */
  101903. static readonly RIG_MODE_NONE: number;
  101904. /**
  101905. * Simulates a camera Rig with one blue eye and one red eye.
  101906. * This can be use with 3d blue and red glasses.
  101907. */
  101908. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  101909. /**
  101910. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  101911. */
  101912. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  101913. /**
  101914. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  101915. */
  101916. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  101917. /**
  101918. * Defines that both eyes of the camera will be rendered over under each other.
  101919. */
  101920. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  101921. /**
  101922. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  101923. */
  101924. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  101925. /**
  101926. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  101927. */
  101928. static readonly RIG_MODE_VR: number;
  101929. /**
  101930. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  101931. */
  101932. static readonly RIG_MODE_WEBVR: number;
  101933. /**
  101934. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  101935. */
  101936. static readonly RIG_MODE_CUSTOM: number;
  101937. /**
  101938. * Defines if by default attaching controls should prevent the default javascript event to continue.
  101939. */
  101940. static ForceAttachControlToAlwaysPreventDefault: boolean;
  101941. /**
  101942. * Define the input manager associated with the camera.
  101943. */
  101944. inputs: CameraInputsManager<Camera>;
  101945. /** @hidden */
  101946. _position: Vector3;
  101947. /**
  101948. * Define the current local position of the camera in the scene
  101949. */
  101950. get position(): Vector3;
  101951. set position(newPosition: Vector3);
  101952. /**
  101953. * The vector the camera should consider as up.
  101954. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  101955. */
  101956. upVector: Vector3;
  101957. /**
  101958. * Define the current limit on the left side for an orthographic camera
  101959. * In scene unit
  101960. */
  101961. orthoLeft: Nullable<number>;
  101962. /**
  101963. * Define the current limit on the right side for an orthographic camera
  101964. * In scene unit
  101965. */
  101966. orthoRight: Nullable<number>;
  101967. /**
  101968. * Define the current limit on the bottom side for an orthographic camera
  101969. * In scene unit
  101970. */
  101971. orthoBottom: Nullable<number>;
  101972. /**
  101973. * Define the current limit on the top side for an orthographic camera
  101974. * In scene unit
  101975. */
  101976. orthoTop: Nullable<number>;
  101977. /**
  101978. * Field Of View is set in Radians. (default is 0.8)
  101979. */
  101980. fov: number;
  101981. /**
  101982. * Define the minimum distance the camera can see from.
  101983. * This is important to note that the depth buffer are not infinite and the closer it starts
  101984. * the more your scene might encounter depth fighting issue.
  101985. */
  101986. minZ: number;
  101987. /**
  101988. * Define the maximum distance the camera can see to.
  101989. * This is important to note that the depth buffer are not infinite and the further it end
  101990. * the more your scene might encounter depth fighting issue.
  101991. */
  101992. maxZ: number;
  101993. /**
  101994. * Define the default inertia of the camera.
  101995. * This helps giving a smooth feeling to the camera movement.
  101996. */
  101997. inertia: number;
  101998. /**
  101999. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  102000. */
  102001. mode: number;
  102002. /**
  102003. * Define whether the camera is intermediate.
  102004. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  102005. */
  102006. isIntermediate: boolean;
  102007. /**
  102008. * Define the viewport of the camera.
  102009. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  102010. */
  102011. viewport: Viewport;
  102012. /**
  102013. * Restricts the camera to viewing objects with the same layerMask.
  102014. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  102015. */
  102016. layerMask: number;
  102017. /**
  102018. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  102019. */
  102020. fovMode: number;
  102021. /**
  102022. * Rig mode of the camera.
  102023. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  102024. * This is normally controlled byt the camera themselves as internal use.
  102025. */
  102026. cameraRigMode: number;
  102027. /**
  102028. * Defines the distance between both "eyes" in case of a RIG
  102029. */
  102030. interaxialDistance: number;
  102031. /**
  102032. * Defines if stereoscopic rendering is done side by side or over under.
  102033. */
  102034. isStereoscopicSideBySide: boolean;
  102035. /**
  102036. * 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
  102037. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  102038. * else in the scene. (Eg. security camera)
  102039. *
  102040. * 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)
  102041. */
  102042. customRenderTargets: RenderTargetTexture[];
  102043. /**
  102044. * When set, the camera will render to this render target instead of the default canvas
  102045. *
  102046. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  102047. */
  102048. outputRenderTarget: Nullable<RenderTargetTexture>;
  102049. /**
  102050. * Observable triggered when the camera view matrix has changed.
  102051. */
  102052. onViewMatrixChangedObservable: Observable<Camera>;
  102053. /**
  102054. * Observable triggered when the camera Projection matrix has changed.
  102055. */
  102056. onProjectionMatrixChangedObservable: Observable<Camera>;
  102057. /**
  102058. * Observable triggered when the inputs have been processed.
  102059. */
  102060. onAfterCheckInputsObservable: Observable<Camera>;
  102061. /**
  102062. * Observable triggered when reset has been called and applied to the camera.
  102063. */
  102064. onRestoreStateObservable: Observable<Camera>;
  102065. /**
  102066. * Is this camera a part of a rig system?
  102067. */
  102068. isRigCamera: boolean;
  102069. /**
  102070. * If isRigCamera set to true this will be set with the parent camera.
  102071. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  102072. */
  102073. rigParent?: Camera;
  102074. /** @hidden */
  102075. _cameraRigParams: any;
  102076. /** @hidden */
  102077. _rigCameras: Camera[];
  102078. /** @hidden */
  102079. _rigPostProcess: Nullable<PostProcess>;
  102080. protected _webvrViewMatrix: Matrix;
  102081. /** @hidden */
  102082. _skipRendering: boolean;
  102083. /** @hidden */
  102084. _projectionMatrix: Matrix;
  102085. /** @hidden */
  102086. _postProcesses: Nullable<PostProcess>[];
  102087. /** @hidden */
  102088. _activeMeshes: SmartArray<AbstractMesh>;
  102089. protected _globalPosition: Vector3;
  102090. /** @hidden */
  102091. _computedViewMatrix: Matrix;
  102092. private _doNotComputeProjectionMatrix;
  102093. private _transformMatrix;
  102094. private _frustumPlanes;
  102095. private _refreshFrustumPlanes;
  102096. private _storedFov;
  102097. private _stateStored;
  102098. /**
  102099. * Instantiates a new camera object.
  102100. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  102101. * @see http://doc.babylonjs.com/features/cameras
  102102. * @param name Defines the name of the camera in the scene
  102103. * @param position Defines the position of the camera
  102104. * @param scene Defines the scene the camera belongs too
  102105. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  102106. */
  102107. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102108. /**
  102109. * Store current camera state (fov, position, etc..)
  102110. * @returns the camera
  102111. */
  102112. storeState(): Camera;
  102113. /**
  102114. * Restores the camera state values if it has been stored. You must call storeState() first
  102115. */
  102116. protected _restoreStateValues(): boolean;
  102117. /**
  102118. * Restored camera state. You must call storeState() first.
  102119. * @returns true if restored and false otherwise
  102120. */
  102121. restoreState(): boolean;
  102122. /**
  102123. * Gets the class name of the camera.
  102124. * @returns the class name
  102125. */
  102126. getClassName(): string;
  102127. /** @hidden */
  102128. readonly _isCamera: boolean;
  102129. /**
  102130. * Gets a string representation of the camera useful for debug purpose.
  102131. * @param fullDetails Defines that a more verboe level of logging is required
  102132. * @returns the string representation
  102133. */
  102134. toString(fullDetails?: boolean): string;
  102135. /**
  102136. * Gets the current world space position of the camera.
  102137. */
  102138. get globalPosition(): Vector3;
  102139. /**
  102140. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  102141. * @returns the active meshe list
  102142. */
  102143. getActiveMeshes(): SmartArray<AbstractMesh>;
  102144. /**
  102145. * Check whether a mesh is part of the current active mesh list of the camera
  102146. * @param mesh Defines the mesh to check
  102147. * @returns true if active, false otherwise
  102148. */
  102149. isActiveMesh(mesh: Mesh): boolean;
  102150. /**
  102151. * Is this camera ready to be used/rendered
  102152. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  102153. * @return true if the camera is ready
  102154. */
  102155. isReady(completeCheck?: boolean): boolean;
  102156. /** @hidden */
  102157. _initCache(): void;
  102158. /** @hidden */
  102159. _updateCache(ignoreParentClass?: boolean): void;
  102160. /** @hidden */
  102161. _isSynchronized(): boolean;
  102162. /** @hidden */
  102163. _isSynchronizedViewMatrix(): boolean;
  102164. /** @hidden */
  102165. _isSynchronizedProjectionMatrix(): boolean;
  102166. /**
  102167. * Attach the input controls to a specific dom element to get the input from.
  102168. * @param element Defines the element the controls should be listened from
  102169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102170. */
  102171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102172. /**
  102173. * Detach the current controls from the specified dom element.
  102174. * @param element Defines the element to stop listening the inputs from
  102175. */
  102176. detachControl(element: HTMLElement): void;
  102177. /**
  102178. * Update the camera state according to the different inputs gathered during the frame.
  102179. */
  102180. update(): void;
  102181. /** @hidden */
  102182. _checkInputs(): void;
  102183. /** @hidden */
  102184. get rigCameras(): Camera[];
  102185. /**
  102186. * Gets the post process used by the rig cameras
  102187. */
  102188. get rigPostProcess(): Nullable<PostProcess>;
  102189. /**
  102190. * Internal, gets the first post proces.
  102191. * @returns the first post process to be run on this camera.
  102192. */
  102193. _getFirstPostProcess(): Nullable<PostProcess>;
  102194. private _cascadePostProcessesToRigCams;
  102195. /**
  102196. * Attach a post process to the camera.
  102197. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  102198. * @param postProcess The post process to attach to the camera
  102199. * @param insertAt The position of the post process in case several of them are in use in the scene
  102200. * @returns the position the post process has been inserted at
  102201. */
  102202. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  102203. /**
  102204. * Detach a post process to the camera.
  102205. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  102206. * @param postProcess The post process to detach from the camera
  102207. */
  102208. detachPostProcess(postProcess: PostProcess): void;
  102209. /**
  102210. * Gets the current world matrix of the camera
  102211. */
  102212. getWorldMatrix(): Matrix;
  102213. /** @hidden */
  102214. _getViewMatrix(): Matrix;
  102215. /**
  102216. * Gets the current view matrix of the camera.
  102217. * @param force forces the camera to recompute the matrix without looking at the cached state
  102218. * @returns the view matrix
  102219. */
  102220. getViewMatrix(force?: boolean): Matrix;
  102221. /**
  102222. * Freeze the projection matrix.
  102223. * It will prevent the cache check of the camera projection compute and can speed up perf
  102224. * if no parameter of the camera are meant to change
  102225. * @param projection Defines manually a projection if necessary
  102226. */
  102227. freezeProjectionMatrix(projection?: Matrix): void;
  102228. /**
  102229. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  102230. */
  102231. unfreezeProjectionMatrix(): void;
  102232. /**
  102233. * Gets the current projection matrix of the camera.
  102234. * @param force forces the camera to recompute the matrix without looking at the cached state
  102235. * @returns the projection matrix
  102236. */
  102237. getProjectionMatrix(force?: boolean): Matrix;
  102238. /**
  102239. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  102240. * @returns a Matrix
  102241. */
  102242. getTransformationMatrix(): Matrix;
  102243. private _updateFrustumPlanes;
  102244. /**
  102245. * Checks if a cullable object (mesh...) is in the camera frustum
  102246. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  102247. * @param target The object to check
  102248. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  102249. * @returns true if the object is in frustum otherwise false
  102250. */
  102251. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  102252. /**
  102253. * Checks if a cullable object (mesh...) is in the camera frustum
  102254. * Unlike isInFrustum this cheks the full bounding box
  102255. * @param target The object to check
  102256. * @returns true if the object is in frustum otherwise false
  102257. */
  102258. isCompletelyInFrustum(target: ICullable): boolean;
  102259. /**
  102260. * Gets a ray in the forward direction from the camera.
  102261. * @param length Defines the length of the ray to create
  102262. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  102263. * @param origin Defines the start point of the ray which defaults to the camera position
  102264. * @returns the forward ray
  102265. */
  102266. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  102267. /**
  102268. * Releases resources associated with this node.
  102269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102271. */
  102272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102273. /** @hidden */
  102274. _isLeftCamera: boolean;
  102275. /**
  102276. * Gets the left camera of a rig setup in case of Rigged Camera
  102277. */
  102278. get isLeftCamera(): boolean;
  102279. /** @hidden */
  102280. _isRightCamera: boolean;
  102281. /**
  102282. * Gets the right camera of a rig setup in case of Rigged Camera
  102283. */
  102284. get isRightCamera(): boolean;
  102285. /**
  102286. * Gets the left camera of a rig setup in case of Rigged Camera
  102287. */
  102288. get leftCamera(): Nullable<FreeCamera>;
  102289. /**
  102290. * Gets the right camera of a rig setup in case of Rigged Camera
  102291. */
  102292. get rightCamera(): Nullable<FreeCamera>;
  102293. /**
  102294. * Gets the left camera target of a rig setup in case of Rigged Camera
  102295. * @returns the target position
  102296. */
  102297. getLeftTarget(): Nullable<Vector3>;
  102298. /**
  102299. * Gets the right camera target of a rig setup in case of Rigged Camera
  102300. * @returns the target position
  102301. */
  102302. getRightTarget(): Nullable<Vector3>;
  102303. /**
  102304. * @hidden
  102305. */
  102306. setCameraRigMode(mode: number, rigParams: any): void;
  102307. /** @hidden */
  102308. static _setStereoscopicRigMode(camera: Camera): void;
  102309. /** @hidden */
  102310. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  102311. /** @hidden */
  102312. static _setVRRigMode(camera: Camera, rigParams: any): void;
  102313. /** @hidden */
  102314. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  102315. /** @hidden */
  102316. _getVRProjectionMatrix(): Matrix;
  102317. protected _updateCameraRotationMatrix(): void;
  102318. protected _updateWebVRCameraRotationMatrix(): void;
  102319. /**
  102320. * This function MUST be overwritten by the different WebVR cameras available.
  102321. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102322. * @hidden
  102323. */
  102324. _getWebVRProjectionMatrix(): Matrix;
  102325. /**
  102326. * This function MUST be overwritten by the different WebVR cameras available.
  102327. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102328. * @hidden
  102329. */
  102330. _getWebVRViewMatrix(): Matrix;
  102331. /** @hidden */
  102332. setCameraRigParameter(name: string, value: any): void;
  102333. /**
  102334. * needs to be overridden by children so sub has required properties to be copied
  102335. * @hidden
  102336. */
  102337. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  102338. /**
  102339. * May need to be overridden by children
  102340. * @hidden
  102341. */
  102342. _updateRigCameras(): void;
  102343. /** @hidden */
  102344. _setupInputs(): void;
  102345. /**
  102346. * Serialiaze the camera setup to a json represention
  102347. * @returns the JSON representation
  102348. */
  102349. serialize(): any;
  102350. /**
  102351. * Clones the current camera.
  102352. * @param name The cloned camera name
  102353. * @returns the cloned camera
  102354. */
  102355. clone(name: string): Camera;
  102356. /**
  102357. * Gets the direction of the camera relative to a given local axis.
  102358. * @param localAxis Defines the reference axis to provide a relative direction.
  102359. * @return the direction
  102360. */
  102361. getDirection(localAxis: Vector3): Vector3;
  102362. /**
  102363. * Returns the current camera absolute rotation
  102364. */
  102365. get absoluteRotation(): Quaternion;
  102366. /**
  102367. * Gets the direction of the camera relative to a given local axis into a passed vector.
  102368. * @param localAxis Defines the reference axis to provide a relative direction.
  102369. * @param result Defines the vector to store the result in
  102370. */
  102371. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  102372. /**
  102373. * Gets a camera constructor for a given camera type
  102374. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  102375. * @param name The name of the camera the result will be able to instantiate
  102376. * @param scene The scene the result will construct the camera in
  102377. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  102378. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  102379. * @returns a factory method to construc the camera
  102380. */
  102381. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  102382. /**
  102383. * Compute the world matrix of the camera.
  102384. * @returns the camera world matrix
  102385. */
  102386. computeWorldMatrix(): Matrix;
  102387. /**
  102388. * Parse a JSON and creates the camera from the parsed information
  102389. * @param parsedCamera The JSON to parse
  102390. * @param scene The scene to instantiate the camera in
  102391. * @returns the newly constructed camera
  102392. */
  102393. static Parse(parsedCamera: any, scene: Scene): Camera;
  102394. }
  102395. }
  102396. declare module BABYLON {
  102397. /**
  102398. * Class containing static functions to help procedurally build meshes
  102399. */
  102400. export class DiscBuilder {
  102401. /**
  102402. * Creates a plane polygonal mesh. By default, this is a disc
  102403. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  102404. * * 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
  102405. * * 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
  102406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102407. * * 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
  102408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102409. * @param name defines the name of the mesh
  102410. * @param options defines the options used to create the mesh
  102411. * @param scene defines the hosting scene
  102412. * @returns the plane polygonal mesh
  102413. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  102414. */
  102415. static CreateDisc(name: string, options: {
  102416. radius?: number;
  102417. tessellation?: number;
  102418. arc?: number;
  102419. updatable?: boolean;
  102420. sideOrientation?: number;
  102421. frontUVs?: Vector4;
  102422. backUVs?: Vector4;
  102423. }, scene?: Nullable<Scene>): Mesh;
  102424. }
  102425. }
  102426. declare module BABYLON {
  102427. /**
  102428. * Options to be used when creating a FresnelParameters.
  102429. */
  102430. export type IFresnelParametersCreationOptions = {
  102431. /**
  102432. * Define the color used on edges (grazing angle)
  102433. */
  102434. leftColor?: Color3;
  102435. /**
  102436. * Define the color used on center
  102437. */
  102438. rightColor?: Color3;
  102439. /**
  102440. * Define bias applied to computed fresnel term
  102441. */
  102442. bias?: number;
  102443. /**
  102444. * Defined the power exponent applied to fresnel term
  102445. */
  102446. power?: number;
  102447. /**
  102448. * Define if the fresnel effect is enable or not.
  102449. */
  102450. isEnabled?: boolean;
  102451. };
  102452. /**
  102453. * Serialized format for FresnelParameters.
  102454. */
  102455. export type IFresnelParametersSerialized = {
  102456. /**
  102457. * Define the color used on edges (grazing angle) [as an array]
  102458. */
  102459. leftColor: number[];
  102460. /**
  102461. * Define the color used on center [as an array]
  102462. */
  102463. rightColor: number[];
  102464. /**
  102465. * Define bias applied to computed fresnel term
  102466. */
  102467. bias: number;
  102468. /**
  102469. * Defined the power exponent applied to fresnel term
  102470. */
  102471. power?: number;
  102472. /**
  102473. * Define if the fresnel effect is enable or not.
  102474. */
  102475. isEnabled: boolean;
  102476. };
  102477. /**
  102478. * This represents all the required information to add a fresnel effect on a material:
  102479. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102480. */
  102481. export class FresnelParameters {
  102482. private _isEnabled;
  102483. /**
  102484. * Define if the fresnel effect is enable or not.
  102485. */
  102486. get isEnabled(): boolean;
  102487. set isEnabled(value: boolean);
  102488. /**
  102489. * Define the color used on edges (grazing angle)
  102490. */
  102491. leftColor: Color3;
  102492. /**
  102493. * Define the color used on center
  102494. */
  102495. rightColor: Color3;
  102496. /**
  102497. * Define bias applied to computed fresnel term
  102498. */
  102499. bias: number;
  102500. /**
  102501. * Defined the power exponent applied to fresnel term
  102502. */
  102503. power: number;
  102504. /**
  102505. * Creates a new FresnelParameters object.
  102506. *
  102507. * @param options provide your own settings to optionally to override defaults
  102508. */
  102509. constructor(options?: IFresnelParametersCreationOptions);
  102510. /**
  102511. * Clones the current fresnel and its valuues
  102512. * @returns a clone fresnel configuration
  102513. */
  102514. clone(): FresnelParameters;
  102515. /**
  102516. * Determines equality between FresnelParameters objects
  102517. * @param otherFresnelParameters defines the second operand
  102518. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  102519. */
  102520. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  102521. /**
  102522. * Serializes the current fresnel parameters to a JSON representation.
  102523. * @return the JSON serialization
  102524. */
  102525. serialize(): IFresnelParametersSerialized;
  102526. /**
  102527. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  102528. * @param parsedFresnelParameters Define the JSON representation
  102529. * @returns the parsed parameters
  102530. */
  102531. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  102532. }
  102533. }
  102534. declare module BABYLON {
  102535. /**
  102536. * Base class of materials working in push mode in babylon JS
  102537. * @hidden
  102538. */
  102539. export class PushMaterial extends Material {
  102540. protected _activeEffect: Effect;
  102541. protected _normalMatrix: Matrix;
  102542. /**
  102543. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102544. * This means that the material can keep using a previous shader while a new one is being compiled.
  102545. * This is mostly used when shader parallel compilation is supported (true by default)
  102546. */
  102547. allowShaderHotSwapping: boolean;
  102548. constructor(name: string, scene: Scene);
  102549. getEffect(): Effect;
  102550. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102551. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102552. /**
  102553. * Binds the given world matrix to the active effect
  102554. *
  102555. * @param world the matrix to bind
  102556. */
  102557. bindOnlyWorldMatrix(world: Matrix): void;
  102558. /**
  102559. * Binds the given normal matrix to the active effect
  102560. *
  102561. * @param normalMatrix the matrix to bind
  102562. */
  102563. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102564. bind(world: Matrix, mesh?: Mesh): void;
  102565. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102566. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102567. }
  102568. }
  102569. declare module BABYLON {
  102570. /**
  102571. * This groups all the flags used to control the materials channel.
  102572. */
  102573. export class MaterialFlags {
  102574. private static _DiffuseTextureEnabled;
  102575. /**
  102576. * Are diffuse textures enabled in the application.
  102577. */
  102578. static get DiffuseTextureEnabled(): boolean;
  102579. static set DiffuseTextureEnabled(value: boolean);
  102580. private static _AmbientTextureEnabled;
  102581. /**
  102582. * Are ambient textures enabled in the application.
  102583. */
  102584. static get AmbientTextureEnabled(): boolean;
  102585. static set AmbientTextureEnabled(value: boolean);
  102586. private static _OpacityTextureEnabled;
  102587. /**
  102588. * Are opacity textures enabled in the application.
  102589. */
  102590. static get OpacityTextureEnabled(): boolean;
  102591. static set OpacityTextureEnabled(value: boolean);
  102592. private static _ReflectionTextureEnabled;
  102593. /**
  102594. * Are reflection textures enabled in the application.
  102595. */
  102596. static get ReflectionTextureEnabled(): boolean;
  102597. static set ReflectionTextureEnabled(value: boolean);
  102598. private static _EmissiveTextureEnabled;
  102599. /**
  102600. * Are emissive textures enabled in the application.
  102601. */
  102602. static get EmissiveTextureEnabled(): boolean;
  102603. static set EmissiveTextureEnabled(value: boolean);
  102604. private static _SpecularTextureEnabled;
  102605. /**
  102606. * Are specular textures enabled in the application.
  102607. */
  102608. static get SpecularTextureEnabled(): boolean;
  102609. static set SpecularTextureEnabled(value: boolean);
  102610. private static _BumpTextureEnabled;
  102611. /**
  102612. * Are bump textures enabled in the application.
  102613. */
  102614. static get BumpTextureEnabled(): boolean;
  102615. static set BumpTextureEnabled(value: boolean);
  102616. private static _LightmapTextureEnabled;
  102617. /**
  102618. * Are lightmap textures enabled in the application.
  102619. */
  102620. static get LightmapTextureEnabled(): boolean;
  102621. static set LightmapTextureEnabled(value: boolean);
  102622. private static _RefractionTextureEnabled;
  102623. /**
  102624. * Are refraction textures enabled in the application.
  102625. */
  102626. static get RefractionTextureEnabled(): boolean;
  102627. static set RefractionTextureEnabled(value: boolean);
  102628. private static _ColorGradingTextureEnabled;
  102629. /**
  102630. * Are color grading textures enabled in the application.
  102631. */
  102632. static get ColorGradingTextureEnabled(): boolean;
  102633. static set ColorGradingTextureEnabled(value: boolean);
  102634. private static _FresnelEnabled;
  102635. /**
  102636. * Are fresnels enabled in the application.
  102637. */
  102638. static get FresnelEnabled(): boolean;
  102639. static set FresnelEnabled(value: boolean);
  102640. private static _ClearCoatTextureEnabled;
  102641. /**
  102642. * Are clear coat textures enabled in the application.
  102643. */
  102644. static get ClearCoatTextureEnabled(): boolean;
  102645. static set ClearCoatTextureEnabled(value: boolean);
  102646. private static _ClearCoatBumpTextureEnabled;
  102647. /**
  102648. * Are clear coat bump textures enabled in the application.
  102649. */
  102650. static get ClearCoatBumpTextureEnabled(): boolean;
  102651. static set ClearCoatBumpTextureEnabled(value: boolean);
  102652. private static _ClearCoatTintTextureEnabled;
  102653. /**
  102654. * Are clear coat tint textures enabled in the application.
  102655. */
  102656. static get ClearCoatTintTextureEnabled(): boolean;
  102657. static set ClearCoatTintTextureEnabled(value: boolean);
  102658. private static _SheenTextureEnabled;
  102659. /**
  102660. * Are sheen textures enabled in the application.
  102661. */
  102662. static get SheenTextureEnabled(): boolean;
  102663. static set SheenTextureEnabled(value: boolean);
  102664. private static _AnisotropicTextureEnabled;
  102665. /**
  102666. * Are anisotropic textures enabled in the application.
  102667. */
  102668. static get AnisotropicTextureEnabled(): boolean;
  102669. static set AnisotropicTextureEnabled(value: boolean);
  102670. private static _ThicknessTextureEnabled;
  102671. /**
  102672. * Are thickness textures enabled in the application.
  102673. */
  102674. static get ThicknessTextureEnabled(): boolean;
  102675. static set ThicknessTextureEnabled(value: boolean);
  102676. }
  102677. }
  102678. declare module BABYLON {
  102679. /** @hidden */
  102680. export var defaultFragmentDeclaration: {
  102681. name: string;
  102682. shader: string;
  102683. };
  102684. }
  102685. declare module BABYLON {
  102686. /** @hidden */
  102687. export var defaultUboDeclaration: {
  102688. name: string;
  102689. shader: string;
  102690. };
  102691. }
  102692. declare module BABYLON {
  102693. /** @hidden */
  102694. export var lightFragmentDeclaration: {
  102695. name: string;
  102696. shader: string;
  102697. };
  102698. }
  102699. declare module BABYLON {
  102700. /** @hidden */
  102701. export var lightUboDeclaration: {
  102702. name: string;
  102703. shader: string;
  102704. };
  102705. }
  102706. declare module BABYLON {
  102707. /** @hidden */
  102708. export var lightsFragmentFunctions: {
  102709. name: string;
  102710. shader: string;
  102711. };
  102712. }
  102713. declare module BABYLON {
  102714. /** @hidden */
  102715. export var shadowsFragmentFunctions: {
  102716. name: string;
  102717. shader: string;
  102718. };
  102719. }
  102720. declare module BABYLON {
  102721. /** @hidden */
  102722. export var fresnelFunction: {
  102723. name: string;
  102724. shader: string;
  102725. };
  102726. }
  102727. declare module BABYLON {
  102728. /** @hidden */
  102729. export var reflectionFunction: {
  102730. name: string;
  102731. shader: string;
  102732. };
  102733. }
  102734. declare module BABYLON {
  102735. /** @hidden */
  102736. export var bumpFragmentMainFunctions: {
  102737. name: string;
  102738. shader: string;
  102739. };
  102740. }
  102741. declare module BABYLON {
  102742. /** @hidden */
  102743. export var bumpFragmentFunctions: {
  102744. name: string;
  102745. shader: string;
  102746. };
  102747. }
  102748. declare module BABYLON {
  102749. /** @hidden */
  102750. export var logDepthDeclaration: {
  102751. name: string;
  102752. shader: string;
  102753. };
  102754. }
  102755. declare module BABYLON {
  102756. /** @hidden */
  102757. export var bumpFragment: {
  102758. name: string;
  102759. shader: string;
  102760. };
  102761. }
  102762. declare module BABYLON {
  102763. /** @hidden */
  102764. export var depthPrePass: {
  102765. name: string;
  102766. shader: string;
  102767. };
  102768. }
  102769. declare module BABYLON {
  102770. /** @hidden */
  102771. export var lightFragment: {
  102772. name: string;
  102773. shader: string;
  102774. };
  102775. }
  102776. declare module BABYLON {
  102777. /** @hidden */
  102778. export var logDepthFragment: {
  102779. name: string;
  102780. shader: string;
  102781. };
  102782. }
  102783. declare module BABYLON {
  102784. /** @hidden */
  102785. export var defaultPixelShader: {
  102786. name: string;
  102787. shader: string;
  102788. };
  102789. }
  102790. declare module BABYLON {
  102791. /** @hidden */
  102792. export var defaultVertexDeclaration: {
  102793. name: string;
  102794. shader: string;
  102795. };
  102796. }
  102797. declare module BABYLON {
  102798. /** @hidden */
  102799. export var bumpVertexDeclaration: {
  102800. name: string;
  102801. shader: string;
  102802. };
  102803. }
  102804. declare module BABYLON {
  102805. /** @hidden */
  102806. export var bumpVertex: {
  102807. name: string;
  102808. shader: string;
  102809. };
  102810. }
  102811. declare module BABYLON {
  102812. /** @hidden */
  102813. export var fogVertex: {
  102814. name: string;
  102815. shader: string;
  102816. };
  102817. }
  102818. declare module BABYLON {
  102819. /** @hidden */
  102820. export var shadowsVertex: {
  102821. name: string;
  102822. shader: string;
  102823. };
  102824. }
  102825. declare module BABYLON {
  102826. /** @hidden */
  102827. export var pointCloudVertex: {
  102828. name: string;
  102829. shader: string;
  102830. };
  102831. }
  102832. declare module BABYLON {
  102833. /** @hidden */
  102834. export var logDepthVertex: {
  102835. name: string;
  102836. shader: string;
  102837. };
  102838. }
  102839. declare module BABYLON {
  102840. /** @hidden */
  102841. export var defaultVertexShader: {
  102842. name: string;
  102843. shader: string;
  102844. };
  102845. }
  102846. declare module BABYLON {
  102847. /** @hidden */
  102848. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102849. MAINUV1: boolean;
  102850. MAINUV2: boolean;
  102851. DIFFUSE: boolean;
  102852. DIFFUSEDIRECTUV: number;
  102853. AMBIENT: boolean;
  102854. AMBIENTDIRECTUV: number;
  102855. OPACITY: boolean;
  102856. OPACITYDIRECTUV: number;
  102857. OPACITYRGB: boolean;
  102858. REFLECTION: boolean;
  102859. EMISSIVE: boolean;
  102860. EMISSIVEDIRECTUV: number;
  102861. SPECULAR: boolean;
  102862. SPECULARDIRECTUV: number;
  102863. BUMP: boolean;
  102864. BUMPDIRECTUV: number;
  102865. PARALLAX: boolean;
  102866. PARALLAXOCCLUSION: boolean;
  102867. SPECULAROVERALPHA: boolean;
  102868. CLIPPLANE: boolean;
  102869. CLIPPLANE2: boolean;
  102870. CLIPPLANE3: boolean;
  102871. CLIPPLANE4: boolean;
  102872. CLIPPLANE5: boolean;
  102873. CLIPPLANE6: boolean;
  102874. ALPHATEST: boolean;
  102875. DEPTHPREPASS: boolean;
  102876. ALPHAFROMDIFFUSE: boolean;
  102877. POINTSIZE: boolean;
  102878. FOG: boolean;
  102879. SPECULARTERM: boolean;
  102880. DIFFUSEFRESNEL: boolean;
  102881. OPACITYFRESNEL: boolean;
  102882. REFLECTIONFRESNEL: boolean;
  102883. REFRACTIONFRESNEL: boolean;
  102884. EMISSIVEFRESNEL: boolean;
  102885. FRESNEL: boolean;
  102886. NORMAL: boolean;
  102887. UV1: boolean;
  102888. UV2: boolean;
  102889. VERTEXCOLOR: boolean;
  102890. VERTEXALPHA: boolean;
  102891. NUM_BONE_INFLUENCERS: number;
  102892. BonesPerMesh: number;
  102893. BONETEXTURE: boolean;
  102894. INSTANCES: boolean;
  102895. GLOSSINESS: boolean;
  102896. ROUGHNESS: boolean;
  102897. EMISSIVEASILLUMINATION: boolean;
  102898. LINKEMISSIVEWITHDIFFUSE: boolean;
  102899. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102900. LIGHTMAP: boolean;
  102901. LIGHTMAPDIRECTUV: number;
  102902. OBJECTSPACE_NORMALMAP: boolean;
  102903. USELIGHTMAPASSHADOWMAP: boolean;
  102904. REFLECTIONMAP_3D: boolean;
  102905. REFLECTIONMAP_SPHERICAL: boolean;
  102906. REFLECTIONMAP_PLANAR: boolean;
  102907. REFLECTIONMAP_CUBIC: boolean;
  102908. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102909. REFLECTIONMAP_PROJECTION: boolean;
  102910. REFLECTIONMAP_SKYBOX: boolean;
  102911. REFLECTIONMAP_EXPLICIT: boolean;
  102912. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102913. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102914. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102915. INVERTCUBICMAP: boolean;
  102916. LOGARITHMICDEPTH: boolean;
  102917. REFRACTION: boolean;
  102918. REFRACTIONMAP_3D: boolean;
  102919. REFLECTIONOVERALPHA: boolean;
  102920. TWOSIDEDLIGHTING: boolean;
  102921. SHADOWFLOAT: boolean;
  102922. MORPHTARGETS: boolean;
  102923. MORPHTARGETS_NORMAL: boolean;
  102924. MORPHTARGETS_TANGENT: boolean;
  102925. MORPHTARGETS_UV: boolean;
  102926. NUM_MORPH_INFLUENCERS: number;
  102927. NONUNIFORMSCALING: boolean;
  102928. PREMULTIPLYALPHA: boolean;
  102929. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  102930. ALPHABLEND: boolean;
  102931. IMAGEPROCESSING: boolean;
  102932. VIGNETTE: boolean;
  102933. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102934. VIGNETTEBLENDMODEOPAQUE: boolean;
  102935. TONEMAPPING: boolean;
  102936. TONEMAPPING_ACES: boolean;
  102937. CONTRAST: boolean;
  102938. COLORCURVES: boolean;
  102939. COLORGRADING: boolean;
  102940. COLORGRADING3D: boolean;
  102941. SAMPLER3DGREENDEPTH: boolean;
  102942. SAMPLER3DBGRMAP: boolean;
  102943. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102944. MULTIVIEW: boolean;
  102945. /**
  102946. * If the reflection texture on this material is in linear color space
  102947. * @hidden
  102948. */
  102949. IS_REFLECTION_LINEAR: boolean;
  102950. /**
  102951. * If the refraction texture on this material is in linear color space
  102952. * @hidden
  102953. */
  102954. IS_REFRACTION_LINEAR: boolean;
  102955. EXPOSURE: boolean;
  102956. constructor();
  102957. setReflectionMode(modeToEnable: string): void;
  102958. }
  102959. /**
  102960. * This is the default material used in Babylon. It is the best trade off between quality
  102961. * and performances.
  102962. * @see http://doc.babylonjs.com/babylon101/materials
  102963. */
  102964. export class StandardMaterial extends PushMaterial {
  102965. private _diffuseTexture;
  102966. /**
  102967. * The basic texture of the material as viewed under a light.
  102968. */
  102969. diffuseTexture: Nullable<BaseTexture>;
  102970. private _ambientTexture;
  102971. /**
  102972. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102973. */
  102974. ambientTexture: Nullable<BaseTexture>;
  102975. private _opacityTexture;
  102976. /**
  102977. * Define the transparency of the material from a texture.
  102978. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102979. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102980. */
  102981. opacityTexture: Nullable<BaseTexture>;
  102982. private _reflectionTexture;
  102983. /**
  102984. * Define the texture used to display the reflection.
  102985. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102986. */
  102987. reflectionTexture: Nullable<BaseTexture>;
  102988. private _emissiveTexture;
  102989. /**
  102990. * Define texture of the material as if self lit.
  102991. * This will be mixed in the final result even in the absence of light.
  102992. */
  102993. emissiveTexture: Nullable<BaseTexture>;
  102994. private _specularTexture;
  102995. /**
  102996. * Define how the color and intensity of the highlight given by the light in the material.
  102997. */
  102998. specularTexture: Nullable<BaseTexture>;
  102999. private _bumpTexture;
  103000. /**
  103001. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103002. * 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.
  103003. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  103004. */
  103005. bumpTexture: Nullable<BaseTexture>;
  103006. private _lightmapTexture;
  103007. /**
  103008. * Complex lighting can be computationally expensive to compute at runtime.
  103009. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103010. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  103011. */
  103012. lightmapTexture: Nullable<BaseTexture>;
  103013. private _refractionTexture;
  103014. /**
  103015. * Define the texture used to display the refraction.
  103016. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103017. */
  103018. refractionTexture: Nullable<BaseTexture>;
  103019. /**
  103020. * The color of the material lit by the environmental background lighting.
  103021. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103022. */
  103023. ambientColor: Color3;
  103024. /**
  103025. * The basic color of the material as viewed under a light.
  103026. */
  103027. diffuseColor: Color3;
  103028. /**
  103029. * Define how the color and intensity of the highlight given by the light in the material.
  103030. */
  103031. specularColor: Color3;
  103032. /**
  103033. * Define the color of the material as if self lit.
  103034. * This will be mixed in the final result even in the absence of light.
  103035. */
  103036. emissiveColor: Color3;
  103037. /**
  103038. * Defines how sharp are the highlights in the material.
  103039. * The bigger the value the sharper giving a more glossy feeling to the result.
  103040. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103041. */
  103042. specularPower: number;
  103043. private _useAlphaFromDiffuseTexture;
  103044. /**
  103045. * Does the transparency come from the diffuse texture alpha channel.
  103046. */
  103047. useAlphaFromDiffuseTexture: boolean;
  103048. private _useEmissiveAsIllumination;
  103049. /**
  103050. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103051. */
  103052. useEmissiveAsIllumination: boolean;
  103053. private _linkEmissiveWithDiffuse;
  103054. /**
  103055. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103056. * the emissive level when the final color is close to one.
  103057. */
  103058. linkEmissiveWithDiffuse: boolean;
  103059. private _useSpecularOverAlpha;
  103060. /**
  103061. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103062. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103063. */
  103064. useSpecularOverAlpha: boolean;
  103065. private _useReflectionOverAlpha;
  103066. /**
  103067. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103068. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103069. */
  103070. useReflectionOverAlpha: boolean;
  103071. private _disableLighting;
  103072. /**
  103073. * Does lights from the scene impacts this material.
  103074. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103075. */
  103076. disableLighting: boolean;
  103077. private _useObjectSpaceNormalMap;
  103078. /**
  103079. * Allows using an object space normal map (instead of tangent space).
  103080. */
  103081. useObjectSpaceNormalMap: boolean;
  103082. private _useParallax;
  103083. /**
  103084. * Is parallax enabled or not.
  103085. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103086. */
  103087. useParallax: boolean;
  103088. private _useParallaxOcclusion;
  103089. /**
  103090. * Is parallax occlusion enabled or not.
  103091. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103092. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103093. */
  103094. useParallaxOcclusion: boolean;
  103095. /**
  103096. * 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.
  103097. */
  103098. parallaxScaleBias: number;
  103099. private _roughness;
  103100. /**
  103101. * Helps to define how blurry the reflections should appears in the material.
  103102. */
  103103. roughness: number;
  103104. /**
  103105. * In case of refraction, define the value of the index of refraction.
  103106. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103107. */
  103108. indexOfRefraction: number;
  103109. /**
  103110. * Invert the refraction texture alongside the y axis.
  103111. * It can be useful with procedural textures or probe for instance.
  103112. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103113. */
  103114. invertRefractionY: boolean;
  103115. /**
  103116. * Defines the alpha limits in alpha test mode.
  103117. */
  103118. alphaCutOff: number;
  103119. private _useLightmapAsShadowmap;
  103120. /**
  103121. * In case of light mapping, define whether the map contains light or shadow informations.
  103122. */
  103123. useLightmapAsShadowmap: boolean;
  103124. private _diffuseFresnelParameters;
  103125. /**
  103126. * Define the diffuse fresnel parameters of the material.
  103127. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103128. */
  103129. diffuseFresnelParameters: FresnelParameters;
  103130. private _opacityFresnelParameters;
  103131. /**
  103132. * Define the opacity fresnel parameters of the material.
  103133. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103134. */
  103135. opacityFresnelParameters: FresnelParameters;
  103136. private _reflectionFresnelParameters;
  103137. /**
  103138. * Define the reflection fresnel parameters of the material.
  103139. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103140. */
  103141. reflectionFresnelParameters: FresnelParameters;
  103142. private _refractionFresnelParameters;
  103143. /**
  103144. * Define the refraction fresnel parameters of the material.
  103145. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103146. */
  103147. refractionFresnelParameters: FresnelParameters;
  103148. private _emissiveFresnelParameters;
  103149. /**
  103150. * Define the emissive fresnel parameters of the material.
  103151. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103152. */
  103153. emissiveFresnelParameters: FresnelParameters;
  103154. private _useReflectionFresnelFromSpecular;
  103155. /**
  103156. * If true automatically deducts the fresnels values from the material specularity.
  103157. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103158. */
  103159. useReflectionFresnelFromSpecular: boolean;
  103160. private _useGlossinessFromSpecularMapAlpha;
  103161. /**
  103162. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103163. */
  103164. useGlossinessFromSpecularMapAlpha: boolean;
  103165. private _maxSimultaneousLights;
  103166. /**
  103167. * Defines the maximum number of lights that can be used in the material
  103168. */
  103169. maxSimultaneousLights: number;
  103170. private _invertNormalMapX;
  103171. /**
  103172. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103173. */
  103174. invertNormalMapX: boolean;
  103175. private _invertNormalMapY;
  103176. /**
  103177. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103178. */
  103179. invertNormalMapY: boolean;
  103180. private _twoSidedLighting;
  103181. /**
  103182. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103183. */
  103184. twoSidedLighting: boolean;
  103185. /**
  103186. * Default configuration related to image processing available in the standard Material.
  103187. */
  103188. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103189. /**
  103190. * Gets the image processing configuration used either in this material.
  103191. */
  103192. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103193. /**
  103194. * Sets the Default image processing configuration used either in the this material.
  103195. *
  103196. * If sets to null, the scene one is in use.
  103197. */
  103198. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103199. /**
  103200. * Keep track of the image processing observer to allow dispose and replace.
  103201. */
  103202. private _imageProcessingObserver;
  103203. /**
  103204. * Attaches a new image processing configuration to the Standard Material.
  103205. * @param configuration
  103206. */
  103207. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103208. /**
  103209. * Gets wether the color curves effect is enabled.
  103210. */
  103211. get cameraColorCurvesEnabled(): boolean;
  103212. /**
  103213. * Sets wether the color curves effect is enabled.
  103214. */
  103215. set cameraColorCurvesEnabled(value: boolean);
  103216. /**
  103217. * Gets wether the color grading effect is enabled.
  103218. */
  103219. get cameraColorGradingEnabled(): boolean;
  103220. /**
  103221. * Gets wether the color grading effect is enabled.
  103222. */
  103223. set cameraColorGradingEnabled(value: boolean);
  103224. /**
  103225. * Gets wether tonemapping is enabled or not.
  103226. */
  103227. get cameraToneMappingEnabled(): boolean;
  103228. /**
  103229. * Sets wether tonemapping is enabled or not
  103230. */
  103231. set cameraToneMappingEnabled(value: boolean);
  103232. /**
  103233. * The camera exposure used on this material.
  103234. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103235. * This corresponds to a photographic exposure.
  103236. */
  103237. get cameraExposure(): number;
  103238. /**
  103239. * The camera exposure used on this material.
  103240. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103241. * This corresponds to a photographic exposure.
  103242. */
  103243. set cameraExposure(value: number);
  103244. /**
  103245. * Gets The camera contrast used on this material.
  103246. */
  103247. get cameraContrast(): number;
  103248. /**
  103249. * Sets The camera contrast used on this material.
  103250. */
  103251. set cameraContrast(value: number);
  103252. /**
  103253. * Gets the Color Grading 2D Lookup Texture.
  103254. */
  103255. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103256. /**
  103257. * Sets the Color Grading 2D Lookup Texture.
  103258. */
  103259. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103260. /**
  103261. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103262. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103263. * 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;
  103264. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103265. */
  103266. get cameraColorCurves(): Nullable<ColorCurves>;
  103267. /**
  103268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103270. * 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;
  103271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103272. */
  103273. set cameraColorCurves(value: Nullable<ColorCurves>);
  103274. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103275. protected _worldViewProjectionMatrix: Matrix;
  103276. protected _globalAmbientColor: Color3;
  103277. protected _useLogarithmicDepth: boolean;
  103278. protected _rebuildInParallel: boolean;
  103279. /**
  103280. * Instantiates a new standard material.
  103281. * This is the default material used in Babylon. It is the best trade off between quality
  103282. * and performances.
  103283. * @see http://doc.babylonjs.com/babylon101/materials
  103284. * @param name Define the name of the material in the scene
  103285. * @param scene Define the scene the material belong to
  103286. */
  103287. constructor(name: string, scene: Scene);
  103288. /**
  103289. * Gets a boolean indicating that current material needs to register RTT
  103290. */
  103291. get hasRenderTargetTextures(): boolean;
  103292. /**
  103293. * Gets the current class name of the material e.g. "StandardMaterial"
  103294. * Mainly use in serialization.
  103295. * @returns the class name
  103296. */
  103297. getClassName(): string;
  103298. /**
  103299. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103300. * You can try switching to logarithmic depth.
  103301. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103302. */
  103303. get useLogarithmicDepth(): boolean;
  103304. set useLogarithmicDepth(value: boolean);
  103305. /**
  103306. * Specifies if the material will require alpha blending
  103307. * @returns a boolean specifying if alpha blending is needed
  103308. */
  103309. needAlphaBlending(): boolean;
  103310. /**
  103311. * Specifies if this material should be rendered in alpha test mode
  103312. * @returns a boolean specifying if an alpha test is needed.
  103313. */
  103314. needAlphaTesting(): boolean;
  103315. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103316. /**
  103317. * Get the texture used for alpha test purpose.
  103318. * @returns the diffuse texture in case of the standard material.
  103319. */
  103320. getAlphaTestTexture(): Nullable<BaseTexture>;
  103321. /**
  103322. * Get if the submesh is ready to be used and all its information available.
  103323. * Child classes can use it to update shaders
  103324. * @param mesh defines the mesh to check
  103325. * @param subMesh defines which submesh to check
  103326. * @param useInstances specifies that instances should be used
  103327. * @returns a boolean indicating that the submesh is ready or not
  103328. */
  103329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103330. /**
  103331. * Builds the material UBO layouts.
  103332. * Used internally during the effect preparation.
  103333. */
  103334. buildUniformLayout(): void;
  103335. /**
  103336. * Unbinds the material from the mesh
  103337. */
  103338. unbind(): void;
  103339. /**
  103340. * Binds the submesh to this material by preparing the effect and shader to draw
  103341. * @param world defines the world transformation matrix
  103342. * @param mesh defines the mesh containing the submesh
  103343. * @param subMesh defines the submesh to bind the material to
  103344. */
  103345. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103346. /**
  103347. * Get the list of animatables in the material.
  103348. * @returns the list of animatables object used in the material
  103349. */
  103350. getAnimatables(): IAnimatable[];
  103351. /**
  103352. * Gets the active textures from the material
  103353. * @returns an array of textures
  103354. */
  103355. getActiveTextures(): BaseTexture[];
  103356. /**
  103357. * Specifies if the material uses a texture
  103358. * @param texture defines the texture to check against the material
  103359. * @returns a boolean specifying if the material uses the texture
  103360. */
  103361. hasTexture(texture: BaseTexture): boolean;
  103362. /**
  103363. * Disposes the material
  103364. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103365. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103366. */
  103367. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103368. /**
  103369. * Makes a duplicate of the material, and gives it a new name
  103370. * @param name defines the new name for the duplicated material
  103371. * @returns the cloned material
  103372. */
  103373. clone(name: string): StandardMaterial;
  103374. /**
  103375. * Serializes this material in a JSON representation
  103376. * @returns the serialized material object
  103377. */
  103378. serialize(): any;
  103379. /**
  103380. * Creates a standard material from parsed material data
  103381. * @param source defines the JSON representation of the material
  103382. * @param scene defines the hosting scene
  103383. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103384. * @returns a new standard material
  103385. */
  103386. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103387. /**
  103388. * Are diffuse textures enabled in the application.
  103389. */
  103390. static get DiffuseTextureEnabled(): boolean;
  103391. static set DiffuseTextureEnabled(value: boolean);
  103392. /**
  103393. * Are ambient textures enabled in the application.
  103394. */
  103395. static get AmbientTextureEnabled(): boolean;
  103396. static set AmbientTextureEnabled(value: boolean);
  103397. /**
  103398. * Are opacity textures enabled in the application.
  103399. */
  103400. static get OpacityTextureEnabled(): boolean;
  103401. static set OpacityTextureEnabled(value: boolean);
  103402. /**
  103403. * Are reflection textures enabled in the application.
  103404. */
  103405. static get ReflectionTextureEnabled(): boolean;
  103406. static set ReflectionTextureEnabled(value: boolean);
  103407. /**
  103408. * Are emissive textures enabled in the application.
  103409. */
  103410. static get EmissiveTextureEnabled(): boolean;
  103411. static set EmissiveTextureEnabled(value: boolean);
  103412. /**
  103413. * Are specular textures enabled in the application.
  103414. */
  103415. static get SpecularTextureEnabled(): boolean;
  103416. static set SpecularTextureEnabled(value: boolean);
  103417. /**
  103418. * Are bump textures enabled in the application.
  103419. */
  103420. static get BumpTextureEnabled(): boolean;
  103421. static set BumpTextureEnabled(value: boolean);
  103422. /**
  103423. * Are lightmap textures enabled in the application.
  103424. */
  103425. static get LightmapTextureEnabled(): boolean;
  103426. static set LightmapTextureEnabled(value: boolean);
  103427. /**
  103428. * Are refraction textures enabled in the application.
  103429. */
  103430. static get RefractionTextureEnabled(): boolean;
  103431. static set RefractionTextureEnabled(value: boolean);
  103432. /**
  103433. * Are color grading textures enabled in the application.
  103434. */
  103435. static get ColorGradingTextureEnabled(): boolean;
  103436. static set ColorGradingTextureEnabled(value: boolean);
  103437. /**
  103438. * Are fresnels enabled in the application.
  103439. */
  103440. static get FresnelEnabled(): boolean;
  103441. static set FresnelEnabled(value: boolean);
  103442. }
  103443. }
  103444. declare module BABYLON {
  103445. /**
  103446. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  103447. *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.
  103448. * The SPS is also a particle system. It provides some methods to manage the particles.
  103449. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  103450. *
  103451. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  103452. */
  103453. export class SolidParticleSystem implements IDisposable {
  103454. /**
  103455. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  103456. * Example : var p = SPS.particles[i];
  103457. */
  103458. particles: SolidParticle[];
  103459. /**
  103460. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  103461. */
  103462. nbParticles: number;
  103463. /**
  103464. * If the particles must ever face the camera (default false). Useful for planar particles.
  103465. */
  103466. billboard: boolean;
  103467. /**
  103468. * Recompute normals when adding a shape
  103469. */
  103470. recomputeNormals: boolean;
  103471. /**
  103472. * This a counter ofr your own usage. It's not set by any SPS functions.
  103473. */
  103474. counter: number;
  103475. /**
  103476. * The SPS name. This name is also given to the underlying mesh.
  103477. */
  103478. name: string;
  103479. /**
  103480. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  103481. */
  103482. mesh: Mesh;
  103483. /**
  103484. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  103485. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  103486. */
  103487. vars: any;
  103488. /**
  103489. * This array is populated when the SPS is set as 'pickable'.
  103490. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  103491. * Each element of this array is an object `{idx: int, faceId: int}`.
  103492. * `idx` is the picked particle index in the `SPS.particles` array
  103493. * `faceId` is the picked face index counted within this particle.
  103494. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  103495. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  103496. * Use the method SPS.pickedParticle(pickingInfo) instead.
  103497. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103498. */
  103499. pickedParticles: {
  103500. idx: number;
  103501. faceId: number;
  103502. }[];
  103503. /**
  103504. * This array is populated when the SPS is set as 'pickable'
  103505. * Each key of this array is a submesh index.
  103506. * Each element of this array is a second array defined like this :
  103507. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  103508. * Each element of this second array is an object `{idx: int, faceId: int}`.
  103509. * `idx` is the picked particle index in the `SPS.particles` array
  103510. * `faceId` is the picked face index counted within this particle.
  103511. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  103512. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103513. */
  103514. pickedBySubMesh: {
  103515. idx: number;
  103516. faceId: number;
  103517. }[][];
  103518. /**
  103519. * This array is populated when `enableDepthSort` is set to true.
  103520. * Each element of this array is an instance of the class DepthSortedParticle.
  103521. */
  103522. depthSortedParticles: DepthSortedParticle[];
  103523. /**
  103524. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  103525. * @hidden
  103526. */
  103527. _bSphereOnly: boolean;
  103528. /**
  103529. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  103530. * @hidden
  103531. */
  103532. _bSphereRadiusFactor: number;
  103533. private _scene;
  103534. private _positions;
  103535. private _indices;
  103536. private _normals;
  103537. private _colors;
  103538. private _uvs;
  103539. private _indices32;
  103540. private _positions32;
  103541. private _normals32;
  103542. private _fixedNormal32;
  103543. private _colors32;
  103544. private _uvs32;
  103545. private _index;
  103546. private _updatable;
  103547. private _pickable;
  103548. private _isVisibilityBoxLocked;
  103549. private _alwaysVisible;
  103550. private _depthSort;
  103551. private _expandable;
  103552. private _shapeCounter;
  103553. private _copy;
  103554. private _color;
  103555. private _computeParticleColor;
  103556. private _computeParticleTexture;
  103557. private _computeParticleRotation;
  103558. private _computeParticleVertex;
  103559. private _computeBoundingBox;
  103560. private _depthSortParticles;
  103561. private _camera;
  103562. private _mustUnrotateFixedNormals;
  103563. private _particlesIntersect;
  103564. private _needs32Bits;
  103565. private _isNotBuilt;
  103566. private _lastParticleId;
  103567. private _idxOfId;
  103568. private _multimaterialEnabled;
  103569. private _useModelMaterial;
  103570. private _indicesByMaterial;
  103571. private _materialIndexes;
  103572. private _depthSortFunction;
  103573. private _materialSortFunction;
  103574. private _materials;
  103575. private _multimaterial;
  103576. private _materialIndexesById;
  103577. private _defaultMaterial;
  103578. private _autoUpdateSubMeshes;
  103579. private _tmpVertex;
  103580. /**
  103581. * Creates a SPS (Solid Particle System) object.
  103582. * @param name (String) is the SPS name, this will be the underlying mesh name.
  103583. * @param scene (Scene) is the scene in which the SPS is added.
  103584. * @param options defines the options of the sps e.g.
  103585. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  103586. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  103587. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  103588. * * 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.
  103589. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  103590. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  103591. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  103592. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  103593. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  103594. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  103595. */
  103596. constructor(name: string, scene: Scene, options?: {
  103597. updatable?: boolean;
  103598. isPickable?: boolean;
  103599. enableDepthSort?: boolean;
  103600. particleIntersection?: boolean;
  103601. boundingSphereOnly?: boolean;
  103602. bSphereRadiusFactor?: number;
  103603. expandable?: boolean;
  103604. useModelMaterial?: boolean;
  103605. enableMultiMaterial?: boolean;
  103606. });
  103607. /**
  103608. * Builds the SPS underlying mesh. Returns a standard Mesh.
  103609. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  103610. * @returns the created mesh
  103611. */
  103612. buildMesh(): Mesh;
  103613. /**
  103614. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  103615. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  103616. * Thus the particles generated from `digest()` have their property `position` set yet.
  103617. * @param mesh ( Mesh ) is the mesh to be digested
  103618. * @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
  103619. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  103620. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  103621. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103622. * @returns the current SPS
  103623. */
  103624. digest(mesh: Mesh, options?: {
  103625. facetNb?: number;
  103626. number?: number;
  103627. delta?: number;
  103628. storage?: [];
  103629. }): SolidParticleSystem;
  103630. /**
  103631. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  103632. * @hidden
  103633. */
  103634. private _unrotateFixedNormals;
  103635. /**
  103636. * Resets the temporary working copy particle
  103637. * @hidden
  103638. */
  103639. private _resetCopy;
  103640. /**
  103641. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  103642. * @param p the current index in the positions array to be updated
  103643. * @param ind the current index in the indices array
  103644. * @param shape a Vector3 array, the shape geometry
  103645. * @param positions the positions array to be updated
  103646. * @param meshInd the shape indices array
  103647. * @param indices the indices array to be updated
  103648. * @param meshUV the shape uv array
  103649. * @param uvs the uv array to be updated
  103650. * @param meshCol the shape color array
  103651. * @param colors the color array to be updated
  103652. * @param meshNor the shape normals array
  103653. * @param normals the normals array to be updated
  103654. * @param idx the particle index
  103655. * @param idxInShape the particle index in its shape
  103656. * @param options the addShape() method passed options
  103657. * @model the particle model
  103658. * @hidden
  103659. */
  103660. private _meshBuilder;
  103661. /**
  103662. * Returns a shape Vector3 array from positions float array
  103663. * @param positions float array
  103664. * @returns a vector3 array
  103665. * @hidden
  103666. */
  103667. private _posToShape;
  103668. /**
  103669. * Returns a shapeUV array from a float uvs (array deep copy)
  103670. * @param uvs as a float array
  103671. * @returns a shapeUV array
  103672. * @hidden
  103673. */
  103674. private _uvsToShapeUV;
  103675. /**
  103676. * Adds a new particle object in the particles array
  103677. * @param idx particle index in particles array
  103678. * @param id particle id
  103679. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  103680. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  103681. * @param model particle ModelShape object
  103682. * @param shapeId model shape identifier
  103683. * @param idxInShape index of the particle in the current model
  103684. * @param bInfo model bounding info object
  103685. * @param storage target storage array, if any
  103686. * @hidden
  103687. */
  103688. private _addParticle;
  103689. /**
  103690. * Adds some particles to the SPS from the model shape. Returns the shape id.
  103691. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  103692. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  103693. * @param nb (positive integer) the number of particles to be created from this model
  103694. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  103695. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  103696. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103697. * @returns the number of shapes in the system
  103698. */
  103699. addShape(mesh: Mesh, nb: number, options?: {
  103700. positionFunction?: any;
  103701. vertexFunction?: any;
  103702. storage?: [];
  103703. }): number;
  103704. /**
  103705. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  103706. * @hidden
  103707. */
  103708. private _rebuildParticle;
  103709. /**
  103710. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  103711. * @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.
  103712. * @returns the SPS.
  103713. */
  103714. rebuildMesh(reset?: boolean): SolidParticleSystem;
  103715. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  103716. * Returns an array with the removed particles.
  103717. * 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.
  103718. * The SPS can't be empty so at least one particle needs to remain in place.
  103719. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  103720. * @param start index of the first particle to remove
  103721. * @param end index of the last particle to remove (included)
  103722. * @returns an array populated with the removed particles
  103723. */
  103724. removeParticles(start: number, end: number): SolidParticle[];
  103725. /**
  103726. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  103727. * @param solidParticleArray an array populated with Solid Particles objects
  103728. * @returns the SPS
  103729. */
  103730. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  103731. /**
  103732. * Creates a new particle and modifies the SPS mesh geometry :
  103733. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  103734. * - calls _addParticle() to populate the particle array
  103735. * factorized code from addShape() and insertParticlesFromArray()
  103736. * @param idx particle index in the particles array
  103737. * @param i particle index in its shape
  103738. * @param modelShape particle ModelShape object
  103739. * @param shape shape vertex array
  103740. * @param meshInd shape indices array
  103741. * @param meshUV shape uv array
  103742. * @param meshCol shape color array
  103743. * @param meshNor shape normals array
  103744. * @param bbInfo shape bounding info
  103745. * @param storage target particle storage
  103746. * @options addShape() passed options
  103747. * @hidden
  103748. */
  103749. private _insertNewParticle;
  103750. /**
  103751. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  103752. * This method calls `updateParticle()` for each particle of the SPS.
  103753. * For an animated SPS, it is usually called within the render loop.
  103754. * 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.
  103755. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  103756. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  103757. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  103758. * @returns the SPS.
  103759. */
  103760. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  103761. /**
  103762. * Disposes the SPS.
  103763. */
  103764. dispose(): void;
  103765. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  103766. * idx is the particle index in the SPS
  103767. * faceId is the picked face index counted within this particle.
  103768. * Returns null if the pickInfo can't identify a picked particle.
  103769. * @param pickingInfo (PickingInfo object)
  103770. * @returns {idx: number, faceId: number} or null
  103771. */
  103772. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  103773. idx: number;
  103774. faceId: number;
  103775. }>;
  103776. /**
  103777. * Returns a SolidParticle object from its identifier : particle.id
  103778. * @param id (integer) the particle Id
  103779. * @returns the searched particle or null if not found in the SPS.
  103780. */
  103781. getParticleById(id: number): Nullable<SolidParticle>;
  103782. /**
  103783. * Returns a new array populated with the particles having the passed shapeId.
  103784. * @param shapeId (integer) the shape identifier
  103785. * @returns a new solid particle array
  103786. */
  103787. getParticlesByShapeId(shapeId: number): SolidParticle[];
  103788. /**
  103789. * Populates the passed array "ref" with the particles having the passed shapeId.
  103790. * @param shapeId the shape identifier
  103791. * @returns the SPS
  103792. * @param ref
  103793. */
  103794. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  103795. /**
  103796. * Computes the required SubMeshes according the materials assigned to the particles.
  103797. * @returns the solid particle system.
  103798. * Does nothing if called before the SPS mesh is built.
  103799. */
  103800. computeSubMeshes(): SolidParticleSystem;
  103801. /**
  103802. * Sorts the solid particles by material when MultiMaterial is enabled.
  103803. * Updates the indices32 array.
  103804. * Updates the indicesByMaterial array.
  103805. * Updates the mesh indices array.
  103806. * @returns the SPS
  103807. * @hidden
  103808. */
  103809. private _sortParticlesByMaterial;
  103810. /**
  103811. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  103812. * @hidden
  103813. */
  103814. private _setMaterialIndexesById;
  103815. /**
  103816. * Returns an array with unique values of Materials from the passed array
  103817. * @param array the material array to be checked and filtered
  103818. * @hidden
  103819. */
  103820. private _filterUniqueMaterialId;
  103821. /**
  103822. * Sets a new Standard Material as _defaultMaterial if not already set.
  103823. * @hidden
  103824. */
  103825. private _setDefaultMaterial;
  103826. /**
  103827. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  103828. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103829. * @returns the SPS.
  103830. */
  103831. refreshVisibleSize(): SolidParticleSystem;
  103832. /**
  103833. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  103834. * @param size the size (float) of the visibility box
  103835. * note : this doesn't lock the SPS mesh bounding box.
  103836. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103837. */
  103838. setVisibilityBox(size: number): void;
  103839. /**
  103840. * Gets whether the SPS as always visible or not
  103841. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103842. */
  103843. get isAlwaysVisible(): boolean;
  103844. /**
  103845. * Sets the SPS as always visible or not
  103846. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103847. */
  103848. set isAlwaysVisible(val: boolean);
  103849. /**
  103850. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103851. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103852. */
  103853. set isVisibilityBoxLocked(val: boolean);
  103854. /**
  103855. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103856. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103857. */
  103858. get isVisibilityBoxLocked(): boolean;
  103859. /**
  103860. * Tells to `setParticles()` to compute the particle rotations or not.
  103861. * Default value : true. The SPS is faster when it's set to false.
  103862. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103863. */
  103864. set computeParticleRotation(val: boolean);
  103865. /**
  103866. * Tells to `setParticles()` to compute the particle colors or not.
  103867. * Default value : true. The SPS is faster when it's set to false.
  103868. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103869. */
  103870. set computeParticleColor(val: boolean);
  103871. set computeParticleTexture(val: boolean);
  103872. /**
  103873. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  103874. * Default value : false. The SPS is faster when it's set to false.
  103875. * Note : the particle custom vertex positions aren't stored values.
  103876. */
  103877. set computeParticleVertex(val: boolean);
  103878. /**
  103879. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  103880. */
  103881. set computeBoundingBox(val: boolean);
  103882. /**
  103883. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  103884. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103885. * Default : `true`
  103886. */
  103887. set depthSortParticles(val: boolean);
  103888. /**
  103889. * Gets if `setParticles()` computes the particle rotations or not.
  103890. * Default value : true. The SPS is faster when it's set to false.
  103891. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103892. */
  103893. get computeParticleRotation(): boolean;
  103894. /**
  103895. * Gets if `setParticles()` computes the particle colors or not.
  103896. * Default value : true. The SPS is faster when it's set to false.
  103897. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103898. */
  103899. get computeParticleColor(): boolean;
  103900. /**
  103901. * Gets if `setParticles()` computes the particle textures or not.
  103902. * Default value : true. The SPS is faster when it's set to false.
  103903. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  103904. */
  103905. get computeParticleTexture(): boolean;
  103906. /**
  103907. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  103908. * Default value : false. The SPS is faster when it's set to false.
  103909. * Note : the particle custom vertex positions aren't stored values.
  103910. */
  103911. get computeParticleVertex(): boolean;
  103912. /**
  103913. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  103914. */
  103915. get computeBoundingBox(): boolean;
  103916. /**
  103917. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  103918. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103919. * Default : `true`
  103920. */
  103921. get depthSortParticles(): boolean;
  103922. /**
  103923. * Gets if the SPS is created as expandable at construction time.
  103924. * Default : `false`
  103925. */
  103926. get expandable(): boolean;
  103927. /**
  103928. * Gets if the SPS supports the Multi Materials
  103929. */
  103930. get multimaterialEnabled(): boolean;
  103931. /**
  103932. * Gets if the SPS uses the model materials for its own multimaterial.
  103933. */
  103934. get useModelMaterial(): boolean;
  103935. /**
  103936. * The SPS used material array.
  103937. */
  103938. get materials(): Material[];
  103939. /**
  103940. * Sets the SPS MultiMaterial from the passed materials.
  103941. * Note : the passed array is internally copied and not used then by reference.
  103942. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  103943. */
  103944. setMultiMaterial(materials: Material[]): void;
  103945. /**
  103946. * The SPS computed multimaterial object
  103947. */
  103948. get multimaterial(): MultiMaterial;
  103949. set multimaterial(mm: MultiMaterial);
  103950. /**
  103951. * If the subMeshes must be updated on the next call to setParticles()
  103952. */
  103953. get autoUpdateSubMeshes(): boolean;
  103954. set autoUpdateSubMeshes(val: boolean);
  103955. /**
  103956. * This function does nothing. It may be overwritten to set all the particle first values.
  103957. * The SPS doesn't call this function, you may have to call it by your own.
  103958. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103959. */
  103960. initParticles(): void;
  103961. /**
  103962. * This function does nothing. It may be overwritten to recycle a particle.
  103963. * The SPS doesn't call this function, you may have to call it by your own.
  103964. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103965. * @param particle The particle to recycle
  103966. * @returns the recycled particle
  103967. */
  103968. recycleParticle(particle: SolidParticle): SolidParticle;
  103969. /**
  103970. * Updates a particle : this function should be overwritten by the user.
  103971. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  103972. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103973. * @example : just set a particle position or velocity and recycle conditions
  103974. * @param particle The particle to update
  103975. * @returns the updated particle
  103976. */
  103977. updateParticle(particle: SolidParticle): SolidParticle;
  103978. /**
  103979. * Updates a vertex of a particle : it can be overwritten by the user.
  103980. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  103981. * @param particle the current particle
  103982. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  103983. * @param pt the index of the current vertex in the particle shape
  103984. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  103985. * @example : just set a vertex particle position or color
  103986. * @returns the sps
  103987. */
  103988. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  103989. /**
  103990. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  103991. * This does nothing and may be overwritten by the user.
  103992. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103993. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103994. * @param update the boolean update value actually passed to setParticles()
  103995. */
  103996. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103997. /**
  103998. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  103999. * This will be passed three parameters.
  104000. * This does nothing and may be overwritten by the user.
  104001. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  104002. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  104003. * @param update the boolean update value actually passed to setParticles()
  104004. */
  104005. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  104006. }
  104007. }
  104008. declare module BABYLON {
  104009. /**
  104010. * Represents one particle of a solid particle system.
  104011. */
  104012. export class SolidParticle {
  104013. /**
  104014. * particle global index
  104015. */
  104016. idx: number;
  104017. /**
  104018. * particle identifier
  104019. */
  104020. id: number;
  104021. /**
  104022. * The color of the particle
  104023. */
  104024. color: Nullable<Color4>;
  104025. /**
  104026. * The world space position of the particle.
  104027. */
  104028. position: Vector3;
  104029. /**
  104030. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  104031. */
  104032. rotation: Vector3;
  104033. /**
  104034. * The world space rotation quaternion of the particle.
  104035. */
  104036. rotationQuaternion: Nullable<Quaternion>;
  104037. /**
  104038. * The scaling of the particle.
  104039. */
  104040. scaling: Vector3;
  104041. /**
  104042. * The uvs of the particle.
  104043. */
  104044. uvs: Vector4;
  104045. /**
  104046. * The current speed of the particle.
  104047. */
  104048. velocity: Vector3;
  104049. /**
  104050. * The pivot point in the particle local space.
  104051. */
  104052. pivot: Vector3;
  104053. /**
  104054. * Must the particle be translated from its pivot point in its local space ?
  104055. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  104056. * Default : false
  104057. */
  104058. translateFromPivot: boolean;
  104059. /**
  104060. * Is the particle active or not ?
  104061. */
  104062. alive: boolean;
  104063. /**
  104064. * Is the particle visible or not ?
  104065. */
  104066. isVisible: boolean;
  104067. /**
  104068. * Index of this particle in the global "positions" array (Internal use)
  104069. * @hidden
  104070. */
  104071. _pos: number;
  104072. /**
  104073. * @hidden Index of this particle in the global "indices" array (Internal use)
  104074. */
  104075. _ind: number;
  104076. /**
  104077. * @hidden ModelShape of this particle (Internal use)
  104078. */
  104079. _model: ModelShape;
  104080. /**
  104081. * ModelShape id of this particle
  104082. */
  104083. shapeId: number;
  104084. /**
  104085. * Index of the particle in its shape id
  104086. */
  104087. idxInShape: number;
  104088. /**
  104089. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  104090. */
  104091. _modelBoundingInfo: BoundingInfo;
  104092. /**
  104093. * @hidden Particle BoundingInfo object (Internal use)
  104094. */
  104095. _boundingInfo: BoundingInfo;
  104096. /**
  104097. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  104098. */
  104099. _sps: SolidParticleSystem;
  104100. /**
  104101. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  104102. */
  104103. _stillInvisible: boolean;
  104104. /**
  104105. * @hidden Last computed particle rotation matrix
  104106. */
  104107. _rotationMatrix: number[];
  104108. /**
  104109. * Parent particle Id, if any.
  104110. * Default null.
  104111. */
  104112. parentId: Nullable<number>;
  104113. /**
  104114. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  104115. */
  104116. materialIndex: Nullable<number>;
  104117. /**
  104118. * Custom object or properties.
  104119. */
  104120. props: Nullable<any>;
  104121. /**
  104122. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  104123. * The possible values are :
  104124. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104125. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104126. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104127. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104128. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104129. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  104130. * */
  104131. cullingStrategy: number;
  104132. /**
  104133. * @hidden Internal global position in the SPS.
  104134. */
  104135. _globalPosition: Vector3;
  104136. /**
  104137. * Creates a Solid Particle object.
  104138. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  104139. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  104140. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  104141. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  104142. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  104143. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  104144. * @param shapeId (integer) is the model shape identifier in the SPS.
  104145. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  104146. * @param sps defines the sps it is associated to
  104147. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  104148. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  104149. */
  104150. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  104151. /**
  104152. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  104153. * @param target the particle target
  104154. * @returns the current particle
  104155. */
  104156. copyToRef(target: SolidParticle): SolidParticle;
  104157. /**
  104158. * Legacy support, changed scale to scaling
  104159. */
  104160. get scale(): Vector3;
  104161. /**
  104162. * Legacy support, changed scale to scaling
  104163. */
  104164. set scale(scale: Vector3);
  104165. /**
  104166. * Legacy support, changed quaternion to rotationQuaternion
  104167. */
  104168. get quaternion(): Nullable<Quaternion>;
  104169. /**
  104170. * Legacy support, changed quaternion to rotationQuaternion
  104171. */
  104172. set quaternion(q: Nullable<Quaternion>);
  104173. /**
  104174. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  104175. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  104176. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  104177. * @returns true if it intersects
  104178. */
  104179. intersectsMesh(target: Mesh | SolidParticle): boolean;
  104180. /**
  104181. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  104182. * A particle is in the frustum if its bounding box intersects the frustum
  104183. * @param frustumPlanes defines the frustum to test
  104184. * @returns true if the particle is in the frustum planes
  104185. */
  104186. isInFrustum(frustumPlanes: Plane[]): boolean;
  104187. /**
  104188. * get the rotation matrix of the particle
  104189. * @hidden
  104190. */
  104191. getRotationMatrix(m: Matrix): void;
  104192. }
  104193. /**
  104194. * Represents the shape of the model used by one particle of a solid particle system.
  104195. * SPS internal tool, don't use it manually.
  104196. */
  104197. export class ModelShape {
  104198. /**
  104199. * The shape id
  104200. * @hidden
  104201. */
  104202. shapeID: number;
  104203. /**
  104204. * flat array of model positions (internal use)
  104205. * @hidden
  104206. */
  104207. _shape: Vector3[];
  104208. /**
  104209. * flat array of model UVs (internal use)
  104210. * @hidden
  104211. */
  104212. _shapeUV: number[];
  104213. /**
  104214. * color array of the model
  104215. * @hidden
  104216. */
  104217. _shapeColors: number[];
  104218. /**
  104219. * indices array of the model
  104220. * @hidden
  104221. */
  104222. _indices: number[];
  104223. /**
  104224. * normals array of the model
  104225. * @hidden
  104226. */
  104227. _normals: number[];
  104228. /**
  104229. * length of the shape in the model indices array (internal use)
  104230. * @hidden
  104231. */
  104232. _indicesLength: number;
  104233. /**
  104234. * Custom position function (internal use)
  104235. * @hidden
  104236. */
  104237. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  104238. /**
  104239. * Custom vertex function (internal use)
  104240. * @hidden
  104241. */
  104242. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  104243. /**
  104244. * Model material (internal use)
  104245. * @hidden
  104246. */
  104247. _material: Nullable<Material>;
  104248. /**
  104249. * 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.
  104250. * SPS internal tool, don't use it manually.
  104251. * @hidden
  104252. */
  104253. 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>);
  104254. }
  104255. /**
  104256. * Represents a Depth Sorted Particle in the solid particle system.
  104257. * @hidden
  104258. */
  104259. export class DepthSortedParticle {
  104260. /**
  104261. * Particle index
  104262. */
  104263. idx: number;
  104264. /**
  104265. * Index of the particle in the "indices" array
  104266. */
  104267. ind: number;
  104268. /**
  104269. * Length of the particle shape in the "indices" array
  104270. */
  104271. indicesLength: number;
  104272. /**
  104273. * Squared distance from the particle to the camera
  104274. */
  104275. sqDistance: number;
  104276. /**
  104277. * Material index when used with MultiMaterials
  104278. */
  104279. materialIndex: number;
  104280. /**
  104281. * Creates a new sorted particle
  104282. * @param materialIndex
  104283. */
  104284. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  104285. }
  104286. /**
  104287. * Represents a solid particle vertex
  104288. */
  104289. export class SolidParticleVertex {
  104290. /**
  104291. * Vertex position
  104292. */
  104293. position: Vector3;
  104294. /**
  104295. * Vertex color
  104296. */
  104297. color: Color4;
  104298. /**
  104299. * Vertex UV
  104300. */
  104301. uv: Vector2;
  104302. /**
  104303. * Creates a new solid particle vertex
  104304. */
  104305. constructor();
  104306. /** Vertex x coordinate */
  104307. get x(): number;
  104308. set x(val: number);
  104309. /** Vertex y coordinate */
  104310. get y(): number;
  104311. set y(val: number);
  104312. /** Vertex z coordinate */
  104313. get z(): number;
  104314. set z(val: number);
  104315. }
  104316. }
  104317. declare module BABYLON {
  104318. /**
  104319. * @hidden
  104320. */
  104321. export class _MeshCollisionData {
  104322. _checkCollisions: boolean;
  104323. _collisionMask: number;
  104324. _collisionGroup: number;
  104325. _surroundingMeshes: Nullable<AbstractMesh[]>;
  104326. _collider: Nullable<Collider>;
  104327. _oldPositionForCollisions: Vector3;
  104328. _diffPositionForCollisions: Vector3;
  104329. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  104330. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  104331. }
  104332. }
  104333. declare module BABYLON {
  104334. /** @hidden */
  104335. class _FacetDataStorage {
  104336. facetPositions: Vector3[];
  104337. facetNormals: Vector3[];
  104338. facetPartitioning: number[][];
  104339. facetNb: number;
  104340. partitioningSubdivisions: number;
  104341. partitioningBBoxRatio: number;
  104342. facetDataEnabled: boolean;
  104343. facetParameters: any;
  104344. bbSize: Vector3;
  104345. subDiv: {
  104346. max: number;
  104347. X: number;
  104348. Y: number;
  104349. Z: number;
  104350. };
  104351. facetDepthSort: boolean;
  104352. facetDepthSortEnabled: boolean;
  104353. depthSortedIndices: IndicesArray;
  104354. depthSortedFacets: {
  104355. ind: number;
  104356. sqDistance: number;
  104357. }[];
  104358. facetDepthSortFunction: (f1: {
  104359. ind: number;
  104360. sqDistance: number;
  104361. }, f2: {
  104362. ind: number;
  104363. sqDistance: number;
  104364. }) => number;
  104365. facetDepthSortFrom: Vector3;
  104366. facetDepthSortOrigin: Vector3;
  104367. invertedMatrix: Matrix;
  104368. }
  104369. /**
  104370. * @hidden
  104371. **/
  104372. class _InternalAbstractMeshDataInfo {
  104373. _hasVertexAlpha: boolean;
  104374. _useVertexColors: boolean;
  104375. _numBoneInfluencers: number;
  104376. _applyFog: boolean;
  104377. _receiveShadows: boolean;
  104378. _facetData: _FacetDataStorage;
  104379. _visibility: number;
  104380. _skeleton: Nullable<Skeleton>;
  104381. _layerMask: number;
  104382. _computeBonesUsingShaders: boolean;
  104383. _isActive: boolean;
  104384. _onlyForInstances: boolean;
  104385. _isActiveIntermediate: boolean;
  104386. _onlyForInstancesIntermediate: boolean;
  104387. _actAsRegularMesh: boolean;
  104388. }
  104389. /**
  104390. * Class used to store all common mesh properties
  104391. */
  104392. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  104393. /** No occlusion */
  104394. static OCCLUSION_TYPE_NONE: number;
  104395. /** Occlusion set to optimisitic */
  104396. static OCCLUSION_TYPE_OPTIMISTIC: number;
  104397. /** Occlusion set to strict */
  104398. static OCCLUSION_TYPE_STRICT: number;
  104399. /** Use an accurante occlusion algorithm */
  104400. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  104401. /** Use a conservative occlusion algorithm */
  104402. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  104403. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  104404. * Test order :
  104405. * Is the bounding sphere outside the frustum ?
  104406. * If not, are the bounding box vertices outside the frustum ?
  104407. * It not, then the cullable object is in the frustum.
  104408. */
  104409. static readonly CULLINGSTRATEGY_STANDARD: number;
  104410. /** Culling strategy : Bounding Sphere Only.
  104411. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  104412. * It's also less accurate than the standard because some not visible objects can still be selected.
  104413. * Test : is the bounding sphere outside the frustum ?
  104414. * If not, then the cullable object is in the frustum.
  104415. */
  104416. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  104417. /** Culling strategy : Optimistic Inclusion.
  104418. * This in an inclusion test first, then the standard exclusion test.
  104419. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  104420. * 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.
  104421. * Anyway, it's as accurate as the standard strategy.
  104422. * Test :
  104423. * Is the cullable object bounding sphere center in the frustum ?
  104424. * If not, apply the default culling strategy.
  104425. */
  104426. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  104427. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  104428. * This in an inclusion test first, then the bounding sphere only exclusion test.
  104429. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  104430. * 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.
  104431. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  104432. * Test :
  104433. * Is the cullable object bounding sphere center in the frustum ?
  104434. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  104435. */
  104436. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  104437. /**
  104438. * No billboard
  104439. */
  104440. static get BILLBOARDMODE_NONE(): number;
  104441. /** Billboard on X axis */
  104442. static get BILLBOARDMODE_X(): number;
  104443. /** Billboard on Y axis */
  104444. static get BILLBOARDMODE_Y(): number;
  104445. /** Billboard on Z axis */
  104446. static get BILLBOARDMODE_Z(): number;
  104447. /** Billboard on all axes */
  104448. static get BILLBOARDMODE_ALL(): number;
  104449. /** Billboard on using position instead of orientation */
  104450. static get BILLBOARDMODE_USE_POSITION(): number;
  104451. /** @hidden */
  104452. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  104453. /**
  104454. * The culling strategy to use to check whether the mesh must be rendered or not.
  104455. * This value can be changed at any time and will be used on the next render mesh selection.
  104456. * The possible values are :
  104457. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104458. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104459. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104460. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104461. * Please read each static variable documentation to get details about the culling process.
  104462. * */
  104463. cullingStrategy: number;
  104464. /**
  104465. * Gets the number of facets in the mesh
  104466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104467. */
  104468. get facetNb(): number;
  104469. /**
  104470. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  104471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104472. */
  104473. get partitioningSubdivisions(): number;
  104474. set partitioningSubdivisions(nb: number);
  104475. /**
  104476. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  104477. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  104478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104479. */
  104480. get partitioningBBoxRatio(): number;
  104481. set partitioningBBoxRatio(ratio: number);
  104482. /**
  104483. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  104484. * Works only for updatable meshes.
  104485. * Doesn't work with multi-materials
  104486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104487. */
  104488. get mustDepthSortFacets(): boolean;
  104489. set mustDepthSortFacets(sort: boolean);
  104490. /**
  104491. * The location (Vector3) where the facet depth sort must be computed from.
  104492. * By default, the active camera position.
  104493. * Used only when facet depth sort is enabled
  104494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104495. */
  104496. get facetDepthSortFrom(): Vector3;
  104497. set facetDepthSortFrom(location: Vector3);
  104498. /**
  104499. * gets a boolean indicating if facetData is enabled
  104500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104501. */
  104502. get isFacetDataEnabled(): boolean;
  104503. /** @hidden */
  104504. _updateNonUniformScalingState(value: boolean): boolean;
  104505. /**
  104506. * An event triggered when this mesh collides with another one
  104507. */
  104508. onCollideObservable: Observable<AbstractMesh>;
  104509. /** Set a function to call when this mesh collides with another one */
  104510. set onCollide(callback: () => void);
  104511. /**
  104512. * An event triggered when the collision's position changes
  104513. */
  104514. onCollisionPositionChangeObservable: Observable<Vector3>;
  104515. /** Set a function to call when the collision's position changes */
  104516. set onCollisionPositionChange(callback: () => void);
  104517. /**
  104518. * An event triggered when material is changed
  104519. */
  104520. onMaterialChangedObservable: Observable<AbstractMesh>;
  104521. /**
  104522. * Gets or sets the orientation for POV movement & rotation
  104523. */
  104524. definedFacingForward: boolean;
  104525. /** @hidden */
  104526. _occlusionQuery: Nullable<WebGLQuery>;
  104527. /** @hidden */
  104528. _renderingGroup: Nullable<RenderingGroup>;
  104529. /**
  104530. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104531. */
  104532. get visibility(): number;
  104533. /**
  104534. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104535. */
  104536. set visibility(value: number);
  104537. /** Gets or sets the alpha index used to sort transparent meshes
  104538. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  104539. */
  104540. alphaIndex: number;
  104541. /**
  104542. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  104543. */
  104544. isVisible: boolean;
  104545. /**
  104546. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104547. */
  104548. isPickable: boolean;
  104549. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  104550. showSubMeshesBoundingBox: boolean;
  104551. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  104552. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104553. */
  104554. isBlocker: boolean;
  104555. /**
  104556. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  104557. */
  104558. enablePointerMoveEvents: boolean;
  104559. /**
  104560. * Specifies the rendering group id for this mesh (0 by default)
  104561. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104562. */
  104563. renderingGroupId: number;
  104564. private _material;
  104565. /** Gets or sets current material */
  104566. get material(): Nullable<Material>;
  104567. set material(value: Nullable<Material>);
  104568. /**
  104569. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  104570. * @see http://doc.babylonjs.com/babylon101/shadows
  104571. */
  104572. get receiveShadows(): boolean;
  104573. set receiveShadows(value: boolean);
  104574. /** Defines color to use when rendering outline */
  104575. outlineColor: Color3;
  104576. /** Define width to use when rendering outline */
  104577. outlineWidth: number;
  104578. /** Defines color to use when rendering overlay */
  104579. overlayColor: Color3;
  104580. /** Defines alpha to use when rendering overlay */
  104581. overlayAlpha: number;
  104582. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  104583. get hasVertexAlpha(): boolean;
  104584. set hasVertexAlpha(value: boolean);
  104585. /** 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) */
  104586. get useVertexColors(): boolean;
  104587. set useVertexColors(value: boolean);
  104588. /**
  104589. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  104590. */
  104591. get computeBonesUsingShaders(): boolean;
  104592. set computeBonesUsingShaders(value: boolean);
  104593. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  104594. get numBoneInfluencers(): number;
  104595. set numBoneInfluencers(value: number);
  104596. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  104597. get applyFog(): boolean;
  104598. set applyFog(value: boolean);
  104599. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  104600. useOctreeForRenderingSelection: boolean;
  104601. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  104602. useOctreeForPicking: boolean;
  104603. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  104604. useOctreeForCollisions: boolean;
  104605. /**
  104606. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  104607. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  104608. */
  104609. get layerMask(): number;
  104610. set layerMask(value: number);
  104611. /**
  104612. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  104613. */
  104614. alwaysSelectAsActiveMesh: boolean;
  104615. /**
  104616. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  104617. */
  104618. doNotSyncBoundingInfo: boolean;
  104619. /**
  104620. * Gets or sets the current action manager
  104621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104622. */
  104623. actionManager: Nullable<AbstractActionManager>;
  104624. private _meshCollisionData;
  104625. /**
  104626. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  104627. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104628. */
  104629. ellipsoid: Vector3;
  104630. /**
  104631. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  104632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104633. */
  104634. ellipsoidOffset: Vector3;
  104635. /**
  104636. * Gets or sets a collision mask used to mask collisions (default is -1).
  104637. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104638. */
  104639. get collisionMask(): number;
  104640. set collisionMask(mask: number);
  104641. /**
  104642. * Gets or sets the current collision group mask (-1 by default).
  104643. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104644. */
  104645. get collisionGroup(): number;
  104646. set collisionGroup(mask: number);
  104647. /**
  104648. * Gets or sets current surrounding meshes (null by default).
  104649. *
  104650. * By default collision detection is tested against every mesh in the scene.
  104651. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  104652. * meshes will be tested for the collision.
  104653. *
  104654. * Note: if set to an empty array no collision will happen when this mesh is moved.
  104655. */
  104656. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  104657. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  104658. /**
  104659. * Defines edge width used when edgesRenderer is enabled
  104660. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104661. */
  104662. edgesWidth: number;
  104663. /**
  104664. * Defines edge color used when edgesRenderer is enabled
  104665. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104666. */
  104667. edgesColor: Color4;
  104668. /** @hidden */
  104669. _edgesRenderer: Nullable<IEdgesRenderer>;
  104670. /** @hidden */
  104671. _masterMesh: Nullable<AbstractMesh>;
  104672. /** @hidden */
  104673. _boundingInfo: Nullable<BoundingInfo>;
  104674. /** @hidden */
  104675. _renderId: number;
  104676. /**
  104677. * Gets or sets the list of subMeshes
  104678. * @see http://doc.babylonjs.com/how_to/multi_materials
  104679. */
  104680. subMeshes: SubMesh[];
  104681. /** @hidden */
  104682. _intersectionsInProgress: AbstractMesh[];
  104683. /** @hidden */
  104684. _unIndexed: boolean;
  104685. /** @hidden */
  104686. _lightSources: Light[];
  104687. /** Gets the list of lights affecting that mesh */
  104688. get lightSources(): Light[];
  104689. /** @hidden */
  104690. get _positions(): Nullable<Vector3[]>;
  104691. /** @hidden */
  104692. _waitingData: {
  104693. lods: Nullable<any>;
  104694. actions: Nullable<any>;
  104695. freezeWorldMatrix: Nullable<boolean>;
  104696. };
  104697. /** @hidden */
  104698. _bonesTransformMatrices: Nullable<Float32Array>;
  104699. /** @hidden */
  104700. _transformMatrixTexture: Nullable<RawTexture>;
  104701. /**
  104702. * Gets or sets a skeleton to apply skining transformations
  104703. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  104704. */
  104705. set skeleton(value: Nullable<Skeleton>);
  104706. get skeleton(): Nullable<Skeleton>;
  104707. /**
  104708. * An event triggered when the mesh is rebuilt.
  104709. */
  104710. onRebuildObservable: Observable<AbstractMesh>;
  104711. /**
  104712. * Creates a new AbstractMesh
  104713. * @param name defines the name of the mesh
  104714. * @param scene defines the hosting scene
  104715. */
  104716. constructor(name: string, scene?: Nullable<Scene>);
  104717. /**
  104718. * Returns the string "AbstractMesh"
  104719. * @returns "AbstractMesh"
  104720. */
  104721. getClassName(): string;
  104722. /**
  104723. * Gets a string representation of the current mesh
  104724. * @param fullDetails defines a boolean indicating if full details must be included
  104725. * @returns a string representation of the current mesh
  104726. */
  104727. toString(fullDetails?: boolean): string;
  104728. /**
  104729. * @hidden
  104730. */
  104731. protected _getEffectiveParent(): Nullable<Node>;
  104732. /** @hidden */
  104733. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  104734. /** @hidden */
  104735. _rebuild(): void;
  104736. /** @hidden */
  104737. _resyncLightSources(): void;
  104738. /** @hidden */
  104739. _resyncLightSource(light: Light): void;
  104740. /** @hidden */
  104741. _unBindEffect(): void;
  104742. /** @hidden */
  104743. _removeLightSource(light: Light, dispose: boolean): void;
  104744. private _markSubMeshesAsDirty;
  104745. /** @hidden */
  104746. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  104747. /** @hidden */
  104748. _markSubMeshesAsAttributesDirty(): void;
  104749. /** @hidden */
  104750. _markSubMeshesAsMiscDirty(): void;
  104751. /**
  104752. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  104753. */
  104754. get scaling(): Vector3;
  104755. set scaling(newScaling: Vector3);
  104756. /**
  104757. * Returns true if the mesh is blocked. Implemented by child classes
  104758. */
  104759. get isBlocked(): boolean;
  104760. /**
  104761. * Returns the mesh itself by default. Implemented by child classes
  104762. * @param camera defines the camera to use to pick the right LOD level
  104763. * @returns the currentAbstractMesh
  104764. */
  104765. getLOD(camera: Camera): Nullable<AbstractMesh>;
  104766. /**
  104767. * Returns 0 by default. Implemented by child classes
  104768. * @returns an integer
  104769. */
  104770. getTotalVertices(): number;
  104771. /**
  104772. * Returns a positive integer : the total number of indices in this mesh geometry.
  104773. * @returns the numner of indices or zero if the mesh has no geometry.
  104774. */
  104775. getTotalIndices(): number;
  104776. /**
  104777. * Returns null by default. Implemented by child classes
  104778. * @returns null
  104779. */
  104780. getIndices(): Nullable<IndicesArray>;
  104781. /**
  104782. * Returns the array of the requested vertex data kind. Implemented by child classes
  104783. * @param kind defines the vertex data kind to use
  104784. * @returns null
  104785. */
  104786. getVerticesData(kind: string): Nullable<FloatArray>;
  104787. /**
  104788. * Sets the vertex data of the mesh geometry for the requested `kind`.
  104789. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  104790. * Note that a new underlying VertexBuffer object is created each call.
  104791. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  104792. * @param kind defines vertex data kind:
  104793. * * VertexBuffer.PositionKind
  104794. * * VertexBuffer.UVKind
  104795. * * VertexBuffer.UV2Kind
  104796. * * VertexBuffer.UV3Kind
  104797. * * VertexBuffer.UV4Kind
  104798. * * VertexBuffer.UV5Kind
  104799. * * VertexBuffer.UV6Kind
  104800. * * VertexBuffer.ColorKind
  104801. * * VertexBuffer.MatricesIndicesKind
  104802. * * VertexBuffer.MatricesIndicesExtraKind
  104803. * * VertexBuffer.MatricesWeightsKind
  104804. * * VertexBuffer.MatricesWeightsExtraKind
  104805. * @param data defines the data source
  104806. * @param updatable defines if the data must be flagged as updatable (or static)
  104807. * @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
  104808. * @returns the current mesh
  104809. */
  104810. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104811. /**
  104812. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  104813. * If the mesh has no geometry, it is simply returned as it is.
  104814. * @param kind defines vertex data kind:
  104815. * * VertexBuffer.PositionKind
  104816. * * VertexBuffer.UVKind
  104817. * * VertexBuffer.UV2Kind
  104818. * * VertexBuffer.UV3Kind
  104819. * * VertexBuffer.UV4Kind
  104820. * * VertexBuffer.UV5Kind
  104821. * * VertexBuffer.UV6Kind
  104822. * * VertexBuffer.ColorKind
  104823. * * VertexBuffer.MatricesIndicesKind
  104824. * * VertexBuffer.MatricesIndicesExtraKind
  104825. * * VertexBuffer.MatricesWeightsKind
  104826. * * VertexBuffer.MatricesWeightsExtraKind
  104827. * @param data defines the data source
  104828. * @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
  104829. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  104830. * @returns the current mesh
  104831. */
  104832. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104833. /**
  104834. * Sets the mesh indices,
  104835. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  104836. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  104837. * @param totalVertices Defines the total number of vertices
  104838. * @returns the current mesh
  104839. */
  104840. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  104841. /**
  104842. * Gets a boolean indicating if specific vertex data is present
  104843. * @param kind defines the vertex data kind to use
  104844. * @returns true is data kind is present
  104845. */
  104846. isVerticesDataPresent(kind: string): boolean;
  104847. /**
  104848. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  104849. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  104850. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  104851. * @returns a BoundingInfo
  104852. */
  104853. getBoundingInfo(): BoundingInfo;
  104854. /**
  104855. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  104856. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  104857. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  104858. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  104859. * @returns the current mesh
  104860. */
  104861. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  104862. /**
  104863. * Overwrite the current bounding info
  104864. * @param boundingInfo defines the new bounding info
  104865. * @returns the current mesh
  104866. */
  104867. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  104868. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  104869. get useBones(): boolean;
  104870. /** @hidden */
  104871. _preActivate(): void;
  104872. /** @hidden */
  104873. _preActivateForIntermediateRendering(renderId: number): void;
  104874. /** @hidden */
  104875. _activate(renderId: number, intermediateRendering: boolean): boolean;
  104876. /** @hidden */
  104877. _postActivate(): void;
  104878. /** @hidden */
  104879. _freeze(): void;
  104880. /** @hidden */
  104881. _unFreeze(): void;
  104882. /**
  104883. * Gets the current world matrix
  104884. * @returns a Matrix
  104885. */
  104886. getWorldMatrix(): Matrix;
  104887. /** @hidden */
  104888. _getWorldMatrixDeterminant(): number;
  104889. /**
  104890. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  104891. */
  104892. get isAnInstance(): boolean;
  104893. /**
  104894. * Gets a boolean indicating if this mesh has instances
  104895. */
  104896. get hasInstances(): boolean;
  104897. /**
  104898. * Perform relative position change from the point of view of behind the front of the mesh.
  104899. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104900. * Supports definition of mesh facing forward or backward
  104901. * @param amountRight defines the distance on the right axis
  104902. * @param amountUp defines the distance on the up axis
  104903. * @param amountForward defines the distance on the forward axis
  104904. * @returns the current mesh
  104905. */
  104906. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  104907. /**
  104908. * Calculate relative position change from the point of view of behind the front of the mesh.
  104909. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104910. * Supports definition of mesh facing forward or backward
  104911. * @param amountRight defines the distance on the right axis
  104912. * @param amountUp defines the distance on the up axis
  104913. * @param amountForward defines the distance on the forward axis
  104914. * @returns the new displacement vector
  104915. */
  104916. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  104917. /**
  104918. * Perform relative rotation change from the point of view of behind the front of the mesh.
  104919. * Supports definition of mesh facing forward or backward
  104920. * @param flipBack defines the flip
  104921. * @param twirlClockwise defines the twirl
  104922. * @param tiltRight defines the tilt
  104923. * @returns the current mesh
  104924. */
  104925. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  104926. /**
  104927. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  104928. * Supports definition of mesh facing forward or backward.
  104929. * @param flipBack defines the flip
  104930. * @param twirlClockwise defines the twirl
  104931. * @param tiltRight defines the tilt
  104932. * @returns the new rotation vector
  104933. */
  104934. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  104935. /**
  104936. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104937. * This means the mesh underlying bounding box and sphere are recomputed.
  104938. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104939. * @returns the current mesh
  104940. */
  104941. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  104942. /** @hidden */
  104943. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  104944. /** @hidden */
  104945. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  104946. /** @hidden */
  104947. _updateBoundingInfo(): AbstractMesh;
  104948. /** @hidden */
  104949. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  104950. /** @hidden */
  104951. protected _afterComputeWorldMatrix(): void;
  104952. /** @hidden */
  104953. get _effectiveMesh(): AbstractMesh;
  104954. /**
  104955. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104956. * A mesh is in the frustum if its bounding box intersects the frustum
  104957. * @param frustumPlanes defines the frustum to test
  104958. * @returns true if the mesh is in the frustum planes
  104959. */
  104960. isInFrustum(frustumPlanes: Plane[]): boolean;
  104961. /**
  104962. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  104963. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  104964. * @param frustumPlanes defines the frustum to test
  104965. * @returns true if the mesh is completely in the frustum planes
  104966. */
  104967. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104968. /**
  104969. * True if the mesh intersects another mesh or a SolidParticle object
  104970. * @param mesh defines a target mesh or SolidParticle to test
  104971. * @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)
  104972. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  104973. * @returns true if there is an intersection
  104974. */
  104975. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  104976. /**
  104977. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  104978. * @param point defines the point to test
  104979. * @returns true if there is an intersection
  104980. */
  104981. intersectsPoint(point: Vector3): boolean;
  104982. /**
  104983. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  104984. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104985. */
  104986. get checkCollisions(): boolean;
  104987. set checkCollisions(collisionEnabled: boolean);
  104988. /**
  104989. * Gets Collider object used to compute collisions (not physics)
  104990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104991. */
  104992. get collider(): Nullable<Collider>;
  104993. /**
  104994. * Move the mesh using collision engine
  104995. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104996. * @param displacement defines the requested displacement vector
  104997. * @returns the current mesh
  104998. */
  104999. moveWithCollisions(displacement: Vector3): AbstractMesh;
  105000. private _onCollisionPositionChange;
  105001. /** @hidden */
  105002. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  105003. /** @hidden */
  105004. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  105005. /** @hidden */
  105006. _checkCollision(collider: Collider): AbstractMesh;
  105007. /** @hidden */
  105008. _generatePointsArray(): boolean;
  105009. /**
  105010. * Checks if the passed Ray intersects with the mesh
  105011. * @param ray defines the ray to use
  105012. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  105013. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105014. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  105015. * @returns the picking info
  105016. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  105017. */
  105018. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  105019. /**
  105020. * Clones the current mesh
  105021. * @param name defines the mesh name
  105022. * @param newParent defines the new mesh parent
  105023. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  105024. * @returns the new mesh
  105025. */
  105026. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  105027. /**
  105028. * Disposes all the submeshes of the current meshnp
  105029. * @returns the current mesh
  105030. */
  105031. releaseSubMeshes(): AbstractMesh;
  105032. /**
  105033. * Releases resources associated with this abstract mesh.
  105034. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105035. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105036. */
  105037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105038. /**
  105039. * Adds the passed mesh as a child to the current mesh
  105040. * @param mesh defines the child mesh
  105041. * @returns the current mesh
  105042. */
  105043. addChild(mesh: AbstractMesh): AbstractMesh;
  105044. /**
  105045. * Removes the passed mesh from the current mesh children list
  105046. * @param mesh defines the child mesh
  105047. * @returns the current mesh
  105048. */
  105049. removeChild(mesh: AbstractMesh): AbstractMesh;
  105050. /** @hidden */
  105051. private _initFacetData;
  105052. /**
  105053. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  105054. * This method can be called within the render loop.
  105055. * 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
  105056. * @returns the current mesh
  105057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105058. */
  105059. updateFacetData(): AbstractMesh;
  105060. /**
  105061. * Returns the facetLocalNormals array.
  105062. * The normals are expressed in the mesh local spac
  105063. * @returns an array of Vector3
  105064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105065. */
  105066. getFacetLocalNormals(): Vector3[];
  105067. /**
  105068. * Returns the facetLocalPositions array.
  105069. * The facet positions are expressed in the mesh local space
  105070. * @returns an array of Vector3
  105071. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105072. */
  105073. getFacetLocalPositions(): Vector3[];
  105074. /**
  105075. * Returns the facetLocalPartioning array
  105076. * @returns an array of array of numbers
  105077. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105078. */
  105079. getFacetLocalPartitioning(): number[][];
  105080. /**
  105081. * Returns the i-th facet position in the world system.
  105082. * This method allocates a new Vector3 per call
  105083. * @param i defines the facet index
  105084. * @returns a new Vector3
  105085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105086. */
  105087. getFacetPosition(i: number): Vector3;
  105088. /**
  105089. * Sets the reference Vector3 with the i-th facet position in the world system
  105090. * @param i defines the facet index
  105091. * @param ref defines the target vector
  105092. * @returns the current mesh
  105093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105094. */
  105095. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  105096. /**
  105097. * Returns the i-th facet normal in the world system.
  105098. * This method allocates a new Vector3 per call
  105099. * @param i defines the facet index
  105100. * @returns a new Vector3
  105101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105102. */
  105103. getFacetNormal(i: number): Vector3;
  105104. /**
  105105. * Sets the reference Vector3 with the i-th facet normal in the world system
  105106. * @param i defines the facet index
  105107. * @param ref defines the target vector
  105108. * @returns the current mesh
  105109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105110. */
  105111. getFacetNormalToRef(i: number, ref: Vector3): this;
  105112. /**
  105113. * 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)
  105114. * @param x defines x coordinate
  105115. * @param y defines y coordinate
  105116. * @param z defines z coordinate
  105117. * @returns the array of facet indexes
  105118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105119. */
  105120. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  105121. /**
  105122. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  105123. * @param projected sets as the (x,y,z) world projection on the facet
  105124. * @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
  105125. * @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
  105126. * @param x defines x coordinate
  105127. * @param y defines y coordinate
  105128. * @param z defines z coordinate
  105129. * @returns the face index if found (or null instead)
  105130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105131. */
  105132. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  105133. /**
  105134. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  105135. * @param projected sets as the (x,y,z) local projection on the facet
  105136. * @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
  105137. * @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
  105138. * @param x defines x coordinate
  105139. * @param y defines y coordinate
  105140. * @param z defines z coordinate
  105141. * @returns the face index if found (or null instead)
  105142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105143. */
  105144. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  105145. /**
  105146. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  105147. * @returns the parameters
  105148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105149. */
  105150. getFacetDataParameters(): any;
  105151. /**
  105152. * Disables the feature FacetData and frees the related memory
  105153. * @returns the current mesh
  105154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105155. */
  105156. disableFacetData(): AbstractMesh;
  105157. /**
  105158. * Updates the AbstractMesh indices array
  105159. * @param indices defines the data source
  105160. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105161. * @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)
  105162. * @returns the current mesh
  105163. */
  105164. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105165. /**
  105166. * Creates new normals data for the mesh
  105167. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  105168. * @returns the current mesh
  105169. */
  105170. createNormals(updatable: boolean): AbstractMesh;
  105171. /**
  105172. * Align the mesh with a normal
  105173. * @param normal defines the normal to use
  105174. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  105175. * @returns the current mesh
  105176. */
  105177. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  105178. /** @hidden */
  105179. _checkOcclusionQuery(): boolean;
  105180. /**
  105181. * Disables the mesh edge rendering mode
  105182. * @returns the currentAbstractMesh
  105183. */
  105184. disableEdgesRendering(): AbstractMesh;
  105185. /**
  105186. * Enables the edge rendering mode on the mesh.
  105187. * This mode makes the mesh edges visible
  105188. * @param epsilon defines the maximal distance between two angles to detect a face
  105189. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  105190. * @returns the currentAbstractMesh
  105191. * @see https://www.babylonjs-playground.com/#19O9TU#0
  105192. */
  105193. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  105194. }
  105195. }
  105196. declare module BABYLON {
  105197. /**
  105198. * Interface used to define ActionEvent
  105199. */
  105200. export interface IActionEvent {
  105201. /** The mesh or sprite that triggered the action */
  105202. source: any;
  105203. /** The X mouse cursor position at the time of the event */
  105204. pointerX: number;
  105205. /** The Y mouse cursor position at the time of the event */
  105206. pointerY: number;
  105207. /** The mesh that is currently pointed at (can be null) */
  105208. meshUnderPointer: Nullable<AbstractMesh>;
  105209. /** the original (browser) event that triggered the ActionEvent */
  105210. sourceEvent?: any;
  105211. /** additional data for the event */
  105212. additionalData?: any;
  105213. }
  105214. /**
  105215. * ActionEvent is the event being sent when an action is triggered.
  105216. */
  105217. export class ActionEvent implements IActionEvent {
  105218. /** The mesh or sprite that triggered the action */
  105219. source: any;
  105220. /** The X mouse cursor position at the time of the event */
  105221. pointerX: number;
  105222. /** The Y mouse cursor position at the time of the event */
  105223. pointerY: number;
  105224. /** The mesh that is currently pointed at (can be null) */
  105225. meshUnderPointer: Nullable<AbstractMesh>;
  105226. /** the original (browser) event that triggered the ActionEvent */
  105227. sourceEvent?: any;
  105228. /** additional data for the event */
  105229. additionalData?: any;
  105230. /**
  105231. * Creates a new ActionEvent
  105232. * @param source The mesh or sprite that triggered the action
  105233. * @param pointerX The X mouse cursor position at the time of the event
  105234. * @param pointerY The Y mouse cursor position at the time of the event
  105235. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  105236. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  105237. * @param additionalData additional data for the event
  105238. */
  105239. constructor(
  105240. /** The mesh or sprite that triggered the action */
  105241. source: any,
  105242. /** The X mouse cursor position at the time of the event */
  105243. pointerX: number,
  105244. /** The Y mouse cursor position at the time of the event */
  105245. pointerY: number,
  105246. /** The mesh that is currently pointed at (can be null) */
  105247. meshUnderPointer: Nullable<AbstractMesh>,
  105248. /** the original (browser) event that triggered the ActionEvent */
  105249. sourceEvent?: any,
  105250. /** additional data for the event */
  105251. additionalData?: any);
  105252. /**
  105253. * Helper function to auto-create an ActionEvent from a source mesh.
  105254. * @param source The source mesh that triggered the event
  105255. * @param evt The original (browser) event
  105256. * @param additionalData additional data for the event
  105257. * @returns the new ActionEvent
  105258. */
  105259. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  105260. /**
  105261. * Helper function to auto-create an ActionEvent from a source sprite
  105262. * @param source The source sprite that triggered the event
  105263. * @param scene Scene associated with the sprite
  105264. * @param evt The original (browser) event
  105265. * @param additionalData additional data for the event
  105266. * @returns the new ActionEvent
  105267. */
  105268. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  105269. /**
  105270. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  105271. * @param scene the scene where the event occurred
  105272. * @param evt The original (browser) event
  105273. * @returns the new ActionEvent
  105274. */
  105275. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  105276. /**
  105277. * Helper function to auto-create an ActionEvent from a primitive
  105278. * @param prim defines the target primitive
  105279. * @param pointerPos defines the pointer position
  105280. * @param evt The original (browser) event
  105281. * @param additionalData additional data for the event
  105282. * @returns the new ActionEvent
  105283. */
  105284. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  105285. }
  105286. }
  105287. declare module BABYLON {
  105288. /**
  105289. * Abstract class used to decouple action Manager from scene and meshes.
  105290. * Do not instantiate.
  105291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105292. */
  105293. export abstract class AbstractActionManager implements IDisposable {
  105294. /** Gets the list of active triggers */
  105295. static Triggers: {
  105296. [key: string]: number;
  105297. };
  105298. /** Gets the cursor to use when hovering items */
  105299. hoverCursor: string;
  105300. /** Gets the list of actions */
  105301. actions: IAction[];
  105302. /**
  105303. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  105304. */
  105305. isRecursive: boolean;
  105306. /**
  105307. * Releases all associated resources
  105308. */
  105309. abstract dispose(): void;
  105310. /**
  105311. * Does this action manager has pointer triggers
  105312. */
  105313. abstract get hasPointerTriggers(): boolean;
  105314. /**
  105315. * Does this action manager has pick triggers
  105316. */
  105317. abstract get hasPickTriggers(): boolean;
  105318. /**
  105319. * Process a specific trigger
  105320. * @param trigger defines the trigger to process
  105321. * @param evt defines the event details to be processed
  105322. */
  105323. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  105324. /**
  105325. * Does this action manager handles actions of any of the given triggers
  105326. * @param triggers defines the triggers to be tested
  105327. * @return a boolean indicating whether one (or more) of the triggers is handled
  105328. */
  105329. abstract hasSpecificTriggers(triggers: number[]): boolean;
  105330. /**
  105331. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  105332. * speed.
  105333. * @param triggerA defines the trigger to be tested
  105334. * @param triggerB defines the trigger to be tested
  105335. * @return a boolean indicating whether one (or more) of the triggers is handled
  105336. */
  105337. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  105338. /**
  105339. * Does this action manager handles actions of a given trigger
  105340. * @param trigger defines the trigger to be tested
  105341. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  105342. * @return whether the trigger is handled
  105343. */
  105344. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  105345. /**
  105346. * Serialize this manager to a JSON object
  105347. * @param name defines the property name to store this manager
  105348. * @returns a JSON representation of this manager
  105349. */
  105350. abstract serialize(name: string): any;
  105351. /**
  105352. * Registers an action to this action manager
  105353. * @param action defines the action to be registered
  105354. * @return the action amended (prepared) after registration
  105355. */
  105356. abstract registerAction(action: IAction): Nullable<IAction>;
  105357. /**
  105358. * Unregisters an action to this action manager
  105359. * @param action defines the action to be unregistered
  105360. * @return a boolean indicating whether the action has been unregistered
  105361. */
  105362. abstract unregisterAction(action: IAction): Boolean;
  105363. /**
  105364. * Does exist one action manager with at least one trigger
  105365. **/
  105366. static get HasTriggers(): boolean;
  105367. /**
  105368. * Does exist one action manager with at least one pick trigger
  105369. **/
  105370. static get HasPickTriggers(): boolean;
  105371. /**
  105372. * Does exist one action manager that handles actions of a given trigger
  105373. * @param trigger defines the trigger to be tested
  105374. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  105375. **/
  105376. static HasSpecificTrigger(trigger: number): boolean;
  105377. }
  105378. }
  105379. declare module BABYLON {
  105380. /**
  105381. * Defines how a node can be built from a string name.
  105382. */
  105383. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  105384. /**
  105385. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  105386. */
  105387. export class Node implements IBehaviorAware<Node> {
  105388. /** @hidden */
  105389. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  105390. private static _NodeConstructors;
  105391. /**
  105392. * Add a new node constructor
  105393. * @param type defines the type name of the node to construct
  105394. * @param constructorFunc defines the constructor function
  105395. */
  105396. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  105397. /**
  105398. * Returns a node constructor based on type name
  105399. * @param type defines the type name
  105400. * @param name defines the new node name
  105401. * @param scene defines the hosting scene
  105402. * @param options defines optional options to transmit to constructors
  105403. * @returns the new constructor or null
  105404. */
  105405. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  105406. /**
  105407. * Gets or sets the name of the node
  105408. */
  105409. name: string;
  105410. /**
  105411. * Gets or sets the id of the node
  105412. */
  105413. id: string;
  105414. /**
  105415. * Gets or sets the unique id of the node
  105416. */
  105417. uniqueId: number;
  105418. /**
  105419. * Gets or sets a string used to store user defined state for the node
  105420. */
  105421. state: string;
  105422. /**
  105423. * Gets or sets an object used to store user defined information for the node
  105424. */
  105425. metadata: any;
  105426. /**
  105427. * For internal use only. Please do not use.
  105428. */
  105429. reservedDataStore: any;
  105430. /**
  105431. * List of inspectable custom properties (used by the Inspector)
  105432. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105433. */
  105434. inspectableCustomProperties: IInspectable[];
  105435. private _doNotSerialize;
  105436. /**
  105437. * Gets or sets a boolean used to define if the node must be serialized
  105438. */
  105439. get doNotSerialize(): boolean;
  105440. set doNotSerialize(value: boolean);
  105441. /** @hidden */
  105442. _isDisposed: boolean;
  105443. /**
  105444. * Gets a list of Animations associated with the node
  105445. */
  105446. animations: Animation[];
  105447. protected _ranges: {
  105448. [name: string]: Nullable<AnimationRange>;
  105449. };
  105450. /**
  105451. * Callback raised when the node is ready to be used
  105452. */
  105453. onReady: Nullable<(node: Node) => void>;
  105454. private _isEnabled;
  105455. private _isParentEnabled;
  105456. private _isReady;
  105457. /** @hidden */
  105458. _currentRenderId: number;
  105459. private _parentUpdateId;
  105460. /** @hidden */
  105461. _childUpdateId: number;
  105462. /** @hidden */
  105463. _waitingParentId: Nullable<string>;
  105464. /** @hidden */
  105465. _scene: Scene;
  105466. /** @hidden */
  105467. _cache: any;
  105468. private _parentNode;
  105469. private _children;
  105470. /** @hidden */
  105471. _worldMatrix: Matrix;
  105472. /** @hidden */
  105473. _worldMatrixDeterminant: number;
  105474. /** @hidden */
  105475. _worldMatrixDeterminantIsDirty: boolean;
  105476. /** @hidden */
  105477. private _sceneRootNodesIndex;
  105478. /**
  105479. * Gets a boolean indicating if the node has been disposed
  105480. * @returns true if the node was disposed
  105481. */
  105482. isDisposed(): boolean;
  105483. /**
  105484. * Gets or sets the parent of the node (without keeping the current position in the scene)
  105485. * @see https://doc.babylonjs.com/how_to/parenting
  105486. */
  105487. set parent(parent: Nullable<Node>);
  105488. get parent(): Nullable<Node>;
  105489. /** @hidden */
  105490. _addToSceneRootNodes(): void;
  105491. /** @hidden */
  105492. _removeFromSceneRootNodes(): void;
  105493. private _animationPropertiesOverride;
  105494. /**
  105495. * Gets or sets the animation properties override
  105496. */
  105497. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105498. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105499. /**
  105500. * Gets a string idenfifying the name of the class
  105501. * @returns "Node" string
  105502. */
  105503. getClassName(): string;
  105504. /** @hidden */
  105505. readonly _isNode: boolean;
  105506. /**
  105507. * An event triggered when the mesh is disposed
  105508. */
  105509. onDisposeObservable: Observable<Node>;
  105510. private _onDisposeObserver;
  105511. /**
  105512. * Sets a callback that will be raised when the node will be disposed
  105513. */
  105514. set onDispose(callback: () => void);
  105515. /**
  105516. * Creates a new Node
  105517. * @param name the name and id to be given to this node
  105518. * @param scene the scene this node will be added to
  105519. */
  105520. constructor(name: string, scene?: Nullable<Scene>);
  105521. /**
  105522. * Gets the scene of the node
  105523. * @returns a scene
  105524. */
  105525. getScene(): Scene;
  105526. /**
  105527. * Gets the engine of the node
  105528. * @returns a Engine
  105529. */
  105530. getEngine(): Engine;
  105531. private _behaviors;
  105532. /**
  105533. * Attach a behavior to the node
  105534. * @see http://doc.babylonjs.com/features/behaviour
  105535. * @param behavior defines the behavior to attach
  105536. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  105537. * @returns the current Node
  105538. */
  105539. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  105540. /**
  105541. * Remove an attached behavior
  105542. * @see http://doc.babylonjs.com/features/behaviour
  105543. * @param behavior defines the behavior to attach
  105544. * @returns the current Node
  105545. */
  105546. removeBehavior(behavior: Behavior<Node>): Node;
  105547. /**
  105548. * Gets the list of attached behaviors
  105549. * @see http://doc.babylonjs.com/features/behaviour
  105550. */
  105551. get behaviors(): Behavior<Node>[];
  105552. /**
  105553. * Gets an attached behavior by name
  105554. * @param name defines the name of the behavior to look for
  105555. * @see http://doc.babylonjs.com/features/behaviour
  105556. * @returns null if behavior was not found else the requested behavior
  105557. */
  105558. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  105559. /**
  105560. * Returns the latest update of the World matrix
  105561. * @returns a Matrix
  105562. */
  105563. getWorldMatrix(): Matrix;
  105564. /** @hidden */
  105565. _getWorldMatrixDeterminant(): number;
  105566. /**
  105567. * Returns directly the latest state of the mesh World matrix.
  105568. * A Matrix is returned.
  105569. */
  105570. get worldMatrixFromCache(): Matrix;
  105571. /** @hidden */
  105572. _initCache(): void;
  105573. /** @hidden */
  105574. updateCache(force?: boolean): void;
  105575. /** @hidden */
  105576. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  105577. /** @hidden */
  105578. _updateCache(ignoreParentClass?: boolean): void;
  105579. /** @hidden */
  105580. _isSynchronized(): boolean;
  105581. /** @hidden */
  105582. _markSyncedWithParent(): void;
  105583. /** @hidden */
  105584. isSynchronizedWithParent(): boolean;
  105585. /** @hidden */
  105586. isSynchronized(): boolean;
  105587. /**
  105588. * Is this node ready to be used/rendered
  105589. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105590. * @return true if the node is ready
  105591. */
  105592. isReady(completeCheck?: boolean): boolean;
  105593. /**
  105594. * Is this node enabled?
  105595. * 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
  105596. * @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
  105597. * @return whether this node (and its parent) is enabled
  105598. */
  105599. isEnabled(checkAncestors?: boolean): boolean;
  105600. /** @hidden */
  105601. protected _syncParentEnabledState(): void;
  105602. /**
  105603. * Set the enabled state of this node
  105604. * @param value defines the new enabled state
  105605. */
  105606. setEnabled(value: boolean): void;
  105607. /**
  105608. * Is this node a descendant of the given node?
  105609. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  105610. * @param ancestor defines the parent node to inspect
  105611. * @returns a boolean indicating if this node is a descendant of the given node
  105612. */
  105613. isDescendantOf(ancestor: Node): boolean;
  105614. /** @hidden */
  105615. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  105616. /**
  105617. * Will return all nodes that have this node as ascendant
  105618. * @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
  105619. * @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
  105620. * @return all children nodes of all types
  105621. */
  105622. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  105623. /**
  105624. * Get all child-meshes of this node
  105625. * @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)
  105626. * @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
  105627. * @returns an array of AbstractMesh
  105628. */
  105629. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  105630. /**
  105631. * Get all direct children of this node
  105632. * @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
  105633. * @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)
  105634. * @returns an array of Node
  105635. */
  105636. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  105637. /** @hidden */
  105638. _setReady(state: boolean): void;
  105639. /**
  105640. * Get an animation by name
  105641. * @param name defines the name of the animation to look for
  105642. * @returns null if not found else the requested animation
  105643. */
  105644. getAnimationByName(name: string): Nullable<Animation>;
  105645. /**
  105646. * Creates an animation range for this node
  105647. * @param name defines the name of the range
  105648. * @param from defines the starting key
  105649. * @param to defines the end key
  105650. */
  105651. createAnimationRange(name: string, from: number, to: number): void;
  105652. /**
  105653. * Delete a specific animation range
  105654. * @param name defines the name of the range to delete
  105655. * @param deleteFrames defines if animation frames from the range must be deleted as well
  105656. */
  105657. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  105658. /**
  105659. * Get an animation range by name
  105660. * @param name defines the name of the animation range to look for
  105661. * @returns null if not found else the requested animation range
  105662. */
  105663. getAnimationRange(name: string): Nullable<AnimationRange>;
  105664. /**
  105665. * Gets the list of all animation ranges defined on this node
  105666. * @returns an array
  105667. */
  105668. getAnimationRanges(): Nullable<AnimationRange>[];
  105669. /**
  105670. * Will start the animation sequence
  105671. * @param name defines the range frames for animation sequence
  105672. * @param loop defines if the animation should loop (false by default)
  105673. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  105674. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  105675. * @returns the object created for this animation. If range does not exist, it will return null
  105676. */
  105677. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  105678. /**
  105679. * Serialize animation ranges into a JSON compatible object
  105680. * @returns serialization object
  105681. */
  105682. serializeAnimationRanges(): any;
  105683. /**
  105684. * Computes the world matrix of the node
  105685. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  105686. * @returns the world matrix
  105687. */
  105688. computeWorldMatrix(force?: boolean): Matrix;
  105689. /**
  105690. * Releases resources associated with this node.
  105691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105693. */
  105694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105695. /**
  105696. * Parse animation range data from a serialization object and store them into a given node
  105697. * @param node defines where to store the animation ranges
  105698. * @param parsedNode defines the serialization object to read data from
  105699. * @param scene defines the hosting scene
  105700. */
  105701. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  105702. /**
  105703. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  105704. * @param includeDescendants Include bounding info from descendants as well (true by default)
  105705. * @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
  105706. * @returns the new bounding vectors
  105707. */
  105708. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  105709. min: Vector3;
  105710. max: Vector3;
  105711. };
  105712. }
  105713. }
  105714. declare module BABYLON {
  105715. /**
  105716. * @hidden
  105717. */
  105718. export class _IAnimationState {
  105719. key: number;
  105720. repeatCount: number;
  105721. workValue?: any;
  105722. loopMode?: number;
  105723. offsetValue?: any;
  105724. highLimitValue?: any;
  105725. }
  105726. /**
  105727. * Class used to store any kind of animation
  105728. */
  105729. export class Animation {
  105730. /**Name of the animation */
  105731. name: string;
  105732. /**Property to animate */
  105733. targetProperty: string;
  105734. /**The frames per second of the animation */
  105735. framePerSecond: number;
  105736. /**The data type of the animation */
  105737. dataType: number;
  105738. /**The loop mode of the animation */
  105739. loopMode?: number | undefined;
  105740. /**Specifies if blending should be enabled */
  105741. enableBlending?: boolean | undefined;
  105742. /**
  105743. * Use matrix interpolation instead of using direct key value when animating matrices
  105744. */
  105745. static AllowMatricesInterpolation: boolean;
  105746. /**
  105747. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  105748. */
  105749. static AllowMatrixDecomposeForInterpolation: boolean;
  105750. /**
  105751. * Stores the key frames of the animation
  105752. */
  105753. private _keys;
  105754. /**
  105755. * Stores the easing function of the animation
  105756. */
  105757. private _easingFunction;
  105758. /**
  105759. * @hidden Internal use only
  105760. */
  105761. _runtimeAnimations: RuntimeAnimation[];
  105762. /**
  105763. * The set of event that will be linked to this animation
  105764. */
  105765. private _events;
  105766. /**
  105767. * Stores an array of target property paths
  105768. */
  105769. targetPropertyPath: string[];
  105770. /**
  105771. * Stores the blending speed of the animation
  105772. */
  105773. blendingSpeed: number;
  105774. /**
  105775. * Stores the animation ranges for the animation
  105776. */
  105777. private _ranges;
  105778. /**
  105779. * @hidden Internal use
  105780. */
  105781. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  105782. /**
  105783. * Sets up an animation
  105784. * @param property The property to animate
  105785. * @param animationType The animation type to apply
  105786. * @param framePerSecond The frames per second of the animation
  105787. * @param easingFunction The easing function used in the animation
  105788. * @returns The created animation
  105789. */
  105790. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  105791. /**
  105792. * Create and start an animation on a node
  105793. * @param name defines the name of the global animation that will be run on all nodes
  105794. * @param node defines the root node where the animation will take place
  105795. * @param targetProperty defines property to animate
  105796. * @param framePerSecond defines the number of frame per second yo use
  105797. * @param totalFrame defines the number of frames in total
  105798. * @param from defines the initial value
  105799. * @param to defines the final value
  105800. * @param loopMode defines which loop mode you want to use (off by default)
  105801. * @param easingFunction defines the easing function to use (linear by default)
  105802. * @param onAnimationEnd defines the callback to call when animation end
  105803. * @returns the animatable created for this animation
  105804. */
  105805. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105806. /**
  105807. * Create and start an animation on a node and its descendants
  105808. * @param name defines the name of the global animation that will be run on all nodes
  105809. * @param node defines the root node where the animation will take place
  105810. * @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
  105811. * @param targetProperty defines property to animate
  105812. * @param framePerSecond defines the number of frame per second to use
  105813. * @param totalFrame defines the number of frames in total
  105814. * @param from defines the initial value
  105815. * @param to defines the final value
  105816. * @param loopMode defines which loop mode you want to use (off by default)
  105817. * @param easingFunction defines the easing function to use (linear by default)
  105818. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  105819. * @returns the list of animatables created for all nodes
  105820. * @example https://www.babylonjs-playground.com/#MH0VLI
  105821. */
  105822. 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[]>;
  105823. /**
  105824. * Creates a new animation, merges it with the existing animations and starts it
  105825. * @param name Name of the animation
  105826. * @param node Node which contains the scene that begins the animations
  105827. * @param targetProperty Specifies which property to animate
  105828. * @param framePerSecond The frames per second of the animation
  105829. * @param totalFrame The total number of frames
  105830. * @param from The frame at the beginning of the animation
  105831. * @param to The frame at the end of the animation
  105832. * @param loopMode Specifies the loop mode of the animation
  105833. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  105834. * @param onAnimationEnd Callback to run once the animation is complete
  105835. * @returns Nullable animation
  105836. */
  105837. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105838. /**
  105839. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  105840. * @param sourceAnimation defines the Animation containing keyframes to convert
  105841. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  105842. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  105843. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  105844. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  105845. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  105846. */
  105847. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  105848. /**
  105849. * Transition property of an host to the target Value
  105850. * @param property The property to transition
  105851. * @param targetValue The target Value of the property
  105852. * @param host The object where the property to animate belongs
  105853. * @param scene Scene used to run the animation
  105854. * @param frameRate Framerate (in frame/s) to use
  105855. * @param transition The transition type we want to use
  105856. * @param duration The duration of the animation, in milliseconds
  105857. * @param onAnimationEnd Callback trigger at the end of the animation
  105858. * @returns Nullable animation
  105859. */
  105860. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  105861. /**
  105862. * Return the array of runtime animations currently using this animation
  105863. */
  105864. get runtimeAnimations(): RuntimeAnimation[];
  105865. /**
  105866. * Specifies if any of the runtime animations are currently running
  105867. */
  105868. get hasRunningRuntimeAnimations(): boolean;
  105869. /**
  105870. * Initializes the animation
  105871. * @param name Name of the animation
  105872. * @param targetProperty Property to animate
  105873. * @param framePerSecond The frames per second of the animation
  105874. * @param dataType The data type of the animation
  105875. * @param loopMode The loop mode of the animation
  105876. * @param enableBlending Specifies if blending should be enabled
  105877. */
  105878. constructor(
  105879. /**Name of the animation */
  105880. name: string,
  105881. /**Property to animate */
  105882. targetProperty: string,
  105883. /**The frames per second of the animation */
  105884. framePerSecond: number,
  105885. /**The data type of the animation */
  105886. dataType: number,
  105887. /**The loop mode of the animation */
  105888. loopMode?: number | undefined,
  105889. /**Specifies if blending should be enabled */
  105890. enableBlending?: boolean | undefined);
  105891. /**
  105892. * Converts the animation to a string
  105893. * @param fullDetails support for multiple levels of logging within scene loading
  105894. * @returns String form of the animation
  105895. */
  105896. toString(fullDetails?: boolean): string;
  105897. /**
  105898. * Add an event to this animation
  105899. * @param event Event to add
  105900. */
  105901. addEvent(event: AnimationEvent): void;
  105902. /**
  105903. * Remove all events found at the given frame
  105904. * @param frame The frame to remove events from
  105905. */
  105906. removeEvents(frame: number): void;
  105907. /**
  105908. * Retrieves all the events from the animation
  105909. * @returns Events from the animation
  105910. */
  105911. getEvents(): AnimationEvent[];
  105912. /**
  105913. * Creates an animation range
  105914. * @param name Name of the animation range
  105915. * @param from Starting frame of the animation range
  105916. * @param to Ending frame of the animation
  105917. */
  105918. createRange(name: string, from: number, to: number): void;
  105919. /**
  105920. * Deletes an animation range by name
  105921. * @param name Name of the animation range to delete
  105922. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  105923. */
  105924. deleteRange(name: string, deleteFrames?: boolean): void;
  105925. /**
  105926. * Gets the animation range by name, or null if not defined
  105927. * @param name Name of the animation range
  105928. * @returns Nullable animation range
  105929. */
  105930. getRange(name: string): Nullable<AnimationRange>;
  105931. /**
  105932. * Gets the key frames from the animation
  105933. * @returns The key frames of the animation
  105934. */
  105935. getKeys(): Array<IAnimationKey>;
  105936. /**
  105937. * Gets the highest frame rate of the animation
  105938. * @returns Highest frame rate of the animation
  105939. */
  105940. getHighestFrame(): number;
  105941. /**
  105942. * Gets the easing function of the animation
  105943. * @returns Easing function of the animation
  105944. */
  105945. getEasingFunction(): IEasingFunction;
  105946. /**
  105947. * Sets the easing function of the animation
  105948. * @param easingFunction A custom mathematical formula for animation
  105949. */
  105950. setEasingFunction(easingFunction: EasingFunction): void;
  105951. /**
  105952. * Interpolates a scalar linearly
  105953. * @param startValue Start value of the animation curve
  105954. * @param endValue End value of the animation curve
  105955. * @param gradient Scalar amount to interpolate
  105956. * @returns Interpolated scalar value
  105957. */
  105958. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  105959. /**
  105960. * Interpolates a scalar cubically
  105961. * @param startValue Start value of the animation curve
  105962. * @param outTangent End tangent of the animation
  105963. * @param endValue End value of the animation curve
  105964. * @param inTangent Start tangent of the animation curve
  105965. * @param gradient Scalar amount to interpolate
  105966. * @returns Interpolated scalar value
  105967. */
  105968. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  105969. /**
  105970. * Interpolates a quaternion using a spherical linear interpolation
  105971. * @param startValue Start value of the animation curve
  105972. * @param endValue End value of the animation curve
  105973. * @param gradient Scalar amount to interpolate
  105974. * @returns Interpolated quaternion value
  105975. */
  105976. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  105977. /**
  105978. * Interpolates a quaternion cubically
  105979. * @param startValue Start value of the animation curve
  105980. * @param outTangent End tangent of the animation curve
  105981. * @param endValue End value of the animation curve
  105982. * @param inTangent Start tangent of the animation curve
  105983. * @param gradient Scalar amount to interpolate
  105984. * @returns Interpolated quaternion value
  105985. */
  105986. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  105987. /**
  105988. * Interpolates a Vector3 linearl
  105989. * @param startValue Start value of the animation curve
  105990. * @param endValue End value of the animation curve
  105991. * @param gradient Scalar amount to interpolate
  105992. * @returns Interpolated scalar value
  105993. */
  105994. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  105995. /**
  105996. * Interpolates a Vector3 cubically
  105997. * @param startValue Start value of the animation curve
  105998. * @param outTangent End tangent of the animation
  105999. * @param endValue End value of the animation curve
  106000. * @param inTangent Start tangent of the animation curve
  106001. * @param gradient Scalar amount to interpolate
  106002. * @returns InterpolatedVector3 value
  106003. */
  106004. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  106005. /**
  106006. * Interpolates a Vector2 linearly
  106007. * @param startValue Start value of the animation curve
  106008. * @param endValue End value of the animation curve
  106009. * @param gradient Scalar amount to interpolate
  106010. * @returns Interpolated Vector2 value
  106011. */
  106012. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  106013. /**
  106014. * Interpolates a Vector2 cubically
  106015. * @param startValue Start value of the animation curve
  106016. * @param outTangent End tangent of the animation
  106017. * @param endValue End value of the animation curve
  106018. * @param inTangent Start tangent of the animation curve
  106019. * @param gradient Scalar amount to interpolate
  106020. * @returns Interpolated Vector2 value
  106021. */
  106022. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  106023. /**
  106024. * Interpolates a size linearly
  106025. * @param startValue Start value of the animation curve
  106026. * @param endValue End value of the animation curve
  106027. * @param gradient Scalar amount to interpolate
  106028. * @returns Interpolated Size value
  106029. */
  106030. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  106031. /**
  106032. * Interpolates a Color3 linearly
  106033. * @param startValue Start value of the animation curve
  106034. * @param endValue End value of the animation curve
  106035. * @param gradient Scalar amount to interpolate
  106036. * @returns Interpolated Color3 value
  106037. */
  106038. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  106039. /**
  106040. * Interpolates a Color4 linearly
  106041. * @param startValue Start value of the animation curve
  106042. * @param endValue End value of the animation curve
  106043. * @param gradient Scalar amount to interpolate
  106044. * @returns Interpolated Color3 value
  106045. */
  106046. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  106047. /**
  106048. * @hidden Internal use only
  106049. */
  106050. _getKeyValue(value: any): any;
  106051. /**
  106052. * @hidden Internal use only
  106053. */
  106054. _interpolate(currentFrame: number, state: _IAnimationState): any;
  106055. /**
  106056. * Defines the function to use to interpolate matrices
  106057. * @param startValue defines the start matrix
  106058. * @param endValue defines the end matrix
  106059. * @param gradient defines the gradient between both matrices
  106060. * @param result defines an optional target matrix where to store the interpolation
  106061. * @returns the interpolated matrix
  106062. */
  106063. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  106064. /**
  106065. * Makes a copy of the animation
  106066. * @returns Cloned animation
  106067. */
  106068. clone(): Animation;
  106069. /**
  106070. * Sets the key frames of the animation
  106071. * @param values The animation key frames to set
  106072. */
  106073. setKeys(values: Array<IAnimationKey>): void;
  106074. /**
  106075. * Serializes the animation to an object
  106076. * @returns Serialized object
  106077. */
  106078. serialize(): any;
  106079. /**
  106080. * Float animation type
  106081. */
  106082. static readonly ANIMATIONTYPE_FLOAT: number;
  106083. /**
  106084. * Vector3 animation type
  106085. */
  106086. static readonly ANIMATIONTYPE_VECTOR3: number;
  106087. /**
  106088. * Quaternion animation type
  106089. */
  106090. static readonly ANIMATIONTYPE_QUATERNION: number;
  106091. /**
  106092. * Matrix animation type
  106093. */
  106094. static readonly ANIMATIONTYPE_MATRIX: number;
  106095. /**
  106096. * Color3 animation type
  106097. */
  106098. static readonly ANIMATIONTYPE_COLOR3: number;
  106099. /**
  106100. * Color3 animation type
  106101. */
  106102. static readonly ANIMATIONTYPE_COLOR4: number;
  106103. /**
  106104. * Vector2 animation type
  106105. */
  106106. static readonly ANIMATIONTYPE_VECTOR2: number;
  106107. /**
  106108. * Size animation type
  106109. */
  106110. static readonly ANIMATIONTYPE_SIZE: number;
  106111. /**
  106112. * Relative Loop Mode
  106113. */
  106114. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  106115. /**
  106116. * Cycle Loop Mode
  106117. */
  106118. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  106119. /**
  106120. * Constant Loop Mode
  106121. */
  106122. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  106123. /** @hidden */
  106124. static _UniversalLerp(left: any, right: any, amount: number): any;
  106125. /**
  106126. * Parses an animation object and creates an animation
  106127. * @param parsedAnimation Parsed animation object
  106128. * @returns Animation object
  106129. */
  106130. static Parse(parsedAnimation: any): Animation;
  106131. /**
  106132. * Appends the serialized animations from the source animations
  106133. * @param source Source containing the animations
  106134. * @param destination Target to store the animations
  106135. */
  106136. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  106137. }
  106138. }
  106139. declare module BABYLON {
  106140. /**
  106141. * Interface containing an array of animations
  106142. */
  106143. export interface IAnimatable {
  106144. /**
  106145. * Array of animations
  106146. */
  106147. animations: Nullable<Array<Animation>>;
  106148. }
  106149. }
  106150. declare module BABYLON {
  106151. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  106152. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106153. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106154. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106155. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106156. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106157. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106158. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106159. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106160. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106161. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106162. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106163. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106164. /**
  106165. * Decorator used to define property that can be serialized as reference to a camera
  106166. * @param sourceName defines the name of the property to decorate
  106167. */
  106168. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106169. /**
  106170. * Class used to help serialization objects
  106171. */
  106172. export class SerializationHelper {
  106173. /** @hidden */
  106174. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  106175. /** @hidden */
  106176. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  106177. /** @hidden */
  106178. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  106179. /** @hidden */
  106180. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  106181. /**
  106182. * Appends the serialized animations from the source animations
  106183. * @param source Source containing the animations
  106184. * @param destination Target to store the animations
  106185. */
  106186. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  106187. /**
  106188. * Static function used to serialized a specific entity
  106189. * @param entity defines the entity to serialize
  106190. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  106191. * @returns a JSON compatible object representing the serialization of the entity
  106192. */
  106193. static Serialize<T>(entity: T, serializationObject?: any): any;
  106194. /**
  106195. * Creates a new entity from a serialization data object
  106196. * @param creationFunction defines a function used to instanciated the new entity
  106197. * @param source defines the source serialization data
  106198. * @param scene defines the hosting scene
  106199. * @param rootUrl defines the root url for resources
  106200. * @returns a new entity
  106201. */
  106202. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  106203. /**
  106204. * Clones an object
  106205. * @param creationFunction defines the function used to instanciate the new object
  106206. * @param source defines the source object
  106207. * @returns the cloned object
  106208. */
  106209. static Clone<T>(creationFunction: () => T, source: T): T;
  106210. /**
  106211. * Instanciates a new object based on a source one (some data will be shared between both object)
  106212. * @param creationFunction defines the function used to instanciate the new object
  106213. * @param source defines the source object
  106214. * @returns the new object
  106215. */
  106216. static Instanciate<T>(creationFunction: () => T, source: T): T;
  106217. }
  106218. }
  106219. declare module BABYLON {
  106220. /**
  106221. * Base class of all the textures in babylon.
  106222. * It groups all the common properties the materials, post process, lights... might need
  106223. * in order to make a correct use of the texture.
  106224. */
  106225. export class BaseTexture implements IAnimatable {
  106226. /**
  106227. * Default anisotropic filtering level for the application.
  106228. * It is set to 4 as a good tradeoff between perf and quality.
  106229. */
  106230. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  106231. /**
  106232. * Gets or sets the unique id of the texture
  106233. */
  106234. uniqueId: number;
  106235. /**
  106236. * Define the name of the texture.
  106237. */
  106238. name: string;
  106239. /**
  106240. * Gets or sets an object used to store user defined information.
  106241. */
  106242. metadata: any;
  106243. /**
  106244. * For internal use only. Please do not use.
  106245. */
  106246. reservedDataStore: any;
  106247. private _hasAlpha;
  106248. /**
  106249. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  106250. */
  106251. set hasAlpha(value: boolean);
  106252. get hasAlpha(): boolean;
  106253. /**
  106254. * Defines if the alpha value should be determined via the rgb values.
  106255. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  106256. */
  106257. getAlphaFromRGB: boolean;
  106258. /**
  106259. * Intensity or strength of the texture.
  106260. * It is commonly used by materials to fine tune the intensity of the texture
  106261. */
  106262. level: number;
  106263. /**
  106264. * Define the UV chanel to use starting from 0 and defaulting to 0.
  106265. * This is part of the texture as textures usually maps to one uv set.
  106266. */
  106267. coordinatesIndex: number;
  106268. private _coordinatesMode;
  106269. /**
  106270. * How a texture is mapped.
  106271. *
  106272. * | Value | Type | Description |
  106273. * | ----- | ----------------------------------- | ----------- |
  106274. * | 0 | EXPLICIT_MODE | |
  106275. * | 1 | SPHERICAL_MODE | |
  106276. * | 2 | PLANAR_MODE | |
  106277. * | 3 | CUBIC_MODE | |
  106278. * | 4 | PROJECTION_MODE | |
  106279. * | 5 | SKYBOX_MODE | |
  106280. * | 6 | INVCUBIC_MODE | |
  106281. * | 7 | EQUIRECTANGULAR_MODE | |
  106282. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  106283. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  106284. */
  106285. set coordinatesMode(value: number);
  106286. get coordinatesMode(): number;
  106287. /**
  106288. * | Value | Type | Description |
  106289. * | ----- | ------------------ | ----------- |
  106290. * | 0 | CLAMP_ADDRESSMODE | |
  106291. * | 1 | WRAP_ADDRESSMODE | |
  106292. * | 2 | MIRROR_ADDRESSMODE | |
  106293. */
  106294. wrapU: number;
  106295. /**
  106296. * | Value | Type | Description |
  106297. * | ----- | ------------------ | ----------- |
  106298. * | 0 | CLAMP_ADDRESSMODE | |
  106299. * | 1 | WRAP_ADDRESSMODE | |
  106300. * | 2 | MIRROR_ADDRESSMODE | |
  106301. */
  106302. wrapV: number;
  106303. /**
  106304. * | Value | Type | Description |
  106305. * | ----- | ------------------ | ----------- |
  106306. * | 0 | CLAMP_ADDRESSMODE | |
  106307. * | 1 | WRAP_ADDRESSMODE | |
  106308. * | 2 | MIRROR_ADDRESSMODE | |
  106309. */
  106310. wrapR: number;
  106311. /**
  106312. * With compliant hardware and browser (supporting anisotropic filtering)
  106313. * this defines the level of anisotropic filtering in the texture.
  106314. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  106315. */
  106316. anisotropicFilteringLevel: number;
  106317. /**
  106318. * Define if the texture is a cube texture or if false a 2d texture.
  106319. */
  106320. get isCube(): boolean;
  106321. set isCube(value: boolean);
  106322. /**
  106323. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  106324. */
  106325. get is3D(): boolean;
  106326. set is3D(value: boolean);
  106327. /**
  106328. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  106329. */
  106330. get is2DArray(): boolean;
  106331. set is2DArray(value: boolean);
  106332. /**
  106333. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  106334. * HDR texture are usually stored in linear space.
  106335. * This only impacts the PBR and Background materials
  106336. */
  106337. gammaSpace: boolean;
  106338. /**
  106339. * Gets or sets whether or not the texture contains RGBD data.
  106340. */
  106341. get isRGBD(): boolean;
  106342. set isRGBD(value: boolean);
  106343. /**
  106344. * Is Z inverted in the texture (useful in a cube texture).
  106345. */
  106346. invertZ: boolean;
  106347. /**
  106348. * Are mip maps generated for this texture or not.
  106349. */
  106350. get noMipmap(): boolean;
  106351. /**
  106352. * @hidden
  106353. */
  106354. lodLevelInAlpha: boolean;
  106355. /**
  106356. * With prefiltered texture, defined the offset used during the prefiltering steps.
  106357. */
  106358. get lodGenerationOffset(): number;
  106359. set lodGenerationOffset(value: number);
  106360. /**
  106361. * With prefiltered texture, defined the scale used during the prefiltering steps.
  106362. */
  106363. get lodGenerationScale(): number;
  106364. set lodGenerationScale(value: number);
  106365. /**
  106366. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  106367. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  106368. * average roughness values.
  106369. */
  106370. get linearSpecularLOD(): boolean;
  106371. set linearSpecularLOD(value: boolean);
  106372. /**
  106373. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  106374. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  106375. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  106376. */
  106377. get irradianceTexture(): Nullable<BaseTexture>;
  106378. set irradianceTexture(value: Nullable<BaseTexture>);
  106379. /**
  106380. * Define if the texture is a render target.
  106381. */
  106382. isRenderTarget: boolean;
  106383. /**
  106384. * Define the unique id of the texture in the scene.
  106385. */
  106386. get uid(): string;
  106387. /**
  106388. * Return a string representation of the texture.
  106389. * @returns the texture as a string
  106390. */
  106391. toString(): string;
  106392. /**
  106393. * Get the class name of the texture.
  106394. * @returns "BaseTexture"
  106395. */
  106396. getClassName(): string;
  106397. /**
  106398. * Define the list of animation attached to the texture.
  106399. */
  106400. animations: Animation[];
  106401. /**
  106402. * An event triggered when the texture is disposed.
  106403. */
  106404. onDisposeObservable: Observable<BaseTexture>;
  106405. private _onDisposeObserver;
  106406. /**
  106407. * Callback triggered when the texture has been disposed.
  106408. * Kept for back compatibility, you can use the onDisposeObservable instead.
  106409. */
  106410. set onDispose(callback: () => void);
  106411. /**
  106412. * Define the current state of the loading sequence when in delayed load mode.
  106413. */
  106414. delayLoadState: number;
  106415. private _scene;
  106416. private _engine;
  106417. /** @hidden */
  106418. _texture: Nullable<InternalTexture>;
  106419. private _uid;
  106420. /**
  106421. * Define if the texture is preventinga material to render or not.
  106422. * If not and the texture is not ready, the engine will use a default black texture instead.
  106423. */
  106424. get isBlocking(): boolean;
  106425. /**
  106426. * Instantiates a new BaseTexture.
  106427. * Base class of all the textures in babylon.
  106428. * It groups all the common properties the materials, post process, lights... might need
  106429. * in order to make a correct use of the texture.
  106430. * @param sceneOrEngine Define the scene or engine the texture blongs to
  106431. */
  106432. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  106433. /**
  106434. * Get the scene the texture belongs to.
  106435. * @returns the scene or null if undefined
  106436. */
  106437. getScene(): Nullable<Scene>;
  106438. /** @hidden */
  106439. protected _getEngine(): Nullable<ThinEngine>;
  106440. /**
  106441. * Get the texture transform matrix used to offset tile the texture for istance.
  106442. * @returns the transformation matrix
  106443. */
  106444. getTextureMatrix(): Matrix;
  106445. /**
  106446. * Get the texture reflection matrix used to rotate/transform the reflection.
  106447. * @returns the reflection matrix
  106448. */
  106449. getReflectionTextureMatrix(): Matrix;
  106450. /**
  106451. * Get the underlying lower level texture from Babylon.
  106452. * @returns the insternal texture
  106453. */
  106454. getInternalTexture(): Nullable<InternalTexture>;
  106455. /**
  106456. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  106457. * @returns true if ready or not blocking
  106458. */
  106459. isReadyOrNotBlocking(): boolean;
  106460. /**
  106461. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  106462. * @returns true if fully ready
  106463. */
  106464. isReady(): boolean;
  106465. private _cachedSize;
  106466. /**
  106467. * Get the size of the texture.
  106468. * @returns the texture size.
  106469. */
  106470. getSize(): ISize;
  106471. /**
  106472. * Get the base size of the texture.
  106473. * It can be different from the size if the texture has been resized for POT for instance
  106474. * @returns the base size
  106475. */
  106476. getBaseSize(): ISize;
  106477. /**
  106478. * Update the sampling mode of the texture.
  106479. * Default is Trilinear mode.
  106480. *
  106481. * | Value | Type | Description |
  106482. * | ----- | ------------------ | ----------- |
  106483. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  106484. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  106485. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  106486. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  106487. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  106488. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  106489. * | 7 | NEAREST_LINEAR | |
  106490. * | 8 | NEAREST_NEAREST | |
  106491. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  106492. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  106493. * | 11 | LINEAR_LINEAR | |
  106494. * | 12 | LINEAR_NEAREST | |
  106495. *
  106496. * > _mag_: magnification filter (close to the viewer)
  106497. * > _min_: minification filter (far from the viewer)
  106498. * > _mip_: filter used between mip map levels
  106499. *@param samplingMode Define the new sampling mode of the texture
  106500. */
  106501. updateSamplingMode(samplingMode: number): void;
  106502. /**
  106503. * Scales the texture if is `canRescale()`
  106504. * @param ratio the resize factor we want to use to rescale
  106505. */
  106506. scale(ratio: number): void;
  106507. /**
  106508. * Get if the texture can rescale.
  106509. */
  106510. get canRescale(): boolean;
  106511. /** @hidden */
  106512. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  106513. /** @hidden */
  106514. _rebuild(): void;
  106515. /**
  106516. * Triggers the load sequence in delayed load mode.
  106517. */
  106518. delayLoad(): void;
  106519. /**
  106520. * Clones the texture.
  106521. * @returns the cloned texture
  106522. */
  106523. clone(): Nullable<BaseTexture>;
  106524. /**
  106525. * Get the texture underlying type (INT, FLOAT...)
  106526. */
  106527. get textureType(): number;
  106528. /**
  106529. * Get the texture underlying format (RGB, RGBA...)
  106530. */
  106531. get textureFormat(): number;
  106532. /**
  106533. * Indicates that textures need to be re-calculated for all materials
  106534. */
  106535. protected _markAllSubMeshesAsTexturesDirty(): void;
  106536. /**
  106537. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  106538. * This will returns an RGBA array buffer containing either in values (0-255) or
  106539. * float values (0-1) depending of the underlying buffer type.
  106540. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  106541. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  106542. * @param buffer defines a user defined buffer to fill with data (can be null)
  106543. * @returns The Array buffer containing the pixels data.
  106544. */
  106545. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  106546. /**
  106547. * Release and destroy the underlying lower level texture aka internalTexture.
  106548. */
  106549. releaseInternalTexture(): void;
  106550. /** @hidden */
  106551. get _lodTextureHigh(): Nullable<BaseTexture>;
  106552. /** @hidden */
  106553. get _lodTextureMid(): Nullable<BaseTexture>;
  106554. /** @hidden */
  106555. get _lodTextureLow(): Nullable<BaseTexture>;
  106556. /**
  106557. * Dispose the texture and release its associated resources.
  106558. */
  106559. dispose(): void;
  106560. /**
  106561. * Serialize the texture into a JSON representation that can be parsed later on.
  106562. * @returns the JSON representation of the texture
  106563. */
  106564. serialize(): any;
  106565. /**
  106566. * Helper function to be called back once a list of texture contains only ready textures.
  106567. * @param textures Define the list of textures to wait for
  106568. * @param callback Define the callback triggered once the entire list will be ready
  106569. */
  106570. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  106571. private static _isScene;
  106572. }
  106573. }
  106574. declare module BABYLON {
  106575. /**
  106576. * Options to be used when creating an effect.
  106577. */
  106578. export interface IEffectCreationOptions {
  106579. /**
  106580. * Atrributes that will be used in the shader.
  106581. */
  106582. attributes: string[];
  106583. /**
  106584. * Uniform varible names that will be set in the shader.
  106585. */
  106586. uniformsNames: string[];
  106587. /**
  106588. * Uniform buffer variable names that will be set in the shader.
  106589. */
  106590. uniformBuffersNames: string[];
  106591. /**
  106592. * Sampler texture variable names that will be set in the shader.
  106593. */
  106594. samplers: string[];
  106595. /**
  106596. * Define statements that will be set in the shader.
  106597. */
  106598. defines: any;
  106599. /**
  106600. * Possible fallbacks for this effect to improve performance when needed.
  106601. */
  106602. fallbacks: Nullable<IEffectFallbacks>;
  106603. /**
  106604. * Callback that will be called when the shader is compiled.
  106605. */
  106606. onCompiled: Nullable<(effect: Effect) => void>;
  106607. /**
  106608. * Callback that will be called if an error occurs during shader compilation.
  106609. */
  106610. onError: Nullable<(effect: Effect, errors: string) => void>;
  106611. /**
  106612. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106613. */
  106614. indexParameters?: any;
  106615. /**
  106616. * Max number of lights that can be used in the shader.
  106617. */
  106618. maxSimultaneousLights?: number;
  106619. /**
  106620. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  106621. */
  106622. transformFeedbackVaryings?: Nullable<string[]>;
  106623. }
  106624. /**
  106625. * Effect containing vertex and fragment shader that can be executed on an object.
  106626. */
  106627. export class Effect implements IDisposable {
  106628. /**
  106629. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  106630. */
  106631. static ShadersRepository: string;
  106632. /**
  106633. * Enable logging of the shader code when a compilation error occurs
  106634. */
  106635. static LogShaderCodeOnCompilationError: boolean;
  106636. /**
  106637. * Name of the effect.
  106638. */
  106639. name: any;
  106640. /**
  106641. * String container all the define statements that should be set on the shader.
  106642. */
  106643. defines: string;
  106644. /**
  106645. * Callback that will be called when the shader is compiled.
  106646. */
  106647. onCompiled: Nullable<(effect: Effect) => void>;
  106648. /**
  106649. * Callback that will be called if an error occurs during shader compilation.
  106650. */
  106651. onError: Nullable<(effect: Effect, errors: string) => void>;
  106652. /**
  106653. * Callback that will be called when effect is bound.
  106654. */
  106655. onBind: Nullable<(effect: Effect) => void>;
  106656. /**
  106657. * Unique ID of the effect.
  106658. */
  106659. uniqueId: number;
  106660. /**
  106661. * Observable that will be called when the shader is compiled.
  106662. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  106663. */
  106664. onCompileObservable: Observable<Effect>;
  106665. /**
  106666. * Observable that will be called if an error occurs during shader compilation.
  106667. */
  106668. onErrorObservable: Observable<Effect>;
  106669. /** @hidden */
  106670. _onBindObservable: Nullable<Observable<Effect>>;
  106671. /**
  106672. * @hidden
  106673. * Specifies if the effect was previously ready
  106674. */
  106675. _wasPreviouslyReady: boolean;
  106676. /**
  106677. * Observable that will be called when effect is bound.
  106678. */
  106679. get onBindObservable(): Observable<Effect>;
  106680. /** @hidden */
  106681. _bonesComputationForcedToCPU: boolean;
  106682. private static _uniqueIdSeed;
  106683. private _engine;
  106684. private _uniformBuffersNames;
  106685. private _uniformBuffersNamesList;
  106686. private _uniformsNames;
  106687. private _samplerList;
  106688. private _samplers;
  106689. private _isReady;
  106690. private _compilationError;
  106691. private _allFallbacksProcessed;
  106692. private _attributesNames;
  106693. private _attributes;
  106694. private _attributeLocationByName;
  106695. private _uniforms;
  106696. /**
  106697. * Key for the effect.
  106698. * @hidden
  106699. */
  106700. _key: string;
  106701. private _indexParameters;
  106702. private _fallbacks;
  106703. private _vertexSourceCode;
  106704. private _fragmentSourceCode;
  106705. private _vertexSourceCodeOverride;
  106706. private _fragmentSourceCodeOverride;
  106707. private _transformFeedbackVaryings;
  106708. /**
  106709. * Compiled shader to webGL program.
  106710. * @hidden
  106711. */
  106712. _pipelineContext: Nullable<IPipelineContext>;
  106713. private _valueCache;
  106714. private static _baseCache;
  106715. /**
  106716. * Instantiates an effect.
  106717. * An effect can be used to create/manage/execute vertex and fragment shaders.
  106718. * @param baseName Name of the effect.
  106719. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  106720. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  106721. * @param samplers List of sampler variables that will be passed to the shader.
  106722. * @param engine Engine to be used to render the effect
  106723. * @param defines Define statements to be added to the shader.
  106724. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  106725. * @param onCompiled Callback that will be called when the shader is compiled.
  106726. * @param onError Callback that will be called if an error occurs during shader compilation.
  106727. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106728. */
  106729. 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);
  106730. private _useFinalCode;
  106731. /**
  106732. * Unique key for this effect
  106733. */
  106734. get key(): string;
  106735. /**
  106736. * If the effect has been compiled and prepared.
  106737. * @returns if the effect is compiled and prepared.
  106738. */
  106739. isReady(): boolean;
  106740. private _isReadyInternal;
  106741. /**
  106742. * The engine the effect was initialized with.
  106743. * @returns the engine.
  106744. */
  106745. getEngine(): Engine;
  106746. /**
  106747. * The pipeline context for this effect
  106748. * @returns the associated pipeline context
  106749. */
  106750. getPipelineContext(): Nullable<IPipelineContext>;
  106751. /**
  106752. * The set of names of attribute variables for the shader.
  106753. * @returns An array of attribute names.
  106754. */
  106755. getAttributesNames(): string[];
  106756. /**
  106757. * Returns the attribute at the given index.
  106758. * @param index The index of the attribute.
  106759. * @returns The location of the attribute.
  106760. */
  106761. getAttributeLocation(index: number): number;
  106762. /**
  106763. * Returns the attribute based on the name of the variable.
  106764. * @param name of the attribute to look up.
  106765. * @returns the attribute location.
  106766. */
  106767. getAttributeLocationByName(name: string): number;
  106768. /**
  106769. * The number of attributes.
  106770. * @returns the numnber of attributes.
  106771. */
  106772. getAttributesCount(): number;
  106773. /**
  106774. * Gets the index of a uniform variable.
  106775. * @param uniformName of the uniform to look up.
  106776. * @returns the index.
  106777. */
  106778. getUniformIndex(uniformName: string): number;
  106779. /**
  106780. * Returns the attribute based on the name of the variable.
  106781. * @param uniformName of the uniform to look up.
  106782. * @returns the location of the uniform.
  106783. */
  106784. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  106785. /**
  106786. * Returns an array of sampler variable names
  106787. * @returns The array of sampler variable names.
  106788. */
  106789. getSamplers(): string[];
  106790. /**
  106791. * Returns an array of uniform variable names
  106792. * @returns The array of uniform variable names.
  106793. */
  106794. getUniformNames(): string[];
  106795. /**
  106796. * Returns an array of uniform buffer variable names
  106797. * @returns The array of uniform buffer variable names.
  106798. */
  106799. getUniformBuffersNames(): string[];
  106800. /**
  106801. * Returns the index parameters used to create the effect
  106802. * @returns The index parameters object
  106803. */
  106804. getIndexParameters(): any;
  106805. /**
  106806. * The error from the last compilation.
  106807. * @returns the error string.
  106808. */
  106809. getCompilationError(): string;
  106810. /**
  106811. * Gets a boolean indicating that all fallbacks were used during compilation
  106812. * @returns true if all fallbacks were used
  106813. */
  106814. allFallbacksProcessed(): boolean;
  106815. /**
  106816. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  106817. * @param func The callback to be used.
  106818. */
  106819. executeWhenCompiled(func: (effect: Effect) => void): void;
  106820. private _checkIsReady;
  106821. private _loadShader;
  106822. /**
  106823. * Gets the vertex shader source code of this effect
  106824. */
  106825. get vertexSourceCode(): string;
  106826. /**
  106827. * Gets the fragment shader source code of this effect
  106828. */
  106829. get fragmentSourceCode(): string;
  106830. /**
  106831. * Recompiles the webGL program
  106832. * @param vertexSourceCode The source code for the vertex shader.
  106833. * @param fragmentSourceCode The source code for the fragment shader.
  106834. * @param onCompiled Callback called when completed.
  106835. * @param onError Callback called on error.
  106836. * @hidden
  106837. */
  106838. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  106839. /**
  106840. * Prepares the effect
  106841. * @hidden
  106842. */
  106843. _prepareEffect(): void;
  106844. private _getShaderCodeAndErrorLine;
  106845. private _processCompilationErrors;
  106846. /**
  106847. * Checks if the effect is supported. (Must be called after compilation)
  106848. */
  106849. get isSupported(): boolean;
  106850. /**
  106851. * Binds a texture to the engine to be used as output of the shader.
  106852. * @param channel Name of the output variable.
  106853. * @param texture Texture to bind.
  106854. * @hidden
  106855. */
  106856. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  106857. /**
  106858. * Sets a texture on the engine to be used in the shader.
  106859. * @param channel Name of the sampler variable.
  106860. * @param texture Texture to set.
  106861. */
  106862. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  106863. /**
  106864. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  106865. * @param channel Name of the sampler variable.
  106866. * @param texture Texture to set.
  106867. */
  106868. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  106869. /**
  106870. * Sets an array of textures on the engine to be used in the shader.
  106871. * @param channel Name of the variable.
  106872. * @param textures Textures to set.
  106873. */
  106874. setTextureArray(channel: string, textures: BaseTexture[]): void;
  106875. /**
  106876. * 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)
  106877. * @param channel Name of the sampler variable.
  106878. * @param postProcess Post process to get the input texture from.
  106879. */
  106880. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  106881. /**
  106882. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  106883. * 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)
  106884. * @param channel Name of the sampler variable.
  106885. * @param postProcess Post process to get the output texture from.
  106886. */
  106887. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  106888. /** @hidden */
  106889. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  106890. /** @hidden */
  106891. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  106892. /** @hidden */
  106893. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  106894. /** @hidden */
  106895. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  106896. /**
  106897. * Binds a buffer to a uniform.
  106898. * @param buffer Buffer to bind.
  106899. * @param name Name of the uniform variable to bind to.
  106900. */
  106901. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  106902. /**
  106903. * Binds block to a uniform.
  106904. * @param blockName Name of the block to bind.
  106905. * @param index Index to bind.
  106906. */
  106907. bindUniformBlock(blockName: string, index: number): void;
  106908. /**
  106909. * Sets an interger value on a uniform variable.
  106910. * @param uniformName Name of the variable.
  106911. * @param value Value to be set.
  106912. * @returns this effect.
  106913. */
  106914. setInt(uniformName: string, value: number): Effect;
  106915. /**
  106916. * Sets an int array on a uniform variable.
  106917. * @param uniformName Name of the variable.
  106918. * @param array array to be set.
  106919. * @returns this effect.
  106920. */
  106921. setIntArray(uniformName: string, array: Int32Array): Effect;
  106922. /**
  106923. * 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)
  106924. * @param uniformName Name of the variable.
  106925. * @param array array to be set.
  106926. * @returns this effect.
  106927. */
  106928. setIntArray2(uniformName: string, array: Int32Array): Effect;
  106929. /**
  106930. * 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)
  106931. * @param uniformName Name of the variable.
  106932. * @param array array to be set.
  106933. * @returns this effect.
  106934. */
  106935. setIntArray3(uniformName: string, array: Int32Array): Effect;
  106936. /**
  106937. * 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)
  106938. * @param uniformName Name of the variable.
  106939. * @param array array to be set.
  106940. * @returns this effect.
  106941. */
  106942. setIntArray4(uniformName: string, array: Int32Array): Effect;
  106943. /**
  106944. * Sets an float array on a uniform variable.
  106945. * @param uniformName Name of the variable.
  106946. * @param array array to be set.
  106947. * @returns this effect.
  106948. */
  106949. setFloatArray(uniformName: string, array: Float32Array): Effect;
  106950. /**
  106951. * 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)
  106952. * @param uniformName Name of the variable.
  106953. * @param array array to be set.
  106954. * @returns this effect.
  106955. */
  106956. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  106957. /**
  106958. * 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)
  106959. * @param uniformName Name of the variable.
  106960. * @param array array to be set.
  106961. * @returns this effect.
  106962. */
  106963. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  106964. /**
  106965. * 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)
  106966. * @param uniformName Name of the variable.
  106967. * @param array array to be set.
  106968. * @returns this effect.
  106969. */
  106970. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  106971. /**
  106972. * Sets an array on a uniform variable.
  106973. * @param uniformName Name of the variable.
  106974. * @param array array to be set.
  106975. * @returns this effect.
  106976. */
  106977. setArray(uniformName: string, array: number[]): Effect;
  106978. /**
  106979. * 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)
  106980. * @param uniformName Name of the variable.
  106981. * @param array array to be set.
  106982. * @returns this effect.
  106983. */
  106984. setArray2(uniformName: string, array: number[]): Effect;
  106985. /**
  106986. * 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)
  106987. * @param uniformName Name of the variable.
  106988. * @param array array to be set.
  106989. * @returns this effect.
  106990. */
  106991. setArray3(uniformName: string, array: number[]): Effect;
  106992. /**
  106993. * 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)
  106994. * @param uniformName Name of the variable.
  106995. * @param array array to be set.
  106996. * @returns this effect.
  106997. */
  106998. setArray4(uniformName: string, array: number[]): Effect;
  106999. /**
  107000. * Sets matrices on a uniform variable.
  107001. * @param uniformName Name of the variable.
  107002. * @param matrices matrices to be set.
  107003. * @returns this effect.
  107004. */
  107005. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  107006. /**
  107007. * Sets matrix on a uniform variable.
  107008. * @param uniformName Name of the variable.
  107009. * @param matrix matrix to be set.
  107010. * @returns this effect.
  107011. */
  107012. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  107013. /**
  107014. * 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)
  107015. * @param uniformName Name of the variable.
  107016. * @param matrix matrix to be set.
  107017. * @returns this effect.
  107018. */
  107019. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  107020. /**
  107021. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  107022. * @param uniformName Name of the variable.
  107023. * @param matrix matrix to be set.
  107024. * @returns this effect.
  107025. */
  107026. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  107027. /**
  107028. * Sets a float on a uniform variable.
  107029. * @param uniformName Name of the variable.
  107030. * @param value value to be set.
  107031. * @returns this effect.
  107032. */
  107033. setFloat(uniformName: string, value: number): Effect;
  107034. /**
  107035. * Sets a boolean on a uniform variable.
  107036. * @param uniformName Name of the variable.
  107037. * @param bool value to be set.
  107038. * @returns this effect.
  107039. */
  107040. setBool(uniformName: string, bool: boolean): Effect;
  107041. /**
  107042. * Sets a Vector2 on a uniform variable.
  107043. * @param uniformName Name of the variable.
  107044. * @param vector2 vector2 to be set.
  107045. * @returns this effect.
  107046. */
  107047. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  107048. /**
  107049. * Sets a float2 on a uniform variable.
  107050. * @param uniformName Name of the variable.
  107051. * @param x First float in float2.
  107052. * @param y Second float in float2.
  107053. * @returns this effect.
  107054. */
  107055. setFloat2(uniformName: string, x: number, y: number): Effect;
  107056. /**
  107057. * Sets a Vector3 on a uniform variable.
  107058. * @param uniformName Name of the variable.
  107059. * @param vector3 Value to be set.
  107060. * @returns this effect.
  107061. */
  107062. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  107063. /**
  107064. * Sets a float3 on a uniform variable.
  107065. * @param uniformName Name of the variable.
  107066. * @param x First float in float3.
  107067. * @param y Second float in float3.
  107068. * @param z Third float in float3.
  107069. * @returns this effect.
  107070. */
  107071. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  107072. /**
  107073. * Sets a Vector4 on a uniform variable.
  107074. * @param uniformName Name of the variable.
  107075. * @param vector4 Value to be set.
  107076. * @returns this effect.
  107077. */
  107078. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  107079. /**
  107080. * Sets a float4 on a uniform variable.
  107081. * @param uniformName Name of the variable.
  107082. * @param x First float in float4.
  107083. * @param y Second float in float4.
  107084. * @param z Third float in float4.
  107085. * @param w Fourth float in float4.
  107086. * @returns this effect.
  107087. */
  107088. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  107089. /**
  107090. * Sets a Color3 on a uniform variable.
  107091. * @param uniformName Name of the variable.
  107092. * @param color3 Value to be set.
  107093. * @returns this effect.
  107094. */
  107095. setColor3(uniformName: string, color3: IColor3Like): Effect;
  107096. /**
  107097. * Sets a Color4 on a uniform variable.
  107098. * @param uniformName Name of the variable.
  107099. * @param color3 Value to be set.
  107100. * @param alpha Alpha value to be set.
  107101. * @returns this effect.
  107102. */
  107103. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  107104. /**
  107105. * Sets a Color4 on a uniform variable
  107106. * @param uniformName defines the name of the variable
  107107. * @param color4 defines the value to be set
  107108. * @returns this effect.
  107109. */
  107110. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  107111. /** Release all associated resources */
  107112. dispose(): void;
  107113. /**
  107114. * This function will add a new shader to the shader store
  107115. * @param name the name of the shader
  107116. * @param pixelShader optional pixel shader content
  107117. * @param vertexShader optional vertex shader content
  107118. */
  107119. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  107120. /**
  107121. * Store of each shader (The can be looked up using effect.key)
  107122. */
  107123. static ShadersStore: {
  107124. [key: string]: string;
  107125. };
  107126. /**
  107127. * Store of each included file for a shader (The can be looked up using effect.key)
  107128. */
  107129. static IncludesShadersStore: {
  107130. [key: string]: string;
  107131. };
  107132. /**
  107133. * Resets the cache of effects.
  107134. */
  107135. static ResetCache(): void;
  107136. }
  107137. }
  107138. declare module BABYLON {
  107139. /**
  107140. * Interface used to describe the capabilities of the engine relatively to the current browser
  107141. */
  107142. export interface EngineCapabilities {
  107143. /** Maximum textures units per fragment shader */
  107144. maxTexturesImageUnits: number;
  107145. /** Maximum texture units per vertex shader */
  107146. maxVertexTextureImageUnits: number;
  107147. /** Maximum textures units in the entire pipeline */
  107148. maxCombinedTexturesImageUnits: number;
  107149. /** Maximum texture size */
  107150. maxTextureSize: number;
  107151. /** Maximum texture samples */
  107152. maxSamples?: number;
  107153. /** Maximum cube texture size */
  107154. maxCubemapTextureSize: number;
  107155. /** Maximum render texture size */
  107156. maxRenderTextureSize: number;
  107157. /** Maximum number of vertex attributes */
  107158. maxVertexAttribs: number;
  107159. /** Maximum number of varyings */
  107160. maxVaryingVectors: number;
  107161. /** Maximum number of uniforms per vertex shader */
  107162. maxVertexUniformVectors: number;
  107163. /** Maximum number of uniforms per fragment shader */
  107164. maxFragmentUniformVectors: number;
  107165. /** Defines if standard derivates (dx/dy) are supported */
  107166. standardDerivatives: boolean;
  107167. /** Defines if s3tc texture compression is supported */
  107168. s3tc?: WEBGL_compressed_texture_s3tc;
  107169. /** Defines if pvrtc texture compression is supported */
  107170. pvrtc: any;
  107171. /** Defines if etc1 texture compression is supported */
  107172. etc1: any;
  107173. /** Defines if etc2 texture compression is supported */
  107174. etc2: any;
  107175. /** Defines if astc texture compression is supported */
  107176. astc: any;
  107177. /** Defines if float textures are supported */
  107178. textureFloat: boolean;
  107179. /** Defines if vertex array objects are supported */
  107180. vertexArrayObject: boolean;
  107181. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  107182. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  107183. /** Gets the maximum level of anisotropy supported */
  107184. maxAnisotropy: number;
  107185. /** Defines if instancing is supported */
  107186. instancedArrays: boolean;
  107187. /** Defines if 32 bits indices are supported */
  107188. uintIndices: boolean;
  107189. /** Defines if high precision shaders are supported */
  107190. highPrecisionShaderSupported: boolean;
  107191. /** Defines if depth reading in the fragment shader is supported */
  107192. fragmentDepthSupported: boolean;
  107193. /** Defines if float texture linear filtering is supported*/
  107194. textureFloatLinearFiltering: boolean;
  107195. /** Defines if rendering to float textures is supported */
  107196. textureFloatRender: boolean;
  107197. /** Defines if half float textures are supported*/
  107198. textureHalfFloat: boolean;
  107199. /** Defines if half float texture linear filtering is supported*/
  107200. textureHalfFloatLinearFiltering: boolean;
  107201. /** Defines if rendering to half float textures is supported */
  107202. textureHalfFloatRender: boolean;
  107203. /** Defines if textureLOD shader command is supported */
  107204. textureLOD: boolean;
  107205. /** Defines if draw buffers extension is supported */
  107206. drawBuffersExtension: boolean;
  107207. /** Defines if depth textures are supported */
  107208. depthTextureExtension: boolean;
  107209. /** Defines if float color buffer are supported */
  107210. colorBufferFloat: boolean;
  107211. /** Gets disjoint timer query extension (null if not supported) */
  107212. timerQuery?: EXT_disjoint_timer_query;
  107213. /** Defines if timestamp can be used with timer query */
  107214. canUseTimestampForTimerQuery: boolean;
  107215. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  107216. multiview?: any;
  107217. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  107218. oculusMultiview?: any;
  107219. /** Function used to let the system compiles shaders in background */
  107220. parallelShaderCompile?: {
  107221. COMPLETION_STATUS_KHR: number;
  107222. };
  107223. /** Max number of texture samples for MSAA */
  107224. maxMSAASamples: number;
  107225. /** Defines if the blend min max extension is supported */
  107226. blendMinMax: boolean;
  107227. }
  107228. }
  107229. declare module BABYLON {
  107230. /**
  107231. * @hidden
  107232. **/
  107233. export class DepthCullingState {
  107234. private _isDepthTestDirty;
  107235. private _isDepthMaskDirty;
  107236. private _isDepthFuncDirty;
  107237. private _isCullFaceDirty;
  107238. private _isCullDirty;
  107239. private _isZOffsetDirty;
  107240. private _isFrontFaceDirty;
  107241. private _depthTest;
  107242. private _depthMask;
  107243. private _depthFunc;
  107244. private _cull;
  107245. private _cullFace;
  107246. private _zOffset;
  107247. private _frontFace;
  107248. /**
  107249. * Initializes the state.
  107250. */
  107251. constructor();
  107252. get isDirty(): boolean;
  107253. get zOffset(): number;
  107254. set zOffset(value: number);
  107255. get cullFace(): Nullable<number>;
  107256. set cullFace(value: Nullable<number>);
  107257. get cull(): Nullable<boolean>;
  107258. set cull(value: Nullable<boolean>);
  107259. get depthFunc(): Nullable<number>;
  107260. set depthFunc(value: Nullable<number>);
  107261. get depthMask(): boolean;
  107262. set depthMask(value: boolean);
  107263. get depthTest(): boolean;
  107264. set depthTest(value: boolean);
  107265. get frontFace(): Nullable<number>;
  107266. set frontFace(value: Nullable<number>);
  107267. reset(): void;
  107268. apply(gl: WebGLRenderingContext): void;
  107269. }
  107270. }
  107271. declare module BABYLON {
  107272. /**
  107273. * @hidden
  107274. **/
  107275. export class StencilState {
  107276. /** 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 */
  107277. static readonly ALWAYS: number;
  107278. /** Passed to stencilOperation to specify that stencil value must be kept */
  107279. static readonly KEEP: number;
  107280. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107281. static readonly REPLACE: number;
  107282. private _isStencilTestDirty;
  107283. private _isStencilMaskDirty;
  107284. private _isStencilFuncDirty;
  107285. private _isStencilOpDirty;
  107286. private _stencilTest;
  107287. private _stencilMask;
  107288. private _stencilFunc;
  107289. private _stencilFuncRef;
  107290. private _stencilFuncMask;
  107291. private _stencilOpStencilFail;
  107292. private _stencilOpDepthFail;
  107293. private _stencilOpStencilDepthPass;
  107294. get isDirty(): boolean;
  107295. get stencilFunc(): number;
  107296. set stencilFunc(value: number);
  107297. get stencilFuncRef(): number;
  107298. set stencilFuncRef(value: number);
  107299. get stencilFuncMask(): number;
  107300. set stencilFuncMask(value: number);
  107301. get stencilOpStencilFail(): number;
  107302. set stencilOpStencilFail(value: number);
  107303. get stencilOpDepthFail(): number;
  107304. set stencilOpDepthFail(value: number);
  107305. get stencilOpStencilDepthPass(): number;
  107306. set stencilOpStencilDepthPass(value: number);
  107307. get stencilMask(): number;
  107308. set stencilMask(value: number);
  107309. get stencilTest(): boolean;
  107310. set stencilTest(value: boolean);
  107311. constructor();
  107312. reset(): void;
  107313. apply(gl: WebGLRenderingContext): void;
  107314. }
  107315. }
  107316. declare module BABYLON {
  107317. /**
  107318. * @hidden
  107319. **/
  107320. export class AlphaState {
  107321. private _isAlphaBlendDirty;
  107322. private _isBlendFunctionParametersDirty;
  107323. private _isBlendEquationParametersDirty;
  107324. private _isBlendConstantsDirty;
  107325. private _alphaBlend;
  107326. private _blendFunctionParameters;
  107327. private _blendEquationParameters;
  107328. private _blendConstants;
  107329. /**
  107330. * Initializes the state.
  107331. */
  107332. constructor();
  107333. get isDirty(): boolean;
  107334. get alphaBlend(): boolean;
  107335. set alphaBlend(value: boolean);
  107336. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  107337. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  107338. setAlphaEquationParameters(rgb: number, alpha: number): void;
  107339. reset(): void;
  107340. apply(gl: WebGLRenderingContext): void;
  107341. }
  107342. }
  107343. declare module BABYLON {
  107344. /** @hidden */
  107345. export class WebGL2ShaderProcessor implements IShaderProcessor {
  107346. attributeProcessor(attribute: string): string;
  107347. varyingProcessor(varying: string, isFragment: boolean): string;
  107348. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  107349. }
  107350. }
  107351. declare module BABYLON {
  107352. /**
  107353. * Interface for attribute information associated with buffer instanciation
  107354. */
  107355. export interface InstancingAttributeInfo {
  107356. /**
  107357. * Name of the GLSL attribute
  107358. * if attribute index is not specified, this is used to retrieve the index from the effect
  107359. */
  107360. attributeName: string;
  107361. /**
  107362. * Index/offset of the attribute in the vertex shader
  107363. * if not specified, this will be computes from the name.
  107364. */
  107365. index?: number;
  107366. /**
  107367. * size of the attribute, 1, 2, 3 or 4
  107368. */
  107369. attributeSize: number;
  107370. /**
  107371. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  107372. */
  107373. offset: number;
  107374. /**
  107375. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  107376. * default to 1
  107377. */
  107378. divisor?: number;
  107379. /**
  107380. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  107381. * default is FLOAT
  107382. */
  107383. attributeType?: number;
  107384. /**
  107385. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  107386. */
  107387. normalized?: boolean;
  107388. }
  107389. }
  107390. declare module BABYLON {
  107391. interface ThinEngine {
  107392. /**
  107393. * Update a video texture
  107394. * @param texture defines the texture to update
  107395. * @param video defines the video element to use
  107396. * @param invertY defines if data must be stored with Y axis inverted
  107397. */
  107398. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  107399. }
  107400. }
  107401. declare module BABYLON {
  107402. /**
  107403. * Settings for finer control over video usage
  107404. */
  107405. export interface VideoTextureSettings {
  107406. /**
  107407. * Applies `autoplay` to video, if specified
  107408. */
  107409. autoPlay?: boolean;
  107410. /**
  107411. * Applies `loop` to video, if specified
  107412. */
  107413. loop?: boolean;
  107414. /**
  107415. * Automatically updates internal texture from video at every frame in the render loop
  107416. */
  107417. autoUpdateTexture: boolean;
  107418. /**
  107419. * Image src displayed during the video loading or until the user interacts with the video.
  107420. */
  107421. poster?: string;
  107422. }
  107423. /**
  107424. * If you want to display a video in your scene, this is the special texture for that.
  107425. * This special texture works similar to other textures, with the exception of a few parameters.
  107426. * @see https://doc.babylonjs.com/how_to/video_texture
  107427. */
  107428. export class VideoTexture extends Texture {
  107429. /**
  107430. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  107431. */
  107432. readonly autoUpdateTexture: boolean;
  107433. /**
  107434. * The video instance used by the texture internally
  107435. */
  107436. readonly video: HTMLVideoElement;
  107437. private _onUserActionRequestedObservable;
  107438. /**
  107439. * Event triggerd when a dom action is required by the user to play the video.
  107440. * This happens due to recent changes in browser policies preventing video to auto start.
  107441. */
  107442. get onUserActionRequestedObservable(): Observable<Texture>;
  107443. private _generateMipMaps;
  107444. private _stillImageCaptured;
  107445. private _displayingPosterTexture;
  107446. private _settings;
  107447. private _createInternalTextureOnEvent;
  107448. private _frameId;
  107449. private _currentSrc;
  107450. /**
  107451. * Creates a video texture.
  107452. * If you want to display a video in your scene, this is the special texture for that.
  107453. * This special texture works similar to other textures, with the exception of a few parameters.
  107454. * @see https://doc.babylonjs.com/how_to/video_texture
  107455. * @param name optional name, will detect from video source, if not defined
  107456. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  107457. * @param scene is obviously the current scene.
  107458. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  107459. * @param invertY is false by default but can be used to invert video on Y axis
  107460. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  107461. * @param settings allows finer control over video usage
  107462. */
  107463. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  107464. private _getName;
  107465. private _getVideo;
  107466. private _createInternalTexture;
  107467. private reset;
  107468. /**
  107469. * @hidden Internal method to initiate `update`.
  107470. */
  107471. _rebuild(): void;
  107472. /**
  107473. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  107474. */
  107475. update(): void;
  107476. /**
  107477. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  107478. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  107479. */
  107480. updateTexture(isVisible: boolean): void;
  107481. protected _updateInternalTexture: () => void;
  107482. /**
  107483. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  107484. * @param url New url.
  107485. */
  107486. updateURL(url: string): void;
  107487. /**
  107488. * Clones the texture.
  107489. * @returns the cloned texture
  107490. */
  107491. clone(): VideoTexture;
  107492. /**
  107493. * Dispose the texture and release its associated resources.
  107494. */
  107495. dispose(): void;
  107496. /**
  107497. * Creates a video texture straight from a stream.
  107498. * @param scene Define the scene the texture should be created in
  107499. * @param stream Define the stream the texture should be created from
  107500. * @returns The created video texture as a promise
  107501. */
  107502. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  107503. /**
  107504. * Creates a video texture straight from your WebCam video feed.
  107505. * @param scene Define the scene the texture should be created in
  107506. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107507. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107508. * @returns The created video texture as a promise
  107509. */
  107510. static CreateFromWebCamAsync(scene: Scene, constraints: {
  107511. minWidth: number;
  107512. maxWidth: number;
  107513. minHeight: number;
  107514. maxHeight: number;
  107515. deviceId: string;
  107516. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  107517. /**
  107518. * Creates a video texture straight from your WebCam video feed.
  107519. * @param scene Define the scene the texture should be created in
  107520. * @param onReady Define a callback to triggered once the texture will be ready
  107521. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107522. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107523. */
  107524. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  107525. minWidth: number;
  107526. maxWidth: number;
  107527. minHeight: number;
  107528. maxHeight: number;
  107529. deviceId: string;
  107530. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  107531. }
  107532. }
  107533. declare module BABYLON {
  107534. /**
  107535. * Defines the interface used by objects working like Scene
  107536. * @hidden
  107537. */
  107538. export interface ISceneLike {
  107539. _addPendingData(data: any): void;
  107540. _removePendingData(data: any): void;
  107541. offlineProvider: IOfflineProvider;
  107542. }
  107543. /** Interface defining initialization parameters for Engine class */
  107544. export interface EngineOptions extends WebGLContextAttributes {
  107545. /**
  107546. * Defines if the engine should no exceed a specified device ratio
  107547. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  107548. */
  107549. limitDeviceRatio?: number;
  107550. /**
  107551. * Defines if webvr should be enabled automatically
  107552. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107553. */
  107554. autoEnableWebVR?: boolean;
  107555. /**
  107556. * Defines if webgl2 should be turned off even if supported
  107557. * @see http://doc.babylonjs.com/features/webgl2
  107558. */
  107559. disableWebGL2Support?: boolean;
  107560. /**
  107561. * Defines if webaudio should be initialized as well
  107562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107563. */
  107564. audioEngine?: boolean;
  107565. /**
  107566. * Defines if animations should run using a deterministic lock step
  107567. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107568. */
  107569. deterministicLockstep?: boolean;
  107570. /** Defines the maximum steps to use with deterministic lock step mode */
  107571. lockstepMaxSteps?: number;
  107572. /** Defines the seconds between each deterministic lock step */
  107573. timeStep?: number;
  107574. /**
  107575. * Defines that engine should ignore context lost events
  107576. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  107577. */
  107578. doNotHandleContextLost?: boolean;
  107579. /**
  107580. * Defines that engine should ignore modifying touch action attribute and style
  107581. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  107582. */
  107583. doNotHandleTouchAction?: boolean;
  107584. /**
  107585. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  107586. */
  107587. useHighPrecisionFloats?: boolean;
  107588. }
  107589. /**
  107590. * The base engine class (root of all engines)
  107591. */
  107592. export class ThinEngine {
  107593. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  107594. static ExceptionList: ({
  107595. key: string;
  107596. capture: string;
  107597. captureConstraint: number;
  107598. targets: string[];
  107599. } | {
  107600. key: string;
  107601. capture: null;
  107602. captureConstraint: null;
  107603. targets: string[];
  107604. })[];
  107605. /** @hidden */
  107606. static _TextureLoaders: IInternalTextureLoader[];
  107607. /**
  107608. * Returns the current npm package of the sdk
  107609. */
  107610. static get NpmPackage(): string;
  107611. /**
  107612. * Returns the current version of the framework
  107613. */
  107614. static get Version(): string;
  107615. /**
  107616. * Returns a string describing the current engine
  107617. */
  107618. get description(): string;
  107619. /**
  107620. * Gets or sets the epsilon value used by collision engine
  107621. */
  107622. static CollisionsEpsilon: number;
  107623. /**
  107624. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  107625. */
  107626. static get ShadersRepository(): string;
  107627. static set ShadersRepository(value: string);
  107628. /** @hidden */
  107629. _shaderProcessor: IShaderProcessor;
  107630. /**
  107631. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  107632. */
  107633. forcePOTTextures: boolean;
  107634. /**
  107635. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  107636. */
  107637. isFullscreen: boolean;
  107638. /**
  107639. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  107640. */
  107641. cullBackFaces: boolean;
  107642. /**
  107643. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  107644. */
  107645. renderEvenInBackground: boolean;
  107646. /**
  107647. * Gets or sets a boolean indicating that cache can be kept between frames
  107648. */
  107649. preventCacheWipeBetweenFrames: boolean;
  107650. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  107651. validateShaderPrograms: boolean;
  107652. /**
  107653. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  107654. * This can provide greater z depth for distant objects.
  107655. */
  107656. useReverseDepthBuffer: boolean;
  107657. /**
  107658. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  107659. */
  107660. disableUniformBuffers: boolean;
  107661. /** @hidden */
  107662. _uniformBuffers: UniformBuffer[];
  107663. /**
  107664. * Gets a boolean indicating that the engine supports uniform buffers
  107665. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  107666. */
  107667. get supportsUniformBuffers(): boolean;
  107668. /** @hidden */
  107669. _gl: WebGLRenderingContext;
  107670. /** @hidden */
  107671. _webGLVersion: number;
  107672. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  107673. protected _windowIsBackground: boolean;
  107674. protected _creationOptions: EngineOptions;
  107675. protected _highPrecisionShadersAllowed: boolean;
  107676. /** @hidden */
  107677. get _shouldUseHighPrecisionShader(): boolean;
  107678. /**
  107679. * Gets a boolean indicating that only power of 2 textures are supported
  107680. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  107681. */
  107682. get needPOTTextures(): boolean;
  107683. /** @hidden */
  107684. _badOS: boolean;
  107685. /** @hidden */
  107686. _badDesktopOS: boolean;
  107687. private _hardwareScalingLevel;
  107688. /** @hidden */
  107689. _caps: EngineCapabilities;
  107690. private _isStencilEnable;
  107691. private _glVersion;
  107692. private _glRenderer;
  107693. private _glVendor;
  107694. /** @hidden */
  107695. _videoTextureSupported: boolean;
  107696. protected _renderingQueueLaunched: boolean;
  107697. protected _activeRenderLoops: (() => void)[];
  107698. /**
  107699. * Observable signaled when a context lost event is raised
  107700. */
  107701. onContextLostObservable: Observable<ThinEngine>;
  107702. /**
  107703. * Observable signaled when a context restored event is raised
  107704. */
  107705. onContextRestoredObservable: Observable<ThinEngine>;
  107706. private _onContextLost;
  107707. private _onContextRestored;
  107708. protected _contextWasLost: boolean;
  107709. /** @hidden */
  107710. _doNotHandleContextLost: boolean;
  107711. /**
  107712. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  107713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  107714. */
  107715. get doNotHandleContextLost(): boolean;
  107716. set doNotHandleContextLost(value: boolean);
  107717. /**
  107718. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  107719. */
  107720. disableVertexArrayObjects: boolean;
  107721. /** @hidden */
  107722. protected _colorWrite: boolean;
  107723. /** @hidden */
  107724. protected _colorWriteChanged: boolean;
  107725. /** @hidden */
  107726. protected _depthCullingState: DepthCullingState;
  107727. /** @hidden */
  107728. protected _stencilState: StencilState;
  107729. /** @hidden */
  107730. _alphaState: AlphaState;
  107731. /** @hidden */
  107732. _alphaMode: number;
  107733. /** @hidden */
  107734. _alphaEquation: number;
  107735. /** @hidden */
  107736. _internalTexturesCache: InternalTexture[];
  107737. /** @hidden */
  107738. protected _activeChannel: number;
  107739. private _currentTextureChannel;
  107740. /** @hidden */
  107741. protected _boundTexturesCache: {
  107742. [key: string]: Nullable<InternalTexture>;
  107743. };
  107744. /** @hidden */
  107745. protected _currentEffect: Nullable<Effect>;
  107746. /** @hidden */
  107747. protected _currentProgram: Nullable<WebGLProgram>;
  107748. private _compiledEffects;
  107749. private _vertexAttribArraysEnabled;
  107750. /** @hidden */
  107751. protected _cachedViewport: Nullable<IViewportLike>;
  107752. private _cachedVertexArrayObject;
  107753. /** @hidden */
  107754. protected _cachedVertexBuffers: any;
  107755. /** @hidden */
  107756. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  107757. /** @hidden */
  107758. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  107759. /** @hidden */
  107760. _currentRenderTarget: Nullable<InternalTexture>;
  107761. private _uintIndicesCurrentlySet;
  107762. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  107763. /** @hidden */
  107764. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  107765. /** @hidden */
  107766. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  107767. private _currentBufferPointers;
  107768. private _currentInstanceLocations;
  107769. private _currentInstanceBuffers;
  107770. private _textureUnits;
  107771. /** @hidden */
  107772. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107773. /** @hidden */
  107774. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107775. /** @hidden */
  107776. _boundRenderFunction: any;
  107777. private _vaoRecordInProgress;
  107778. private _mustWipeVertexAttributes;
  107779. private _emptyTexture;
  107780. private _emptyCubeTexture;
  107781. private _emptyTexture3D;
  107782. private _emptyTexture2DArray;
  107783. /** @hidden */
  107784. _frameHandler: number;
  107785. private _nextFreeTextureSlots;
  107786. private _maxSimultaneousTextures;
  107787. private _activeRequests;
  107788. /** @hidden */
  107789. _transformTextureUrl: Nullable<(url: string) => string>;
  107790. protected get _supportsHardwareTextureRescaling(): boolean;
  107791. private _framebufferDimensionsObject;
  107792. /**
  107793. * sets the object from which width and height will be taken from when getting render width and height
  107794. * Will fallback to the gl object
  107795. * @param dimensions the framebuffer width and height that will be used.
  107796. */
  107797. set framebufferDimensionsObject(dimensions: Nullable<{
  107798. framebufferWidth: number;
  107799. framebufferHeight: number;
  107800. }>);
  107801. /**
  107802. * Gets the current viewport
  107803. */
  107804. get currentViewport(): Nullable<IViewportLike>;
  107805. /**
  107806. * Gets the default empty texture
  107807. */
  107808. get emptyTexture(): InternalTexture;
  107809. /**
  107810. * Gets the default empty 3D texture
  107811. */
  107812. get emptyTexture3D(): InternalTexture;
  107813. /**
  107814. * Gets the default empty 2D array texture
  107815. */
  107816. get emptyTexture2DArray(): InternalTexture;
  107817. /**
  107818. * Gets the default empty cube texture
  107819. */
  107820. get emptyCubeTexture(): InternalTexture;
  107821. /**
  107822. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  107823. */
  107824. readonly premultipliedAlpha: boolean;
  107825. /**
  107826. * Observable event triggered before each texture is initialized
  107827. */
  107828. onBeforeTextureInitObservable: Observable<Texture>;
  107829. /**
  107830. * Creates a new engine
  107831. * @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
  107832. * @param antialias defines enable antialiasing (default: false)
  107833. * @param options defines further options to be sent to the getContext() function
  107834. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107835. */
  107836. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107837. private _rebuildInternalTextures;
  107838. private _rebuildEffects;
  107839. /**
  107840. * Gets a boolean indicating if all created effects are ready
  107841. * @returns true if all effects are ready
  107842. */
  107843. areAllEffectsReady(): boolean;
  107844. protected _rebuildBuffers(): void;
  107845. protected _initGLContext(): void;
  107846. /**
  107847. * Gets version of the current webGL context
  107848. */
  107849. get webGLVersion(): number;
  107850. /**
  107851. * Gets a string idenfifying the name of the class
  107852. * @returns "Engine" string
  107853. */
  107854. getClassName(): string;
  107855. /**
  107856. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  107857. */
  107858. get isStencilEnable(): boolean;
  107859. /** @hidden */
  107860. _prepareWorkingCanvas(): void;
  107861. /**
  107862. * Reset the texture cache to empty state
  107863. */
  107864. resetTextureCache(): void;
  107865. /**
  107866. * Gets an object containing information about the current webGL context
  107867. * @returns an object containing the vender, the renderer and the version of the current webGL context
  107868. */
  107869. getGlInfo(): {
  107870. vendor: string;
  107871. renderer: string;
  107872. version: string;
  107873. };
  107874. /**
  107875. * Defines the hardware scaling level.
  107876. * By default the hardware scaling level is computed from the window device ratio.
  107877. * 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.
  107878. * @param level defines the level to use
  107879. */
  107880. setHardwareScalingLevel(level: number): void;
  107881. /**
  107882. * Gets the current hardware scaling level.
  107883. * By default the hardware scaling level is computed from the window device ratio.
  107884. * 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.
  107885. * @returns a number indicating the current hardware scaling level
  107886. */
  107887. getHardwareScalingLevel(): number;
  107888. /**
  107889. * Gets the list of loaded textures
  107890. * @returns an array containing all loaded textures
  107891. */
  107892. getLoadedTexturesCache(): InternalTexture[];
  107893. /**
  107894. * Gets the object containing all engine capabilities
  107895. * @returns the EngineCapabilities object
  107896. */
  107897. getCaps(): EngineCapabilities;
  107898. /**
  107899. * stop executing a render loop function and remove it from the execution array
  107900. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  107901. */
  107902. stopRenderLoop(renderFunction?: () => void): void;
  107903. /** @hidden */
  107904. _renderLoop(): void;
  107905. /**
  107906. * Gets the HTML canvas attached with the current webGL context
  107907. * @returns a HTML canvas
  107908. */
  107909. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  107910. /**
  107911. * Gets host window
  107912. * @returns the host window object
  107913. */
  107914. getHostWindow(): Nullable<Window>;
  107915. /**
  107916. * Gets the current render width
  107917. * @param useScreen defines if screen size must be used (or the current render target if any)
  107918. * @returns a number defining the current render width
  107919. */
  107920. getRenderWidth(useScreen?: boolean): number;
  107921. /**
  107922. * Gets the current render height
  107923. * @param useScreen defines if screen size must be used (or the current render target if any)
  107924. * @returns a number defining the current render height
  107925. */
  107926. getRenderHeight(useScreen?: boolean): number;
  107927. /**
  107928. * Can be used to override the current requestAnimationFrame requester.
  107929. * @hidden
  107930. */
  107931. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  107932. /**
  107933. * Register and execute a render loop. The engine can have more than one render function
  107934. * @param renderFunction defines the function to continuously execute
  107935. */
  107936. runRenderLoop(renderFunction: () => void): void;
  107937. /**
  107938. * Clear the current render buffer or the current render target (if any is set up)
  107939. * @param color defines the color to use
  107940. * @param backBuffer defines if the back buffer must be cleared
  107941. * @param depth defines if the depth buffer must be cleared
  107942. * @param stencil defines if the stencil buffer must be cleared
  107943. */
  107944. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107945. private _viewportCached;
  107946. /** @hidden */
  107947. _viewport(x: number, y: number, width: number, height: number): void;
  107948. /**
  107949. * Set the WebGL's viewport
  107950. * @param viewport defines the viewport element to be used
  107951. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  107952. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  107953. */
  107954. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107955. /**
  107956. * Begin a new frame
  107957. */
  107958. beginFrame(): void;
  107959. /**
  107960. * Enf the current frame
  107961. */
  107962. endFrame(): void;
  107963. /**
  107964. * Resize the view according to the canvas' size
  107965. */
  107966. resize(): void;
  107967. /**
  107968. * Force a specific size of the canvas
  107969. * @param width defines the new canvas' width
  107970. * @param height defines the new canvas' height
  107971. */
  107972. setSize(width: number, height: number): void;
  107973. /**
  107974. * Binds the frame buffer to the specified texture.
  107975. * @param texture The texture to render to or null for the default canvas
  107976. * @param faceIndex The face of the texture to render to in case of cube texture
  107977. * @param requiredWidth The width of the target to render to
  107978. * @param requiredHeight The height of the target to render to
  107979. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  107980. * @param lodLevel defines the lod level to bind to the frame buffer
  107981. * @param layer defines the 2d array index to bind to frame buffer to
  107982. */
  107983. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  107984. /** @hidden */
  107985. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  107986. /**
  107987. * Unbind the current render target texture from the webGL context
  107988. * @param texture defines the render target texture to unbind
  107989. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107990. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107991. */
  107992. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107993. /**
  107994. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  107995. */
  107996. flushFramebuffer(): void;
  107997. /**
  107998. * Unbind the current render target and bind the default framebuffer
  107999. */
  108000. restoreDefaultFramebuffer(): void;
  108001. /** @hidden */
  108002. protected _resetVertexBufferBinding(): void;
  108003. /**
  108004. * Creates a vertex buffer
  108005. * @param data the data for the vertex buffer
  108006. * @returns the new WebGL static buffer
  108007. */
  108008. createVertexBuffer(data: DataArray): DataBuffer;
  108009. private _createVertexBuffer;
  108010. /**
  108011. * Creates a dynamic vertex buffer
  108012. * @param data the data for the dynamic vertex buffer
  108013. * @returns the new WebGL dynamic buffer
  108014. */
  108015. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  108016. protected _resetIndexBufferBinding(): void;
  108017. /**
  108018. * Creates a new index buffer
  108019. * @param indices defines the content of the index buffer
  108020. * @param updatable defines if the index buffer must be updatable
  108021. * @returns a new webGL buffer
  108022. */
  108023. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  108024. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  108025. /**
  108026. * Bind a webGL buffer to the webGL context
  108027. * @param buffer defines the buffer to bind
  108028. */
  108029. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  108030. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  108031. private bindBuffer;
  108032. /**
  108033. * update the bound buffer with the given data
  108034. * @param data defines the data to update
  108035. */
  108036. updateArrayBuffer(data: Float32Array): void;
  108037. private _vertexAttribPointer;
  108038. /** @hidden */
  108039. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  108040. private _bindVertexBuffersAttributes;
  108041. /**
  108042. * Records a vertex array object
  108043. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  108044. * @param vertexBuffers defines the list of vertex buffers to store
  108045. * @param indexBuffer defines the index buffer to store
  108046. * @param effect defines the effect to store
  108047. * @returns the new vertex array object
  108048. */
  108049. recordVertexArrayObject(vertexBuffers: {
  108050. [key: string]: VertexBuffer;
  108051. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  108052. /**
  108053. * Bind a specific vertex array object
  108054. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  108055. * @param vertexArrayObject defines the vertex array object to bind
  108056. * @param indexBuffer defines the index buffer to bind
  108057. */
  108058. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  108059. /**
  108060. * Bind webGl buffers directly to the webGL context
  108061. * @param vertexBuffer defines the vertex buffer to bind
  108062. * @param indexBuffer defines the index buffer to bind
  108063. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  108064. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  108065. * @param effect defines the effect associated with the vertex buffer
  108066. */
  108067. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  108068. private _unbindVertexArrayObject;
  108069. /**
  108070. * Bind a list of vertex buffers to the webGL context
  108071. * @param vertexBuffers defines the list of vertex buffers to bind
  108072. * @param indexBuffer defines the index buffer to bind
  108073. * @param effect defines the effect associated with the vertex buffers
  108074. */
  108075. bindBuffers(vertexBuffers: {
  108076. [key: string]: Nullable<VertexBuffer>;
  108077. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  108078. /**
  108079. * Unbind all instance attributes
  108080. */
  108081. unbindInstanceAttributes(): void;
  108082. /**
  108083. * Release and free the memory of a vertex array object
  108084. * @param vao defines the vertex array object to delete
  108085. */
  108086. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  108087. /** @hidden */
  108088. _releaseBuffer(buffer: DataBuffer): boolean;
  108089. protected _deleteBuffer(buffer: DataBuffer): void;
  108090. /**
  108091. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  108092. * @param instancesBuffer defines the webGL buffer to update and bind
  108093. * @param data defines the data to store in the buffer
  108094. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  108095. */
  108096. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  108097. /**
  108098. * Bind the content of a webGL buffer used with instantiation
  108099. * @param instancesBuffer defines the webGL buffer to bind
  108100. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  108101. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  108102. */
  108103. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  108104. /**
  108105. * Disable the instance attribute corresponding to the name in parameter
  108106. * @param name defines the name of the attribute to disable
  108107. */
  108108. disableInstanceAttributeByName(name: string): void;
  108109. /**
  108110. * Disable the instance attribute corresponding to the location in parameter
  108111. * @param attributeLocation defines the attribute location of the attribute to disable
  108112. */
  108113. disableInstanceAttribute(attributeLocation: number): void;
  108114. /**
  108115. * Disable the attribute corresponding to the location in parameter
  108116. * @param attributeLocation defines the attribute location of the attribute to disable
  108117. */
  108118. disableAttributeByIndex(attributeLocation: number): void;
  108119. /**
  108120. * Send a draw order
  108121. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  108122. * @param indexStart defines the starting index
  108123. * @param indexCount defines the number of index to draw
  108124. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108125. */
  108126. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108127. /**
  108128. * Draw a list of points
  108129. * @param verticesStart defines the index of first vertex to draw
  108130. * @param verticesCount defines the count of vertices to draw
  108131. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108132. */
  108133. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108134. /**
  108135. * Draw a list of unindexed primitives
  108136. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  108137. * @param verticesStart defines the index of first vertex to draw
  108138. * @param verticesCount defines the count of vertices to draw
  108139. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108140. */
  108141. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108142. /**
  108143. * Draw a list of indexed primitives
  108144. * @param fillMode defines the primitive to use
  108145. * @param indexStart defines the starting index
  108146. * @param indexCount defines the number of index to draw
  108147. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108148. */
  108149. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108150. /**
  108151. * Draw a list of unindexed primitives
  108152. * @param fillMode defines the primitive to use
  108153. * @param verticesStart defines the index of first vertex to draw
  108154. * @param verticesCount defines the count of vertices to draw
  108155. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108156. */
  108157. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108158. private _drawMode;
  108159. /** @hidden */
  108160. protected _reportDrawCall(): void;
  108161. /** @hidden */
  108162. _releaseEffect(effect: Effect): void;
  108163. /** @hidden */
  108164. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108165. /**
  108166. * Create a new effect (used to store vertex/fragment shaders)
  108167. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  108168. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  108169. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  108170. * @param samplers defines an array of string used to represent textures
  108171. * @param defines defines the string containing the defines to use to compile the shaders
  108172. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108173. * @param onCompiled defines a function to call when the effect creation is successful
  108174. * @param onError defines a function to call when the effect creation has failed
  108175. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  108176. * @returns the new Effect
  108177. */
  108178. 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;
  108179. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  108180. private _compileShader;
  108181. private _compileRawShader;
  108182. /** @hidden */
  108183. _getShaderSource(shader: WebGLShader): Nullable<string>;
  108184. /**
  108185. * Directly creates a webGL program
  108186. * @param pipelineContext defines the pipeline context to attach to
  108187. * @param vertexCode defines the vertex shader code to use
  108188. * @param fragmentCode defines the fragment shader code to use
  108189. * @param context defines the webGL context to use (if not set, the current one will be used)
  108190. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  108191. * @returns the new webGL program
  108192. */
  108193. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108194. /**
  108195. * Creates a webGL program
  108196. * @param pipelineContext defines the pipeline context to attach to
  108197. * @param vertexCode defines the vertex shader code to use
  108198. * @param fragmentCode defines the fragment shader code to use
  108199. * @param defines defines the string containing the defines to use to compile the shaders
  108200. * @param context defines the webGL context to use (if not set, the current one will be used)
  108201. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  108202. * @returns the new webGL program
  108203. */
  108204. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108205. /**
  108206. * Creates a new pipeline context
  108207. * @returns the new pipeline
  108208. */
  108209. createPipelineContext(): IPipelineContext;
  108210. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108211. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  108212. /** @hidden */
  108213. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  108214. /** @hidden */
  108215. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  108216. /** @hidden */
  108217. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  108218. /**
  108219. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  108220. * @param pipelineContext defines the pipeline context to use
  108221. * @param uniformsNames defines the list of uniform names
  108222. * @returns an array of webGL uniform locations
  108223. */
  108224. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108225. /**
  108226. * Gets the lsit of active attributes for a given webGL program
  108227. * @param pipelineContext defines the pipeline context to use
  108228. * @param attributesNames defines the list of attribute names to get
  108229. * @returns an array of indices indicating the offset of each attribute
  108230. */
  108231. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108232. /**
  108233. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  108234. * @param effect defines the effect to activate
  108235. */
  108236. enableEffect(effect: Nullable<Effect>): void;
  108237. /**
  108238. * Set the value of an uniform to a number (int)
  108239. * @param uniform defines the webGL uniform location where to store the value
  108240. * @param value defines the int number to store
  108241. */
  108242. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108243. /**
  108244. * Set the value of an uniform to an array of int32
  108245. * @param uniform defines the webGL uniform location where to store the value
  108246. * @param array defines the array of int32 to store
  108247. */
  108248. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108249. /**
  108250. * Set the value of an uniform to an array of int32 (stored as vec2)
  108251. * @param uniform defines the webGL uniform location where to store the value
  108252. * @param array defines the array of int32 to store
  108253. */
  108254. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108255. /**
  108256. * Set the value of an uniform to an array of int32 (stored as vec3)
  108257. * @param uniform defines the webGL uniform location where to store the value
  108258. * @param array defines the array of int32 to store
  108259. */
  108260. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108261. /**
  108262. * Set the value of an uniform to an array of int32 (stored as vec4)
  108263. * @param uniform defines the webGL uniform location where to store the value
  108264. * @param array defines the array of int32 to store
  108265. */
  108266. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108267. /**
  108268. * Set the value of an uniform to an array of number
  108269. * @param uniform defines the webGL uniform location where to store the value
  108270. * @param array defines the array of number to store
  108271. */
  108272. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108273. /**
  108274. * Set the value of an uniform to an array of number (stored as vec2)
  108275. * @param uniform defines the webGL uniform location where to store the value
  108276. * @param array defines the array of number to store
  108277. */
  108278. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108279. /**
  108280. * Set the value of an uniform to an array of number (stored as vec3)
  108281. * @param uniform defines the webGL uniform location where to store the value
  108282. * @param array defines the array of number to store
  108283. */
  108284. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108285. /**
  108286. * Set the value of an uniform to an array of number (stored as vec4)
  108287. * @param uniform defines the webGL uniform location where to store the value
  108288. * @param array defines the array of number to store
  108289. */
  108290. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108291. /**
  108292. * Set the value of an uniform to an array of float32 (stored as matrices)
  108293. * @param uniform defines the webGL uniform location where to store the value
  108294. * @param matrices defines the array of float32 to store
  108295. */
  108296. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  108297. /**
  108298. * Set the value of an uniform to a matrix (3x3)
  108299. * @param uniform defines the webGL uniform location where to store the value
  108300. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  108301. */
  108302. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108303. /**
  108304. * Set the value of an uniform to a matrix (2x2)
  108305. * @param uniform defines the webGL uniform location where to store the value
  108306. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  108307. */
  108308. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108309. /**
  108310. * Set the value of an uniform to a number (float)
  108311. * @param uniform defines the webGL uniform location where to store the value
  108312. * @param value defines the float number to store
  108313. */
  108314. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108315. /**
  108316. * Set the value of an uniform to a vec2
  108317. * @param uniform defines the webGL uniform location where to store the value
  108318. * @param x defines the 1st component of the value
  108319. * @param y defines the 2nd component of the value
  108320. */
  108321. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  108322. /**
  108323. * Set the value of an uniform to a vec3
  108324. * @param uniform defines the webGL uniform location where to store the value
  108325. * @param x defines the 1st component of the value
  108326. * @param y defines the 2nd component of the value
  108327. * @param z defines the 3rd component of the value
  108328. */
  108329. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  108330. /**
  108331. * Set the value of an uniform to a vec4
  108332. * @param uniform defines the webGL uniform location where to store the value
  108333. * @param x defines the 1st component of the value
  108334. * @param y defines the 2nd component of the value
  108335. * @param z defines the 3rd component of the value
  108336. * @param w defines the 4th component of the value
  108337. */
  108338. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  108339. /**
  108340. * Apply all cached states (depth, culling, stencil and alpha)
  108341. */
  108342. applyStates(): void;
  108343. /**
  108344. * Enable or disable color writing
  108345. * @param enable defines the state to set
  108346. */
  108347. setColorWrite(enable: boolean): void;
  108348. /**
  108349. * Gets a boolean indicating if color writing is enabled
  108350. * @returns the current color writing state
  108351. */
  108352. getColorWrite(): boolean;
  108353. /**
  108354. * Gets the depth culling state manager
  108355. */
  108356. get depthCullingState(): DepthCullingState;
  108357. /**
  108358. * Gets the alpha state manager
  108359. */
  108360. get alphaState(): AlphaState;
  108361. /**
  108362. * Gets the stencil state manager
  108363. */
  108364. get stencilState(): StencilState;
  108365. /**
  108366. * Clears the list of texture accessible through engine.
  108367. * This can help preventing texture load conflict due to name collision.
  108368. */
  108369. clearInternalTexturesCache(): void;
  108370. /**
  108371. * Force the entire cache to be cleared
  108372. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  108373. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  108374. */
  108375. wipeCaches(bruteForce?: boolean): void;
  108376. /** @hidden */
  108377. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  108378. min: number;
  108379. mag: number;
  108380. };
  108381. /** @hidden */
  108382. _createTexture(): WebGLTexture;
  108383. /**
  108384. * Usually called from Texture.ts.
  108385. * Passed information to create a WebGLTexture
  108386. * @param url defines a value which contains one of the following:
  108387. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  108388. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  108389. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  108390. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  108391. * @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)
  108392. * @param scene needed for loading to the correct scene
  108393. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  108394. * @param onLoad optional callback to be called upon successful completion
  108395. * @param onError optional callback to be called upon failure
  108396. * @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
  108397. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  108398. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  108399. * @param forcedExtension defines the extension to use to pick the right loader
  108400. * @param mimeType defines an optional mime type
  108401. * @returns a InternalTexture for assignment back into BABYLON.Texture
  108402. */
  108403. 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;
  108404. /**
  108405. * Loads an image as an HTMLImageElement.
  108406. * @param input url string, ArrayBuffer, or Blob to load
  108407. * @param onLoad callback called when the image successfully loads
  108408. * @param onError callback called when the image fails to load
  108409. * @param offlineProvider offline provider for caching
  108410. * @param mimeType optional mime type
  108411. * @returns the HTMLImageElement of the loaded image
  108412. * @hidden
  108413. */
  108414. 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>;
  108415. /**
  108416. * @hidden
  108417. */
  108418. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108419. private _unpackFlipYCached;
  108420. /**
  108421. * In case you are sharing the context with other applications, it might
  108422. * be interested to not cache the unpack flip y state to ensure a consistent
  108423. * value would be set.
  108424. */
  108425. enableUnpackFlipYCached: boolean;
  108426. /** @hidden */
  108427. _unpackFlipY(value: boolean): void;
  108428. /** @hidden */
  108429. _getUnpackAlignement(): number;
  108430. private _getTextureTarget;
  108431. /**
  108432. * Update the sampling mode of a given texture
  108433. * @param samplingMode defines the required sampling mode
  108434. * @param texture defines the texture to update
  108435. * @param generateMipMaps defines whether to generate mipmaps for the texture
  108436. */
  108437. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  108438. /**
  108439. * Update the sampling mode of a given texture
  108440. * @param texture defines the texture to update
  108441. * @param wrapU defines the texture wrap mode of the u coordinates
  108442. * @param wrapV defines the texture wrap mode of the v coordinates
  108443. * @param wrapR defines the texture wrap mode of the r coordinates
  108444. */
  108445. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  108446. /** @hidden */
  108447. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  108448. width: number;
  108449. height: number;
  108450. layers?: number;
  108451. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  108452. /** @hidden */
  108453. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108454. /** @hidden */
  108455. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  108456. /**
  108457. * Update a portion of an internal texture
  108458. * @param texture defines the texture to update
  108459. * @param imageData defines the data to store into the texture
  108460. * @param xOffset defines the x coordinates of the update rectangle
  108461. * @param yOffset defines the y coordinates of the update rectangle
  108462. * @param width defines the width of the update rectangle
  108463. * @param height defines the height of the update rectangle
  108464. * @param faceIndex defines the face index if texture is a cube (0 by default)
  108465. * @param lod defines the lod level to update (0 by default)
  108466. */
  108467. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  108468. /** @hidden */
  108469. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108470. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  108471. private _prepareWebGLTexture;
  108472. /** @hidden */
  108473. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  108474. private _getDepthStencilBuffer;
  108475. /** @hidden */
  108476. _releaseFramebufferObjects(texture: InternalTexture): void;
  108477. /** @hidden */
  108478. _releaseTexture(texture: InternalTexture): void;
  108479. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  108480. protected _setProgram(program: WebGLProgram): void;
  108481. protected _boundUniforms: {
  108482. [key: number]: WebGLUniformLocation;
  108483. };
  108484. /**
  108485. * Binds an effect to the webGL context
  108486. * @param effect defines the effect to bind
  108487. */
  108488. bindSamplers(effect: Effect): void;
  108489. private _activateCurrentTexture;
  108490. /** @hidden */
  108491. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  108492. /** @hidden */
  108493. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  108494. /**
  108495. * Unbind all textures from the webGL context
  108496. */
  108497. unbindAllTextures(): void;
  108498. /**
  108499. * Sets a texture to the according uniform.
  108500. * @param channel The texture channel
  108501. * @param uniform The uniform to set
  108502. * @param texture The texture to apply
  108503. */
  108504. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  108505. private _bindSamplerUniformToChannel;
  108506. private _getTextureWrapMode;
  108507. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  108508. /**
  108509. * Sets an array of texture to the webGL context
  108510. * @param channel defines the channel where the texture array must be set
  108511. * @param uniform defines the associated uniform location
  108512. * @param textures defines the array of textures to bind
  108513. */
  108514. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  108515. /** @hidden */
  108516. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  108517. private _setTextureParameterFloat;
  108518. private _setTextureParameterInteger;
  108519. /**
  108520. * Unbind all vertex attributes from the webGL context
  108521. */
  108522. unbindAllAttributes(): void;
  108523. /**
  108524. * 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
  108525. */
  108526. releaseEffects(): void;
  108527. /**
  108528. * Dispose and release all associated resources
  108529. */
  108530. dispose(): void;
  108531. /**
  108532. * Attach a new callback raised when context lost event is fired
  108533. * @param callback defines the callback to call
  108534. */
  108535. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108536. /**
  108537. * Attach a new callback raised when context restored event is fired
  108538. * @param callback defines the callback to call
  108539. */
  108540. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108541. /**
  108542. * Get the current error code of the webGL context
  108543. * @returns the error code
  108544. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108545. */
  108546. getError(): number;
  108547. private _canRenderToFloatFramebuffer;
  108548. private _canRenderToHalfFloatFramebuffer;
  108549. private _canRenderToFramebuffer;
  108550. /** @hidden */
  108551. _getWebGLTextureType(type: number): number;
  108552. /** @hidden */
  108553. _getInternalFormat(format: number): number;
  108554. /** @hidden */
  108555. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  108556. /** @hidden */
  108557. _getRGBAMultiSampleBufferFormat(type: number): number;
  108558. /** @hidden */
  108559. _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;
  108560. /**
  108561. * Loads a file from a url
  108562. * @param url url to load
  108563. * @param onSuccess callback called when the file successfully loads
  108564. * @param onProgress callback called while file is loading (if the server supports this mode)
  108565. * @param offlineProvider defines the offline provider for caching
  108566. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108567. * @param onError callback called when the file fails to load
  108568. * @returns a file request object
  108569. * @hidden
  108570. */
  108571. 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;
  108572. /**
  108573. * Reads pixels from the current frame buffer. Please note that this function can be slow
  108574. * @param x defines the x coordinate of the rectangle where pixels must be read
  108575. * @param y defines the y coordinate of the rectangle where pixels must be read
  108576. * @param width defines the width of the rectangle where pixels must be read
  108577. * @param height defines the height of the rectangle where pixels must be read
  108578. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  108579. * @returns a Uint8Array containing RGBA colors
  108580. */
  108581. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  108582. private static _isSupported;
  108583. /**
  108584. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  108585. * @returns true if the engine can be created
  108586. * @ignorenaming
  108587. */
  108588. static isSupported(): boolean;
  108589. /**
  108590. * Find the next highest power of two.
  108591. * @param x Number to start search from.
  108592. * @return Next highest power of two.
  108593. */
  108594. static CeilingPOT(x: number): number;
  108595. /**
  108596. * Find the next lowest power of two.
  108597. * @param x Number to start search from.
  108598. * @return Next lowest power of two.
  108599. */
  108600. static FloorPOT(x: number): number;
  108601. /**
  108602. * Find the nearest power of two.
  108603. * @param x Number to start search from.
  108604. * @return Next nearest power of two.
  108605. */
  108606. static NearestPOT(x: number): number;
  108607. /**
  108608. * Get the closest exponent of two
  108609. * @param value defines the value to approximate
  108610. * @param max defines the maximum value to return
  108611. * @param mode defines how to define the closest value
  108612. * @returns closest exponent of two of the given value
  108613. */
  108614. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  108615. /**
  108616. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  108617. * @param func - the function to be called
  108618. * @param requester - the object that will request the next frame. Falls back to window.
  108619. * @returns frame number
  108620. */
  108621. static QueueNewFrame(func: () => void, requester?: any): number;
  108622. /**
  108623. * Gets host document
  108624. * @returns the host document object
  108625. */
  108626. getHostDocument(): Nullable<Document>;
  108627. }
  108628. }
  108629. declare module BABYLON {
  108630. /**
  108631. * Class representing spherical harmonics coefficients to the 3rd degree
  108632. */
  108633. export class SphericalHarmonics {
  108634. /**
  108635. * Defines whether or not the harmonics have been prescaled for rendering.
  108636. */
  108637. preScaled: boolean;
  108638. /**
  108639. * The l0,0 coefficients of the spherical harmonics
  108640. */
  108641. l00: Vector3;
  108642. /**
  108643. * The l1,-1 coefficients of the spherical harmonics
  108644. */
  108645. l1_1: Vector3;
  108646. /**
  108647. * The l1,0 coefficients of the spherical harmonics
  108648. */
  108649. l10: Vector3;
  108650. /**
  108651. * The l1,1 coefficients of the spherical harmonics
  108652. */
  108653. l11: Vector3;
  108654. /**
  108655. * The l2,-2 coefficients of the spherical harmonics
  108656. */
  108657. l2_2: Vector3;
  108658. /**
  108659. * The l2,-1 coefficients of the spherical harmonics
  108660. */
  108661. l2_1: Vector3;
  108662. /**
  108663. * The l2,0 coefficients of the spherical harmonics
  108664. */
  108665. l20: Vector3;
  108666. /**
  108667. * The l2,1 coefficients of the spherical harmonics
  108668. */
  108669. l21: Vector3;
  108670. /**
  108671. * The l2,2 coefficients of the spherical harmonics
  108672. */
  108673. l22: Vector3;
  108674. /**
  108675. * Adds a light to the spherical harmonics
  108676. * @param direction the direction of the light
  108677. * @param color the color of the light
  108678. * @param deltaSolidAngle the delta solid angle of the light
  108679. */
  108680. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  108681. /**
  108682. * Scales the spherical harmonics by the given amount
  108683. * @param scale the amount to scale
  108684. */
  108685. scaleInPlace(scale: number): void;
  108686. /**
  108687. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  108688. *
  108689. * ```
  108690. * E_lm = A_l * L_lm
  108691. * ```
  108692. *
  108693. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  108694. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  108695. * the scaling factors are given in equation 9.
  108696. */
  108697. convertIncidentRadianceToIrradiance(): void;
  108698. /**
  108699. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  108700. *
  108701. * ```
  108702. * L = (1/pi) * E * rho
  108703. * ```
  108704. *
  108705. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  108706. */
  108707. convertIrradianceToLambertianRadiance(): void;
  108708. /**
  108709. * Integrates the reconstruction coefficients directly in to the SH preventing further
  108710. * required operations at run time.
  108711. *
  108712. * This is simply done by scaling back the SH with Ylm constants parameter.
  108713. * The trigonometric part being applied by the shader at run time.
  108714. */
  108715. preScaleForRendering(): void;
  108716. /**
  108717. * Constructs a spherical harmonics from an array.
  108718. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  108719. * @returns the spherical harmonics
  108720. */
  108721. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  108722. /**
  108723. * Gets the spherical harmonics from polynomial
  108724. * @param polynomial the spherical polynomial
  108725. * @returns the spherical harmonics
  108726. */
  108727. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  108728. }
  108729. /**
  108730. * Class representing spherical polynomial coefficients to the 3rd degree
  108731. */
  108732. export class SphericalPolynomial {
  108733. private _harmonics;
  108734. /**
  108735. * The spherical harmonics used to create the polynomials.
  108736. */
  108737. get preScaledHarmonics(): SphericalHarmonics;
  108738. /**
  108739. * The x coefficients of the spherical polynomial
  108740. */
  108741. x: Vector3;
  108742. /**
  108743. * The y coefficients of the spherical polynomial
  108744. */
  108745. y: Vector3;
  108746. /**
  108747. * The z coefficients of the spherical polynomial
  108748. */
  108749. z: Vector3;
  108750. /**
  108751. * The xx coefficients of the spherical polynomial
  108752. */
  108753. xx: Vector3;
  108754. /**
  108755. * The yy coefficients of the spherical polynomial
  108756. */
  108757. yy: Vector3;
  108758. /**
  108759. * The zz coefficients of the spherical polynomial
  108760. */
  108761. zz: Vector3;
  108762. /**
  108763. * The xy coefficients of the spherical polynomial
  108764. */
  108765. xy: Vector3;
  108766. /**
  108767. * The yz coefficients of the spherical polynomial
  108768. */
  108769. yz: Vector3;
  108770. /**
  108771. * The zx coefficients of the spherical polynomial
  108772. */
  108773. zx: Vector3;
  108774. /**
  108775. * Adds an ambient color to the spherical polynomial
  108776. * @param color the color to add
  108777. */
  108778. addAmbient(color: Color3): void;
  108779. /**
  108780. * Scales the spherical polynomial by the given amount
  108781. * @param scale the amount to scale
  108782. */
  108783. scaleInPlace(scale: number): void;
  108784. /**
  108785. * Gets the spherical polynomial from harmonics
  108786. * @param harmonics the spherical harmonics
  108787. * @returns the spherical polynomial
  108788. */
  108789. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  108790. /**
  108791. * Constructs a spherical polynomial from an array.
  108792. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  108793. * @returns the spherical polynomial
  108794. */
  108795. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  108796. }
  108797. }
  108798. declare module BABYLON {
  108799. /**
  108800. * Defines the source of the internal texture
  108801. */
  108802. export enum InternalTextureSource {
  108803. /**
  108804. * The source of the texture data is unknown
  108805. */
  108806. Unknown = 0,
  108807. /**
  108808. * Texture data comes from an URL
  108809. */
  108810. Url = 1,
  108811. /**
  108812. * Texture data is only used for temporary storage
  108813. */
  108814. Temp = 2,
  108815. /**
  108816. * Texture data comes from raw data (ArrayBuffer)
  108817. */
  108818. Raw = 3,
  108819. /**
  108820. * Texture content is dynamic (video or dynamic texture)
  108821. */
  108822. Dynamic = 4,
  108823. /**
  108824. * Texture content is generated by rendering to it
  108825. */
  108826. RenderTarget = 5,
  108827. /**
  108828. * Texture content is part of a multi render target process
  108829. */
  108830. MultiRenderTarget = 6,
  108831. /**
  108832. * Texture data comes from a cube data file
  108833. */
  108834. Cube = 7,
  108835. /**
  108836. * Texture data comes from a raw cube data
  108837. */
  108838. CubeRaw = 8,
  108839. /**
  108840. * Texture data come from a prefiltered cube data file
  108841. */
  108842. CubePrefiltered = 9,
  108843. /**
  108844. * Texture content is raw 3D data
  108845. */
  108846. Raw3D = 10,
  108847. /**
  108848. * Texture content is raw 2D array data
  108849. */
  108850. Raw2DArray = 11,
  108851. /**
  108852. * Texture content is a depth texture
  108853. */
  108854. Depth = 12,
  108855. /**
  108856. * Texture data comes from a raw cube data encoded with RGBD
  108857. */
  108858. CubeRawRGBD = 13
  108859. }
  108860. /**
  108861. * Class used to store data associated with WebGL texture data for the engine
  108862. * This class should not be used directly
  108863. */
  108864. export class InternalTexture {
  108865. /** @hidden */
  108866. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  108867. /**
  108868. * Defines if the texture is ready
  108869. */
  108870. isReady: boolean;
  108871. /**
  108872. * Defines if the texture is a cube texture
  108873. */
  108874. isCube: boolean;
  108875. /**
  108876. * Defines if the texture contains 3D data
  108877. */
  108878. is3D: boolean;
  108879. /**
  108880. * Defines if the texture contains 2D array data
  108881. */
  108882. is2DArray: boolean;
  108883. /**
  108884. * Defines if the texture contains multiview data
  108885. */
  108886. isMultiview: boolean;
  108887. /**
  108888. * Gets the URL used to load this texture
  108889. */
  108890. url: string;
  108891. /**
  108892. * Gets the sampling mode of the texture
  108893. */
  108894. samplingMode: number;
  108895. /**
  108896. * Gets a boolean indicating if the texture needs mipmaps generation
  108897. */
  108898. generateMipMaps: boolean;
  108899. /**
  108900. * Gets the number of samples used by the texture (WebGL2+ only)
  108901. */
  108902. samples: number;
  108903. /**
  108904. * Gets the type of the texture (int, float...)
  108905. */
  108906. type: number;
  108907. /**
  108908. * Gets the format of the texture (RGB, RGBA...)
  108909. */
  108910. format: number;
  108911. /**
  108912. * Observable called when the texture is loaded
  108913. */
  108914. onLoadedObservable: Observable<InternalTexture>;
  108915. /**
  108916. * Gets the width of the texture
  108917. */
  108918. width: number;
  108919. /**
  108920. * Gets the height of the texture
  108921. */
  108922. height: number;
  108923. /**
  108924. * Gets the depth of the texture
  108925. */
  108926. depth: number;
  108927. /**
  108928. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  108929. */
  108930. baseWidth: number;
  108931. /**
  108932. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  108933. */
  108934. baseHeight: number;
  108935. /**
  108936. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  108937. */
  108938. baseDepth: number;
  108939. /**
  108940. * Gets a boolean indicating if the texture is inverted on Y axis
  108941. */
  108942. invertY: boolean;
  108943. /** @hidden */
  108944. _invertVScale: boolean;
  108945. /** @hidden */
  108946. _associatedChannel: number;
  108947. /** @hidden */
  108948. _source: InternalTextureSource;
  108949. /** @hidden */
  108950. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108951. /** @hidden */
  108952. _bufferView: Nullable<ArrayBufferView>;
  108953. /** @hidden */
  108954. _bufferViewArray: Nullable<ArrayBufferView[]>;
  108955. /** @hidden */
  108956. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  108957. /** @hidden */
  108958. _size: number;
  108959. /** @hidden */
  108960. _extension: string;
  108961. /** @hidden */
  108962. _files: Nullable<string[]>;
  108963. /** @hidden */
  108964. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  108965. /** @hidden */
  108966. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  108967. /** @hidden */
  108968. _framebuffer: Nullable<WebGLFramebuffer>;
  108969. /** @hidden */
  108970. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  108971. /** @hidden */
  108972. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  108973. /** @hidden */
  108974. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  108975. /** @hidden */
  108976. _attachments: Nullable<number[]>;
  108977. /** @hidden */
  108978. _cachedCoordinatesMode: Nullable<number>;
  108979. /** @hidden */
  108980. _cachedWrapU: Nullable<number>;
  108981. /** @hidden */
  108982. _cachedWrapV: Nullable<number>;
  108983. /** @hidden */
  108984. _cachedWrapR: Nullable<number>;
  108985. /** @hidden */
  108986. _cachedAnisotropicFilteringLevel: Nullable<number>;
  108987. /** @hidden */
  108988. _isDisabled: boolean;
  108989. /** @hidden */
  108990. _compression: Nullable<string>;
  108991. /** @hidden */
  108992. _generateStencilBuffer: boolean;
  108993. /** @hidden */
  108994. _generateDepthBuffer: boolean;
  108995. /** @hidden */
  108996. _comparisonFunction: number;
  108997. /** @hidden */
  108998. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  108999. /** @hidden */
  109000. _lodGenerationScale: number;
  109001. /** @hidden */
  109002. _lodGenerationOffset: number;
  109003. /** @hidden */
  109004. _depthStencilTexture: Nullable<InternalTexture>;
  109005. /** @hidden */
  109006. _colorTextureArray: Nullable<WebGLTexture>;
  109007. /** @hidden */
  109008. _depthStencilTextureArray: Nullable<WebGLTexture>;
  109009. /** @hidden */
  109010. _lodTextureHigh: Nullable<BaseTexture>;
  109011. /** @hidden */
  109012. _lodTextureMid: Nullable<BaseTexture>;
  109013. /** @hidden */
  109014. _lodTextureLow: Nullable<BaseTexture>;
  109015. /** @hidden */
  109016. _isRGBD: boolean;
  109017. /** @hidden */
  109018. _linearSpecularLOD: boolean;
  109019. /** @hidden */
  109020. _irradianceTexture: Nullable<BaseTexture>;
  109021. /** @hidden */
  109022. _webGLTexture: Nullable<WebGLTexture>;
  109023. /** @hidden */
  109024. _references: number;
  109025. private _engine;
  109026. /**
  109027. * Gets the Engine the texture belongs to.
  109028. * @returns The babylon engine
  109029. */
  109030. getEngine(): ThinEngine;
  109031. /**
  109032. * Gets the data source type of the texture
  109033. */
  109034. get source(): InternalTextureSource;
  109035. /**
  109036. * Creates a new InternalTexture
  109037. * @param engine defines the engine to use
  109038. * @param source defines the type of data that will be used
  109039. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109040. */
  109041. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  109042. /**
  109043. * Increments the number of references (ie. the number of Texture that point to it)
  109044. */
  109045. incrementReferences(): void;
  109046. /**
  109047. * Change the size of the texture (not the size of the content)
  109048. * @param width defines the new width
  109049. * @param height defines the new height
  109050. * @param depth defines the new depth (1 by default)
  109051. */
  109052. updateSize(width: int, height: int, depth?: int): void;
  109053. /** @hidden */
  109054. _rebuild(): void;
  109055. /** @hidden */
  109056. _swapAndDie(target: InternalTexture): void;
  109057. /**
  109058. * Dispose the current allocated resources
  109059. */
  109060. dispose(): void;
  109061. }
  109062. }
  109063. declare module BABYLON {
  109064. /**
  109065. * Class used to work with sound analyzer using fast fourier transform (FFT)
  109066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109067. */
  109068. export class Analyser {
  109069. /**
  109070. * Gets or sets the smoothing
  109071. * @ignorenaming
  109072. */
  109073. SMOOTHING: number;
  109074. /**
  109075. * Gets or sets the FFT table size
  109076. * @ignorenaming
  109077. */
  109078. FFT_SIZE: number;
  109079. /**
  109080. * Gets or sets the bar graph amplitude
  109081. * @ignorenaming
  109082. */
  109083. BARGRAPHAMPLITUDE: number;
  109084. /**
  109085. * Gets or sets the position of the debug canvas
  109086. * @ignorenaming
  109087. */
  109088. DEBUGCANVASPOS: {
  109089. x: number;
  109090. y: number;
  109091. };
  109092. /**
  109093. * Gets or sets the debug canvas size
  109094. * @ignorenaming
  109095. */
  109096. DEBUGCANVASSIZE: {
  109097. width: number;
  109098. height: number;
  109099. };
  109100. private _byteFreqs;
  109101. private _byteTime;
  109102. private _floatFreqs;
  109103. private _webAudioAnalyser;
  109104. private _debugCanvas;
  109105. private _debugCanvasContext;
  109106. private _scene;
  109107. private _registerFunc;
  109108. private _audioEngine;
  109109. /**
  109110. * Creates a new analyser
  109111. * @param scene defines hosting scene
  109112. */
  109113. constructor(scene: Scene);
  109114. /**
  109115. * Get the number of data values you will have to play with for the visualization
  109116. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  109117. * @returns a number
  109118. */
  109119. getFrequencyBinCount(): number;
  109120. /**
  109121. * Gets the current frequency data as a byte array
  109122. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  109123. * @returns a Uint8Array
  109124. */
  109125. getByteFrequencyData(): Uint8Array;
  109126. /**
  109127. * Gets the current waveform as a byte array
  109128. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  109129. * @returns a Uint8Array
  109130. */
  109131. getByteTimeDomainData(): Uint8Array;
  109132. /**
  109133. * Gets the current frequency data as a float array
  109134. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  109135. * @returns a Float32Array
  109136. */
  109137. getFloatFrequencyData(): Float32Array;
  109138. /**
  109139. * Renders the debug canvas
  109140. */
  109141. drawDebugCanvas(): void;
  109142. /**
  109143. * Stops rendering the debug canvas and removes it
  109144. */
  109145. stopDebugCanvas(): void;
  109146. /**
  109147. * Connects two audio nodes
  109148. * @param inputAudioNode defines first node to connect
  109149. * @param outputAudioNode defines second node to connect
  109150. */
  109151. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  109152. /**
  109153. * Releases all associated resources
  109154. */
  109155. dispose(): void;
  109156. }
  109157. }
  109158. declare module BABYLON {
  109159. /**
  109160. * This represents an audio engine and it is responsible
  109161. * to play, synchronize and analyse sounds throughout the application.
  109162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109163. */
  109164. export interface IAudioEngine extends IDisposable {
  109165. /**
  109166. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  109167. */
  109168. readonly canUseWebAudio: boolean;
  109169. /**
  109170. * Gets the current AudioContext if available.
  109171. */
  109172. readonly audioContext: Nullable<AudioContext>;
  109173. /**
  109174. * The master gain node defines the global audio volume of your audio engine.
  109175. */
  109176. readonly masterGain: GainNode;
  109177. /**
  109178. * Gets whether or not mp3 are supported by your browser.
  109179. */
  109180. readonly isMP3supported: boolean;
  109181. /**
  109182. * Gets whether or not ogg are supported by your browser.
  109183. */
  109184. readonly isOGGsupported: boolean;
  109185. /**
  109186. * Defines if Babylon should emit a warning if WebAudio is not supported.
  109187. * @ignoreNaming
  109188. */
  109189. WarnedWebAudioUnsupported: boolean;
  109190. /**
  109191. * Defines if the audio engine relies on a custom unlocked button.
  109192. * In this case, the embedded button will not be displayed.
  109193. */
  109194. useCustomUnlockedButton: boolean;
  109195. /**
  109196. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  109197. */
  109198. readonly unlocked: boolean;
  109199. /**
  109200. * Event raised when audio has been unlocked on the browser.
  109201. */
  109202. onAudioUnlockedObservable: Observable<AudioEngine>;
  109203. /**
  109204. * Event raised when audio has been locked on the browser.
  109205. */
  109206. onAudioLockedObservable: Observable<AudioEngine>;
  109207. /**
  109208. * Flags the audio engine in Locked state.
  109209. * This happens due to new browser policies preventing audio to autoplay.
  109210. */
  109211. lock(): void;
  109212. /**
  109213. * Unlocks the audio engine once a user action has been done on the dom.
  109214. * This is helpful to resume play once browser policies have been satisfied.
  109215. */
  109216. unlock(): void;
  109217. /**
  109218. * Gets the global volume sets on the master gain.
  109219. * @returns the global volume if set or -1 otherwise
  109220. */
  109221. getGlobalVolume(): number;
  109222. /**
  109223. * Sets the global volume of your experience (sets on the master gain).
  109224. * @param newVolume Defines the new global volume of the application
  109225. */
  109226. setGlobalVolume(newVolume: number): void;
  109227. /**
  109228. * Connect the audio engine to an audio analyser allowing some amazing
  109229. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109231. * @param analyser The analyser to connect to the engine
  109232. */
  109233. connectToAnalyser(analyser: Analyser): void;
  109234. }
  109235. /**
  109236. * This represents the default audio engine used in babylon.
  109237. * It is responsible to play, synchronize and analyse sounds throughout the application.
  109238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109239. */
  109240. export class AudioEngine implements IAudioEngine {
  109241. private _audioContext;
  109242. private _audioContextInitialized;
  109243. private _muteButton;
  109244. private _hostElement;
  109245. /**
  109246. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  109247. */
  109248. canUseWebAudio: boolean;
  109249. /**
  109250. * The master gain node defines the global audio volume of your audio engine.
  109251. */
  109252. masterGain: GainNode;
  109253. /**
  109254. * Defines if Babylon should emit a warning if WebAudio is not supported.
  109255. * @ignoreNaming
  109256. */
  109257. WarnedWebAudioUnsupported: boolean;
  109258. /**
  109259. * Gets whether or not mp3 are supported by your browser.
  109260. */
  109261. isMP3supported: boolean;
  109262. /**
  109263. * Gets whether or not ogg are supported by your browser.
  109264. */
  109265. isOGGsupported: boolean;
  109266. /**
  109267. * Gets whether audio has been unlocked on the device.
  109268. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  109269. * a user interaction has happened.
  109270. */
  109271. unlocked: boolean;
  109272. /**
  109273. * Defines if the audio engine relies on a custom unlocked button.
  109274. * In this case, the embedded button will not be displayed.
  109275. */
  109276. useCustomUnlockedButton: boolean;
  109277. /**
  109278. * Event raised when audio has been unlocked on the browser.
  109279. */
  109280. onAudioUnlockedObservable: Observable<AudioEngine>;
  109281. /**
  109282. * Event raised when audio has been locked on the browser.
  109283. */
  109284. onAudioLockedObservable: Observable<AudioEngine>;
  109285. /**
  109286. * Gets the current AudioContext if available.
  109287. */
  109288. get audioContext(): Nullable<AudioContext>;
  109289. private _connectedAnalyser;
  109290. /**
  109291. * Instantiates a new audio engine.
  109292. *
  109293. * There should be only one per page as some browsers restrict the number
  109294. * of audio contexts you can create.
  109295. * @param hostElement defines the host element where to display the mute icon if necessary
  109296. */
  109297. constructor(hostElement?: Nullable<HTMLElement>);
  109298. /**
  109299. * Flags the audio engine in Locked state.
  109300. * This happens due to new browser policies preventing audio to autoplay.
  109301. */
  109302. lock(): void;
  109303. /**
  109304. * Unlocks the audio engine once a user action has been done on the dom.
  109305. * This is helpful to resume play once browser policies have been satisfied.
  109306. */
  109307. unlock(): void;
  109308. private _resumeAudioContext;
  109309. private _initializeAudioContext;
  109310. private _tryToRun;
  109311. private _triggerRunningState;
  109312. private _triggerSuspendedState;
  109313. private _displayMuteButton;
  109314. private _moveButtonToTopLeft;
  109315. private _onResize;
  109316. private _hideMuteButton;
  109317. /**
  109318. * Destroy and release the resources associated with the audio ccontext.
  109319. */
  109320. dispose(): void;
  109321. /**
  109322. * Gets the global volume sets on the master gain.
  109323. * @returns the global volume if set or -1 otherwise
  109324. */
  109325. getGlobalVolume(): number;
  109326. /**
  109327. * Sets the global volume of your experience (sets on the master gain).
  109328. * @param newVolume Defines the new global volume of the application
  109329. */
  109330. setGlobalVolume(newVolume: number): void;
  109331. /**
  109332. * Connect the audio engine to an audio analyser allowing some amazing
  109333. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109335. * @param analyser The analyser to connect to the engine
  109336. */
  109337. connectToAnalyser(analyser: Analyser): void;
  109338. }
  109339. }
  109340. declare module BABYLON {
  109341. /**
  109342. * Interface used to present a loading screen while loading a scene
  109343. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109344. */
  109345. export interface ILoadingScreen {
  109346. /**
  109347. * Function called to display the loading screen
  109348. */
  109349. displayLoadingUI: () => void;
  109350. /**
  109351. * Function called to hide the loading screen
  109352. */
  109353. hideLoadingUI: () => void;
  109354. /**
  109355. * Gets or sets the color to use for the background
  109356. */
  109357. loadingUIBackgroundColor: string;
  109358. /**
  109359. * Gets or sets the text to display while loading
  109360. */
  109361. loadingUIText: string;
  109362. }
  109363. /**
  109364. * Class used for the default loading screen
  109365. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109366. */
  109367. export class DefaultLoadingScreen implements ILoadingScreen {
  109368. private _renderingCanvas;
  109369. private _loadingText;
  109370. private _loadingDivBackgroundColor;
  109371. private _loadingDiv;
  109372. private _loadingTextDiv;
  109373. /** Gets or sets the logo url to use for the default loading screen */
  109374. static DefaultLogoUrl: string;
  109375. /** Gets or sets the spinner url to use for the default loading screen */
  109376. static DefaultSpinnerUrl: string;
  109377. /**
  109378. * Creates a new default loading screen
  109379. * @param _renderingCanvas defines the canvas used to render the scene
  109380. * @param _loadingText defines the default text to display
  109381. * @param _loadingDivBackgroundColor defines the default background color
  109382. */
  109383. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  109384. /**
  109385. * Function called to display the loading screen
  109386. */
  109387. displayLoadingUI(): void;
  109388. /**
  109389. * Function called to hide the loading screen
  109390. */
  109391. hideLoadingUI(): void;
  109392. /**
  109393. * Gets or sets the text to display while loading
  109394. */
  109395. set loadingUIText(text: string);
  109396. get loadingUIText(): string;
  109397. /**
  109398. * Gets or sets the color to use for the background
  109399. */
  109400. get loadingUIBackgroundColor(): string;
  109401. set loadingUIBackgroundColor(color: string);
  109402. private _resizeLoadingUI;
  109403. }
  109404. }
  109405. declare module BABYLON {
  109406. /**
  109407. * Interface for any object that can request an animation frame
  109408. */
  109409. export interface ICustomAnimationFrameRequester {
  109410. /**
  109411. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  109412. */
  109413. renderFunction?: Function;
  109414. /**
  109415. * Called to request the next frame to render to
  109416. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  109417. */
  109418. requestAnimationFrame: Function;
  109419. /**
  109420. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  109421. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  109422. */
  109423. requestID?: number;
  109424. }
  109425. }
  109426. declare module BABYLON {
  109427. /**
  109428. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  109429. */
  109430. export class PerformanceMonitor {
  109431. private _enabled;
  109432. private _rollingFrameTime;
  109433. private _lastFrameTimeMs;
  109434. /**
  109435. * constructor
  109436. * @param frameSampleSize The number of samples required to saturate the sliding window
  109437. */
  109438. constructor(frameSampleSize?: number);
  109439. /**
  109440. * Samples current frame
  109441. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  109442. */
  109443. sampleFrame(timeMs?: number): void;
  109444. /**
  109445. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109446. */
  109447. get averageFrameTime(): number;
  109448. /**
  109449. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109450. */
  109451. get averageFrameTimeVariance(): number;
  109452. /**
  109453. * Returns the frame time of the most recent frame
  109454. */
  109455. get instantaneousFrameTime(): number;
  109456. /**
  109457. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  109458. */
  109459. get averageFPS(): number;
  109460. /**
  109461. * Returns the average framerate in frames per second using the most recent frame time
  109462. */
  109463. get instantaneousFPS(): number;
  109464. /**
  109465. * Returns true if enough samples have been taken to completely fill the sliding window
  109466. */
  109467. get isSaturated(): boolean;
  109468. /**
  109469. * Enables contributions to the sliding window sample set
  109470. */
  109471. enable(): void;
  109472. /**
  109473. * Disables contributions to the sliding window sample set
  109474. * Samples will not be interpolated over the disabled period
  109475. */
  109476. disable(): void;
  109477. /**
  109478. * Returns true if sampling is enabled
  109479. */
  109480. get isEnabled(): boolean;
  109481. /**
  109482. * Resets performance monitor
  109483. */
  109484. reset(): void;
  109485. }
  109486. /**
  109487. * RollingAverage
  109488. *
  109489. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  109490. */
  109491. export class RollingAverage {
  109492. /**
  109493. * Current average
  109494. */
  109495. average: number;
  109496. /**
  109497. * Current variance
  109498. */
  109499. variance: number;
  109500. protected _samples: Array<number>;
  109501. protected _sampleCount: number;
  109502. protected _pos: number;
  109503. protected _m2: number;
  109504. /**
  109505. * constructor
  109506. * @param length The number of samples required to saturate the sliding window
  109507. */
  109508. constructor(length: number);
  109509. /**
  109510. * Adds a sample to the sample set
  109511. * @param v The sample value
  109512. */
  109513. add(v: number): void;
  109514. /**
  109515. * Returns previously added values or null if outside of history or outside the sliding window domain
  109516. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  109517. * @return Value previously recorded with add() or null if outside of range
  109518. */
  109519. history(i: number): number;
  109520. /**
  109521. * Returns true if enough samples have been taken to completely fill the sliding window
  109522. * @return true if sample-set saturated
  109523. */
  109524. isSaturated(): boolean;
  109525. /**
  109526. * Resets the rolling average (equivalent to 0 samples taken so far)
  109527. */
  109528. reset(): void;
  109529. /**
  109530. * Wraps a value around the sample range boundaries
  109531. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  109532. * @return Wrapped position in sample range
  109533. */
  109534. protected _wrapPosition(i: number): number;
  109535. }
  109536. }
  109537. declare module BABYLON {
  109538. /**
  109539. * This class is used to track a performance counter which is number based.
  109540. * The user has access to many properties which give statistics of different nature.
  109541. *
  109542. * The implementer can track two kinds of Performance Counter: time and count.
  109543. * 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.
  109544. * 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.
  109545. */
  109546. export class PerfCounter {
  109547. /**
  109548. * Gets or sets a global boolean to turn on and off all the counters
  109549. */
  109550. static Enabled: boolean;
  109551. /**
  109552. * Returns the smallest value ever
  109553. */
  109554. get min(): number;
  109555. /**
  109556. * Returns the biggest value ever
  109557. */
  109558. get max(): number;
  109559. /**
  109560. * Returns the average value since the performance counter is running
  109561. */
  109562. get average(): number;
  109563. /**
  109564. * Returns the average value of the last second the counter was monitored
  109565. */
  109566. get lastSecAverage(): number;
  109567. /**
  109568. * Returns the current value
  109569. */
  109570. get current(): number;
  109571. /**
  109572. * Gets the accumulated total
  109573. */
  109574. get total(): number;
  109575. /**
  109576. * Gets the total value count
  109577. */
  109578. get count(): number;
  109579. /**
  109580. * Creates a new counter
  109581. */
  109582. constructor();
  109583. /**
  109584. * Call this method to start monitoring a new frame.
  109585. * 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.
  109586. */
  109587. fetchNewFrame(): void;
  109588. /**
  109589. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  109590. * @param newCount the count value to add to the monitored count
  109591. * @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.
  109592. */
  109593. addCount(newCount: number, fetchResult: boolean): void;
  109594. /**
  109595. * Start monitoring this performance counter
  109596. */
  109597. beginMonitoring(): void;
  109598. /**
  109599. * Compute the time lapsed since the previous beginMonitoring() call.
  109600. * @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
  109601. */
  109602. endMonitoring(newFrame?: boolean): void;
  109603. private _fetchResult;
  109604. private _startMonitoringTime;
  109605. private _min;
  109606. private _max;
  109607. private _average;
  109608. private _current;
  109609. private _totalValueCount;
  109610. private _totalAccumulated;
  109611. private _lastSecAverage;
  109612. private _lastSecAccumulated;
  109613. private _lastSecTime;
  109614. private _lastSecValueCount;
  109615. }
  109616. }
  109617. declare module BABYLON {
  109618. interface ThinEngine {
  109619. /**
  109620. * Sets alpha constants used by some alpha blending modes
  109621. * @param r defines the red component
  109622. * @param g defines the green component
  109623. * @param b defines the blue component
  109624. * @param a defines the alpha component
  109625. */
  109626. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109627. /**
  109628. * Sets the current alpha mode
  109629. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  109630. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109631. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109632. */
  109633. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109634. /**
  109635. * Gets the current alpha mode
  109636. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109637. * @returns the current alpha mode
  109638. */
  109639. getAlphaMode(): number;
  109640. /**
  109641. * Sets the current alpha equation
  109642. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  109643. */
  109644. setAlphaEquation(equation: number): void;
  109645. /**
  109646. * Gets the current alpha equation.
  109647. * @returns the current alpha equation
  109648. */
  109649. getAlphaEquation(): number;
  109650. }
  109651. }
  109652. declare module BABYLON {
  109653. interface ThinEngine {
  109654. /** @hidden */
  109655. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  109656. }
  109657. }
  109658. declare module BABYLON {
  109659. /**
  109660. * Defines the interface used by display changed events
  109661. */
  109662. export interface IDisplayChangedEventArgs {
  109663. /** Gets the vrDisplay object (if any) */
  109664. vrDisplay: Nullable<any>;
  109665. /** Gets a boolean indicating if webVR is supported */
  109666. vrSupported: boolean;
  109667. }
  109668. /**
  109669. * Defines the interface used by objects containing a viewport (like a camera)
  109670. */
  109671. interface IViewportOwnerLike {
  109672. /**
  109673. * Gets or sets the viewport
  109674. */
  109675. viewport: IViewportLike;
  109676. }
  109677. /**
  109678. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  109679. */
  109680. export class Engine extends ThinEngine {
  109681. /** Defines that alpha blending is disabled */
  109682. static readonly ALPHA_DISABLE: number;
  109683. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  109684. static readonly ALPHA_ADD: number;
  109685. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  109686. static readonly ALPHA_COMBINE: number;
  109687. /** Defines that alpha blending to DEST - SRC * DEST */
  109688. static readonly ALPHA_SUBTRACT: number;
  109689. /** Defines that alpha blending to SRC * DEST */
  109690. static readonly ALPHA_MULTIPLY: number;
  109691. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  109692. static readonly ALPHA_MAXIMIZED: number;
  109693. /** Defines that alpha blending to SRC + DEST */
  109694. static readonly ALPHA_ONEONE: number;
  109695. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  109696. static readonly ALPHA_PREMULTIPLIED: number;
  109697. /**
  109698. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  109699. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  109700. */
  109701. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  109702. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  109703. static readonly ALPHA_INTERPOLATE: number;
  109704. /**
  109705. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  109706. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  109707. */
  109708. static readonly ALPHA_SCREENMODE: number;
  109709. /** Defines that the ressource is not delayed*/
  109710. static readonly DELAYLOADSTATE_NONE: number;
  109711. /** Defines that the ressource was successfully delay loaded */
  109712. static readonly DELAYLOADSTATE_LOADED: number;
  109713. /** Defines that the ressource is currently delay loading */
  109714. static readonly DELAYLOADSTATE_LOADING: number;
  109715. /** Defines that the ressource is delayed and has not started loading */
  109716. static readonly DELAYLOADSTATE_NOTLOADED: number;
  109717. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  109718. static readonly NEVER: number;
  109719. /** 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 */
  109720. static readonly ALWAYS: number;
  109721. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  109722. static readonly LESS: number;
  109723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  109724. static readonly EQUAL: number;
  109725. /** 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 */
  109726. static readonly LEQUAL: number;
  109727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  109728. static readonly GREATER: number;
  109729. /** 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 */
  109730. static readonly GEQUAL: number;
  109731. /** 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 */
  109732. static readonly NOTEQUAL: number;
  109733. /** Passed to stencilOperation to specify that stencil value must be kept */
  109734. static readonly KEEP: number;
  109735. /** Passed to stencilOperation to specify that stencil value must be replaced */
  109736. static readonly REPLACE: number;
  109737. /** Passed to stencilOperation to specify that stencil value must be incremented */
  109738. static readonly INCR: number;
  109739. /** Passed to stencilOperation to specify that stencil value must be decremented */
  109740. static readonly DECR: number;
  109741. /** Passed to stencilOperation to specify that stencil value must be inverted */
  109742. static readonly INVERT: number;
  109743. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  109744. static readonly INCR_WRAP: number;
  109745. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  109746. static readonly DECR_WRAP: number;
  109747. /** Texture is not repeating outside of 0..1 UVs */
  109748. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  109749. /** Texture is repeating outside of 0..1 UVs */
  109750. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  109751. /** Texture is repeating and mirrored */
  109752. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  109753. /** ALPHA */
  109754. static readonly TEXTUREFORMAT_ALPHA: number;
  109755. /** LUMINANCE */
  109756. static readonly TEXTUREFORMAT_LUMINANCE: number;
  109757. /** LUMINANCE_ALPHA */
  109758. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  109759. /** RGB */
  109760. static readonly TEXTUREFORMAT_RGB: number;
  109761. /** RGBA */
  109762. static readonly TEXTUREFORMAT_RGBA: number;
  109763. /** RED */
  109764. static readonly TEXTUREFORMAT_RED: number;
  109765. /** RED (2nd reference) */
  109766. static readonly TEXTUREFORMAT_R: number;
  109767. /** RG */
  109768. static readonly TEXTUREFORMAT_RG: number;
  109769. /** RED_INTEGER */
  109770. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  109771. /** RED_INTEGER (2nd reference) */
  109772. static readonly TEXTUREFORMAT_R_INTEGER: number;
  109773. /** RG_INTEGER */
  109774. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  109775. /** RGB_INTEGER */
  109776. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  109777. /** RGBA_INTEGER */
  109778. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  109779. /** UNSIGNED_BYTE */
  109780. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  109781. /** UNSIGNED_BYTE (2nd reference) */
  109782. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  109783. /** FLOAT */
  109784. static readonly TEXTURETYPE_FLOAT: number;
  109785. /** HALF_FLOAT */
  109786. static readonly TEXTURETYPE_HALF_FLOAT: number;
  109787. /** BYTE */
  109788. static readonly TEXTURETYPE_BYTE: number;
  109789. /** SHORT */
  109790. static readonly TEXTURETYPE_SHORT: number;
  109791. /** UNSIGNED_SHORT */
  109792. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  109793. /** INT */
  109794. static readonly TEXTURETYPE_INT: number;
  109795. /** UNSIGNED_INT */
  109796. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  109797. /** UNSIGNED_SHORT_4_4_4_4 */
  109798. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  109799. /** UNSIGNED_SHORT_5_5_5_1 */
  109800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  109801. /** UNSIGNED_SHORT_5_6_5 */
  109802. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  109803. /** UNSIGNED_INT_2_10_10_10_REV */
  109804. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  109805. /** UNSIGNED_INT_24_8 */
  109806. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  109807. /** UNSIGNED_INT_10F_11F_11F_REV */
  109808. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  109809. /** UNSIGNED_INT_5_9_9_9_REV */
  109810. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  109811. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  109812. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109813. /** nearest is mag = nearest and min = nearest and mip = linear */
  109814. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  109815. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  109817. /** Trilinear is mag = linear and min = linear and mip = linear */
  109818. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  109819. /** nearest is mag = nearest and min = nearest and mip = linear */
  109820. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  109821. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109822. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  109823. /** Trilinear is mag = linear and min = linear and mip = linear */
  109824. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  109825. /** mag = nearest and min = nearest and mip = nearest */
  109826. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  109827. /** mag = nearest and min = linear and mip = nearest */
  109828. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  109829. /** mag = nearest and min = linear and mip = linear */
  109830. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  109831. /** mag = nearest and min = linear and mip = none */
  109832. static readonly TEXTURE_NEAREST_LINEAR: number;
  109833. /** mag = nearest and min = nearest and mip = none */
  109834. static readonly TEXTURE_NEAREST_NEAREST: number;
  109835. /** mag = linear and min = nearest and mip = nearest */
  109836. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  109837. /** mag = linear and min = nearest and mip = linear */
  109838. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  109839. /** mag = linear and min = linear and mip = none */
  109840. static readonly TEXTURE_LINEAR_LINEAR: number;
  109841. /** mag = linear and min = nearest and mip = none */
  109842. static readonly TEXTURE_LINEAR_NEAREST: number;
  109843. /** Explicit coordinates mode */
  109844. static readonly TEXTURE_EXPLICIT_MODE: number;
  109845. /** Spherical coordinates mode */
  109846. static readonly TEXTURE_SPHERICAL_MODE: number;
  109847. /** Planar coordinates mode */
  109848. static readonly TEXTURE_PLANAR_MODE: number;
  109849. /** Cubic coordinates mode */
  109850. static readonly TEXTURE_CUBIC_MODE: number;
  109851. /** Projection coordinates mode */
  109852. static readonly TEXTURE_PROJECTION_MODE: number;
  109853. /** Skybox coordinates mode */
  109854. static readonly TEXTURE_SKYBOX_MODE: number;
  109855. /** Inverse Cubic coordinates mode */
  109856. static readonly TEXTURE_INVCUBIC_MODE: number;
  109857. /** Equirectangular coordinates mode */
  109858. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  109859. /** Equirectangular Fixed coordinates mode */
  109860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  109861. /** Equirectangular Fixed Mirrored coordinates mode */
  109862. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109863. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  109864. static readonly SCALEMODE_FLOOR: number;
  109865. /** Defines that texture rescaling will look for the nearest power of 2 size */
  109866. static readonly SCALEMODE_NEAREST: number;
  109867. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  109868. static readonly SCALEMODE_CEILING: number;
  109869. /**
  109870. * Returns the current npm package of the sdk
  109871. */
  109872. static get NpmPackage(): string;
  109873. /**
  109874. * Returns the current version of the framework
  109875. */
  109876. static get Version(): string;
  109877. /** Gets the list of created engines */
  109878. static get Instances(): Engine[];
  109879. /**
  109880. * Gets the latest created engine
  109881. */
  109882. static get LastCreatedEngine(): Nullable<Engine>;
  109883. /**
  109884. * Gets the latest created scene
  109885. */
  109886. static get LastCreatedScene(): Nullable<Scene>;
  109887. /**
  109888. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  109889. * @param flag defines which part of the materials must be marked as dirty
  109890. * @param predicate defines a predicate used to filter which materials should be affected
  109891. */
  109892. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109893. /**
  109894. * Method called to create the default loading screen.
  109895. * This can be overriden in your own app.
  109896. * @param canvas The rendering canvas element
  109897. * @returns The loading screen
  109898. */
  109899. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  109900. /**
  109901. * Method called to create the default rescale post process on each engine.
  109902. */
  109903. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  109904. /**
  109905. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  109906. **/
  109907. enableOfflineSupport: boolean;
  109908. /**
  109909. * 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)
  109910. **/
  109911. disableManifestCheck: boolean;
  109912. /**
  109913. * Gets the list of created scenes
  109914. */
  109915. scenes: Scene[];
  109916. /**
  109917. * Event raised when a new scene is created
  109918. */
  109919. onNewSceneAddedObservable: Observable<Scene>;
  109920. /**
  109921. * Gets the list of created postprocesses
  109922. */
  109923. postProcesses: PostProcess[];
  109924. /**
  109925. * Gets a boolean indicating if the pointer is currently locked
  109926. */
  109927. isPointerLock: boolean;
  109928. /**
  109929. * Observable event triggered each time the rendering canvas is resized
  109930. */
  109931. onResizeObservable: Observable<Engine>;
  109932. /**
  109933. * Observable event triggered each time the canvas loses focus
  109934. */
  109935. onCanvasBlurObservable: Observable<Engine>;
  109936. /**
  109937. * Observable event triggered each time the canvas gains focus
  109938. */
  109939. onCanvasFocusObservable: Observable<Engine>;
  109940. /**
  109941. * Observable event triggered each time the canvas receives pointerout event
  109942. */
  109943. onCanvasPointerOutObservable: Observable<PointerEvent>;
  109944. /**
  109945. * Observable raised when the engine begins a new frame
  109946. */
  109947. onBeginFrameObservable: Observable<Engine>;
  109948. /**
  109949. * If set, will be used to request the next animation frame for the render loop
  109950. */
  109951. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  109952. /**
  109953. * Observable raised when the engine ends the current frame
  109954. */
  109955. onEndFrameObservable: Observable<Engine>;
  109956. /**
  109957. * Observable raised when the engine is about to compile a shader
  109958. */
  109959. onBeforeShaderCompilationObservable: Observable<Engine>;
  109960. /**
  109961. * Observable raised when the engine has jsut compiled a shader
  109962. */
  109963. onAfterShaderCompilationObservable: Observable<Engine>;
  109964. /**
  109965. * Gets the audio engine
  109966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109967. * @ignorenaming
  109968. */
  109969. static audioEngine: IAudioEngine;
  109970. /**
  109971. * Default AudioEngine factory responsible of creating the Audio Engine.
  109972. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  109973. */
  109974. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  109975. /**
  109976. * Default offline support factory responsible of creating a tool used to store data locally.
  109977. * By default, this will create a Database object if the workload has been embedded.
  109978. */
  109979. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  109980. private _loadingScreen;
  109981. private _pointerLockRequested;
  109982. private _rescalePostProcess;
  109983. private _deterministicLockstep;
  109984. private _lockstepMaxSteps;
  109985. private _timeStep;
  109986. protected get _supportsHardwareTextureRescaling(): boolean;
  109987. private _fps;
  109988. private _deltaTime;
  109989. /** @hidden */
  109990. _drawCalls: PerfCounter;
  109991. /** 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 */
  109992. canvasTabIndex: number;
  109993. /**
  109994. * Turn this value on if you want to pause FPS computation when in background
  109995. */
  109996. disablePerformanceMonitorInBackground: boolean;
  109997. private _performanceMonitor;
  109998. /**
  109999. * Gets the performance monitor attached to this engine
  110000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110001. */
  110002. get performanceMonitor(): PerformanceMonitor;
  110003. private _onFocus;
  110004. private _onBlur;
  110005. private _onCanvasPointerOut;
  110006. private _onCanvasBlur;
  110007. private _onCanvasFocus;
  110008. private _onFullscreenChange;
  110009. private _onPointerLockChange;
  110010. /**
  110011. * Gets the HTML element used to attach event listeners
  110012. * @returns a HTML element
  110013. */
  110014. getInputElement(): Nullable<HTMLElement>;
  110015. /**
  110016. * Creates a new engine
  110017. * @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
  110018. * @param antialias defines enable antialiasing (default: false)
  110019. * @param options defines further options to be sent to the getContext() function
  110020. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  110021. */
  110022. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  110023. /**
  110024. * Gets current aspect ratio
  110025. * @param viewportOwner defines the camera to use to get the aspect ratio
  110026. * @param useScreen defines if screen size must be used (or the current render target if any)
  110027. * @returns a number defining the aspect ratio
  110028. */
  110029. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  110030. /**
  110031. * Gets current screen aspect ratio
  110032. * @returns a number defining the aspect ratio
  110033. */
  110034. getScreenAspectRatio(): number;
  110035. /**
  110036. * Gets the client rect of the HTML canvas attached with the current webGL context
  110037. * @returns a client rectanglee
  110038. */
  110039. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  110040. /**
  110041. * Gets the client rect of the HTML element used for events
  110042. * @returns a client rectanglee
  110043. */
  110044. getInputElementClientRect(): Nullable<ClientRect>;
  110045. /**
  110046. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110048. * @returns true if engine is in deterministic lock step mode
  110049. */
  110050. isDeterministicLockStep(): boolean;
  110051. /**
  110052. * Gets the max steps when engine is running in deterministic lock step
  110053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110054. * @returns the max steps
  110055. */
  110056. getLockstepMaxSteps(): number;
  110057. /**
  110058. * Returns the time in ms between steps when using deterministic lock step.
  110059. * @returns time step in (ms)
  110060. */
  110061. getTimeStep(): number;
  110062. /**
  110063. * Force the mipmap generation for the given render target texture
  110064. * @param texture defines the render target texture to use
  110065. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  110066. */
  110067. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  110068. /** States */
  110069. /**
  110070. * Set various states to the webGL context
  110071. * @param culling defines backface culling state
  110072. * @param zOffset defines the value to apply to zOffset (0 by default)
  110073. * @param force defines if states must be applied even if cache is up to date
  110074. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110075. */
  110076. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110077. /**
  110078. * Set the z offset to apply to current rendering
  110079. * @param value defines the offset to apply
  110080. */
  110081. setZOffset(value: number): void;
  110082. /**
  110083. * Gets the current value of the zOffset
  110084. * @returns the current zOffset state
  110085. */
  110086. getZOffset(): number;
  110087. /**
  110088. * Enable or disable depth buffering
  110089. * @param enable defines the state to set
  110090. */
  110091. setDepthBuffer(enable: boolean): void;
  110092. /**
  110093. * Gets a boolean indicating if depth writing is enabled
  110094. * @returns the current depth writing state
  110095. */
  110096. getDepthWrite(): boolean;
  110097. /**
  110098. * Enable or disable depth writing
  110099. * @param enable defines the state to set
  110100. */
  110101. setDepthWrite(enable: boolean): void;
  110102. /**
  110103. * Gets a boolean indicating if stencil buffer is enabled
  110104. * @returns the current stencil buffer state
  110105. */
  110106. getStencilBuffer(): boolean;
  110107. /**
  110108. * Enable or disable the stencil buffer
  110109. * @param enable defines if the stencil buffer must be enabled or disabled
  110110. */
  110111. setStencilBuffer(enable: boolean): void;
  110112. /**
  110113. * Gets the current stencil mask
  110114. * @returns a number defining the new stencil mask to use
  110115. */
  110116. getStencilMask(): number;
  110117. /**
  110118. * Sets the current stencil mask
  110119. * @param mask defines the new stencil mask to use
  110120. */
  110121. setStencilMask(mask: number): void;
  110122. /**
  110123. * Gets the current stencil function
  110124. * @returns a number defining the stencil function to use
  110125. */
  110126. getStencilFunction(): number;
  110127. /**
  110128. * Gets the current stencil reference value
  110129. * @returns a number defining the stencil reference value to use
  110130. */
  110131. getStencilFunctionReference(): number;
  110132. /**
  110133. * Gets the current stencil mask
  110134. * @returns a number defining the stencil mask to use
  110135. */
  110136. getStencilFunctionMask(): number;
  110137. /**
  110138. * Sets the current stencil function
  110139. * @param stencilFunc defines the new stencil function to use
  110140. */
  110141. setStencilFunction(stencilFunc: number): void;
  110142. /**
  110143. * Sets the current stencil reference
  110144. * @param reference defines the new stencil reference to use
  110145. */
  110146. setStencilFunctionReference(reference: number): void;
  110147. /**
  110148. * Sets the current stencil mask
  110149. * @param mask defines the new stencil mask to use
  110150. */
  110151. setStencilFunctionMask(mask: number): void;
  110152. /**
  110153. * Gets the current stencil operation when stencil fails
  110154. * @returns a number defining stencil operation to use when stencil fails
  110155. */
  110156. getStencilOperationFail(): number;
  110157. /**
  110158. * Gets the current stencil operation when depth fails
  110159. * @returns a number defining stencil operation to use when depth fails
  110160. */
  110161. getStencilOperationDepthFail(): number;
  110162. /**
  110163. * Gets the current stencil operation when stencil passes
  110164. * @returns a number defining stencil operation to use when stencil passes
  110165. */
  110166. getStencilOperationPass(): number;
  110167. /**
  110168. * Sets the stencil operation to use when stencil fails
  110169. * @param operation defines the stencil operation to use when stencil fails
  110170. */
  110171. setStencilOperationFail(operation: number): void;
  110172. /**
  110173. * Sets the stencil operation to use when depth fails
  110174. * @param operation defines the stencil operation to use when depth fails
  110175. */
  110176. setStencilOperationDepthFail(operation: number): void;
  110177. /**
  110178. * Sets the stencil operation to use when stencil passes
  110179. * @param operation defines the stencil operation to use when stencil passes
  110180. */
  110181. setStencilOperationPass(operation: number): void;
  110182. /**
  110183. * Sets a boolean indicating if the dithering state is enabled or disabled
  110184. * @param value defines the dithering state
  110185. */
  110186. setDitheringState(value: boolean): void;
  110187. /**
  110188. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  110189. * @param value defines the rasterizer state
  110190. */
  110191. setRasterizerState(value: boolean): void;
  110192. /**
  110193. * Gets the current depth function
  110194. * @returns a number defining the depth function
  110195. */
  110196. getDepthFunction(): Nullable<number>;
  110197. /**
  110198. * Sets the current depth function
  110199. * @param depthFunc defines the function to use
  110200. */
  110201. setDepthFunction(depthFunc: number): void;
  110202. /**
  110203. * Sets the current depth function to GREATER
  110204. */
  110205. setDepthFunctionToGreater(): void;
  110206. /**
  110207. * Sets the current depth function to GEQUAL
  110208. */
  110209. setDepthFunctionToGreaterOrEqual(): void;
  110210. /**
  110211. * Sets the current depth function to LESS
  110212. */
  110213. setDepthFunctionToLess(): void;
  110214. /**
  110215. * Sets the current depth function to LEQUAL
  110216. */
  110217. setDepthFunctionToLessOrEqual(): void;
  110218. private _cachedStencilBuffer;
  110219. private _cachedStencilFunction;
  110220. private _cachedStencilMask;
  110221. private _cachedStencilOperationPass;
  110222. private _cachedStencilOperationFail;
  110223. private _cachedStencilOperationDepthFail;
  110224. private _cachedStencilReference;
  110225. /**
  110226. * Caches the the state of the stencil buffer
  110227. */
  110228. cacheStencilState(): void;
  110229. /**
  110230. * Restores the state of the stencil buffer
  110231. */
  110232. restoreStencilState(): void;
  110233. /**
  110234. * Directly set the WebGL Viewport
  110235. * @param x defines the x coordinate of the viewport (in screen space)
  110236. * @param y defines the y coordinate of the viewport (in screen space)
  110237. * @param width defines the width of the viewport (in screen space)
  110238. * @param height defines the height of the viewport (in screen space)
  110239. * @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
  110240. */
  110241. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  110242. /**
  110243. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  110244. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  110245. * @param y defines the y-coordinate of the corner of the clear rectangle
  110246. * @param width defines the width of the clear rectangle
  110247. * @param height defines the height of the clear rectangle
  110248. * @param clearColor defines the clear color
  110249. */
  110250. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  110251. /**
  110252. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  110253. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  110254. * @param y defines the y-coordinate of the corner of the clear rectangle
  110255. * @param width defines the width of the clear rectangle
  110256. * @param height defines the height of the clear rectangle
  110257. */
  110258. enableScissor(x: number, y: number, width: number, height: number): void;
  110259. /**
  110260. * Disable previously set scissor test rectangle
  110261. */
  110262. disableScissor(): void;
  110263. protected _reportDrawCall(): void;
  110264. /**
  110265. * Initializes a webVR display and starts listening to display change events
  110266. * The onVRDisplayChangedObservable will be notified upon these changes
  110267. * @returns The onVRDisplayChangedObservable
  110268. */
  110269. initWebVR(): Observable<IDisplayChangedEventArgs>;
  110270. /** @hidden */
  110271. _prepareVRComponent(): void;
  110272. /** @hidden */
  110273. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  110274. /** @hidden */
  110275. _submitVRFrame(): void;
  110276. /**
  110277. * Call this function to leave webVR mode
  110278. * Will do nothing if webVR is not supported or if there is no webVR device
  110279. * @see http://doc.babylonjs.com/how_to/webvr_camera
  110280. */
  110281. disableVR(): void;
  110282. /**
  110283. * Gets a boolean indicating that the system is in VR mode and is presenting
  110284. * @returns true if VR mode is engaged
  110285. */
  110286. isVRPresenting(): boolean;
  110287. /** @hidden */
  110288. _requestVRFrame(): void;
  110289. /** @hidden */
  110290. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110291. /**
  110292. * Gets the source code of the vertex shader associated with a specific webGL program
  110293. * @param program defines the program to use
  110294. * @returns a string containing the source code of the vertex shader associated with the program
  110295. */
  110296. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  110297. /**
  110298. * Gets the source code of the fragment shader associated with a specific webGL program
  110299. * @param program defines the program to use
  110300. * @returns a string containing the source code of the fragment shader associated with the program
  110301. */
  110302. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  110303. /**
  110304. * Sets a depth stencil texture from a render target to the according uniform.
  110305. * @param channel The texture channel
  110306. * @param uniform The uniform to set
  110307. * @param texture The render target texture containing the depth stencil texture to apply
  110308. */
  110309. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  110310. /**
  110311. * Sets a texture to the webGL context from a postprocess
  110312. * @param channel defines the channel to use
  110313. * @param postProcess defines the source postprocess
  110314. */
  110315. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  110316. /**
  110317. * Binds the output of the passed in post process to the texture channel specified
  110318. * @param channel The channel the texture should be bound to
  110319. * @param postProcess The post process which's output should be bound
  110320. */
  110321. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  110322. protected _rebuildBuffers(): void;
  110323. /** @hidden */
  110324. _renderFrame(): void;
  110325. _renderLoop(): void;
  110326. /** @hidden */
  110327. _renderViews(): boolean;
  110328. /**
  110329. * Toggle full screen mode
  110330. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110331. */
  110332. switchFullscreen(requestPointerLock: boolean): void;
  110333. /**
  110334. * Enters full screen mode
  110335. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110336. */
  110337. enterFullscreen(requestPointerLock: boolean): void;
  110338. /**
  110339. * Exits full screen mode
  110340. */
  110341. exitFullscreen(): void;
  110342. /**
  110343. * Enters Pointerlock mode
  110344. */
  110345. enterPointerlock(): void;
  110346. /**
  110347. * Exits Pointerlock mode
  110348. */
  110349. exitPointerlock(): void;
  110350. /**
  110351. * Begin a new frame
  110352. */
  110353. beginFrame(): void;
  110354. /**
  110355. * Enf the current frame
  110356. */
  110357. endFrame(): void;
  110358. resize(): void;
  110359. /**
  110360. * Force a specific size of the canvas
  110361. * @param width defines the new canvas' width
  110362. * @param height defines the new canvas' height
  110363. */
  110364. setSize(width: number, height: number): void;
  110365. /**
  110366. * Updates a dynamic vertex buffer.
  110367. * @param vertexBuffer the vertex buffer to update
  110368. * @param data the data used to update the vertex buffer
  110369. * @param byteOffset the byte offset of the data
  110370. * @param byteLength the byte length of the data
  110371. */
  110372. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110373. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110374. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110375. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110376. _releaseTexture(texture: InternalTexture): void;
  110377. /**
  110378. * @hidden
  110379. * Rescales a texture
  110380. * @param source input texutre
  110381. * @param destination destination texture
  110382. * @param scene scene to use to render the resize
  110383. * @param internalFormat format to use when resizing
  110384. * @param onComplete callback to be called when resize has completed
  110385. */
  110386. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  110387. /**
  110388. * Gets the current framerate
  110389. * @returns a number representing the framerate
  110390. */
  110391. getFps(): number;
  110392. /**
  110393. * Gets the time spent between current and previous frame
  110394. * @returns a number representing the delta time in ms
  110395. */
  110396. getDeltaTime(): number;
  110397. private _measureFps;
  110398. /** @hidden */
  110399. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  110400. /**
  110401. * Update a dynamic index buffer
  110402. * @param indexBuffer defines the target index buffer
  110403. * @param indices defines the data to update
  110404. * @param offset defines the offset in the target index buffer where update should start
  110405. */
  110406. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110407. /**
  110408. * Updates the sample count of a render target texture
  110409. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110410. * @param texture defines the texture to update
  110411. * @param samples defines the sample count to set
  110412. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110413. */
  110414. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  110415. /**
  110416. * Updates a depth texture Comparison Mode and Function.
  110417. * If the comparison Function is equal to 0, the mode will be set to none.
  110418. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  110419. * @param texture The texture to set the comparison function for
  110420. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  110421. */
  110422. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  110423. /**
  110424. * Creates a webGL buffer to use with instanciation
  110425. * @param capacity defines the size of the buffer
  110426. * @returns the webGL buffer
  110427. */
  110428. createInstancesBuffer(capacity: number): DataBuffer;
  110429. /**
  110430. * Delete a webGL buffer used with instanciation
  110431. * @param buffer defines the webGL buffer to delete
  110432. */
  110433. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  110434. private _clientWaitAsync;
  110435. /** @hidden */
  110436. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  110437. dispose(): void;
  110438. private _disableTouchAction;
  110439. /**
  110440. * Display the loading screen
  110441. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110442. */
  110443. displayLoadingUI(): void;
  110444. /**
  110445. * Hide the loading screen
  110446. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110447. */
  110448. hideLoadingUI(): void;
  110449. /**
  110450. * Gets the current loading screen object
  110451. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110452. */
  110453. get loadingScreen(): ILoadingScreen;
  110454. /**
  110455. * Sets the current loading screen object
  110456. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110457. */
  110458. set loadingScreen(loadingScreen: ILoadingScreen);
  110459. /**
  110460. * Sets the current loading screen text
  110461. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110462. */
  110463. set loadingUIText(text: string);
  110464. /**
  110465. * Sets the current loading screen background color
  110466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110467. */
  110468. set loadingUIBackgroundColor(color: string);
  110469. /** Pointerlock and fullscreen */
  110470. /**
  110471. * Ask the browser to promote the current element to pointerlock mode
  110472. * @param element defines the DOM element to promote
  110473. */
  110474. static _RequestPointerlock(element: HTMLElement): void;
  110475. /**
  110476. * Asks the browser to exit pointerlock mode
  110477. */
  110478. static _ExitPointerlock(): void;
  110479. /**
  110480. * Ask the browser to promote the current element to fullscreen rendering mode
  110481. * @param element defines the DOM element to promote
  110482. */
  110483. static _RequestFullscreen(element: HTMLElement): void;
  110484. /**
  110485. * Asks the browser to exit fullscreen mode
  110486. */
  110487. static _ExitFullscreen(): void;
  110488. }
  110489. }
  110490. declare module BABYLON {
  110491. /**
  110492. * The engine store class is responsible to hold all the instances of Engine and Scene created
  110493. * during the life time of the application.
  110494. */
  110495. export class EngineStore {
  110496. /** Gets the list of created engines */
  110497. static Instances: Engine[];
  110498. /** @hidden */
  110499. static _LastCreatedScene: Nullable<Scene>;
  110500. /**
  110501. * Gets the latest created engine
  110502. */
  110503. static get LastCreatedEngine(): Nullable<Engine>;
  110504. /**
  110505. * Gets the latest created scene
  110506. */
  110507. static get LastCreatedScene(): Nullable<Scene>;
  110508. /**
  110509. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110510. * @ignorenaming
  110511. */
  110512. static UseFallbackTexture: boolean;
  110513. /**
  110514. * Texture content used if a texture cannot loaded
  110515. * @ignorenaming
  110516. */
  110517. static FallbackTexture: string;
  110518. }
  110519. }
  110520. declare module BABYLON {
  110521. /**
  110522. * Helper class that provides a small promise polyfill
  110523. */
  110524. export class PromisePolyfill {
  110525. /**
  110526. * Static function used to check if the polyfill is required
  110527. * If this is the case then the function will inject the polyfill to window.Promise
  110528. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  110529. */
  110530. static Apply(force?: boolean): void;
  110531. }
  110532. }
  110533. declare module BABYLON {
  110534. /**
  110535. * Interface for screenshot methods with describe argument called `size` as object with options
  110536. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  110537. */
  110538. export interface IScreenshotSize {
  110539. /**
  110540. * number in pixels for canvas height
  110541. */
  110542. height?: number;
  110543. /**
  110544. * multiplier allowing render at a higher or lower resolution
  110545. * If value is defined then height and width will be ignored and taken from camera
  110546. */
  110547. precision?: number;
  110548. /**
  110549. * number in pixels for canvas width
  110550. */
  110551. width?: number;
  110552. }
  110553. }
  110554. declare module BABYLON {
  110555. interface IColor4Like {
  110556. r: float;
  110557. g: float;
  110558. b: float;
  110559. a: float;
  110560. }
  110561. /**
  110562. * Class containing a set of static utilities functions
  110563. */
  110564. export class Tools {
  110565. /**
  110566. * Gets or sets the base URL to use to load assets
  110567. */
  110568. static get BaseUrl(): string;
  110569. static set BaseUrl(value: string);
  110570. /**
  110571. * Enable/Disable Custom HTTP Request Headers globally.
  110572. * default = false
  110573. * @see CustomRequestHeaders
  110574. */
  110575. static UseCustomRequestHeaders: boolean;
  110576. /**
  110577. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  110578. * i.e. when loading files, where the server/service expects an Authorization header
  110579. */
  110580. static CustomRequestHeaders: {
  110581. [key: string]: string;
  110582. };
  110583. /**
  110584. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  110585. */
  110586. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  110587. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  110588. /**
  110589. * Default behaviour for cors in the application.
  110590. * It can be a string if the expected behavior is identical in the entire app.
  110591. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  110592. */
  110593. static get CorsBehavior(): string | ((url: string | string[]) => string);
  110594. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  110595. /**
  110596. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110597. * @ignorenaming
  110598. */
  110599. static get UseFallbackTexture(): boolean;
  110600. static set UseFallbackTexture(value: boolean);
  110601. /**
  110602. * Use this object to register external classes like custom textures or material
  110603. * to allow the laoders to instantiate them
  110604. */
  110605. static get RegisteredExternalClasses(): {
  110606. [key: string]: Object;
  110607. };
  110608. static set RegisteredExternalClasses(classes: {
  110609. [key: string]: Object;
  110610. });
  110611. /**
  110612. * Texture content used if a texture cannot loaded
  110613. * @ignorenaming
  110614. */
  110615. static get fallbackTexture(): string;
  110616. static set fallbackTexture(value: string);
  110617. /**
  110618. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  110619. * @param u defines the coordinate on X axis
  110620. * @param v defines the coordinate on Y axis
  110621. * @param width defines the width of the source data
  110622. * @param height defines the height of the source data
  110623. * @param pixels defines the source byte array
  110624. * @param color defines the output color
  110625. */
  110626. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  110627. /**
  110628. * Interpolates between a and b via alpha
  110629. * @param a The lower value (returned when alpha = 0)
  110630. * @param b The upper value (returned when alpha = 1)
  110631. * @param alpha The interpolation-factor
  110632. * @return The mixed value
  110633. */
  110634. static Mix(a: number, b: number, alpha: number): number;
  110635. /**
  110636. * Tries to instantiate a new object from a given class name
  110637. * @param className defines the class name to instantiate
  110638. * @returns the new object or null if the system was not able to do the instantiation
  110639. */
  110640. static Instantiate(className: string): any;
  110641. /**
  110642. * Provides a slice function that will work even on IE
  110643. * @param data defines the array to slice
  110644. * @param start defines the start of the data (optional)
  110645. * @param end defines the end of the data (optional)
  110646. * @returns the new sliced array
  110647. */
  110648. static Slice<T>(data: T, start?: number, end?: number): T;
  110649. /**
  110650. * Polyfill for setImmediate
  110651. * @param action defines the action to execute after the current execution block
  110652. */
  110653. static SetImmediate(action: () => void): void;
  110654. /**
  110655. * Function indicating if a number is an exponent of 2
  110656. * @param value defines the value to test
  110657. * @returns true if the value is an exponent of 2
  110658. */
  110659. static IsExponentOfTwo(value: number): boolean;
  110660. private static _tmpFloatArray;
  110661. /**
  110662. * Returns the nearest 32-bit single precision float representation of a Number
  110663. * @param value A Number. If the parameter is of a different type, it will get converted
  110664. * to a number or to NaN if it cannot be converted
  110665. * @returns number
  110666. */
  110667. static FloatRound(value: number): number;
  110668. /**
  110669. * Extracts the filename from a path
  110670. * @param path defines the path to use
  110671. * @returns the filename
  110672. */
  110673. static GetFilename(path: string): string;
  110674. /**
  110675. * Extracts the "folder" part of a path (everything before the filename).
  110676. * @param uri The URI to extract the info from
  110677. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  110678. * @returns The "folder" part of the path
  110679. */
  110680. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  110681. /**
  110682. * Extracts text content from a DOM element hierarchy
  110683. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  110684. */
  110685. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  110686. /**
  110687. * Convert an angle in radians to degrees
  110688. * @param angle defines the angle to convert
  110689. * @returns the angle in degrees
  110690. */
  110691. static ToDegrees(angle: number): number;
  110692. /**
  110693. * Convert an angle in degrees to radians
  110694. * @param angle defines the angle to convert
  110695. * @returns the angle in radians
  110696. */
  110697. static ToRadians(angle: number): number;
  110698. /**
  110699. * Returns an array if obj is not an array
  110700. * @param obj defines the object to evaluate as an array
  110701. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  110702. * @returns either obj directly if obj is an array or a new array containing obj
  110703. */
  110704. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  110705. /**
  110706. * Gets the pointer prefix to use
  110707. * @returns "pointer" if touch is enabled. Else returns "mouse"
  110708. */
  110709. static GetPointerPrefix(): string;
  110710. /**
  110711. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  110712. * @param url define the url we are trying
  110713. * @param element define the dom element where to configure the cors policy
  110714. */
  110715. static SetCorsBehavior(url: string | string[], element: {
  110716. crossOrigin: string | null;
  110717. }): void;
  110718. /**
  110719. * Removes unwanted characters from an url
  110720. * @param url defines the url to clean
  110721. * @returns the cleaned url
  110722. */
  110723. static CleanUrl(url: string): string;
  110724. /**
  110725. * Gets or sets a function used to pre-process url before using them to load assets
  110726. */
  110727. static get PreprocessUrl(): (url: string) => string;
  110728. static set PreprocessUrl(processor: (url: string) => string);
  110729. /**
  110730. * Loads an image as an HTMLImageElement.
  110731. * @param input url string, ArrayBuffer, or Blob to load
  110732. * @param onLoad callback called when the image successfully loads
  110733. * @param onError callback called when the image fails to load
  110734. * @param offlineProvider offline provider for caching
  110735. * @param mimeType optional mime type
  110736. * @returns the HTMLImageElement of the loaded image
  110737. */
  110738. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  110739. /**
  110740. * Loads a file from a url
  110741. * @param url url string, ArrayBuffer, or Blob to load
  110742. * @param onSuccess callback called when the file successfully loads
  110743. * @param onProgress callback called while file is loading (if the server supports this mode)
  110744. * @param offlineProvider defines the offline provider for caching
  110745. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110746. * @param onError callback called when the file fails to load
  110747. * @returns a file request object
  110748. */
  110749. 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;
  110750. /**
  110751. * Loads a file from a url
  110752. * @param url the file url to load
  110753. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110754. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  110755. */
  110756. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  110757. /**
  110758. * Load a script (identified by an url). When the url returns, the
  110759. * content of this file is added into a new script element, attached to the DOM (body element)
  110760. * @param scriptUrl defines the url of the script to laod
  110761. * @param onSuccess defines the callback called when the script is loaded
  110762. * @param onError defines the callback to call if an error occurs
  110763. * @param scriptId defines the id of the script element
  110764. */
  110765. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  110766. /**
  110767. * Load an asynchronous script (identified by an url). When the url returns, the
  110768. * content of this file is added into a new script element, attached to the DOM (body element)
  110769. * @param scriptUrl defines the url of the script to laod
  110770. * @param scriptId defines the id of the script element
  110771. * @returns a promise request object
  110772. */
  110773. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  110774. /**
  110775. * Loads a file from a blob
  110776. * @param fileToLoad defines the blob to use
  110777. * @param callback defines the callback to call when data is loaded
  110778. * @param progressCallback defines the callback to call during loading process
  110779. * @returns a file request object
  110780. */
  110781. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  110782. /**
  110783. * Reads a file from a File object
  110784. * @param file defines the file to load
  110785. * @param onSuccess defines the callback to call when data is loaded
  110786. * @param onProgress defines the callback to call during loading process
  110787. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110788. * @param onError defines the callback to call when an error occurs
  110789. * @returns a file request object
  110790. */
  110791. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110792. /**
  110793. * Creates a data url from a given string content
  110794. * @param content defines the content to convert
  110795. * @returns the new data url link
  110796. */
  110797. static FileAsURL(content: string): string;
  110798. /**
  110799. * Format the given number to a specific decimal format
  110800. * @param value defines the number to format
  110801. * @param decimals defines the number of decimals to use
  110802. * @returns the formatted string
  110803. */
  110804. static Format(value: number, decimals?: number): string;
  110805. /**
  110806. * Tries to copy an object by duplicating every property
  110807. * @param source defines the source object
  110808. * @param destination defines the target object
  110809. * @param doNotCopyList defines a list of properties to avoid
  110810. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  110811. */
  110812. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  110813. /**
  110814. * Gets a boolean indicating if the given object has no own property
  110815. * @param obj defines the object to test
  110816. * @returns true if object has no own property
  110817. */
  110818. static IsEmpty(obj: any): boolean;
  110819. /**
  110820. * Function used to register events at window level
  110821. * @param windowElement defines the Window object to use
  110822. * @param events defines the events to register
  110823. */
  110824. static RegisterTopRootEvents(windowElement: Window, events: {
  110825. name: string;
  110826. handler: Nullable<(e: FocusEvent) => any>;
  110827. }[]): void;
  110828. /**
  110829. * Function used to unregister events from window level
  110830. * @param windowElement defines the Window object to use
  110831. * @param events defines the events to unregister
  110832. */
  110833. static UnregisterTopRootEvents(windowElement: Window, events: {
  110834. name: string;
  110835. handler: Nullable<(e: FocusEvent) => any>;
  110836. }[]): void;
  110837. /**
  110838. * @ignore
  110839. */
  110840. static _ScreenshotCanvas: HTMLCanvasElement;
  110841. /**
  110842. * Dumps the current bound framebuffer
  110843. * @param width defines the rendering width
  110844. * @param height defines the rendering height
  110845. * @param engine defines the hosting engine
  110846. * @param successCallback defines the callback triggered once the data are available
  110847. * @param mimeType defines the mime type of the result
  110848. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  110849. */
  110850. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110851. /**
  110852. * Converts the canvas data to blob.
  110853. * This acts as a polyfill for browsers not supporting the to blob function.
  110854. * @param canvas Defines the canvas to extract the data from
  110855. * @param successCallback Defines the callback triggered once the data are available
  110856. * @param mimeType Defines the mime type of the result
  110857. */
  110858. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  110859. /**
  110860. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  110861. * @param successCallback defines the callback triggered once the data are available
  110862. * @param mimeType defines the mime type of the result
  110863. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  110864. */
  110865. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110866. /**
  110867. * Downloads a blob in the browser
  110868. * @param blob defines the blob to download
  110869. * @param fileName defines the name of the downloaded file
  110870. */
  110871. static Download(blob: Blob, fileName: string): void;
  110872. /**
  110873. * Captures a screenshot of the current rendering
  110874. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110875. * @param engine defines the rendering engine
  110876. * @param camera defines the source camera
  110877. * @param size This parameter can be set to a single number or to an object with the
  110878. * following (optional) properties: precision, width, height. If a single number is passed,
  110879. * it will be used for both width and height. If an object is passed, the screenshot size
  110880. * will be derived from the parameters. The precision property is a multiplier allowing
  110881. * rendering at a higher or lower resolution
  110882. * @param successCallback defines the callback receives a single parameter which contains the
  110883. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110884. * src parameter of an <img> to display it
  110885. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110886. * Check your browser for supported MIME types
  110887. */
  110888. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  110889. /**
  110890. * Captures a screenshot of the current rendering
  110891. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110892. * @param engine defines the rendering engine
  110893. * @param camera defines the source camera
  110894. * @param size This parameter can be set to a single number or to an object with the
  110895. * following (optional) properties: precision, width, height. If a single number is passed,
  110896. * it will be used for both width and height. If an object is passed, the screenshot size
  110897. * will be derived from the parameters. The precision property is a multiplier allowing
  110898. * rendering at a higher or lower resolution
  110899. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110900. * Check your browser for supported MIME types
  110901. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110902. * to the src parameter of an <img> to display it
  110903. */
  110904. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  110905. /**
  110906. * Generates an image screenshot from the specified camera.
  110907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110908. * @param engine The engine to use for rendering
  110909. * @param camera The camera to use for rendering
  110910. * @param size This parameter can be set to a single number or to an object with the
  110911. * following (optional) properties: precision, width, height. If a single number is passed,
  110912. * it will be used for both width and height. If an object is passed, the screenshot size
  110913. * will be derived from the parameters. The precision property is a multiplier allowing
  110914. * rendering at a higher or lower resolution
  110915. * @param successCallback The callback receives a single parameter which contains the
  110916. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110917. * src parameter of an <img> to display it
  110918. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110919. * Check your browser for supported MIME types
  110920. * @param samples Texture samples (default: 1)
  110921. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110922. * @param fileName A name for for the downloaded file.
  110923. */
  110924. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110925. /**
  110926. * Generates an image screenshot from the specified camera.
  110927. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110928. * @param engine The engine to use for rendering
  110929. * @param camera The camera to use for rendering
  110930. * @param size This parameter can be set to a single number or to an object with the
  110931. * following (optional) properties: precision, width, height. If a single number is passed,
  110932. * it will be used for both width and height. If an object is passed, the screenshot size
  110933. * will be derived from the parameters. The precision property is a multiplier allowing
  110934. * rendering at a higher or lower resolution
  110935. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110936. * Check your browser for supported MIME types
  110937. * @param samples Texture samples (default: 1)
  110938. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110939. * @param fileName A name for for the downloaded file.
  110940. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110941. * to the src parameter of an <img> to display it
  110942. */
  110943. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  110944. /**
  110945. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110946. * Be aware Math.random() could cause collisions, but:
  110947. * "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"
  110948. * @returns a pseudo random id
  110949. */
  110950. static RandomId(): string;
  110951. /**
  110952. * Test if the given uri is a base64 string
  110953. * @param uri The uri to test
  110954. * @return True if the uri is a base64 string or false otherwise
  110955. */
  110956. static IsBase64(uri: string): boolean;
  110957. /**
  110958. * Decode the given base64 uri.
  110959. * @param uri The uri to decode
  110960. * @return The decoded base64 data.
  110961. */
  110962. static DecodeBase64(uri: string): ArrayBuffer;
  110963. /**
  110964. * Gets the absolute url.
  110965. * @param url the input url
  110966. * @return the absolute url
  110967. */
  110968. static GetAbsoluteUrl(url: string): string;
  110969. /**
  110970. * No log
  110971. */
  110972. static readonly NoneLogLevel: number;
  110973. /**
  110974. * Only message logs
  110975. */
  110976. static readonly MessageLogLevel: number;
  110977. /**
  110978. * Only warning logs
  110979. */
  110980. static readonly WarningLogLevel: number;
  110981. /**
  110982. * Only error logs
  110983. */
  110984. static readonly ErrorLogLevel: number;
  110985. /**
  110986. * All logs
  110987. */
  110988. static readonly AllLogLevel: number;
  110989. /**
  110990. * Gets a value indicating the number of loading errors
  110991. * @ignorenaming
  110992. */
  110993. static get errorsCount(): number;
  110994. /**
  110995. * Callback called when a new log is added
  110996. */
  110997. static OnNewCacheEntry: (entry: string) => void;
  110998. /**
  110999. * Log a message to the console
  111000. * @param message defines the message to log
  111001. */
  111002. static Log(message: string): void;
  111003. /**
  111004. * Write a warning message to the console
  111005. * @param message defines the message to log
  111006. */
  111007. static Warn(message: string): void;
  111008. /**
  111009. * Write an error message to the console
  111010. * @param message defines the message to log
  111011. */
  111012. static Error(message: string): void;
  111013. /**
  111014. * Gets current log cache (list of logs)
  111015. */
  111016. static get LogCache(): string;
  111017. /**
  111018. * Clears the log cache
  111019. */
  111020. static ClearLogCache(): void;
  111021. /**
  111022. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  111023. */
  111024. static set LogLevels(level: number);
  111025. /**
  111026. * Checks if the window object exists
  111027. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  111028. */
  111029. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  111030. /**
  111031. * No performance log
  111032. */
  111033. static readonly PerformanceNoneLogLevel: number;
  111034. /**
  111035. * Use user marks to log performance
  111036. */
  111037. static readonly PerformanceUserMarkLogLevel: number;
  111038. /**
  111039. * Log performance to the console
  111040. */
  111041. static readonly PerformanceConsoleLogLevel: number;
  111042. private static _performance;
  111043. /**
  111044. * Sets the current performance log level
  111045. */
  111046. static set PerformanceLogLevel(level: number);
  111047. private static _StartPerformanceCounterDisabled;
  111048. private static _EndPerformanceCounterDisabled;
  111049. private static _StartUserMark;
  111050. private static _EndUserMark;
  111051. private static _StartPerformanceConsole;
  111052. private static _EndPerformanceConsole;
  111053. /**
  111054. * Starts a performance counter
  111055. */
  111056. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  111057. /**
  111058. * Ends a specific performance coutner
  111059. */
  111060. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  111061. /**
  111062. * Gets either window.performance.now() if supported or Date.now() else
  111063. */
  111064. static get Now(): number;
  111065. /**
  111066. * This method will return the name of the class used to create the instance of the given object.
  111067. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  111068. * @param object the object to get the class name from
  111069. * @param isType defines if the object is actually a type
  111070. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  111071. */
  111072. static GetClassName(object: any, isType?: boolean): string;
  111073. /**
  111074. * Gets the first element of an array satisfying a given predicate
  111075. * @param array defines the array to browse
  111076. * @param predicate defines the predicate to use
  111077. * @returns null if not found or the element
  111078. */
  111079. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  111080. /**
  111081. * This method will return the name of the full name of the class, including its owning module (if any).
  111082. * 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).
  111083. * @param object the object to get the class name from
  111084. * @param isType defines if the object is actually a type
  111085. * @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.
  111086. * @ignorenaming
  111087. */
  111088. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  111089. /**
  111090. * Returns a promise that resolves after the given amount of time.
  111091. * @param delay Number of milliseconds to delay
  111092. * @returns Promise that resolves after the given amount of time
  111093. */
  111094. static DelayAsync(delay: number): Promise<void>;
  111095. /**
  111096. * Utility function to detect if the current user agent is Safari
  111097. * @returns whether or not the current user agent is safari
  111098. */
  111099. static IsSafari(): boolean;
  111100. }
  111101. /**
  111102. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  111103. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  111104. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  111105. * @param name The name of the class, case should be preserved
  111106. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  111107. */
  111108. export function className(name: string, module?: string): (target: Object) => void;
  111109. /**
  111110. * An implementation of a loop for asynchronous functions.
  111111. */
  111112. export class AsyncLoop {
  111113. /**
  111114. * Defines the number of iterations for the loop
  111115. */
  111116. iterations: number;
  111117. /**
  111118. * Defines the current index of the loop.
  111119. */
  111120. index: number;
  111121. private _done;
  111122. private _fn;
  111123. private _successCallback;
  111124. /**
  111125. * Constructor.
  111126. * @param iterations the number of iterations.
  111127. * @param func the function to run each iteration
  111128. * @param successCallback the callback that will be called upon succesful execution
  111129. * @param offset starting offset.
  111130. */
  111131. constructor(
  111132. /**
  111133. * Defines the number of iterations for the loop
  111134. */
  111135. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  111136. /**
  111137. * Execute the next iteration. Must be called after the last iteration was finished.
  111138. */
  111139. executeNext(): void;
  111140. /**
  111141. * Break the loop and run the success callback.
  111142. */
  111143. breakLoop(): void;
  111144. /**
  111145. * Create and run an async loop.
  111146. * @param iterations the number of iterations.
  111147. * @param fn the function to run each iteration
  111148. * @param successCallback the callback that will be called upon succesful execution
  111149. * @param offset starting offset.
  111150. * @returns the created async loop object
  111151. */
  111152. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  111153. /**
  111154. * A for-loop that will run a given number of iterations synchronous and the rest async.
  111155. * @param iterations total number of iterations
  111156. * @param syncedIterations number of synchronous iterations in each async iteration.
  111157. * @param fn the function to call each iteration.
  111158. * @param callback a success call back that will be called when iterating stops.
  111159. * @param breakFunction a break condition (optional)
  111160. * @param timeout timeout settings for the setTimeout function. default - 0.
  111161. * @returns the created async loop object
  111162. */
  111163. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  111164. }
  111165. }
  111166. declare module BABYLON {
  111167. /**
  111168. * This class implement a typical dictionary using a string as key and the generic type T as value.
  111169. * The underlying implementation relies on an associative array to ensure the best performances.
  111170. * The value can be anything including 'null' but except 'undefined'
  111171. */
  111172. export class StringDictionary<T> {
  111173. /**
  111174. * This will clear this dictionary and copy the content from the 'source' one.
  111175. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  111176. * @param source the dictionary to take the content from and copy to this dictionary
  111177. */
  111178. copyFrom(source: StringDictionary<T>): void;
  111179. /**
  111180. * Get a value based from its key
  111181. * @param key the given key to get the matching value from
  111182. * @return the value if found, otherwise undefined is returned
  111183. */
  111184. get(key: string): T | undefined;
  111185. /**
  111186. * Get a value from its key or add it if it doesn't exist.
  111187. * This method will ensure you that a given key/data will be present in the dictionary.
  111188. * @param key the given key to get the matching value from
  111189. * @param factory the factory that will create the value if the key is not present in the dictionary.
  111190. * The factory will only be invoked if there's no data for the given key.
  111191. * @return the value corresponding to the key.
  111192. */
  111193. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  111194. /**
  111195. * Get a value from its key if present in the dictionary otherwise add it
  111196. * @param key the key to get the value from
  111197. * @param val if there's no such key/value pair in the dictionary add it with this value
  111198. * @return the value corresponding to the key
  111199. */
  111200. getOrAdd(key: string, val: T): T;
  111201. /**
  111202. * Check if there's a given key in the dictionary
  111203. * @param key the key to check for
  111204. * @return true if the key is present, false otherwise
  111205. */
  111206. contains(key: string): boolean;
  111207. /**
  111208. * Add a new key and its corresponding value
  111209. * @param key the key to add
  111210. * @param value the value corresponding to the key
  111211. * @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
  111212. */
  111213. add(key: string, value: T): boolean;
  111214. /**
  111215. * Update a specific value associated to a key
  111216. * @param key defines the key to use
  111217. * @param value defines the value to store
  111218. * @returns true if the value was updated (or false if the key was not found)
  111219. */
  111220. set(key: string, value: T): boolean;
  111221. /**
  111222. * Get the element of the given key and remove it from the dictionary
  111223. * @param key defines the key to search
  111224. * @returns the value associated with the key or null if not found
  111225. */
  111226. getAndRemove(key: string): Nullable<T>;
  111227. /**
  111228. * Remove a key/value from the dictionary.
  111229. * @param key the key to remove
  111230. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  111231. */
  111232. remove(key: string): boolean;
  111233. /**
  111234. * Clear the whole content of the dictionary
  111235. */
  111236. clear(): void;
  111237. /**
  111238. * Gets the current count
  111239. */
  111240. get count(): number;
  111241. /**
  111242. * Execute a callback on each key/val of the dictionary.
  111243. * Note that you can remove any element in this dictionary in the callback implementation
  111244. * @param callback the callback to execute on a given key/value pair
  111245. */
  111246. forEach(callback: (key: string, val: T) => void): void;
  111247. /**
  111248. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  111249. * If the callback returns null or undefined the method will iterate to the next key/value pair
  111250. * Note that you can remove any element in this dictionary in the callback implementation
  111251. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  111252. * @returns the first item
  111253. */
  111254. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  111255. private _count;
  111256. private _data;
  111257. }
  111258. }
  111259. declare module BABYLON {
  111260. /** @hidden */
  111261. export interface ICollisionCoordinator {
  111262. createCollider(): Collider;
  111263. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111264. init(scene: Scene): void;
  111265. }
  111266. /** @hidden */
  111267. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  111268. private _scene;
  111269. private _scaledPosition;
  111270. private _scaledVelocity;
  111271. private _finalPosition;
  111272. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111273. createCollider(): Collider;
  111274. init(scene: Scene): void;
  111275. private _collideWithWorld;
  111276. }
  111277. }
  111278. declare module BABYLON {
  111279. /**
  111280. * Class used to manage all inputs for the scene.
  111281. */
  111282. export class InputManager {
  111283. /** The distance in pixel that you have to move to prevent some events */
  111284. static DragMovementThreshold: number;
  111285. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  111286. static LongPressDelay: number;
  111287. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  111288. static DoubleClickDelay: number;
  111289. /** If you need to check double click without raising a single click at first click, enable this flag */
  111290. static ExclusiveDoubleClickMode: boolean;
  111291. private _wheelEventName;
  111292. private _onPointerMove;
  111293. private _onPointerDown;
  111294. private _onPointerUp;
  111295. private _initClickEvent;
  111296. private _initActionManager;
  111297. private _delayedSimpleClick;
  111298. private _delayedSimpleClickTimeout;
  111299. private _previousDelayedSimpleClickTimeout;
  111300. private _meshPickProceed;
  111301. private _previousButtonPressed;
  111302. private _currentPickResult;
  111303. private _previousPickResult;
  111304. private _totalPointersPressed;
  111305. private _doubleClickOccured;
  111306. private _pointerOverMesh;
  111307. private _pickedDownMesh;
  111308. private _pickedUpMesh;
  111309. private _pointerX;
  111310. private _pointerY;
  111311. private _unTranslatedPointerX;
  111312. private _unTranslatedPointerY;
  111313. private _startingPointerPosition;
  111314. private _previousStartingPointerPosition;
  111315. private _startingPointerTime;
  111316. private _previousStartingPointerTime;
  111317. private _pointerCaptures;
  111318. private _onKeyDown;
  111319. private _onKeyUp;
  111320. private _onCanvasFocusObserver;
  111321. private _onCanvasBlurObserver;
  111322. private _scene;
  111323. /**
  111324. * Creates a new InputManager
  111325. * @param scene defines the hosting scene
  111326. */
  111327. constructor(scene: Scene);
  111328. /**
  111329. * Gets the mesh that is currently under the pointer
  111330. */
  111331. get meshUnderPointer(): Nullable<AbstractMesh>;
  111332. /**
  111333. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  111334. */
  111335. get unTranslatedPointer(): Vector2;
  111336. /**
  111337. * Gets or sets the current on-screen X position of the pointer
  111338. */
  111339. get pointerX(): number;
  111340. set pointerX(value: number);
  111341. /**
  111342. * Gets or sets the current on-screen Y position of the pointer
  111343. */
  111344. get pointerY(): number;
  111345. set pointerY(value: number);
  111346. private _updatePointerPosition;
  111347. private _processPointerMove;
  111348. private _setRayOnPointerInfo;
  111349. private _checkPrePointerObservable;
  111350. /**
  111351. * Use this method to simulate a pointer move on a mesh
  111352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111355. */
  111356. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111357. /**
  111358. * Use this method to simulate a pointer down on a mesh
  111359. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111360. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111361. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111362. */
  111363. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111364. private _processPointerDown;
  111365. /** @hidden */
  111366. _isPointerSwiping(): boolean;
  111367. /**
  111368. * Use this method to simulate a pointer up on a mesh
  111369. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111370. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111371. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111372. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  111373. */
  111374. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  111375. private _processPointerUp;
  111376. /**
  111377. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  111378. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  111379. * @returns true if the pointer was captured
  111380. */
  111381. isPointerCaptured(pointerId?: number): boolean;
  111382. /**
  111383. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  111384. * @param attachUp defines if you want to attach events to pointerup
  111385. * @param attachDown defines if you want to attach events to pointerdown
  111386. * @param attachMove defines if you want to attach events to pointermove
  111387. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  111388. */
  111389. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  111390. /**
  111391. * Detaches all event handlers
  111392. */
  111393. detachControl(): void;
  111394. /**
  111395. * Force the value of meshUnderPointer
  111396. * @param mesh defines the mesh to use
  111397. */
  111398. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111399. /**
  111400. * Gets the mesh under the pointer
  111401. * @returns a Mesh or null if no mesh is under the pointer
  111402. */
  111403. getPointerOverMesh(): Nullable<AbstractMesh>;
  111404. }
  111405. }
  111406. declare module BABYLON {
  111407. /**
  111408. * Helper class used to generate session unique ID
  111409. */
  111410. export class UniqueIdGenerator {
  111411. private static _UniqueIdCounter;
  111412. /**
  111413. * Gets an unique (relatively to the current scene) Id
  111414. */
  111415. static get UniqueId(): number;
  111416. }
  111417. }
  111418. declare module BABYLON {
  111419. /**
  111420. * This class defines the direct association between an animation and a target
  111421. */
  111422. export class TargetedAnimation {
  111423. /**
  111424. * Animation to perform
  111425. */
  111426. animation: Animation;
  111427. /**
  111428. * Target to animate
  111429. */
  111430. target: any;
  111431. /**
  111432. * Serialize the object
  111433. * @returns the JSON object representing the current entity
  111434. */
  111435. serialize(): any;
  111436. }
  111437. /**
  111438. * Use this class to create coordinated animations on multiple targets
  111439. */
  111440. export class AnimationGroup implements IDisposable {
  111441. /** The name of the animation group */
  111442. name: string;
  111443. private _scene;
  111444. private _targetedAnimations;
  111445. private _animatables;
  111446. private _from;
  111447. private _to;
  111448. private _isStarted;
  111449. private _isPaused;
  111450. private _speedRatio;
  111451. private _loopAnimation;
  111452. private _isAdditive;
  111453. /**
  111454. * Gets or sets the unique id of the node
  111455. */
  111456. uniqueId: number;
  111457. /**
  111458. * This observable will notify when one animation have ended
  111459. */
  111460. onAnimationEndObservable: Observable<TargetedAnimation>;
  111461. /**
  111462. * Observer raised when one animation loops
  111463. */
  111464. onAnimationLoopObservable: Observable<TargetedAnimation>;
  111465. /**
  111466. * Observer raised when all animations have looped
  111467. */
  111468. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  111469. /**
  111470. * This observable will notify when all animations have ended.
  111471. */
  111472. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  111473. /**
  111474. * This observable will notify when all animations have paused.
  111475. */
  111476. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  111477. /**
  111478. * This observable will notify when all animations are playing.
  111479. */
  111480. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  111481. /**
  111482. * Gets the first frame
  111483. */
  111484. get from(): number;
  111485. /**
  111486. * Gets the last frame
  111487. */
  111488. get to(): number;
  111489. /**
  111490. * Define if the animations are started
  111491. */
  111492. get isStarted(): boolean;
  111493. /**
  111494. * Gets a value indicating that the current group is playing
  111495. */
  111496. get isPlaying(): boolean;
  111497. /**
  111498. * Gets or sets the speed ratio to use for all animations
  111499. */
  111500. get speedRatio(): number;
  111501. /**
  111502. * Gets or sets the speed ratio to use for all animations
  111503. */
  111504. set speedRatio(value: number);
  111505. /**
  111506. * Gets or sets if all animations should loop or not
  111507. */
  111508. get loopAnimation(): boolean;
  111509. set loopAnimation(value: boolean);
  111510. /**
  111511. * Gets or sets if all animations should be evaluated additively
  111512. */
  111513. get isAdditive(): boolean;
  111514. set isAdditive(value: boolean);
  111515. /**
  111516. * Gets the targeted animations for this animation group
  111517. */
  111518. get targetedAnimations(): Array<TargetedAnimation>;
  111519. /**
  111520. * returning the list of animatables controlled by this animation group.
  111521. */
  111522. get animatables(): Array<Animatable>;
  111523. /**
  111524. * Instantiates a new Animation Group.
  111525. * This helps managing several animations at once.
  111526. * @see http://doc.babylonjs.com/how_to/group
  111527. * @param name Defines the name of the group
  111528. * @param scene Defines the scene the group belongs to
  111529. */
  111530. constructor(
  111531. /** The name of the animation group */
  111532. name: string, scene?: Nullable<Scene>);
  111533. /**
  111534. * Add an animation (with its target) in the group
  111535. * @param animation defines the animation we want to add
  111536. * @param target defines the target of the animation
  111537. * @returns the TargetedAnimation object
  111538. */
  111539. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  111540. /**
  111541. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  111542. * It can add constant keys at begin or end
  111543. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  111544. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  111545. * @returns the animation group
  111546. */
  111547. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  111548. private _animationLoopCount;
  111549. private _animationLoopFlags;
  111550. private _processLoop;
  111551. /**
  111552. * Start all animations on given targets
  111553. * @param loop defines if animations must loop
  111554. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  111555. * @param from defines the from key (optional)
  111556. * @param to defines the to key (optional)
  111557. * @param isAdditive defines the additive state for the resulting animatables (optional)
  111558. * @returns the current animation group
  111559. */
  111560. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  111561. /**
  111562. * Pause all animations
  111563. * @returns the animation group
  111564. */
  111565. pause(): AnimationGroup;
  111566. /**
  111567. * Play all animations to initial state
  111568. * This function will start() the animations if they were not started or will restart() them if they were paused
  111569. * @param loop defines if animations must loop
  111570. * @returns the animation group
  111571. */
  111572. play(loop?: boolean): AnimationGroup;
  111573. /**
  111574. * Reset all animations to initial state
  111575. * @returns the animation group
  111576. */
  111577. reset(): AnimationGroup;
  111578. /**
  111579. * Restart animations from key 0
  111580. * @returns the animation group
  111581. */
  111582. restart(): AnimationGroup;
  111583. /**
  111584. * Stop all animations
  111585. * @returns the animation group
  111586. */
  111587. stop(): AnimationGroup;
  111588. /**
  111589. * Set animation weight for all animatables
  111590. * @param weight defines the weight to use
  111591. * @return the animationGroup
  111592. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111593. */
  111594. setWeightForAllAnimatables(weight: number): AnimationGroup;
  111595. /**
  111596. * Synchronize and normalize all animatables with a source animatable
  111597. * @param root defines the root animatable to synchronize with
  111598. * @return the animationGroup
  111599. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111600. */
  111601. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  111602. /**
  111603. * Goes to a specific frame in this animation group
  111604. * @param frame the frame number to go to
  111605. * @return the animationGroup
  111606. */
  111607. goToFrame(frame: number): AnimationGroup;
  111608. /**
  111609. * Dispose all associated resources
  111610. */
  111611. dispose(): void;
  111612. private _checkAnimationGroupEnded;
  111613. /**
  111614. * Clone the current animation group and returns a copy
  111615. * @param newName defines the name of the new group
  111616. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  111617. * @returns the new aniamtion group
  111618. */
  111619. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  111620. /**
  111621. * Serializes the animationGroup to an object
  111622. * @returns Serialized object
  111623. */
  111624. serialize(): any;
  111625. /**
  111626. * Returns a new AnimationGroup object parsed from the source provided.
  111627. * @param parsedAnimationGroup defines the source
  111628. * @param scene defines the scene that will receive the animationGroup
  111629. * @returns a new AnimationGroup
  111630. */
  111631. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  111632. /**
  111633. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111634. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  111635. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111636. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  111637. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  111638. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  111639. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  111640. */
  111641. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  111642. /**
  111643. * Returns the string "AnimationGroup"
  111644. * @returns "AnimationGroup"
  111645. */
  111646. getClassName(): string;
  111647. /**
  111648. * Creates a detailled string about the object
  111649. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  111650. * @returns a string representing the object
  111651. */
  111652. toString(fullDetails?: boolean): string;
  111653. }
  111654. }
  111655. declare module BABYLON {
  111656. /**
  111657. * Define an interface for all classes that will hold resources
  111658. */
  111659. export interface IDisposable {
  111660. /**
  111661. * Releases all held resources
  111662. */
  111663. dispose(): void;
  111664. }
  111665. /** Interface defining initialization parameters for Scene class */
  111666. export interface SceneOptions {
  111667. /**
  111668. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  111669. * It will improve performance when the number of geometries becomes important.
  111670. */
  111671. useGeometryUniqueIdsMap?: boolean;
  111672. /**
  111673. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  111674. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111675. */
  111676. useMaterialMeshMap?: boolean;
  111677. /**
  111678. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  111679. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111680. */
  111681. useClonedMeshMap?: boolean;
  111682. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  111683. virtual?: boolean;
  111684. }
  111685. /**
  111686. * Represents a scene to be rendered by the engine.
  111687. * @see http://doc.babylonjs.com/features/scene
  111688. */
  111689. export class Scene extends AbstractScene implements IAnimatable {
  111690. /** The fog is deactivated */
  111691. static readonly FOGMODE_NONE: number;
  111692. /** The fog density is following an exponential function */
  111693. static readonly FOGMODE_EXP: number;
  111694. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  111695. static readonly FOGMODE_EXP2: number;
  111696. /** The fog density is following a linear function. */
  111697. static readonly FOGMODE_LINEAR: number;
  111698. /**
  111699. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  111700. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111701. */
  111702. static MinDeltaTime: number;
  111703. /**
  111704. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  111705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111706. */
  111707. static MaxDeltaTime: number;
  111708. /**
  111709. * Factory used to create the default material.
  111710. * @param name The name of the material to create
  111711. * @param scene The scene to create the material for
  111712. * @returns The default material
  111713. */
  111714. static DefaultMaterialFactory(scene: Scene): Material;
  111715. /**
  111716. * Factory used to create the a collision coordinator.
  111717. * @returns The collision coordinator
  111718. */
  111719. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  111720. /** @hidden */
  111721. _inputManager: InputManager;
  111722. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  111723. cameraToUseForPointers: Nullable<Camera>;
  111724. /** @hidden */
  111725. readonly _isScene: boolean;
  111726. /** @hidden */
  111727. _blockEntityCollection: boolean;
  111728. /**
  111729. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  111730. */
  111731. autoClear: boolean;
  111732. /**
  111733. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  111734. */
  111735. autoClearDepthAndStencil: boolean;
  111736. /**
  111737. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  111738. */
  111739. clearColor: Color4;
  111740. /**
  111741. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  111742. */
  111743. ambientColor: Color3;
  111744. /**
  111745. * This is use to store the default BRDF lookup for PBR materials in your scene.
  111746. * It should only be one of the following (if not the default embedded one):
  111747. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111748. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  111749. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111750. * The material properties need to be setup according to the type of texture in use.
  111751. */
  111752. environmentBRDFTexture: BaseTexture;
  111753. /** @hidden */
  111754. protected _environmentTexture: Nullable<BaseTexture>;
  111755. /**
  111756. * Texture used in all pbr material as the reflection texture.
  111757. * As in the majority of the scene they are the same (exception for multi room and so on),
  111758. * this is easier to reference from here than from all the materials.
  111759. */
  111760. get environmentTexture(): Nullable<BaseTexture>;
  111761. /**
  111762. * Texture used in all pbr material as the reflection texture.
  111763. * As in the majority of the scene they are the same (exception for multi room and so on),
  111764. * this is easier to set here than in all the materials.
  111765. */
  111766. set environmentTexture(value: Nullable<BaseTexture>);
  111767. /** @hidden */
  111768. protected _environmentIntensity: number;
  111769. /**
  111770. * Intensity of the environment in all pbr material.
  111771. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111772. * As in the majority of the scene they are the same (exception for multi room and so on),
  111773. * this is easier to reference from here than from all the materials.
  111774. */
  111775. get environmentIntensity(): number;
  111776. /**
  111777. * Intensity of the environment in all pbr material.
  111778. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111779. * As in the majority of the scene they are the same (exception for multi room and so on),
  111780. * this is easier to set here than in all the materials.
  111781. */
  111782. set environmentIntensity(value: number);
  111783. /** @hidden */
  111784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111785. /**
  111786. * Default image processing configuration used either in the rendering
  111787. * Forward main pass or through the imageProcessingPostProcess if present.
  111788. * As in the majority of the scene they are the same (exception for multi camera),
  111789. * this is easier to reference from here than from all the materials and post process.
  111790. *
  111791. * No setter as we it is a shared configuration, you can set the values instead.
  111792. */
  111793. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111794. private _forceWireframe;
  111795. /**
  111796. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  111797. */
  111798. set forceWireframe(value: boolean);
  111799. get forceWireframe(): boolean;
  111800. private _skipFrustumClipping;
  111801. /**
  111802. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  111803. */
  111804. set skipFrustumClipping(value: boolean);
  111805. get skipFrustumClipping(): boolean;
  111806. private _forcePointsCloud;
  111807. /**
  111808. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  111809. */
  111810. set forcePointsCloud(value: boolean);
  111811. get forcePointsCloud(): boolean;
  111812. /**
  111813. * Gets or sets the active clipplane 1
  111814. */
  111815. clipPlane: Nullable<Plane>;
  111816. /**
  111817. * Gets or sets the active clipplane 2
  111818. */
  111819. clipPlane2: Nullable<Plane>;
  111820. /**
  111821. * Gets or sets the active clipplane 3
  111822. */
  111823. clipPlane3: Nullable<Plane>;
  111824. /**
  111825. * Gets or sets the active clipplane 4
  111826. */
  111827. clipPlane4: Nullable<Plane>;
  111828. /**
  111829. * Gets or sets the active clipplane 5
  111830. */
  111831. clipPlane5: Nullable<Plane>;
  111832. /**
  111833. * Gets or sets the active clipplane 6
  111834. */
  111835. clipPlane6: Nullable<Plane>;
  111836. /**
  111837. * Gets or sets a boolean indicating if animations are enabled
  111838. */
  111839. animationsEnabled: boolean;
  111840. private _animationPropertiesOverride;
  111841. /**
  111842. * Gets or sets the animation properties override
  111843. */
  111844. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111845. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111846. /**
  111847. * Gets or sets a boolean indicating if a constant deltatime has to be used
  111848. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  111849. */
  111850. useConstantAnimationDeltaTime: boolean;
  111851. /**
  111852. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  111853. * Please note that it requires to run a ray cast through the scene on every frame
  111854. */
  111855. constantlyUpdateMeshUnderPointer: boolean;
  111856. /**
  111857. * Defines the HTML cursor to use when hovering over interactive elements
  111858. */
  111859. hoverCursor: string;
  111860. /**
  111861. * Defines the HTML default cursor to use (empty by default)
  111862. */
  111863. defaultCursor: string;
  111864. /**
  111865. * Defines whether cursors are handled by the scene.
  111866. */
  111867. doNotHandleCursors: boolean;
  111868. /**
  111869. * This is used to call preventDefault() on pointer down
  111870. * in order to block unwanted artifacts like system double clicks
  111871. */
  111872. preventDefaultOnPointerDown: boolean;
  111873. /**
  111874. * This is used to call preventDefault() on pointer up
  111875. * in order to block unwanted artifacts like system double clicks
  111876. */
  111877. preventDefaultOnPointerUp: boolean;
  111878. /**
  111879. * Gets or sets user defined metadata
  111880. */
  111881. metadata: any;
  111882. /**
  111883. * For internal use only. Please do not use.
  111884. */
  111885. reservedDataStore: any;
  111886. /**
  111887. * Gets the name of the plugin used to load this scene (null by default)
  111888. */
  111889. loadingPluginName: string;
  111890. /**
  111891. * Use this array to add regular expressions used to disable offline support for specific urls
  111892. */
  111893. disableOfflineSupportExceptionRules: RegExp[];
  111894. /**
  111895. * An event triggered when the scene is disposed.
  111896. */
  111897. onDisposeObservable: Observable<Scene>;
  111898. private _onDisposeObserver;
  111899. /** Sets a function to be executed when this scene is disposed. */
  111900. set onDispose(callback: () => void);
  111901. /**
  111902. * An event triggered before rendering the scene (right after animations and physics)
  111903. */
  111904. onBeforeRenderObservable: Observable<Scene>;
  111905. private _onBeforeRenderObserver;
  111906. /** Sets a function to be executed before rendering this scene */
  111907. set beforeRender(callback: Nullable<() => void>);
  111908. /**
  111909. * An event triggered after rendering the scene
  111910. */
  111911. onAfterRenderObservable: Observable<Scene>;
  111912. /**
  111913. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  111914. */
  111915. onAfterRenderCameraObservable: Observable<Camera>;
  111916. private _onAfterRenderObserver;
  111917. /** Sets a function to be executed after rendering this scene */
  111918. set afterRender(callback: Nullable<() => void>);
  111919. /**
  111920. * An event triggered before animating the scene
  111921. */
  111922. onBeforeAnimationsObservable: Observable<Scene>;
  111923. /**
  111924. * An event triggered after animations processing
  111925. */
  111926. onAfterAnimationsObservable: Observable<Scene>;
  111927. /**
  111928. * An event triggered before draw calls are ready to be sent
  111929. */
  111930. onBeforeDrawPhaseObservable: Observable<Scene>;
  111931. /**
  111932. * An event triggered after draw calls have been sent
  111933. */
  111934. onAfterDrawPhaseObservable: Observable<Scene>;
  111935. /**
  111936. * An event triggered when the scene is ready
  111937. */
  111938. onReadyObservable: Observable<Scene>;
  111939. /**
  111940. * An event triggered before rendering a camera
  111941. */
  111942. onBeforeCameraRenderObservable: Observable<Camera>;
  111943. private _onBeforeCameraRenderObserver;
  111944. /** Sets a function to be executed before rendering a camera*/
  111945. set beforeCameraRender(callback: () => void);
  111946. /**
  111947. * An event triggered after rendering a camera
  111948. */
  111949. onAfterCameraRenderObservable: Observable<Camera>;
  111950. private _onAfterCameraRenderObserver;
  111951. /** Sets a function to be executed after rendering a camera*/
  111952. set afterCameraRender(callback: () => void);
  111953. /**
  111954. * An event triggered when active meshes evaluation is about to start
  111955. */
  111956. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  111957. /**
  111958. * An event triggered when active meshes evaluation is done
  111959. */
  111960. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  111961. /**
  111962. * An event triggered when particles rendering is about to start
  111963. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111964. */
  111965. onBeforeParticlesRenderingObservable: Observable<Scene>;
  111966. /**
  111967. * An event triggered when particles rendering is done
  111968. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111969. */
  111970. onAfterParticlesRenderingObservable: Observable<Scene>;
  111971. /**
  111972. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  111973. */
  111974. onDataLoadedObservable: Observable<Scene>;
  111975. /**
  111976. * An event triggered when a camera is created
  111977. */
  111978. onNewCameraAddedObservable: Observable<Camera>;
  111979. /**
  111980. * An event triggered when a camera is removed
  111981. */
  111982. onCameraRemovedObservable: Observable<Camera>;
  111983. /**
  111984. * An event triggered when a light is created
  111985. */
  111986. onNewLightAddedObservable: Observable<Light>;
  111987. /**
  111988. * An event triggered when a light is removed
  111989. */
  111990. onLightRemovedObservable: Observable<Light>;
  111991. /**
  111992. * An event triggered when a geometry is created
  111993. */
  111994. onNewGeometryAddedObservable: Observable<Geometry>;
  111995. /**
  111996. * An event triggered when a geometry is removed
  111997. */
  111998. onGeometryRemovedObservable: Observable<Geometry>;
  111999. /**
  112000. * An event triggered when a transform node is created
  112001. */
  112002. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  112003. /**
  112004. * An event triggered when a transform node is removed
  112005. */
  112006. onTransformNodeRemovedObservable: Observable<TransformNode>;
  112007. /**
  112008. * An event triggered when a mesh is created
  112009. */
  112010. onNewMeshAddedObservable: Observable<AbstractMesh>;
  112011. /**
  112012. * An event triggered when a mesh is removed
  112013. */
  112014. onMeshRemovedObservable: Observable<AbstractMesh>;
  112015. /**
  112016. * An event triggered when a skeleton is created
  112017. */
  112018. onNewSkeletonAddedObservable: Observable<Skeleton>;
  112019. /**
  112020. * An event triggered when a skeleton is removed
  112021. */
  112022. onSkeletonRemovedObservable: Observable<Skeleton>;
  112023. /**
  112024. * An event triggered when a material is created
  112025. */
  112026. onNewMaterialAddedObservable: Observable<Material>;
  112027. /**
  112028. * An event triggered when a material is removed
  112029. */
  112030. onMaterialRemovedObservable: Observable<Material>;
  112031. /**
  112032. * An event triggered when a texture is created
  112033. */
  112034. onNewTextureAddedObservable: Observable<BaseTexture>;
  112035. /**
  112036. * An event triggered when a texture is removed
  112037. */
  112038. onTextureRemovedObservable: Observable<BaseTexture>;
  112039. /**
  112040. * An event triggered when render targets are about to be rendered
  112041. * Can happen multiple times per frame.
  112042. */
  112043. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  112044. /**
  112045. * An event triggered when render targets were rendered.
  112046. * Can happen multiple times per frame.
  112047. */
  112048. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  112049. /**
  112050. * An event triggered before calculating deterministic simulation step
  112051. */
  112052. onBeforeStepObservable: Observable<Scene>;
  112053. /**
  112054. * An event triggered after calculating deterministic simulation step
  112055. */
  112056. onAfterStepObservable: Observable<Scene>;
  112057. /**
  112058. * An event triggered when the activeCamera property is updated
  112059. */
  112060. onActiveCameraChanged: Observable<Scene>;
  112061. /**
  112062. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  112063. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  112064. * 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)
  112065. */
  112066. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  112067. /**
  112068. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  112069. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  112070. * 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)
  112071. */
  112072. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  112073. /**
  112074. * This Observable will when a mesh has been imported into the scene.
  112075. */
  112076. onMeshImportedObservable: Observable<AbstractMesh>;
  112077. /**
  112078. * This Observable will when an animation file has been imported into the scene.
  112079. */
  112080. onAnimationFileImportedObservable: Observable<Scene>;
  112081. /**
  112082. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  112083. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  112084. */
  112085. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  112086. /** @hidden */
  112087. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  112088. /**
  112089. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  112090. */
  112091. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  112092. /**
  112093. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  112094. */
  112095. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  112096. /**
  112097. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  112098. */
  112099. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  112100. /** Callback called when a pointer move is detected */
  112101. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  112102. /** Callback called when a pointer down is detected */
  112103. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  112104. /** Callback called when a pointer up is detected */
  112105. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  112106. /** Callback called when a pointer pick is detected */
  112107. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  112108. /**
  112109. * 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).
  112110. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  112111. */
  112112. onPrePointerObservable: Observable<PointerInfoPre>;
  112113. /**
  112114. * Observable event triggered each time an input event is received from the rendering canvas
  112115. */
  112116. onPointerObservable: Observable<PointerInfo>;
  112117. /**
  112118. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  112119. */
  112120. get unTranslatedPointer(): Vector2;
  112121. /**
  112122. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  112123. */
  112124. static get DragMovementThreshold(): number;
  112125. static set DragMovementThreshold(value: number);
  112126. /**
  112127. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  112128. */
  112129. static get LongPressDelay(): number;
  112130. static set LongPressDelay(value: number);
  112131. /**
  112132. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  112133. */
  112134. static get DoubleClickDelay(): number;
  112135. static set DoubleClickDelay(value: number);
  112136. /** If you need to check double click without raising a single click at first click, enable this flag */
  112137. static get ExclusiveDoubleClickMode(): boolean;
  112138. static set ExclusiveDoubleClickMode(value: boolean);
  112139. /** @hidden */
  112140. _mirroredCameraPosition: Nullable<Vector3>;
  112141. /**
  112142. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  112143. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  112144. */
  112145. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  112146. /**
  112147. * Observable event triggered each time an keyboard event is received from the hosting window
  112148. */
  112149. onKeyboardObservable: Observable<KeyboardInfo>;
  112150. private _useRightHandedSystem;
  112151. /**
  112152. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  112153. */
  112154. set useRightHandedSystem(value: boolean);
  112155. get useRightHandedSystem(): boolean;
  112156. private _timeAccumulator;
  112157. private _currentStepId;
  112158. private _currentInternalStep;
  112159. /**
  112160. * Sets the step Id used by deterministic lock step
  112161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112162. * @param newStepId defines the step Id
  112163. */
  112164. setStepId(newStepId: number): void;
  112165. /**
  112166. * Gets the step Id used by deterministic lock step
  112167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112168. * @returns the step Id
  112169. */
  112170. getStepId(): number;
  112171. /**
  112172. * Gets the internal step used by deterministic lock step
  112173. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112174. * @returns the internal step
  112175. */
  112176. getInternalStep(): number;
  112177. private _fogEnabled;
  112178. /**
  112179. * Gets or sets a boolean indicating if fog is enabled on this scene
  112180. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112181. * (Default is true)
  112182. */
  112183. set fogEnabled(value: boolean);
  112184. get fogEnabled(): boolean;
  112185. private _fogMode;
  112186. /**
  112187. * Gets or sets the fog mode to use
  112188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112189. * | mode | value |
  112190. * | --- | --- |
  112191. * | FOGMODE_NONE | 0 |
  112192. * | FOGMODE_EXP | 1 |
  112193. * | FOGMODE_EXP2 | 2 |
  112194. * | FOGMODE_LINEAR | 3 |
  112195. */
  112196. set fogMode(value: number);
  112197. get fogMode(): number;
  112198. /**
  112199. * Gets or sets the fog color to use
  112200. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112201. * (Default is Color3(0.2, 0.2, 0.3))
  112202. */
  112203. fogColor: Color3;
  112204. /**
  112205. * Gets or sets the fog density to use
  112206. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112207. * (Default is 0.1)
  112208. */
  112209. fogDensity: number;
  112210. /**
  112211. * Gets or sets the fog start distance to use
  112212. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112213. * (Default is 0)
  112214. */
  112215. fogStart: number;
  112216. /**
  112217. * Gets or sets the fog end distance to use
  112218. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112219. * (Default is 1000)
  112220. */
  112221. fogEnd: number;
  112222. private _shadowsEnabled;
  112223. /**
  112224. * Gets or sets a boolean indicating if shadows are enabled on this scene
  112225. */
  112226. set shadowsEnabled(value: boolean);
  112227. get shadowsEnabled(): boolean;
  112228. private _lightsEnabled;
  112229. /**
  112230. * Gets or sets a boolean indicating if lights are enabled on this scene
  112231. */
  112232. set lightsEnabled(value: boolean);
  112233. get lightsEnabled(): boolean;
  112234. /** All of the active cameras added to this scene. */
  112235. activeCameras: Camera[];
  112236. /** @hidden */
  112237. _activeCamera: Nullable<Camera>;
  112238. /** Gets or sets the current active camera */
  112239. get activeCamera(): Nullable<Camera>;
  112240. set activeCamera(value: Nullable<Camera>);
  112241. private _defaultMaterial;
  112242. /** The default material used on meshes when no material is affected */
  112243. get defaultMaterial(): Material;
  112244. /** The default material used on meshes when no material is affected */
  112245. set defaultMaterial(value: Material);
  112246. private _texturesEnabled;
  112247. /**
  112248. * Gets or sets a boolean indicating if textures are enabled on this scene
  112249. */
  112250. set texturesEnabled(value: boolean);
  112251. get texturesEnabled(): boolean;
  112252. /**
  112253. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  112254. */
  112255. physicsEnabled: boolean;
  112256. /**
  112257. * Gets or sets a boolean indicating if particles are enabled on this scene
  112258. */
  112259. particlesEnabled: boolean;
  112260. /**
  112261. * Gets or sets a boolean indicating if sprites are enabled on this scene
  112262. */
  112263. spritesEnabled: boolean;
  112264. private _skeletonsEnabled;
  112265. /**
  112266. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  112267. */
  112268. set skeletonsEnabled(value: boolean);
  112269. get skeletonsEnabled(): boolean;
  112270. /**
  112271. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  112272. */
  112273. lensFlaresEnabled: boolean;
  112274. /**
  112275. * Gets or sets a boolean indicating if collisions are enabled on this scene
  112276. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112277. */
  112278. collisionsEnabled: boolean;
  112279. private _collisionCoordinator;
  112280. /** @hidden */
  112281. get collisionCoordinator(): ICollisionCoordinator;
  112282. /**
  112283. * Defines the gravity applied to this scene (used only for collisions)
  112284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112285. */
  112286. gravity: Vector3;
  112287. /**
  112288. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  112289. */
  112290. postProcessesEnabled: boolean;
  112291. /**
  112292. * The list of postprocesses added to the scene
  112293. */
  112294. postProcesses: PostProcess[];
  112295. /**
  112296. * Gets the current postprocess manager
  112297. */
  112298. postProcessManager: PostProcessManager;
  112299. /**
  112300. * Gets or sets a boolean indicating if render targets are enabled on this scene
  112301. */
  112302. renderTargetsEnabled: boolean;
  112303. /**
  112304. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  112305. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  112306. */
  112307. dumpNextRenderTargets: boolean;
  112308. /**
  112309. * The list of user defined render targets added to the scene
  112310. */
  112311. customRenderTargets: RenderTargetTexture[];
  112312. /**
  112313. * Defines if texture loading must be delayed
  112314. * If true, textures will only be loaded when they need to be rendered
  112315. */
  112316. useDelayedTextureLoading: boolean;
  112317. /**
  112318. * Gets the list of meshes imported to the scene through SceneLoader
  112319. */
  112320. importedMeshesFiles: String[];
  112321. /**
  112322. * Gets or sets a boolean indicating if probes are enabled on this scene
  112323. */
  112324. probesEnabled: boolean;
  112325. /**
  112326. * Gets or sets the current offline provider to use to store scene data
  112327. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  112328. */
  112329. offlineProvider: IOfflineProvider;
  112330. /**
  112331. * Gets or sets the action manager associated with the scene
  112332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112333. */
  112334. actionManager: AbstractActionManager;
  112335. private _meshesForIntersections;
  112336. /**
  112337. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  112338. */
  112339. proceduralTexturesEnabled: boolean;
  112340. private _engine;
  112341. private _totalVertices;
  112342. /** @hidden */
  112343. _activeIndices: PerfCounter;
  112344. /** @hidden */
  112345. _activeParticles: PerfCounter;
  112346. /** @hidden */
  112347. _activeBones: PerfCounter;
  112348. private _animationRatio;
  112349. /** @hidden */
  112350. _animationTimeLast: number;
  112351. /** @hidden */
  112352. _animationTime: number;
  112353. /**
  112354. * Gets or sets a general scale for animation speed
  112355. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  112356. */
  112357. animationTimeScale: number;
  112358. /** @hidden */
  112359. _cachedMaterial: Nullable<Material>;
  112360. /** @hidden */
  112361. _cachedEffect: Nullable<Effect>;
  112362. /** @hidden */
  112363. _cachedVisibility: Nullable<number>;
  112364. private _renderId;
  112365. private _frameId;
  112366. private _executeWhenReadyTimeoutId;
  112367. private _intermediateRendering;
  112368. private _viewUpdateFlag;
  112369. private _projectionUpdateFlag;
  112370. /** @hidden */
  112371. _toBeDisposed: Nullable<IDisposable>[];
  112372. private _activeRequests;
  112373. /** @hidden */
  112374. _pendingData: any[];
  112375. private _isDisposed;
  112376. /**
  112377. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  112378. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  112379. */
  112380. dispatchAllSubMeshesOfActiveMeshes: boolean;
  112381. private _activeMeshes;
  112382. private _processedMaterials;
  112383. private _renderTargets;
  112384. /** @hidden */
  112385. _activeParticleSystems: SmartArray<IParticleSystem>;
  112386. private _activeSkeletons;
  112387. private _softwareSkinnedMeshes;
  112388. private _renderingManager;
  112389. /** @hidden */
  112390. _activeAnimatables: Animatable[];
  112391. private _transformMatrix;
  112392. private _sceneUbo;
  112393. /** @hidden */
  112394. _viewMatrix: Matrix;
  112395. private _projectionMatrix;
  112396. /** @hidden */
  112397. _forcedViewPosition: Nullable<Vector3>;
  112398. /** @hidden */
  112399. _frustumPlanes: Plane[];
  112400. /**
  112401. * Gets the list of frustum planes (built from the active camera)
  112402. */
  112403. get frustumPlanes(): Plane[];
  112404. /**
  112405. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  112406. * This is useful if there are more lights that the maximum simulteanous authorized
  112407. */
  112408. requireLightSorting: boolean;
  112409. /** @hidden */
  112410. readonly useMaterialMeshMap: boolean;
  112411. /** @hidden */
  112412. readonly useClonedMeshMap: boolean;
  112413. private _externalData;
  112414. private _uid;
  112415. /**
  112416. * @hidden
  112417. * Backing store of defined scene components.
  112418. */
  112419. _components: ISceneComponent[];
  112420. /**
  112421. * @hidden
  112422. * Backing store of defined scene components.
  112423. */
  112424. _serializableComponents: ISceneSerializableComponent[];
  112425. /**
  112426. * List of components to register on the next registration step.
  112427. */
  112428. private _transientComponents;
  112429. /**
  112430. * Registers the transient components if needed.
  112431. */
  112432. private _registerTransientComponents;
  112433. /**
  112434. * @hidden
  112435. * Add a component to the scene.
  112436. * Note that the ccomponent could be registered on th next frame if this is called after
  112437. * the register component stage.
  112438. * @param component Defines the component to add to the scene
  112439. */
  112440. _addComponent(component: ISceneComponent): void;
  112441. /**
  112442. * @hidden
  112443. * Gets a component from the scene.
  112444. * @param name defines the name of the component to retrieve
  112445. * @returns the component or null if not present
  112446. */
  112447. _getComponent(name: string): Nullable<ISceneComponent>;
  112448. /**
  112449. * @hidden
  112450. * Defines the actions happening before camera updates.
  112451. */
  112452. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  112453. /**
  112454. * @hidden
  112455. * Defines the actions happening before clear the canvas.
  112456. */
  112457. _beforeClearStage: Stage<SimpleStageAction>;
  112458. /**
  112459. * @hidden
  112460. * Defines the actions when collecting render targets for the frame.
  112461. */
  112462. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112463. /**
  112464. * @hidden
  112465. * Defines the actions happening for one camera in the frame.
  112466. */
  112467. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112468. /**
  112469. * @hidden
  112470. * Defines the actions happening during the per mesh ready checks.
  112471. */
  112472. _isReadyForMeshStage: Stage<MeshStageAction>;
  112473. /**
  112474. * @hidden
  112475. * Defines the actions happening before evaluate active mesh checks.
  112476. */
  112477. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  112478. /**
  112479. * @hidden
  112480. * Defines the actions happening during the evaluate sub mesh checks.
  112481. */
  112482. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  112483. /**
  112484. * @hidden
  112485. * Defines the actions happening during the active mesh stage.
  112486. */
  112487. _activeMeshStage: Stage<ActiveMeshStageAction>;
  112488. /**
  112489. * @hidden
  112490. * Defines the actions happening during the per camera render target step.
  112491. */
  112492. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  112493. /**
  112494. * @hidden
  112495. * Defines the actions happening just before the active camera is drawing.
  112496. */
  112497. _beforeCameraDrawStage: Stage<CameraStageAction>;
  112498. /**
  112499. * @hidden
  112500. * Defines the actions happening just before a render target is drawing.
  112501. */
  112502. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112503. /**
  112504. * @hidden
  112505. * Defines the actions happening just before a rendering group is drawing.
  112506. */
  112507. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112508. /**
  112509. * @hidden
  112510. * Defines the actions happening just before a mesh is drawing.
  112511. */
  112512. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112513. /**
  112514. * @hidden
  112515. * Defines the actions happening just after a mesh has been drawn.
  112516. */
  112517. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112518. /**
  112519. * @hidden
  112520. * Defines the actions happening just after a rendering group has been drawn.
  112521. */
  112522. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112523. /**
  112524. * @hidden
  112525. * Defines the actions happening just after the active camera has been drawn.
  112526. */
  112527. _afterCameraDrawStage: Stage<CameraStageAction>;
  112528. /**
  112529. * @hidden
  112530. * Defines the actions happening just after a render target has been drawn.
  112531. */
  112532. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112533. /**
  112534. * @hidden
  112535. * Defines the actions happening just after rendering all cameras and computing intersections.
  112536. */
  112537. _afterRenderStage: Stage<SimpleStageAction>;
  112538. /**
  112539. * @hidden
  112540. * Defines the actions happening when a pointer move event happens.
  112541. */
  112542. _pointerMoveStage: Stage<PointerMoveStageAction>;
  112543. /**
  112544. * @hidden
  112545. * Defines the actions happening when a pointer down event happens.
  112546. */
  112547. _pointerDownStage: Stage<PointerUpDownStageAction>;
  112548. /**
  112549. * @hidden
  112550. * Defines the actions happening when a pointer up event happens.
  112551. */
  112552. _pointerUpStage: Stage<PointerUpDownStageAction>;
  112553. /**
  112554. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  112555. */
  112556. private geometriesByUniqueId;
  112557. /**
  112558. * Creates a new Scene
  112559. * @param engine defines the engine to use to render this scene
  112560. * @param options defines the scene options
  112561. */
  112562. constructor(engine: Engine, options?: SceneOptions);
  112563. /**
  112564. * Gets a string idenfifying the name of the class
  112565. * @returns "Scene" string
  112566. */
  112567. getClassName(): string;
  112568. private _defaultMeshCandidates;
  112569. /**
  112570. * @hidden
  112571. */
  112572. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112573. private _defaultSubMeshCandidates;
  112574. /**
  112575. * @hidden
  112576. */
  112577. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112578. /**
  112579. * Sets the default candidate providers for the scene.
  112580. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  112581. * and getCollidingSubMeshCandidates to their default function
  112582. */
  112583. setDefaultCandidateProviders(): void;
  112584. /**
  112585. * Gets the mesh that is currently under the pointer
  112586. */
  112587. get meshUnderPointer(): Nullable<AbstractMesh>;
  112588. /**
  112589. * Gets or sets the current on-screen X position of the pointer
  112590. */
  112591. get pointerX(): number;
  112592. set pointerX(value: number);
  112593. /**
  112594. * Gets or sets the current on-screen Y position of the pointer
  112595. */
  112596. get pointerY(): number;
  112597. set pointerY(value: number);
  112598. /**
  112599. * Gets the cached material (ie. the latest rendered one)
  112600. * @returns the cached material
  112601. */
  112602. getCachedMaterial(): Nullable<Material>;
  112603. /**
  112604. * Gets the cached effect (ie. the latest rendered one)
  112605. * @returns the cached effect
  112606. */
  112607. getCachedEffect(): Nullable<Effect>;
  112608. /**
  112609. * Gets the cached visibility state (ie. the latest rendered one)
  112610. * @returns the cached visibility state
  112611. */
  112612. getCachedVisibility(): Nullable<number>;
  112613. /**
  112614. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  112615. * @param material defines the current material
  112616. * @param effect defines the current effect
  112617. * @param visibility defines the current visibility state
  112618. * @returns true if one parameter is not cached
  112619. */
  112620. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  112621. /**
  112622. * Gets the engine associated with the scene
  112623. * @returns an Engine
  112624. */
  112625. getEngine(): Engine;
  112626. /**
  112627. * Gets the total number of vertices rendered per frame
  112628. * @returns the total number of vertices rendered per frame
  112629. */
  112630. getTotalVertices(): number;
  112631. /**
  112632. * Gets the performance counter for total vertices
  112633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112634. */
  112635. get totalVerticesPerfCounter(): PerfCounter;
  112636. /**
  112637. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  112638. * @returns the total number of active indices rendered per frame
  112639. */
  112640. getActiveIndices(): number;
  112641. /**
  112642. * Gets the performance counter for active indices
  112643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112644. */
  112645. get totalActiveIndicesPerfCounter(): PerfCounter;
  112646. /**
  112647. * Gets the total number of active particles rendered per frame
  112648. * @returns the total number of active particles rendered per frame
  112649. */
  112650. getActiveParticles(): number;
  112651. /**
  112652. * Gets the performance counter for active particles
  112653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112654. */
  112655. get activeParticlesPerfCounter(): PerfCounter;
  112656. /**
  112657. * Gets the total number of active bones rendered per frame
  112658. * @returns the total number of active bones rendered per frame
  112659. */
  112660. getActiveBones(): number;
  112661. /**
  112662. * Gets the performance counter for active bones
  112663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112664. */
  112665. get activeBonesPerfCounter(): PerfCounter;
  112666. /**
  112667. * Gets the array of active meshes
  112668. * @returns an array of AbstractMesh
  112669. */
  112670. getActiveMeshes(): SmartArray<AbstractMesh>;
  112671. /**
  112672. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  112673. * @returns a number
  112674. */
  112675. getAnimationRatio(): number;
  112676. /**
  112677. * Gets an unique Id for the current render phase
  112678. * @returns a number
  112679. */
  112680. getRenderId(): number;
  112681. /**
  112682. * Gets an unique Id for the current frame
  112683. * @returns a number
  112684. */
  112685. getFrameId(): number;
  112686. /** Call this function if you want to manually increment the render Id*/
  112687. incrementRenderId(): void;
  112688. private _createUbo;
  112689. /**
  112690. * Use this method to simulate a pointer move on a mesh
  112691. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112692. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112693. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112694. * @returns the current scene
  112695. */
  112696. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112697. /**
  112698. * Use this method to simulate a pointer down on a mesh
  112699. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112700. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112701. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112702. * @returns the current scene
  112703. */
  112704. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112705. /**
  112706. * Use this method to simulate a pointer up on a mesh
  112707. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112708. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112709. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112710. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  112711. * @returns the current scene
  112712. */
  112713. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  112714. /**
  112715. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  112716. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  112717. * @returns true if the pointer was captured
  112718. */
  112719. isPointerCaptured(pointerId?: number): boolean;
  112720. /**
  112721. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  112722. * @param attachUp defines if you want to attach events to pointerup
  112723. * @param attachDown defines if you want to attach events to pointerdown
  112724. * @param attachMove defines if you want to attach events to pointermove
  112725. */
  112726. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  112727. /** Detaches all event handlers*/
  112728. detachControl(): void;
  112729. /**
  112730. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  112731. * Delay loaded resources are not taking in account
  112732. * @return true if all required resources are ready
  112733. */
  112734. isReady(): boolean;
  112735. /** Resets all cached information relative to material (including effect and visibility) */
  112736. resetCachedMaterial(): void;
  112737. /**
  112738. * Registers a function to be called before every frame render
  112739. * @param func defines the function to register
  112740. */
  112741. registerBeforeRender(func: () => void): void;
  112742. /**
  112743. * Unregisters a function called before every frame render
  112744. * @param func defines the function to unregister
  112745. */
  112746. unregisterBeforeRender(func: () => void): void;
  112747. /**
  112748. * Registers a function to be called after every frame render
  112749. * @param func defines the function to register
  112750. */
  112751. registerAfterRender(func: () => void): void;
  112752. /**
  112753. * Unregisters a function called after every frame render
  112754. * @param func defines the function to unregister
  112755. */
  112756. unregisterAfterRender(func: () => void): void;
  112757. private _executeOnceBeforeRender;
  112758. /**
  112759. * The provided function will run before render once and will be disposed afterwards.
  112760. * A timeout delay can be provided so that the function will be executed in N ms.
  112761. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  112762. * @param func The function to be executed.
  112763. * @param timeout optional delay in ms
  112764. */
  112765. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  112766. /** @hidden */
  112767. _addPendingData(data: any): void;
  112768. /** @hidden */
  112769. _removePendingData(data: any): void;
  112770. /**
  112771. * Returns the number of items waiting to be loaded
  112772. * @returns the number of items waiting to be loaded
  112773. */
  112774. getWaitingItemsCount(): number;
  112775. /**
  112776. * Returns a boolean indicating if the scene is still loading data
  112777. */
  112778. get isLoading(): boolean;
  112779. /**
  112780. * Registers a function to be executed when the scene is ready
  112781. * @param {Function} func - the function to be executed
  112782. */
  112783. executeWhenReady(func: () => void): void;
  112784. /**
  112785. * Returns a promise that resolves when the scene is ready
  112786. * @returns A promise that resolves when the scene is ready
  112787. */
  112788. whenReadyAsync(): Promise<void>;
  112789. /** @hidden */
  112790. _checkIsReady(): void;
  112791. /**
  112792. * Gets all animatable attached to the scene
  112793. */
  112794. get animatables(): Animatable[];
  112795. /**
  112796. * Resets the last animation time frame.
  112797. * Useful to override when animations start running when loading a scene for the first time.
  112798. */
  112799. resetLastAnimationTimeFrame(): void;
  112800. /**
  112801. * Gets the current view matrix
  112802. * @returns a Matrix
  112803. */
  112804. getViewMatrix(): Matrix;
  112805. /**
  112806. * Gets the current projection matrix
  112807. * @returns a Matrix
  112808. */
  112809. getProjectionMatrix(): Matrix;
  112810. /**
  112811. * Gets the current transform matrix
  112812. * @returns a Matrix made of View * Projection
  112813. */
  112814. getTransformMatrix(): Matrix;
  112815. /**
  112816. * Sets the current transform matrix
  112817. * @param viewL defines the View matrix to use
  112818. * @param projectionL defines the Projection matrix to use
  112819. * @param viewR defines the right View matrix to use (if provided)
  112820. * @param projectionR defines the right Projection matrix to use (if provided)
  112821. */
  112822. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  112823. /**
  112824. * Gets the uniform buffer used to store scene data
  112825. * @returns a UniformBuffer
  112826. */
  112827. getSceneUniformBuffer(): UniformBuffer;
  112828. /**
  112829. * Gets an unique (relatively to the current scene) Id
  112830. * @returns an unique number for the scene
  112831. */
  112832. getUniqueId(): number;
  112833. /**
  112834. * Add a mesh to the list of scene's meshes
  112835. * @param newMesh defines the mesh to add
  112836. * @param recursive if all child meshes should also be added to the scene
  112837. */
  112838. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  112839. /**
  112840. * Remove a mesh for the list of scene's meshes
  112841. * @param toRemove defines the mesh to remove
  112842. * @param recursive if all child meshes should also be removed from the scene
  112843. * @returns the index where the mesh was in the mesh list
  112844. */
  112845. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  112846. /**
  112847. * Add a transform node to the list of scene's transform nodes
  112848. * @param newTransformNode defines the transform node to add
  112849. */
  112850. addTransformNode(newTransformNode: TransformNode): void;
  112851. /**
  112852. * Remove a transform node for the list of scene's transform nodes
  112853. * @param toRemove defines the transform node to remove
  112854. * @returns the index where the transform node was in the transform node list
  112855. */
  112856. removeTransformNode(toRemove: TransformNode): number;
  112857. /**
  112858. * Remove a skeleton for the list of scene's skeletons
  112859. * @param toRemove defines the skeleton to remove
  112860. * @returns the index where the skeleton was in the skeleton list
  112861. */
  112862. removeSkeleton(toRemove: Skeleton): number;
  112863. /**
  112864. * Remove a morph target for the list of scene's morph targets
  112865. * @param toRemove defines the morph target to remove
  112866. * @returns the index where the morph target was in the morph target list
  112867. */
  112868. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  112869. /**
  112870. * Remove a light for the list of scene's lights
  112871. * @param toRemove defines the light to remove
  112872. * @returns the index where the light was in the light list
  112873. */
  112874. removeLight(toRemove: Light): number;
  112875. /**
  112876. * Remove a camera for the list of scene's cameras
  112877. * @param toRemove defines the camera to remove
  112878. * @returns the index where the camera was in the camera list
  112879. */
  112880. removeCamera(toRemove: Camera): number;
  112881. /**
  112882. * Remove a particle system for the list of scene's particle systems
  112883. * @param toRemove defines the particle system to remove
  112884. * @returns the index where the particle system was in the particle system list
  112885. */
  112886. removeParticleSystem(toRemove: IParticleSystem): number;
  112887. /**
  112888. * Remove a animation for the list of scene's animations
  112889. * @param toRemove defines the animation to remove
  112890. * @returns the index where the animation was in the animation list
  112891. */
  112892. removeAnimation(toRemove: Animation): number;
  112893. /**
  112894. * Will stop the animation of the given target
  112895. * @param target - the target
  112896. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  112897. * @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)
  112898. */
  112899. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  112900. /**
  112901. * Removes the given animation group from this scene.
  112902. * @param toRemove The animation group to remove
  112903. * @returns The index of the removed animation group
  112904. */
  112905. removeAnimationGroup(toRemove: AnimationGroup): number;
  112906. /**
  112907. * Removes the given multi-material from this scene.
  112908. * @param toRemove The multi-material to remove
  112909. * @returns The index of the removed multi-material
  112910. */
  112911. removeMultiMaterial(toRemove: MultiMaterial): number;
  112912. /**
  112913. * Removes the given material from this scene.
  112914. * @param toRemove The material to remove
  112915. * @returns The index of the removed material
  112916. */
  112917. removeMaterial(toRemove: Material): number;
  112918. /**
  112919. * Removes the given action manager from this scene.
  112920. * @param toRemove The action manager to remove
  112921. * @returns The index of the removed action manager
  112922. */
  112923. removeActionManager(toRemove: AbstractActionManager): number;
  112924. /**
  112925. * Removes the given texture from this scene.
  112926. * @param toRemove The texture to remove
  112927. * @returns The index of the removed texture
  112928. */
  112929. removeTexture(toRemove: BaseTexture): number;
  112930. /**
  112931. * Adds the given light to this scene
  112932. * @param newLight The light to add
  112933. */
  112934. addLight(newLight: Light): void;
  112935. /**
  112936. * Sorts the list list based on light priorities
  112937. */
  112938. sortLightsByPriority(): void;
  112939. /**
  112940. * Adds the given camera to this scene
  112941. * @param newCamera The camera to add
  112942. */
  112943. addCamera(newCamera: Camera): void;
  112944. /**
  112945. * Adds the given skeleton to this scene
  112946. * @param newSkeleton The skeleton to add
  112947. */
  112948. addSkeleton(newSkeleton: Skeleton): void;
  112949. /**
  112950. * Adds the given particle system to this scene
  112951. * @param newParticleSystem The particle system to add
  112952. */
  112953. addParticleSystem(newParticleSystem: IParticleSystem): void;
  112954. /**
  112955. * Adds the given animation to this scene
  112956. * @param newAnimation The animation to add
  112957. */
  112958. addAnimation(newAnimation: Animation): void;
  112959. /**
  112960. * Adds the given animation group to this scene.
  112961. * @param newAnimationGroup The animation group to add
  112962. */
  112963. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  112964. /**
  112965. * Adds the given multi-material to this scene
  112966. * @param newMultiMaterial The multi-material to add
  112967. */
  112968. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  112969. /**
  112970. * Adds the given material to this scene
  112971. * @param newMaterial The material to add
  112972. */
  112973. addMaterial(newMaterial: Material): void;
  112974. /**
  112975. * Adds the given morph target to this scene
  112976. * @param newMorphTargetManager The morph target to add
  112977. */
  112978. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  112979. /**
  112980. * Adds the given geometry to this scene
  112981. * @param newGeometry The geometry to add
  112982. */
  112983. addGeometry(newGeometry: Geometry): void;
  112984. /**
  112985. * Adds the given action manager to this scene
  112986. * @param newActionManager The action manager to add
  112987. */
  112988. addActionManager(newActionManager: AbstractActionManager): void;
  112989. /**
  112990. * Adds the given texture to this scene.
  112991. * @param newTexture The texture to add
  112992. */
  112993. addTexture(newTexture: BaseTexture): void;
  112994. /**
  112995. * Switch active camera
  112996. * @param newCamera defines the new active camera
  112997. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  112998. */
  112999. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  113000. /**
  113001. * sets the active camera of the scene using its ID
  113002. * @param id defines the camera's ID
  113003. * @return the new active camera or null if none found.
  113004. */
  113005. setActiveCameraByID(id: string): Nullable<Camera>;
  113006. /**
  113007. * sets the active camera of the scene using its name
  113008. * @param name defines the camera's name
  113009. * @returns the new active camera or null if none found.
  113010. */
  113011. setActiveCameraByName(name: string): Nullable<Camera>;
  113012. /**
  113013. * get an animation group using its name
  113014. * @param name defines the material's name
  113015. * @return the animation group or null if none found.
  113016. */
  113017. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  113018. /**
  113019. * Get a material using its unique id
  113020. * @param uniqueId defines the material's unique id
  113021. * @return the material or null if none found.
  113022. */
  113023. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  113024. /**
  113025. * get a material using its id
  113026. * @param id defines the material's ID
  113027. * @return the material or null if none found.
  113028. */
  113029. getMaterialByID(id: string): Nullable<Material>;
  113030. /**
  113031. * Gets a the last added material using a given id
  113032. * @param id defines the material's ID
  113033. * @return the last material with the given id or null if none found.
  113034. */
  113035. getLastMaterialByID(id: string): Nullable<Material>;
  113036. /**
  113037. * Gets a material using its name
  113038. * @param name defines the material's name
  113039. * @return the material or null if none found.
  113040. */
  113041. getMaterialByName(name: string): Nullable<Material>;
  113042. /**
  113043. * Get a texture using its unique id
  113044. * @param uniqueId defines the texture's unique id
  113045. * @return the texture or null if none found.
  113046. */
  113047. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  113048. /**
  113049. * Gets a camera using its id
  113050. * @param id defines the id to look for
  113051. * @returns the camera or null if not found
  113052. */
  113053. getCameraByID(id: string): Nullable<Camera>;
  113054. /**
  113055. * Gets a camera using its unique id
  113056. * @param uniqueId defines the unique id to look for
  113057. * @returns the camera or null if not found
  113058. */
  113059. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  113060. /**
  113061. * Gets a camera using its name
  113062. * @param name defines the camera's name
  113063. * @return the camera or null if none found.
  113064. */
  113065. getCameraByName(name: string): Nullable<Camera>;
  113066. /**
  113067. * Gets a bone using its id
  113068. * @param id defines the bone's id
  113069. * @return the bone or null if not found
  113070. */
  113071. getBoneByID(id: string): Nullable<Bone>;
  113072. /**
  113073. * Gets a bone using its id
  113074. * @param name defines the bone's name
  113075. * @return the bone or null if not found
  113076. */
  113077. getBoneByName(name: string): Nullable<Bone>;
  113078. /**
  113079. * Gets a light node using its name
  113080. * @param name defines the the light's name
  113081. * @return the light or null if none found.
  113082. */
  113083. getLightByName(name: string): Nullable<Light>;
  113084. /**
  113085. * Gets a light node using its id
  113086. * @param id defines the light's id
  113087. * @return the light or null if none found.
  113088. */
  113089. getLightByID(id: string): Nullable<Light>;
  113090. /**
  113091. * Gets a light node using its scene-generated unique ID
  113092. * @param uniqueId defines the light's unique id
  113093. * @return the light or null if none found.
  113094. */
  113095. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  113096. /**
  113097. * Gets a particle system by id
  113098. * @param id defines the particle system id
  113099. * @return the corresponding system or null if none found
  113100. */
  113101. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  113102. /**
  113103. * Gets a geometry using its ID
  113104. * @param id defines the geometry's id
  113105. * @return the geometry or null if none found.
  113106. */
  113107. getGeometryByID(id: string): Nullable<Geometry>;
  113108. private _getGeometryByUniqueID;
  113109. /**
  113110. * Add a new geometry to this scene
  113111. * @param geometry defines the geometry to be added to the scene.
  113112. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  113113. * @return a boolean defining if the geometry was added or not
  113114. */
  113115. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  113116. /**
  113117. * Removes an existing geometry
  113118. * @param geometry defines the geometry to be removed from the scene
  113119. * @return a boolean defining if the geometry was removed or not
  113120. */
  113121. removeGeometry(geometry: Geometry): boolean;
  113122. /**
  113123. * Gets the list of geometries attached to the scene
  113124. * @returns an array of Geometry
  113125. */
  113126. getGeometries(): Geometry[];
  113127. /**
  113128. * Gets the first added mesh found of a given ID
  113129. * @param id defines the id to search for
  113130. * @return the mesh found or null if not found at all
  113131. */
  113132. getMeshByID(id: string): Nullable<AbstractMesh>;
  113133. /**
  113134. * Gets a list of meshes using their id
  113135. * @param id defines the id to search for
  113136. * @returns a list of meshes
  113137. */
  113138. getMeshesByID(id: string): Array<AbstractMesh>;
  113139. /**
  113140. * Gets the first added transform node found of a given ID
  113141. * @param id defines the id to search for
  113142. * @return the found transform node or null if not found at all.
  113143. */
  113144. getTransformNodeByID(id: string): Nullable<TransformNode>;
  113145. /**
  113146. * Gets a transform node with its auto-generated unique id
  113147. * @param uniqueId efines the unique id to search for
  113148. * @return the found transform node or null if not found at all.
  113149. */
  113150. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  113151. /**
  113152. * Gets a list of transform nodes using their id
  113153. * @param id defines the id to search for
  113154. * @returns a list of transform nodes
  113155. */
  113156. getTransformNodesByID(id: string): Array<TransformNode>;
  113157. /**
  113158. * Gets a mesh with its auto-generated unique id
  113159. * @param uniqueId defines the unique id to search for
  113160. * @return the found mesh or null if not found at all.
  113161. */
  113162. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  113163. /**
  113164. * Gets a the last added mesh using a given id
  113165. * @param id defines the id to search for
  113166. * @return the found mesh or null if not found at all.
  113167. */
  113168. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  113169. /**
  113170. * Gets a the last added node (Mesh, Camera, Light) using a given id
  113171. * @param id defines the id to search for
  113172. * @return the found node or null if not found at all
  113173. */
  113174. getLastEntryByID(id: string): Nullable<Node>;
  113175. /**
  113176. * Gets a node (Mesh, Camera, Light) using a given id
  113177. * @param id defines the id to search for
  113178. * @return the found node or null if not found at all
  113179. */
  113180. getNodeByID(id: string): Nullable<Node>;
  113181. /**
  113182. * Gets a node (Mesh, Camera, Light) using a given name
  113183. * @param name defines the name to search for
  113184. * @return the found node or null if not found at all.
  113185. */
  113186. getNodeByName(name: string): Nullable<Node>;
  113187. /**
  113188. * Gets a mesh using a given name
  113189. * @param name defines the name to search for
  113190. * @return the found mesh or null if not found at all.
  113191. */
  113192. getMeshByName(name: string): Nullable<AbstractMesh>;
  113193. /**
  113194. * Gets a transform node using a given name
  113195. * @param name defines the name to search for
  113196. * @return the found transform node or null if not found at all.
  113197. */
  113198. getTransformNodeByName(name: string): Nullable<TransformNode>;
  113199. /**
  113200. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  113201. * @param id defines the id to search for
  113202. * @return the found skeleton or null if not found at all.
  113203. */
  113204. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  113205. /**
  113206. * Gets a skeleton using a given auto generated unique id
  113207. * @param uniqueId defines the unique id to search for
  113208. * @return the found skeleton or null if not found at all.
  113209. */
  113210. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  113211. /**
  113212. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  113213. * @param id defines the id to search for
  113214. * @return the found skeleton or null if not found at all.
  113215. */
  113216. getSkeletonById(id: string): Nullable<Skeleton>;
  113217. /**
  113218. * Gets a skeleton using a given name
  113219. * @param name defines the name to search for
  113220. * @return the found skeleton or null if not found at all.
  113221. */
  113222. getSkeletonByName(name: string): Nullable<Skeleton>;
  113223. /**
  113224. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  113225. * @param id defines the id to search for
  113226. * @return the found morph target manager or null if not found at all.
  113227. */
  113228. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  113229. /**
  113230. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  113231. * @param id defines the id to search for
  113232. * @return the found morph target or null if not found at all.
  113233. */
  113234. getMorphTargetById(id: string): Nullable<MorphTarget>;
  113235. /**
  113236. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  113237. * @param name defines the name to search for
  113238. * @return the found morph target or null if not found at all.
  113239. */
  113240. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  113241. /**
  113242. * Gets a boolean indicating if the given mesh is active
  113243. * @param mesh defines the mesh to look for
  113244. * @returns true if the mesh is in the active list
  113245. */
  113246. isActiveMesh(mesh: AbstractMesh): boolean;
  113247. /**
  113248. * Return a unique id as a string which can serve as an identifier for the scene
  113249. */
  113250. get uid(): string;
  113251. /**
  113252. * Add an externaly attached data from its key.
  113253. * This method call will fail and return false, if such key already exists.
  113254. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  113255. * @param key the unique key that identifies the data
  113256. * @param data the data object to associate to the key for this Engine instance
  113257. * @return true if no such key were already present and the data was added successfully, false otherwise
  113258. */
  113259. addExternalData<T>(key: string, data: T): boolean;
  113260. /**
  113261. * Get an externaly attached data from its key
  113262. * @param key the unique key that identifies the data
  113263. * @return the associated data, if present (can be null), or undefined if not present
  113264. */
  113265. getExternalData<T>(key: string): Nullable<T>;
  113266. /**
  113267. * Get an externaly attached data from its key, create it using a factory if it's not already present
  113268. * @param key the unique key that identifies the data
  113269. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  113270. * @return the associated data, can be null if the factory returned null.
  113271. */
  113272. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  113273. /**
  113274. * Remove an externaly attached data from the Engine instance
  113275. * @param key the unique key that identifies the data
  113276. * @return true if the data was successfully removed, false if it doesn't exist
  113277. */
  113278. removeExternalData(key: string): boolean;
  113279. private _evaluateSubMesh;
  113280. /**
  113281. * Clear the processed materials smart array preventing retention point in material dispose.
  113282. */
  113283. freeProcessedMaterials(): void;
  113284. private _preventFreeActiveMeshesAndRenderingGroups;
  113285. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  113286. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  113287. * when disposing several meshes in a row or a hierarchy of meshes.
  113288. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  113289. */
  113290. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  113291. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  113292. /**
  113293. * Clear the active meshes smart array preventing retention point in mesh dispose.
  113294. */
  113295. freeActiveMeshes(): void;
  113296. /**
  113297. * Clear the info related to rendering groups preventing retention points during dispose.
  113298. */
  113299. freeRenderingGroups(): void;
  113300. /** @hidden */
  113301. _isInIntermediateRendering(): boolean;
  113302. /**
  113303. * Lambda returning the list of potentially active meshes.
  113304. */
  113305. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  113306. /**
  113307. * Lambda returning the list of potentially active sub meshes.
  113308. */
  113309. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  113310. /**
  113311. * Lambda returning the list of potentially intersecting sub meshes.
  113312. */
  113313. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  113314. /**
  113315. * Lambda returning the list of potentially colliding sub meshes.
  113316. */
  113317. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  113318. private _activeMeshesFrozen;
  113319. private _skipEvaluateActiveMeshesCompletely;
  113320. /**
  113321. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  113322. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  113323. * @returns the current scene
  113324. */
  113325. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  113326. /**
  113327. * Use this function to restart evaluating active meshes on every frame
  113328. * @returns the current scene
  113329. */
  113330. unfreezeActiveMeshes(): Scene;
  113331. private _evaluateActiveMeshes;
  113332. private _activeMesh;
  113333. /**
  113334. * Update the transform matrix to update from the current active camera
  113335. * @param force defines a boolean used to force the update even if cache is up to date
  113336. */
  113337. updateTransformMatrix(force?: boolean): void;
  113338. private _bindFrameBuffer;
  113339. /** @hidden */
  113340. _allowPostProcessClearColor: boolean;
  113341. /** @hidden */
  113342. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  113343. private _processSubCameras;
  113344. private _checkIntersections;
  113345. /** @hidden */
  113346. _advancePhysicsEngineStep(step: number): void;
  113347. /**
  113348. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  113349. */
  113350. getDeterministicFrameTime: () => number;
  113351. /** @hidden */
  113352. _animate(): void;
  113353. /** Execute all animations (for a frame) */
  113354. animate(): void;
  113355. /**
  113356. * Render the scene
  113357. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  113358. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  113359. */
  113360. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  113361. /**
  113362. * Freeze all materials
  113363. * A frozen material will not be updatable but should be faster to render
  113364. */
  113365. freezeMaterials(): void;
  113366. /**
  113367. * Unfreeze all materials
  113368. * A frozen material will not be updatable but should be faster to render
  113369. */
  113370. unfreezeMaterials(): void;
  113371. /**
  113372. * Releases all held ressources
  113373. */
  113374. dispose(): void;
  113375. /**
  113376. * Gets if the scene is already disposed
  113377. */
  113378. get isDisposed(): boolean;
  113379. /**
  113380. * Call this function to reduce memory footprint of the scene.
  113381. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  113382. */
  113383. clearCachedVertexData(): void;
  113384. /**
  113385. * This function will remove the local cached buffer data from texture.
  113386. * It will save memory but will prevent the texture from being rebuilt
  113387. */
  113388. cleanCachedTextureBuffer(): void;
  113389. /**
  113390. * Get the world extend vectors with an optional filter
  113391. *
  113392. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  113393. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  113394. */
  113395. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  113396. min: Vector3;
  113397. max: Vector3;
  113398. };
  113399. /**
  113400. * Creates a ray that can be used to pick in the scene
  113401. * @param x defines the x coordinate of the origin (on-screen)
  113402. * @param y defines the y coordinate of the origin (on-screen)
  113403. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113404. * @param camera defines the camera to use for the picking
  113405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113406. * @returns a Ray
  113407. */
  113408. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  113409. /**
  113410. * Creates a ray that can be used to pick in the scene
  113411. * @param x defines the x coordinate of the origin (on-screen)
  113412. * @param y defines the y coordinate of the origin (on-screen)
  113413. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113414. * @param result defines the ray where to store the picking ray
  113415. * @param camera defines the camera to use for the picking
  113416. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113417. * @returns the current scene
  113418. */
  113419. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  113420. /**
  113421. * Creates a ray that can be used to pick in the scene
  113422. * @param x defines the x coordinate of the origin (on-screen)
  113423. * @param y defines the y coordinate of the origin (on-screen)
  113424. * @param camera defines the camera to use for the picking
  113425. * @returns a Ray
  113426. */
  113427. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  113428. /**
  113429. * Creates a ray that can be used to pick in the scene
  113430. * @param x defines the x coordinate of the origin (on-screen)
  113431. * @param y defines the y coordinate of the origin (on-screen)
  113432. * @param result defines the ray where to store the picking ray
  113433. * @param camera defines the camera to use for the picking
  113434. * @returns the current scene
  113435. */
  113436. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  113437. /** Launch a ray to try to pick a mesh in the scene
  113438. * @param x position on screen
  113439. * @param y position on screen
  113440. * @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
  113441. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113442. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113443. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113444. * @returns a PickingInfo
  113445. */
  113446. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113447. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  113448. * @param x position on screen
  113449. * @param y position on screen
  113450. * @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
  113451. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113452. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113453. * @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)
  113454. */
  113455. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  113456. /** Use the given ray to pick a mesh in the scene
  113457. * @param ray The ray to use to pick meshes
  113458. * @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
  113459. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113461. * @returns a PickingInfo
  113462. */
  113463. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113464. /**
  113465. * Launch a ray to try to pick a mesh in the scene
  113466. * @param x X position on screen
  113467. * @param y Y position on screen
  113468. * @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
  113469. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113470. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113471. * @returns an array of PickingInfo
  113472. */
  113473. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113474. /**
  113475. * Launch a ray to try to pick a mesh in the scene
  113476. * @param ray Ray to use
  113477. * @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
  113478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113479. * @returns an array of PickingInfo
  113480. */
  113481. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113482. /**
  113483. * Force the value of meshUnderPointer
  113484. * @param mesh defines the mesh to use
  113485. */
  113486. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  113487. /**
  113488. * Gets the mesh under the pointer
  113489. * @returns a Mesh or null if no mesh is under the pointer
  113490. */
  113491. getPointerOverMesh(): Nullable<AbstractMesh>;
  113492. /** @hidden */
  113493. _rebuildGeometries(): void;
  113494. /** @hidden */
  113495. _rebuildTextures(): void;
  113496. private _getByTags;
  113497. /**
  113498. * Get a list of meshes by tags
  113499. * @param tagsQuery defines the tags query to use
  113500. * @param forEach defines a predicate used to filter results
  113501. * @returns an array of Mesh
  113502. */
  113503. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  113504. /**
  113505. * Get a list of cameras by tags
  113506. * @param tagsQuery defines the tags query to use
  113507. * @param forEach defines a predicate used to filter results
  113508. * @returns an array of Camera
  113509. */
  113510. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  113511. /**
  113512. * Get a list of lights by tags
  113513. * @param tagsQuery defines the tags query to use
  113514. * @param forEach defines a predicate used to filter results
  113515. * @returns an array of Light
  113516. */
  113517. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  113518. /**
  113519. * Get a list of materials by tags
  113520. * @param tagsQuery defines the tags query to use
  113521. * @param forEach defines a predicate used to filter results
  113522. * @returns an array of Material
  113523. */
  113524. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  113525. /**
  113526. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  113527. * This allowed control for front to back rendering or reversly depending of the special needs.
  113528. *
  113529. * @param renderingGroupId The rendering group id corresponding to its index
  113530. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  113531. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  113532. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  113533. */
  113534. 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;
  113535. /**
  113536. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  113537. *
  113538. * @param renderingGroupId The rendering group id corresponding to its index
  113539. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113540. * @param depth Automatically clears depth between groups if true and autoClear is true.
  113541. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  113542. */
  113543. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  113544. /**
  113545. * Gets the current auto clear configuration for one rendering group of the rendering
  113546. * manager.
  113547. * @param index the rendering group index to get the information for
  113548. * @returns The auto clear setup for the requested rendering group
  113549. */
  113550. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  113551. private _blockMaterialDirtyMechanism;
  113552. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  113553. get blockMaterialDirtyMechanism(): boolean;
  113554. set blockMaterialDirtyMechanism(value: boolean);
  113555. /**
  113556. * Will flag all materials as dirty to trigger new shader compilation
  113557. * @param flag defines the flag used to specify which material part must be marked as dirty
  113558. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  113559. */
  113560. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113561. /** @hidden */
  113562. _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;
  113563. /** @hidden */
  113564. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113565. /** @hidden */
  113566. _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;
  113567. /** @hidden */
  113568. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  113569. /** @hidden */
  113570. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  113571. /** @hidden */
  113572. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113573. }
  113574. }
  113575. declare module BABYLON {
  113576. /**
  113577. * Set of assets to keep when moving a scene into an asset container.
  113578. */
  113579. export class KeepAssets extends AbstractScene {
  113580. }
  113581. /**
  113582. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  113583. */
  113584. export class InstantiatedEntries {
  113585. /**
  113586. * List of new root nodes (eg. nodes with no parent)
  113587. */
  113588. rootNodes: TransformNode[];
  113589. /**
  113590. * List of new skeletons
  113591. */
  113592. skeletons: Skeleton[];
  113593. /**
  113594. * List of new animation groups
  113595. */
  113596. animationGroups: AnimationGroup[];
  113597. }
  113598. /**
  113599. * Container with a set of assets that can be added or removed from a scene.
  113600. */
  113601. export class AssetContainer extends AbstractScene {
  113602. private _wasAddedToScene;
  113603. /**
  113604. * The scene the AssetContainer belongs to.
  113605. */
  113606. scene: Scene;
  113607. /**
  113608. * Instantiates an AssetContainer.
  113609. * @param scene The scene the AssetContainer belongs to.
  113610. */
  113611. constructor(scene: Scene);
  113612. /**
  113613. * Instantiate or clone all meshes and add the new ones to the scene.
  113614. * Skeletons and animation groups will all be cloned
  113615. * @param nameFunction defines an optional function used to get new names for clones
  113616. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  113617. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  113618. */
  113619. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  113620. /**
  113621. * Adds all the assets from the container to the scene.
  113622. */
  113623. addAllToScene(): void;
  113624. /**
  113625. * Removes all the assets in the container from the scene
  113626. */
  113627. removeAllFromScene(): void;
  113628. /**
  113629. * Disposes all the assets in the container
  113630. */
  113631. dispose(): void;
  113632. private _moveAssets;
  113633. /**
  113634. * Removes all the assets contained in the scene and adds them to the container.
  113635. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  113636. */
  113637. moveAllFromScene(keepAssets?: KeepAssets): void;
  113638. /**
  113639. * 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.
  113640. * @returns the root mesh
  113641. */
  113642. createRootMesh(): Mesh;
  113643. /**
  113644. * Merge animations (direct and animation groups) from this asset container into a scene
  113645. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113646. * @param animatables set of animatables to retarget to a node from the scene
  113647. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  113648. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  113649. */
  113650. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  113651. }
  113652. }
  113653. declare module BABYLON {
  113654. /**
  113655. * Defines how the parser contract is defined.
  113656. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  113657. */
  113658. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  113659. /**
  113660. * Defines how the individual parser contract is defined.
  113661. * These parser can parse an individual asset
  113662. */
  113663. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  113664. /**
  113665. * Base class of the scene acting as a container for the different elements composing a scene.
  113666. * This class is dynamically extended by the different components of the scene increasing
  113667. * flexibility and reducing coupling
  113668. */
  113669. export abstract class AbstractScene {
  113670. /**
  113671. * Stores the list of available parsers in the application.
  113672. */
  113673. private static _BabylonFileParsers;
  113674. /**
  113675. * Stores the list of available individual parsers in the application.
  113676. */
  113677. private static _IndividualBabylonFileParsers;
  113678. /**
  113679. * Adds a parser in the list of available ones
  113680. * @param name Defines the name of the parser
  113681. * @param parser Defines the parser to add
  113682. */
  113683. static AddParser(name: string, parser: BabylonFileParser): void;
  113684. /**
  113685. * Gets a general parser from the list of avaialble ones
  113686. * @param name Defines the name of the parser
  113687. * @returns the requested parser or null
  113688. */
  113689. static GetParser(name: string): Nullable<BabylonFileParser>;
  113690. /**
  113691. * Adds n individual parser in the list of available ones
  113692. * @param name Defines the name of the parser
  113693. * @param parser Defines the parser to add
  113694. */
  113695. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  113696. /**
  113697. * Gets an individual parser from the list of avaialble ones
  113698. * @param name Defines the name of the parser
  113699. * @returns the requested parser or null
  113700. */
  113701. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  113702. /**
  113703. * Parser json data and populate both a scene and its associated container object
  113704. * @param jsonData Defines the data to parse
  113705. * @param scene Defines the scene to parse the data for
  113706. * @param container Defines the container attached to the parsing sequence
  113707. * @param rootUrl Defines the root url of the data
  113708. */
  113709. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  113710. /**
  113711. * Gets the list of root nodes (ie. nodes with no parent)
  113712. */
  113713. rootNodes: Node[];
  113714. /** All of the cameras added to this scene
  113715. * @see http://doc.babylonjs.com/babylon101/cameras
  113716. */
  113717. cameras: Camera[];
  113718. /**
  113719. * All of the lights added to this scene
  113720. * @see http://doc.babylonjs.com/babylon101/lights
  113721. */
  113722. lights: Light[];
  113723. /**
  113724. * All of the (abstract) meshes added to this scene
  113725. */
  113726. meshes: AbstractMesh[];
  113727. /**
  113728. * The list of skeletons added to the scene
  113729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  113730. */
  113731. skeletons: Skeleton[];
  113732. /**
  113733. * All of the particle systems added to this scene
  113734. * @see http://doc.babylonjs.com/babylon101/particles
  113735. */
  113736. particleSystems: IParticleSystem[];
  113737. /**
  113738. * Gets a list of Animations associated with the scene
  113739. */
  113740. animations: Animation[];
  113741. /**
  113742. * All of the animation groups added to this scene
  113743. * @see http://doc.babylonjs.com/how_to/group
  113744. */
  113745. animationGroups: AnimationGroup[];
  113746. /**
  113747. * All of the multi-materials added to this scene
  113748. * @see http://doc.babylonjs.com/how_to/multi_materials
  113749. */
  113750. multiMaterials: MultiMaterial[];
  113751. /**
  113752. * All of the materials added to this scene
  113753. * In the context of a Scene, it is not supposed to be modified manually.
  113754. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  113755. * Note also that the order of the Material within the array is not significant and might change.
  113756. * @see http://doc.babylonjs.com/babylon101/materials
  113757. */
  113758. materials: Material[];
  113759. /**
  113760. * The list of morph target managers added to the scene
  113761. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113762. */
  113763. morphTargetManagers: MorphTargetManager[];
  113764. /**
  113765. * The list of geometries used in the scene.
  113766. */
  113767. geometries: Geometry[];
  113768. /**
  113769. * All of the tranform nodes added to this scene
  113770. * In the context of a Scene, it is not supposed to be modified manually.
  113771. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  113772. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  113773. * @see http://doc.babylonjs.com/how_to/transformnode
  113774. */
  113775. transformNodes: TransformNode[];
  113776. /**
  113777. * ActionManagers available on the scene.
  113778. */
  113779. actionManagers: AbstractActionManager[];
  113780. /**
  113781. * Textures to keep.
  113782. */
  113783. textures: BaseTexture[];
  113784. /**
  113785. * Environment texture for the scene
  113786. */
  113787. environmentTexture: Nullable<BaseTexture>;
  113788. /**
  113789. * @returns all meshes, lights, cameras, transformNodes and bones
  113790. */
  113791. getNodes(): Array<Node>;
  113792. }
  113793. }
  113794. declare module BABYLON {
  113795. /**
  113796. * Interface used to define options for Sound class
  113797. */
  113798. export interface ISoundOptions {
  113799. /**
  113800. * Does the sound autoplay once loaded.
  113801. */
  113802. autoplay?: boolean;
  113803. /**
  113804. * Does the sound loop after it finishes playing once.
  113805. */
  113806. loop?: boolean;
  113807. /**
  113808. * Sound's volume
  113809. */
  113810. volume?: number;
  113811. /**
  113812. * Is it a spatial sound?
  113813. */
  113814. spatialSound?: boolean;
  113815. /**
  113816. * Maximum distance to hear that sound
  113817. */
  113818. maxDistance?: number;
  113819. /**
  113820. * Uses user defined attenuation function
  113821. */
  113822. useCustomAttenuation?: boolean;
  113823. /**
  113824. * Define the roll off factor of spatial sounds.
  113825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113826. */
  113827. rolloffFactor?: number;
  113828. /**
  113829. * Define the reference distance the sound should be heard perfectly.
  113830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113831. */
  113832. refDistance?: number;
  113833. /**
  113834. * Define the distance attenuation model the sound will follow.
  113835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113836. */
  113837. distanceModel?: string;
  113838. /**
  113839. * Defines the playback speed (1 by default)
  113840. */
  113841. playbackRate?: number;
  113842. /**
  113843. * Defines if the sound is from a streaming source
  113844. */
  113845. streaming?: boolean;
  113846. /**
  113847. * Defines an optional length (in seconds) inside the sound file
  113848. */
  113849. length?: number;
  113850. /**
  113851. * Defines an optional offset (in seconds) inside the sound file
  113852. */
  113853. offset?: number;
  113854. /**
  113855. * If true, URLs will not be required to state the audio file codec to use.
  113856. */
  113857. skipCodecCheck?: boolean;
  113858. }
  113859. /**
  113860. * Defines a sound that can be played in the application.
  113861. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  113862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113863. */
  113864. export class Sound {
  113865. /**
  113866. * The name of the sound in the scene.
  113867. */
  113868. name: string;
  113869. /**
  113870. * Does the sound autoplay once loaded.
  113871. */
  113872. autoplay: boolean;
  113873. /**
  113874. * Does the sound loop after it finishes playing once.
  113875. */
  113876. loop: boolean;
  113877. /**
  113878. * Does the sound use a custom attenuation curve to simulate the falloff
  113879. * happening when the source gets further away from the camera.
  113880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113881. */
  113882. useCustomAttenuation: boolean;
  113883. /**
  113884. * The sound track id this sound belongs to.
  113885. */
  113886. soundTrackId: number;
  113887. /**
  113888. * Is this sound currently played.
  113889. */
  113890. isPlaying: boolean;
  113891. /**
  113892. * Is this sound currently paused.
  113893. */
  113894. isPaused: boolean;
  113895. /**
  113896. * Does this sound enables spatial sound.
  113897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113898. */
  113899. spatialSound: boolean;
  113900. /**
  113901. * Define the reference distance the sound should be heard perfectly.
  113902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113903. */
  113904. refDistance: number;
  113905. /**
  113906. * Define the roll off factor of spatial sounds.
  113907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113908. */
  113909. rolloffFactor: number;
  113910. /**
  113911. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  113912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113913. */
  113914. maxDistance: number;
  113915. /**
  113916. * Define the distance attenuation model the sound will follow.
  113917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113918. */
  113919. distanceModel: string;
  113920. /**
  113921. * @hidden
  113922. * Back Compat
  113923. **/
  113924. onended: () => any;
  113925. /**
  113926. * Observable event when the current playing sound finishes.
  113927. */
  113928. onEndedObservable: Observable<Sound>;
  113929. private _panningModel;
  113930. private _playbackRate;
  113931. private _streaming;
  113932. private _startTime;
  113933. private _startOffset;
  113934. private _position;
  113935. /** @hidden */
  113936. _positionInEmitterSpace: boolean;
  113937. private _localDirection;
  113938. private _volume;
  113939. private _isReadyToPlay;
  113940. private _isDirectional;
  113941. private _readyToPlayCallback;
  113942. private _audioBuffer;
  113943. private _soundSource;
  113944. private _streamingSource;
  113945. private _soundPanner;
  113946. private _soundGain;
  113947. private _inputAudioNode;
  113948. private _outputAudioNode;
  113949. private _coneInnerAngle;
  113950. private _coneOuterAngle;
  113951. private _coneOuterGain;
  113952. private _scene;
  113953. private _connectedTransformNode;
  113954. private _customAttenuationFunction;
  113955. private _registerFunc;
  113956. private _isOutputConnected;
  113957. private _htmlAudioElement;
  113958. private _urlType;
  113959. private _length?;
  113960. private _offset?;
  113961. /** @hidden */
  113962. static _SceneComponentInitialization: (scene: Scene) => void;
  113963. /**
  113964. * Create a sound and attach it to a scene
  113965. * @param name Name of your sound
  113966. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  113967. * @param scene defines the scene the sound belongs to
  113968. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  113969. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  113970. */
  113971. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  113972. /**
  113973. * Release the sound and its associated resources
  113974. */
  113975. dispose(): void;
  113976. /**
  113977. * Gets if the sounds is ready to be played or not.
  113978. * @returns true if ready, otherwise false
  113979. */
  113980. isReady(): boolean;
  113981. private _soundLoaded;
  113982. /**
  113983. * Sets the data of the sound from an audiobuffer
  113984. * @param audioBuffer The audioBuffer containing the data
  113985. */
  113986. setAudioBuffer(audioBuffer: AudioBuffer): void;
  113987. /**
  113988. * Updates the current sounds options such as maxdistance, loop...
  113989. * @param options A JSON object containing values named as the object properties
  113990. */
  113991. updateOptions(options: ISoundOptions): void;
  113992. private _createSpatialParameters;
  113993. private _updateSpatialParameters;
  113994. /**
  113995. * Switch the panning model to HRTF:
  113996. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  113997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113998. */
  113999. switchPanningModelToHRTF(): void;
  114000. /**
  114001. * Switch the panning model to Equal Power:
  114002. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  114003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114004. */
  114005. switchPanningModelToEqualPower(): void;
  114006. private _switchPanningModel;
  114007. /**
  114008. * Connect this sound to a sound track audio node like gain...
  114009. * @param soundTrackAudioNode the sound track audio node to connect to
  114010. */
  114011. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  114012. /**
  114013. * Transform this sound into a directional source
  114014. * @param coneInnerAngle Size of the inner cone in degree
  114015. * @param coneOuterAngle Size of the outer cone in degree
  114016. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  114017. */
  114018. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  114019. /**
  114020. * Gets or sets the inner angle for the directional cone.
  114021. */
  114022. get directionalConeInnerAngle(): number;
  114023. /**
  114024. * Gets or sets the inner angle for the directional cone.
  114025. */
  114026. set directionalConeInnerAngle(value: number);
  114027. /**
  114028. * Gets or sets the outer angle for the directional cone.
  114029. */
  114030. get directionalConeOuterAngle(): number;
  114031. /**
  114032. * Gets or sets the outer angle for the directional cone.
  114033. */
  114034. set directionalConeOuterAngle(value: number);
  114035. /**
  114036. * Sets the position of the emitter if spatial sound is enabled
  114037. * @param newPosition Defines the new posisiton
  114038. */
  114039. setPosition(newPosition: Vector3): void;
  114040. /**
  114041. * Sets the local direction of the emitter if spatial sound is enabled
  114042. * @param newLocalDirection Defines the new local direction
  114043. */
  114044. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  114045. private _updateDirection;
  114046. /** @hidden */
  114047. updateDistanceFromListener(): void;
  114048. /**
  114049. * Sets a new custom attenuation function for the sound.
  114050. * @param callback Defines the function used for the attenuation
  114051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  114052. */
  114053. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  114054. /**
  114055. * Play the sound
  114056. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  114057. * @param offset (optional) Start the sound at a specific time in seconds
  114058. * @param length (optional) Sound duration (in seconds)
  114059. */
  114060. play(time?: number, offset?: number, length?: number): void;
  114061. private _onended;
  114062. /**
  114063. * Stop the sound
  114064. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  114065. */
  114066. stop(time?: number): void;
  114067. /**
  114068. * Put the sound in pause
  114069. */
  114070. pause(): void;
  114071. /**
  114072. * Sets a dedicated volume for this sounds
  114073. * @param newVolume Define the new volume of the sound
  114074. * @param time Define time for gradual change to new volume
  114075. */
  114076. setVolume(newVolume: number, time?: number): void;
  114077. /**
  114078. * Set the sound play back rate
  114079. * @param newPlaybackRate Define the playback rate the sound should be played at
  114080. */
  114081. setPlaybackRate(newPlaybackRate: number): void;
  114082. /**
  114083. * Gets the volume of the sound.
  114084. * @returns the volume of the sound
  114085. */
  114086. getVolume(): number;
  114087. /**
  114088. * Attach the sound to a dedicated mesh
  114089. * @param transformNode The transform node to connect the sound with
  114090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  114091. */
  114092. attachToMesh(transformNode: TransformNode): void;
  114093. /**
  114094. * Detach the sound from the previously attached mesh
  114095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  114096. */
  114097. detachFromMesh(): void;
  114098. private _onRegisterAfterWorldMatrixUpdate;
  114099. /**
  114100. * Clone the current sound in the scene.
  114101. * @returns the new sound clone
  114102. */
  114103. clone(): Nullable<Sound>;
  114104. /**
  114105. * Gets the current underlying audio buffer containing the data
  114106. * @returns the audio buffer
  114107. */
  114108. getAudioBuffer(): Nullable<AudioBuffer>;
  114109. /**
  114110. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  114111. * @returns the source node
  114112. */
  114113. getSoundSource(): Nullable<AudioBufferSourceNode>;
  114114. /**
  114115. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  114116. * @returns the gain node
  114117. */
  114118. getSoundGain(): Nullable<GainNode>;
  114119. /**
  114120. * Serializes the Sound in a JSON representation
  114121. * @returns the JSON representation of the sound
  114122. */
  114123. serialize(): any;
  114124. /**
  114125. * Parse a JSON representation of a sound to innstantiate in a given scene
  114126. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  114127. * @param scene Define the scene the new parsed sound should be created in
  114128. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  114129. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  114130. * @returns the newly parsed sound
  114131. */
  114132. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  114133. }
  114134. }
  114135. declare module BABYLON {
  114136. /**
  114137. * This defines an action helpful to play a defined sound on a triggered action.
  114138. */
  114139. export class PlaySoundAction extends Action {
  114140. private _sound;
  114141. /**
  114142. * Instantiate the action
  114143. * @param triggerOptions defines the trigger options
  114144. * @param sound defines the sound to play
  114145. * @param condition defines the trigger related conditions
  114146. */
  114147. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  114148. /** @hidden */
  114149. _prepare(): void;
  114150. /**
  114151. * Execute the action and play the sound.
  114152. */
  114153. execute(): void;
  114154. /**
  114155. * Serializes the actions and its related information.
  114156. * @param parent defines the object to serialize in
  114157. * @returns the serialized object
  114158. */
  114159. serialize(parent: any): any;
  114160. }
  114161. /**
  114162. * This defines an action helpful to stop a defined sound on a triggered action.
  114163. */
  114164. export class StopSoundAction extends Action {
  114165. private _sound;
  114166. /**
  114167. * Instantiate the action
  114168. * @param triggerOptions defines the trigger options
  114169. * @param sound defines the sound to stop
  114170. * @param condition defines the trigger related conditions
  114171. */
  114172. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  114173. /** @hidden */
  114174. _prepare(): void;
  114175. /**
  114176. * Execute the action and stop the sound.
  114177. */
  114178. execute(): void;
  114179. /**
  114180. * Serializes the actions and its related information.
  114181. * @param parent defines the object to serialize in
  114182. * @returns the serialized object
  114183. */
  114184. serialize(parent: any): any;
  114185. }
  114186. }
  114187. declare module BABYLON {
  114188. /**
  114189. * This defines an action responsible to change the value of a property
  114190. * by interpolating between its current value and the newly set one once triggered.
  114191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  114192. */
  114193. export class InterpolateValueAction extends Action {
  114194. /**
  114195. * Defines the path of the property where the value should be interpolated
  114196. */
  114197. propertyPath: string;
  114198. /**
  114199. * Defines the target value at the end of the interpolation.
  114200. */
  114201. value: any;
  114202. /**
  114203. * Defines the time it will take for the property to interpolate to the value.
  114204. */
  114205. duration: number;
  114206. /**
  114207. * Defines if the other scene animations should be stopped when the action has been triggered
  114208. */
  114209. stopOtherAnimations?: boolean;
  114210. /**
  114211. * Defines a callback raised once the interpolation animation has been done.
  114212. */
  114213. onInterpolationDone?: () => void;
  114214. /**
  114215. * Observable triggered once the interpolation animation has been done.
  114216. */
  114217. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  114218. private _target;
  114219. private _effectiveTarget;
  114220. private _property;
  114221. /**
  114222. * Instantiate the action
  114223. * @param triggerOptions defines the trigger options
  114224. * @param target defines the object containing the value to interpolate
  114225. * @param propertyPath defines the path to the property in the target object
  114226. * @param value defines the target value at the end of the interpolation
  114227. * @param duration deines the time it will take for the property to interpolate to the value.
  114228. * @param condition defines the trigger related conditions
  114229. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  114230. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  114231. */
  114232. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  114233. /** @hidden */
  114234. _prepare(): void;
  114235. /**
  114236. * Execute the action starts the value interpolation.
  114237. */
  114238. execute(): void;
  114239. /**
  114240. * Serializes the actions and its related information.
  114241. * @param parent defines the object to serialize in
  114242. * @returns the serialized object
  114243. */
  114244. serialize(parent: any): any;
  114245. }
  114246. }
  114247. declare module BABYLON {
  114248. /**
  114249. * Options allowed during the creation of a sound track.
  114250. */
  114251. export interface ISoundTrackOptions {
  114252. /**
  114253. * The volume the sound track should take during creation
  114254. */
  114255. volume?: number;
  114256. /**
  114257. * Define if the sound track is the main sound track of the scene
  114258. */
  114259. mainTrack?: boolean;
  114260. }
  114261. /**
  114262. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  114263. * It will be also used in a future release to apply effects on a specific track.
  114264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114265. */
  114266. export class SoundTrack {
  114267. /**
  114268. * The unique identifier of the sound track in the scene.
  114269. */
  114270. id: number;
  114271. /**
  114272. * The list of sounds included in the sound track.
  114273. */
  114274. soundCollection: Array<Sound>;
  114275. private _outputAudioNode;
  114276. private _scene;
  114277. private _connectedAnalyser;
  114278. private _options;
  114279. private _isInitialized;
  114280. /**
  114281. * Creates a new sound track.
  114282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114283. * @param scene Define the scene the sound track belongs to
  114284. * @param options
  114285. */
  114286. constructor(scene: Scene, options?: ISoundTrackOptions);
  114287. private _initializeSoundTrackAudioGraph;
  114288. /**
  114289. * Release the sound track and its associated resources
  114290. */
  114291. dispose(): void;
  114292. /**
  114293. * Adds a sound to this sound track
  114294. * @param sound define the cound to add
  114295. * @ignoreNaming
  114296. */
  114297. AddSound(sound: Sound): void;
  114298. /**
  114299. * Removes a sound to this sound track
  114300. * @param sound define the cound to remove
  114301. * @ignoreNaming
  114302. */
  114303. RemoveSound(sound: Sound): void;
  114304. /**
  114305. * Set a global volume for the full sound track.
  114306. * @param newVolume Define the new volume of the sound track
  114307. */
  114308. setVolume(newVolume: number): void;
  114309. /**
  114310. * Switch the panning model to HRTF:
  114311. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  114312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114313. */
  114314. switchPanningModelToHRTF(): void;
  114315. /**
  114316. * Switch the panning model to Equal Power:
  114317. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  114318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114319. */
  114320. switchPanningModelToEqualPower(): void;
  114321. /**
  114322. * Connect the sound track to an audio analyser allowing some amazing
  114323. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114325. * @param analyser The analyser to connect to the engine
  114326. */
  114327. connectToAnalyser(analyser: Analyser): void;
  114328. }
  114329. }
  114330. declare module BABYLON {
  114331. interface AbstractScene {
  114332. /**
  114333. * The list of sounds used in the scene.
  114334. */
  114335. sounds: Nullable<Array<Sound>>;
  114336. }
  114337. interface Scene {
  114338. /**
  114339. * @hidden
  114340. * Backing field
  114341. */
  114342. _mainSoundTrack: SoundTrack;
  114343. /**
  114344. * The main sound track played by the scene.
  114345. * It cotains your primary collection of sounds.
  114346. */
  114347. mainSoundTrack: SoundTrack;
  114348. /**
  114349. * The list of sound tracks added to the scene
  114350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114351. */
  114352. soundTracks: Nullable<Array<SoundTrack>>;
  114353. /**
  114354. * Gets a sound using a given name
  114355. * @param name defines the name to search for
  114356. * @return the found sound or null if not found at all.
  114357. */
  114358. getSoundByName(name: string): Nullable<Sound>;
  114359. /**
  114360. * Gets or sets if audio support is enabled
  114361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114362. */
  114363. audioEnabled: boolean;
  114364. /**
  114365. * Gets or sets if audio will be output to headphones
  114366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114367. */
  114368. headphone: boolean;
  114369. /**
  114370. * Gets or sets custom audio listener position provider
  114371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114372. */
  114373. audioListenerPositionProvider: Nullable<() => Vector3>;
  114374. /**
  114375. * Gets or sets a refresh rate when using 3D audio positioning
  114376. */
  114377. audioPositioningRefreshRate: number;
  114378. }
  114379. /**
  114380. * Defines the sound scene component responsible to manage any sounds
  114381. * in a given scene.
  114382. */
  114383. export class AudioSceneComponent implements ISceneSerializableComponent {
  114384. /**
  114385. * The component name helpfull to identify the component in the list of scene components.
  114386. */
  114387. readonly name: string;
  114388. /**
  114389. * The scene the component belongs to.
  114390. */
  114391. scene: Scene;
  114392. private _audioEnabled;
  114393. /**
  114394. * Gets whether audio is enabled or not.
  114395. * Please use related enable/disable method to switch state.
  114396. */
  114397. get audioEnabled(): boolean;
  114398. private _headphone;
  114399. /**
  114400. * Gets whether audio is outputing to headphone or not.
  114401. * Please use the according Switch methods to change output.
  114402. */
  114403. get headphone(): boolean;
  114404. /**
  114405. * Gets or sets a refresh rate when using 3D audio positioning
  114406. */
  114407. audioPositioningRefreshRate: number;
  114408. private _audioListenerPositionProvider;
  114409. /**
  114410. * Gets the current audio listener position provider
  114411. */
  114412. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  114413. /**
  114414. * Sets a custom listener position for all sounds in the scene
  114415. * By default, this is the position of the first active camera
  114416. */
  114417. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  114418. /**
  114419. * Creates a new instance of the component for the given scene
  114420. * @param scene Defines the scene to register the component in
  114421. */
  114422. constructor(scene: Scene);
  114423. /**
  114424. * Registers the component in a given scene
  114425. */
  114426. register(): void;
  114427. /**
  114428. * Rebuilds the elements related to this component in case of
  114429. * context lost for instance.
  114430. */
  114431. rebuild(): void;
  114432. /**
  114433. * Serializes the component data to the specified json object
  114434. * @param serializationObject The object to serialize to
  114435. */
  114436. serialize(serializationObject: any): void;
  114437. /**
  114438. * Adds all the elements from the container to the scene
  114439. * @param container the container holding the elements
  114440. */
  114441. addFromContainer(container: AbstractScene): void;
  114442. /**
  114443. * Removes all the elements in the container from the scene
  114444. * @param container contains the elements to remove
  114445. * @param dispose if the removed element should be disposed (default: false)
  114446. */
  114447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114448. /**
  114449. * Disposes the component and the associated ressources.
  114450. */
  114451. dispose(): void;
  114452. /**
  114453. * Disables audio in the associated scene.
  114454. */
  114455. disableAudio(): void;
  114456. /**
  114457. * Enables audio in the associated scene.
  114458. */
  114459. enableAudio(): void;
  114460. /**
  114461. * Switch audio to headphone output.
  114462. */
  114463. switchAudioModeForHeadphones(): void;
  114464. /**
  114465. * Switch audio to normal speakers.
  114466. */
  114467. switchAudioModeForNormalSpeakers(): void;
  114468. private _cachedCameraDirection;
  114469. private _cachedCameraPosition;
  114470. private _lastCheck;
  114471. private _afterRender;
  114472. }
  114473. }
  114474. declare module BABYLON {
  114475. /**
  114476. * Wraps one or more Sound objects and selects one with random weight for playback.
  114477. */
  114478. export class WeightedSound {
  114479. /** When true a Sound will be selected and played when the current playing Sound completes. */
  114480. loop: boolean;
  114481. private _coneInnerAngle;
  114482. private _coneOuterAngle;
  114483. private _volume;
  114484. /** A Sound is currently playing. */
  114485. isPlaying: boolean;
  114486. /** A Sound is currently paused. */
  114487. isPaused: boolean;
  114488. private _sounds;
  114489. private _weights;
  114490. private _currentIndex?;
  114491. /**
  114492. * Creates a new WeightedSound from the list of sounds given.
  114493. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  114494. * @param sounds Array of Sounds that will be selected from.
  114495. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  114496. */
  114497. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  114498. /**
  114499. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  114500. */
  114501. get directionalConeInnerAngle(): number;
  114502. /**
  114503. * The size of cone in degress for a directional sound in which there will be no attenuation.
  114504. */
  114505. set directionalConeInnerAngle(value: number);
  114506. /**
  114507. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114508. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114509. */
  114510. get directionalConeOuterAngle(): number;
  114511. /**
  114512. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114513. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114514. */
  114515. set directionalConeOuterAngle(value: number);
  114516. /**
  114517. * Playback volume.
  114518. */
  114519. get volume(): number;
  114520. /**
  114521. * Playback volume.
  114522. */
  114523. set volume(value: number);
  114524. private _onended;
  114525. /**
  114526. * Suspend playback
  114527. */
  114528. pause(): void;
  114529. /**
  114530. * Stop playback
  114531. */
  114532. stop(): void;
  114533. /**
  114534. * Start playback.
  114535. * @param startOffset Position the clip head at a specific time in seconds.
  114536. */
  114537. play(startOffset?: number): void;
  114538. }
  114539. }
  114540. declare module BABYLON {
  114541. /**
  114542. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  114543. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  114544. */
  114545. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  114546. /**
  114547. * Gets the name of the behavior.
  114548. */
  114549. get name(): string;
  114550. /**
  114551. * The easing function used by animations
  114552. */
  114553. static EasingFunction: BackEase;
  114554. /**
  114555. * The easing mode used by animations
  114556. */
  114557. static EasingMode: number;
  114558. /**
  114559. * The duration of the animation, in milliseconds
  114560. */
  114561. transitionDuration: number;
  114562. /**
  114563. * Length of the distance animated by the transition when lower radius is reached
  114564. */
  114565. lowerRadiusTransitionRange: number;
  114566. /**
  114567. * Length of the distance animated by the transition when upper radius is reached
  114568. */
  114569. upperRadiusTransitionRange: number;
  114570. private _autoTransitionRange;
  114571. /**
  114572. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114573. */
  114574. get autoTransitionRange(): boolean;
  114575. /**
  114576. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114577. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  114578. */
  114579. set autoTransitionRange(value: boolean);
  114580. private _attachedCamera;
  114581. private _onAfterCheckInputsObserver;
  114582. private _onMeshTargetChangedObserver;
  114583. /**
  114584. * Initializes the behavior.
  114585. */
  114586. init(): void;
  114587. /**
  114588. * Attaches the behavior to its arc rotate camera.
  114589. * @param camera Defines the camera to attach the behavior to
  114590. */
  114591. attach(camera: ArcRotateCamera): void;
  114592. /**
  114593. * Detaches the behavior from its current arc rotate camera.
  114594. */
  114595. detach(): void;
  114596. private _radiusIsAnimating;
  114597. private _radiusBounceTransition;
  114598. private _animatables;
  114599. private _cachedWheelPrecision;
  114600. /**
  114601. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  114602. * @param radiusLimit The limit to check against.
  114603. * @return Bool to indicate if at limit.
  114604. */
  114605. private _isRadiusAtLimit;
  114606. /**
  114607. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  114608. * @param radiusDelta The delta by which to animate to. Can be negative.
  114609. */
  114610. private _applyBoundRadiusAnimation;
  114611. /**
  114612. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  114613. */
  114614. protected _clearAnimationLocks(): void;
  114615. /**
  114616. * Stops and removes all animations that have been applied to the camera
  114617. */
  114618. stopAllAnimations(): void;
  114619. }
  114620. }
  114621. declare module BABYLON {
  114622. /**
  114623. * 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.
  114624. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  114625. */
  114626. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  114627. /**
  114628. * Gets the name of the behavior.
  114629. */
  114630. get name(): string;
  114631. private _mode;
  114632. private _radiusScale;
  114633. private _positionScale;
  114634. private _defaultElevation;
  114635. private _elevationReturnTime;
  114636. private _elevationReturnWaitTime;
  114637. private _zoomStopsAnimation;
  114638. private _framingTime;
  114639. /**
  114640. * The easing function used by animations
  114641. */
  114642. static EasingFunction: ExponentialEase;
  114643. /**
  114644. * The easing mode used by animations
  114645. */
  114646. static EasingMode: number;
  114647. /**
  114648. * Sets the current mode used by the behavior
  114649. */
  114650. set mode(mode: number);
  114651. /**
  114652. * Gets current mode used by the behavior.
  114653. */
  114654. get mode(): number;
  114655. /**
  114656. * Sets the scale applied to the radius (1 by default)
  114657. */
  114658. set radiusScale(radius: number);
  114659. /**
  114660. * Gets the scale applied to the radius
  114661. */
  114662. get radiusScale(): number;
  114663. /**
  114664. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114665. */
  114666. set positionScale(scale: number);
  114667. /**
  114668. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114669. */
  114670. get positionScale(): number;
  114671. /**
  114672. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114673. * behaviour is triggered, in radians.
  114674. */
  114675. set defaultElevation(elevation: number);
  114676. /**
  114677. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114678. * behaviour is triggered, in radians.
  114679. */
  114680. get defaultElevation(): number;
  114681. /**
  114682. * Sets the time (in milliseconds) taken to return to the default beta position.
  114683. * Negative value indicates camera should not return to default.
  114684. */
  114685. set elevationReturnTime(speed: number);
  114686. /**
  114687. * Gets the time (in milliseconds) taken to return to the default beta position.
  114688. * Negative value indicates camera should not return to default.
  114689. */
  114690. get elevationReturnTime(): number;
  114691. /**
  114692. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114693. */
  114694. set elevationReturnWaitTime(time: number);
  114695. /**
  114696. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114697. */
  114698. get elevationReturnWaitTime(): number;
  114699. /**
  114700. * Sets the flag that indicates if user zooming should stop animation.
  114701. */
  114702. set zoomStopsAnimation(flag: boolean);
  114703. /**
  114704. * Gets the flag that indicates if user zooming should stop animation.
  114705. */
  114706. get zoomStopsAnimation(): boolean;
  114707. /**
  114708. * Sets the transition time when framing the mesh, in milliseconds
  114709. */
  114710. set framingTime(time: number);
  114711. /**
  114712. * Gets the transition time when framing the mesh, in milliseconds
  114713. */
  114714. get framingTime(): number;
  114715. /**
  114716. * Define if the behavior should automatically change the configured
  114717. * camera limits and sensibilities.
  114718. */
  114719. autoCorrectCameraLimitsAndSensibility: boolean;
  114720. private _onPrePointerObservableObserver;
  114721. private _onAfterCheckInputsObserver;
  114722. private _onMeshTargetChangedObserver;
  114723. private _attachedCamera;
  114724. private _isPointerDown;
  114725. private _lastInteractionTime;
  114726. /**
  114727. * Initializes the behavior.
  114728. */
  114729. init(): void;
  114730. /**
  114731. * Attaches the behavior to its arc rotate camera.
  114732. * @param camera Defines the camera to attach the behavior to
  114733. */
  114734. attach(camera: ArcRotateCamera): void;
  114735. /**
  114736. * Detaches the behavior from its current arc rotate camera.
  114737. */
  114738. detach(): void;
  114739. private _animatables;
  114740. private _betaIsAnimating;
  114741. private _betaTransition;
  114742. private _radiusTransition;
  114743. private _vectorTransition;
  114744. /**
  114745. * Targets the given mesh and updates zoom level accordingly.
  114746. * @param mesh The mesh to target.
  114747. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114748. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114749. */
  114750. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114751. /**
  114752. * Targets the given mesh with its children and updates zoom level accordingly.
  114753. * @param mesh The mesh to target.
  114754. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114755. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114756. */
  114757. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114758. /**
  114759. * Targets the given meshes with their children and updates zoom level accordingly.
  114760. * @param meshes The mesh to target.
  114761. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114762. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114763. */
  114764. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114765. /**
  114766. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  114767. * @param minimumWorld Determines the smaller position of the bounding box extend
  114768. * @param maximumWorld Determines the bigger position of the bounding box extend
  114769. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114770. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114771. */
  114772. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114773. /**
  114774. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  114775. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  114776. * frustum width.
  114777. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  114778. * to fully enclose the mesh in the viewing frustum.
  114779. */
  114780. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  114781. /**
  114782. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  114783. * is automatically returned to its default position (expected to be above ground plane).
  114784. */
  114785. private _maintainCameraAboveGround;
  114786. /**
  114787. * Returns the frustum slope based on the canvas ratio and camera FOV
  114788. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  114789. */
  114790. private _getFrustumSlope;
  114791. /**
  114792. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  114793. */
  114794. private _clearAnimationLocks;
  114795. /**
  114796. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114797. */
  114798. private _applyUserInteraction;
  114799. /**
  114800. * Stops and removes all animations that have been applied to the camera
  114801. */
  114802. stopAllAnimations(): void;
  114803. /**
  114804. * Gets a value indicating if the user is moving the camera
  114805. */
  114806. get isUserIsMoving(): boolean;
  114807. /**
  114808. * The camera can move all the way towards the mesh.
  114809. */
  114810. static IgnoreBoundsSizeMode: number;
  114811. /**
  114812. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  114813. */
  114814. static FitFrustumSidesMode: number;
  114815. }
  114816. }
  114817. declare module BABYLON {
  114818. /**
  114819. * Base class for Camera Pointer Inputs.
  114820. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  114821. * for example usage.
  114822. */
  114823. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  114824. /**
  114825. * Defines the camera the input is attached to.
  114826. */
  114827. abstract camera: Camera;
  114828. /**
  114829. * Whether keyboard modifier keys are pressed at time of last mouse event.
  114830. */
  114831. protected _altKey: boolean;
  114832. protected _ctrlKey: boolean;
  114833. protected _metaKey: boolean;
  114834. protected _shiftKey: boolean;
  114835. /**
  114836. * Which mouse buttons were pressed at time of last mouse event.
  114837. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  114838. */
  114839. protected _buttonsPressed: number;
  114840. /**
  114841. * Defines the buttons associated with the input to handle camera move.
  114842. */
  114843. buttons: number[];
  114844. /**
  114845. * Attach the input controls to a specific dom element to get the input from.
  114846. * @param element Defines the element the controls should be listened from
  114847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114848. */
  114849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114850. /**
  114851. * Detach the current controls from the specified dom element.
  114852. * @param element Defines the element to stop listening the inputs from
  114853. */
  114854. detachControl(element: Nullable<HTMLElement>): void;
  114855. /**
  114856. * Gets the class name of the current input.
  114857. * @returns the class name
  114858. */
  114859. getClassName(): string;
  114860. /**
  114861. * Get the friendly name associated with the input class.
  114862. * @returns the input friendly name
  114863. */
  114864. getSimpleName(): string;
  114865. /**
  114866. * Called on pointer POINTERDOUBLETAP event.
  114867. * Override this method to provide functionality on POINTERDOUBLETAP event.
  114868. */
  114869. protected onDoubleTap(type: string): void;
  114870. /**
  114871. * Called on pointer POINTERMOVE event if only a single touch is active.
  114872. * Override this method to provide functionality.
  114873. */
  114874. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114875. /**
  114876. * Called on pointer POINTERMOVE event if multiple touches are active.
  114877. * Override this method to provide functionality.
  114878. */
  114879. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114880. /**
  114881. * Called on JS contextmenu event.
  114882. * Override this method to provide functionality.
  114883. */
  114884. protected onContextMenu(evt: PointerEvent): void;
  114885. /**
  114886. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114887. * press.
  114888. * Override this method to provide functionality.
  114889. */
  114890. protected onButtonDown(evt: PointerEvent): void;
  114891. /**
  114892. * Called each time a new POINTERUP event occurs. Ie, for each button
  114893. * release.
  114894. * Override this method to provide functionality.
  114895. */
  114896. protected onButtonUp(evt: PointerEvent): void;
  114897. /**
  114898. * Called when window becomes inactive.
  114899. * Override this method to provide functionality.
  114900. */
  114901. protected onLostFocus(): void;
  114902. private _pointerInput;
  114903. private _observer;
  114904. private _onLostFocus;
  114905. private pointA;
  114906. private pointB;
  114907. }
  114908. }
  114909. declare module BABYLON {
  114910. /**
  114911. * Manage the pointers inputs to control an arc rotate camera.
  114912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114913. */
  114914. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  114915. /**
  114916. * Defines the camera the input is attached to.
  114917. */
  114918. camera: ArcRotateCamera;
  114919. /**
  114920. * Gets the class name of the current input.
  114921. * @returns the class name
  114922. */
  114923. getClassName(): string;
  114924. /**
  114925. * Defines the buttons associated with the input to handle camera move.
  114926. */
  114927. buttons: number[];
  114928. /**
  114929. * Defines the pointer angular sensibility along the X axis or how fast is
  114930. * the camera rotating.
  114931. */
  114932. angularSensibilityX: number;
  114933. /**
  114934. * Defines the pointer angular sensibility along the Y axis or how fast is
  114935. * the camera rotating.
  114936. */
  114937. angularSensibilityY: number;
  114938. /**
  114939. * Defines the pointer pinch precision or how fast is the camera zooming.
  114940. */
  114941. pinchPrecision: number;
  114942. /**
  114943. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114944. * from 0.
  114945. * It defines the percentage of current camera.radius to use as delta when
  114946. * pinch zoom is used.
  114947. */
  114948. pinchDeltaPercentage: number;
  114949. /**
  114950. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  114951. * that any object in the plane at the camera's target point will scale
  114952. * perfectly with finger motion.
  114953. * Overrides pinchDeltaPercentage and pinchPrecision.
  114954. */
  114955. useNaturalPinchZoom: boolean;
  114956. /**
  114957. * Defines the pointer panning sensibility or how fast is the camera moving.
  114958. */
  114959. panningSensibility: number;
  114960. /**
  114961. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  114962. */
  114963. multiTouchPanning: boolean;
  114964. /**
  114965. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  114966. * zoom (pinch) through multitouch.
  114967. */
  114968. multiTouchPanAndZoom: boolean;
  114969. /**
  114970. * Revers pinch action direction.
  114971. */
  114972. pinchInwards: boolean;
  114973. private _isPanClick;
  114974. private _twoFingerActivityCount;
  114975. private _isPinching;
  114976. /**
  114977. * Called on pointer POINTERMOVE event if only a single touch is active.
  114978. */
  114979. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114980. /**
  114981. * Called on pointer POINTERDOUBLETAP event.
  114982. */
  114983. protected onDoubleTap(type: string): void;
  114984. /**
  114985. * Called on pointer POINTERMOVE event if multiple touches are active.
  114986. */
  114987. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114988. /**
  114989. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114990. * press.
  114991. */
  114992. protected onButtonDown(evt: PointerEvent): void;
  114993. /**
  114994. * Called each time a new POINTERUP event occurs. Ie, for each button
  114995. * release.
  114996. */
  114997. protected onButtonUp(evt: PointerEvent): void;
  114998. /**
  114999. * Called when window becomes inactive.
  115000. */
  115001. protected onLostFocus(): void;
  115002. }
  115003. }
  115004. declare module BABYLON {
  115005. /**
  115006. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  115007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115008. */
  115009. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  115010. /**
  115011. * Defines the camera the input is attached to.
  115012. */
  115013. camera: ArcRotateCamera;
  115014. /**
  115015. * Defines the list of key codes associated with the up action (increase alpha)
  115016. */
  115017. keysUp: number[];
  115018. /**
  115019. * Defines the list of key codes associated with the down action (decrease alpha)
  115020. */
  115021. keysDown: number[];
  115022. /**
  115023. * Defines the list of key codes associated with the left action (increase beta)
  115024. */
  115025. keysLeft: number[];
  115026. /**
  115027. * Defines the list of key codes associated with the right action (decrease beta)
  115028. */
  115029. keysRight: number[];
  115030. /**
  115031. * Defines the list of key codes associated with the reset action.
  115032. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  115033. */
  115034. keysReset: number[];
  115035. /**
  115036. * Defines the panning sensibility of the inputs.
  115037. * (How fast is the camera panning)
  115038. */
  115039. panningSensibility: number;
  115040. /**
  115041. * Defines the zooming sensibility of the inputs.
  115042. * (How fast is the camera zooming)
  115043. */
  115044. zoomingSensibility: number;
  115045. /**
  115046. * Defines whether maintaining the alt key down switch the movement mode from
  115047. * orientation to zoom.
  115048. */
  115049. useAltToZoom: boolean;
  115050. /**
  115051. * Rotation speed of the camera
  115052. */
  115053. angularSpeed: number;
  115054. private _keys;
  115055. private _ctrlPressed;
  115056. private _altPressed;
  115057. private _onCanvasBlurObserver;
  115058. private _onKeyboardObserver;
  115059. private _engine;
  115060. private _scene;
  115061. /**
  115062. * Attach the input controls to a specific dom element to get the input from.
  115063. * @param element Defines the element the controls should be listened from
  115064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115065. */
  115066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115067. /**
  115068. * Detach the current controls from the specified dom element.
  115069. * @param element Defines the element to stop listening the inputs from
  115070. */
  115071. detachControl(element: Nullable<HTMLElement>): void;
  115072. /**
  115073. * Update the current camera state depending on the inputs that have been used this frame.
  115074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115075. */
  115076. checkInputs(): void;
  115077. /**
  115078. * Gets the class name of the current intput.
  115079. * @returns the class name
  115080. */
  115081. getClassName(): string;
  115082. /**
  115083. * Get the friendly name associated with the input class.
  115084. * @returns the input friendly name
  115085. */
  115086. getSimpleName(): string;
  115087. }
  115088. }
  115089. declare module BABYLON {
  115090. /**
  115091. * Manage the mouse wheel inputs to control an arc rotate camera.
  115092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115093. */
  115094. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  115095. /**
  115096. * Defines the camera the input is attached to.
  115097. */
  115098. camera: ArcRotateCamera;
  115099. /**
  115100. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115101. */
  115102. wheelPrecision: number;
  115103. /**
  115104. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  115105. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  115106. */
  115107. wheelDeltaPercentage: number;
  115108. private _wheel;
  115109. private _observer;
  115110. private computeDeltaFromMouseWheelLegacyEvent;
  115111. /**
  115112. * Attach the input controls to a specific dom element to get the input from.
  115113. * @param element Defines the element the controls should be listened from
  115114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115115. */
  115116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115117. /**
  115118. * Detach the current controls from the specified dom element.
  115119. * @param element Defines the element to stop listening the inputs from
  115120. */
  115121. detachControl(element: Nullable<HTMLElement>): void;
  115122. /**
  115123. * Gets the class name of the current intput.
  115124. * @returns the class name
  115125. */
  115126. getClassName(): string;
  115127. /**
  115128. * Get the friendly name associated with the input class.
  115129. * @returns the input friendly name
  115130. */
  115131. getSimpleName(): string;
  115132. }
  115133. }
  115134. declare module BABYLON {
  115135. /**
  115136. * Default Inputs manager for the ArcRotateCamera.
  115137. * It groups all the default supported inputs for ease of use.
  115138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115139. */
  115140. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  115141. /**
  115142. * Instantiates a new ArcRotateCameraInputsManager.
  115143. * @param camera Defines the camera the inputs belong to
  115144. */
  115145. constructor(camera: ArcRotateCamera);
  115146. /**
  115147. * Add mouse wheel input support to the input manager.
  115148. * @returns the current input manager
  115149. */
  115150. addMouseWheel(): ArcRotateCameraInputsManager;
  115151. /**
  115152. * Add pointers input support to the input manager.
  115153. * @returns the current input manager
  115154. */
  115155. addPointers(): ArcRotateCameraInputsManager;
  115156. /**
  115157. * Add keyboard input support to the input manager.
  115158. * @returns the current input manager
  115159. */
  115160. addKeyboard(): ArcRotateCameraInputsManager;
  115161. }
  115162. }
  115163. declare module BABYLON {
  115164. /**
  115165. * This represents an orbital type of camera.
  115166. *
  115167. * 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.
  115168. * 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.
  115169. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  115170. */
  115171. export class ArcRotateCamera extends TargetCamera {
  115172. /**
  115173. * Defines the rotation angle of the camera along the longitudinal axis.
  115174. */
  115175. alpha: number;
  115176. /**
  115177. * Defines the rotation angle of the camera along the latitudinal axis.
  115178. */
  115179. beta: number;
  115180. /**
  115181. * Defines the radius of the camera from it s target point.
  115182. */
  115183. radius: number;
  115184. protected _target: Vector3;
  115185. protected _targetHost: Nullable<AbstractMesh>;
  115186. /**
  115187. * Defines the target point of the camera.
  115188. * The camera looks towards it form the radius distance.
  115189. */
  115190. get target(): Vector3;
  115191. set target(value: Vector3);
  115192. /**
  115193. * Define the current local position of the camera in the scene
  115194. */
  115195. get position(): Vector3;
  115196. set position(newPosition: Vector3);
  115197. protected _upVector: Vector3;
  115198. protected _upToYMatrix: Matrix;
  115199. protected _YToUpMatrix: Matrix;
  115200. /**
  115201. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  115202. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  115203. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  115204. */
  115205. set upVector(vec: Vector3);
  115206. get upVector(): Vector3;
  115207. /**
  115208. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  115209. */
  115210. setMatUp(): void;
  115211. /**
  115212. * Current inertia value on the longitudinal axis.
  115213. * The bigger this number the longer it will take for the camera to stop.
  115214. */
  115215. inertialAlphaOffset: number;
  115216. /**
  115217. * Current inertia value on the latitudinal axis.
  115218. * The bigger this number the longer it will take for the camera to stop.
  115219. */
  115220. inertialBetaOffset: number;
  115221. /**
  115222. * Current inertia value on the radius axis.
  115223. * The bigger this number the longer it will take for the camera to stop.
  115224. */
  115225. inertialRadiusOffset: number;
  115226. /**
  115227. * Minimum allowed angle on the longitudinal axis.
  115228. * This can help limiting how the Camera is able to move in the scene.
  115229. */
  115230. lowerAlphaLimit: Nullable<number>;
  115231. /**
  115232. * Maximum allowed angle on the longitudinal axis.
  115233. * This can help limiting how the Camera is able to move in the scene.
  115234. */
  115235. upperAlphaLimit: Nullable<number>;
  115236. /**
  115237. * Minimum allowed angle on the latitudinal axis.
  115238. * This can help limiting how the Camera is able to move in the scene.
  115239. */
  115240. lowerBetaLimit: number;
  115241. /**
  115242. * Maximum allowed angle on the latitudinal axis.
  115243. * This can help limiting how the Camera is able to move in the scene.
  115244. */
  115245. upperBetaLimit: number;
  115246. /**
  115247. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  115248. * This can help limiting how the Camera is able to move in the scene.
  115249. */
  115250. lowerRadiusLimit: Nullable<number>;
  115251. /**
  115252. * Maximum allowed distance of the camera to the target (The camera can not get further).
  115253. * This can help limiting how the Camera is able to move in the scene.
  115254. */
  115255. upperRadiusLimit: Nullable<number>;
  115256. /**
  115257. * Defines the current inertia value used during panning of the camera along the X axis.
  115258. */
  115259. inertialPanningX: number;
  115260. /**
  115261. * Defines the current inertia value used during panning of the camera along the Y axis.
  115262. */
  115263. inertialPanningY: number;
  115264. /**
  115265. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  115266. * Basically if your fingers moves away from more than this distance you will be considered
  115267. * in pinch mode.
  115268. */
  115269. pinchToPanMaxDistance: number;
  115270. /**
  115271. * Defines the maximum distance the camera can pan.
  115272. * This could help keeping the cammera always in your scene.
  115273. */
  115274. panningDistanceLimit: Nullable<number>;
  115275. /**
  115276. * Defines the target of the camera before paning.
  115277. */
  115278. panningOriginTarget: Vector3;
  115279. /**
  115280. * Defines the value of the inertia used during panning.
  115281. * 0 would mean stop inertia and one would mean no decelleration at all.
  115282. */
  115283. panningInertia: number;
  115284. /**
  115285. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  115286. */
  115287. get angularSensibilityX(): number;
  115288. set angularSensibilityX(value: number);
  115289. /**
  115290. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  115291. */
  115292. get angularSensibilityY(): number;
  115293. set angularSensibilityY(value: number);
  115294. /**
  115295. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  115296. */
  115297. get pinchPrecision(): number;
  115298. set pinchPrecision(value: number);
  115299. /**
  115300. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  115301. * It will be used instead of pinchDeltaPrecision if different from 0.
  115302. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115303. */
  115304. get pinchDeltaPercentage(): number;
  115305. set pinchDeltaPercentage(value: number);
  115306. /**
  115307. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  115308. * and pinch delta percentage.
  115309. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  115310. * that any object in the plane at the camera's target point will scale
  115311. * perfectly with finger motion.
  115312. */
  115313. get useNaturalPinchZoom(): boolean;
  115314. set useNaturalPinchZoom(value: boolean);
  115315. /**
  115316. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  115317. */
  115318. get panningSensibility(): number;
  115319. set panningSensibility(value: number);
  115320. /**
  115321. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  115322. */
  115323. get keysUp(): number[];
  115324. set keysUp(value: number[]);
  115325. /**
  115326. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  115327. */
  115328. get keysDown(): number[];
  115329. set keysDown(value: number[]);
  115330. /**
  115331. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  115332. */
  115333. get keysLeft(): number[];
  115334. set keysLeft(value: number[]);
  115335. /**
  115336. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  115337. */
  115338. get keysRight(): number[];
  115339. set keysRight(value: number[]);
  115340. /**
  115341. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115342. */
  115343. get wheelPrecision(): number;
  115344. set wheelPrecision(value: number);
  115345. /**
  115346. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  115347. * It will be used instead of pinchDeltaPrecision if different from 0.
  115348. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115349. */
  115350. get wheelDeltaPercentage(): number;
  115351. set wheelDeltaPercentage(value: number);
  115352. /**
  115353. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  115354. */
  115355. zoomOnFactor: number;
  115356. /**
  115357. * Defines a screen offset for the camera position.
  115358. */
  115359. targetScreenOffset: Vector2;
  115360. /**
  115361. * Allows the camera to be completely reversed.
  115362. * If false the camera can not arrive upside down.
  115363. */
  115364. allowUpsideDown: boolean;
  115365. /**
  115366. * Define if double tap/click is used to restore the previously saved state of the camera.
  115367. */
  115368. useInputToRestoreState: boolean;
  115369. /** @hidden */
  115370. _viewMatrix: Matrix;
  115371. /** @hidden */
  115372. _useCtrlForPanning: boolean;
  115373. /** @hidden */
  115374. _panningMouseButton: number;
  115375. /**
  115376. * Defines the input associated to the camera.
  115377. */
  115378. inputs: ArcRotateCameraInputsManager;
  115379. /** @hidden */
  115380. _reset: () => void;
  115381. /**
  115382. * Defines the allowed panning axis.
  115383. */
  115384. panningAxis: Vector3;
  115385. protected _localDirection: Vector3;
  115386. protected _transformedDirection: Vector3;
  115387. private _bouncingBehavior;
  115388. /**
  115389. * Gets the bouncing behavior of the camera if it has been enabled.
  115390. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115391. */
  115392. get bouncingBehavior(): Nullable<BouncingBehavior>;
  115393. /**
  115394. * Defines if the bouncing behavior of the camera is enabled on the camera.
  115395. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115396. */
  115397. get useBouncingBehavior(): boolean;
  115398. set useBouncingBehavior(value: boolean);
  115399. private _framingBehavior;
  115400. /**
  115401. * Gets the framing behavior of the camera if it has been enabled.
  115402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115403. */
  115404. get framingBehavior(): Nullable<FramingBehavior>;
  115405. /**
  115406. * Defines if the framing behavior of the camera is enabled on the camera.
  115407. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115408. */
  115409. get useFramingBehavior(): boolean;
  115410. set useFramingBehavior(value: boolean);
  115411. private _autoRotationBehavior;
  115412. /**
  115413. * Gets the auto rotation behavior of the camera if it has been enabled.
  115414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115415. */
  115416. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  115417. /**
  115418. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  115419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115420. */
  115421. get useAutoRotationBehavior(): boolean;
  115422. set useAutoRotationBehavior(value: boolean);
  115423. /**
  115424. * Observable triggered when the mesh target has been changed on the camera.
  115425. */
  115426. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  115427. /**
  115428. * Event raised when the camera is colliding with a mesh.
  115429. */
  115430. onCollide: (collidedMesh: AbstractMesh) => void;
  115431. /**
  115432. * Defines whether the camera should check collision with the objects oh the scene.
  115433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  115434. */
  115435. checkCollisions: boolean;
  115436. /**
  115437. * Defines the collision radius of the camera.
  115438. * This simulates a sphere around the camera.
  115439. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  115440. */
  115441. collisionRadius: Vector3;
  115442. protected _collider: Collider;
  115443. protected _previousPosition: Vector3;
  115444. protected _collisionVelocity: Vector3;
  115445. protected _newPosition: Vector3;
  115446. protected _previousAlpha: number;
  115447. protected _previousBeta: number;
  115448. protected _previousRadius: number;
  115449. protected _collisionTriggered: boolean;
  115450. protected _targetBoundingCenter: Nullable<Vector3>;
  115451. private _computationVector;
  115452. /**
  115453. * Instantiates a new ArcRotateCamera in a given scene
  115454. * @param name Defines the name of the camera
  115455. * @param alpha Defines the camera rotation along the logitudinal axis
  115456. * @param beta Defines the camera rotation along the latitudinal axis
  115457. * @param radius Defines the camera distance from its target
  115458. * @param target Defines the camera target
  115459. * @param scene Defines the scene the camera belongs to
  115460. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  115461. */
  115462. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115463. /** @hidden */
  115464. _initCache(): void;
  115465. /** @hidden */
  115466. _updateCache(ignoreParentClass?: boolean): void;
  115467. protected _getTargetPosition(): Vector3;
  115468. private _storedAlpha;
  115469. private _storedBeta;
  115470. private _storedRadius;
  115471. private _storedTarget;
  115472. private _storedTargetScreenOffset;
  115473. /**
  115474. * Stores the current state of the camera (alpha, beta, radius and target)
  115475. * @returns the camera itself
  115476. */
  115477. storeState(): Camera;
  115478. /**
  115479. * @hidden
  115480. * Restored camera state. You must call storeState() first
  115481. */
  115482. _restoreStateValues(): boolean;
  115483. /** @hidden */
  115484. _isSynchronizedViewMatrix(): boolean;
  115485. /**
  115486. * Attached controls to the current camera.
  115487. * @param element Defines the element the controls should be listened from
  115488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115489. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  115490. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  115491. */
  115492. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  115493. /**
  115494. * Detach the current controls from the camera.
  115495. * The camera will stop reacting to inputs.
  115496. * @param element Defines the element to stop listening the inputs from
  115497. */
  115498. detachControl(element: HTMLElement): void;
  115499. /** @hidden */
  115500. _checkInputs(): void;
  115501. protected _checkLimits(): void;
  115502. /**
  115503. * Rebuilds angles (alpha, beta) and radius from the give position and target
  115504. */
  115505. rebuildAnglesAndRadius(): void;
  115506. /**
  115507. * Use a position to define the current camera related information like alpha, beta and radius
  115508. * @param position Defines the position to set the camera at
  115509. */
  115510. setPosition(position: Vector3): void;
  115511. /**
  115512. * Defines the target the camera should look at.
  115513. * This will automatically adapt alpha beta and radius to fit within the new target.
  115514. * @param target Defines the new target as a Vector or a mesh
  115515. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  115516. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  115517. */
  115518. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  115519. /** @hidden */
  115520. _getViewMatrix(): Matrix;
  115521. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  115522. /**
  115523. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  115524. * @param meshes Defines the mesh to zoom on
  115525. * @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)
  115526. */
  115527. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  115528. /**
  115529. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  115530. * The target will be changed but the radius
  115531. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  115532. * @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)
  115533. */
  115534. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  115535. min: Vector3;
  115536. max: Vector3;
  115537. distance: number;
  115538. }, doNotUpdateMaxZ?: boolean): void;
  115539. /**
  115540. * @override
  115541. * Override Camera.createRigCamera
  115542. */
  115543. createRigCamera(name: string, cameraIndex: number): Camera;
  115544. /**
  115545. * @hidden
  115546. * @override
  115547. * Override Camera._updateRigCameras
  115548. */
  115549. _updateRigCameras(): void;
  115550. /**
  115551. * Destroy the camera and release the current resources hold by it.
  115552. */
  115553. dispose(): void;
  115554. /**
  115555. * Gets the current object class name.
  115556. * @return the class name
  115557. */
  115558. getClassName(): string;
  115559. }
  115560. }
  115561. declare module BABYLON {
  115562. /**
  115563. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  115564. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115565. */
  115566. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  115567. /**
  115568. * Gets the name of the behavior.
  115569. */
  115570. get name(): string;
  115571. private _zoomStopsAnimation;
  115572. private _idleRotationSpeed;
  115573. private _idleRotationWaitTime;
  115574. private _idleRotationSpinupTime;
  115575. /**
  115576. * Sets the flag that indicates if user zooming should stop animation.
  115577. */
  115578. set zoomStopsAnimation(flag: boolean);
  115579. /**
  115580. * Gets the flag that indicates if user zooming should stop animation.
  115581. */
  115582. get zoomStopsAnimation(): boolean;
  115583. /**
  115584. * Sets the default speed at which the camera rotates around the model.
  115585. */
  115586. set idleRotationSpeed(speed: number);
  115587. /**
  115588. * Gets the default speed at which the camera rotates around the model.
  115589. */
  115590. get idleRotationSpeed(): number;
  115591. /**
  115592. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  115593. */
  115594. set idleRotationWaitTime(time: number);
  115595. /**
  115596. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  115597. */
  115598. get idleRotationWaitTime(): number;
  115599. /**
  115600. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115601. */
  115602. set idleRotationSpinupTime(time: number);
  115603. /**
  115604. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115605. */
  115606. get idleRotationSpinupTime(): number;
  115607. /**
  115608. * Gets a value indicating if the camera is currently rotating because of this behavior
  115609. */
  115610. get rotationInProgress(): boolean;
  115611. private _onPrePointerObservableObserver;
  115612. private _onAfterCheckInputsObserver;
  115613. private _attachedCamera;
  115614. private _isPointerDown;
  115615. private _lastFrameTime;
  115616. private _lastInteractionTime;
  115617. private _cameraRotationSpeed;
  115618. /**
  115619. * Initializes the behavior.
  115620. */
  115621. init(): void;
  115622. /**
  115623. * Attaches the behavior to its arc rotate camera.
  115624. * @param camera Defines the camera to attach the behavior to
  115625. */
  115626. attach(camera: ArcRotateCamera): void;
  115627. /**
  115628. * Detaches the behavior from its current arc rotate camera.
  115629. */
  115630. detach(): void;
  115631. /**
  115632. * Returns true if user is scrolling.
  115633. * @return true if user is scrolling.
  115634. */
  115635. private _userIsZooming;
  115636. private _lastFrameRadius;
  115637. private _shouldAnimationStopForInteraction;
  115638. /**
  115639. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  115640. */
  115641. private _applyUserInteraction;
  115642. private _userIsMoving;
  115643. }
  115644. }
  115645. declare module BABYLON {
  115646. /**
  115647. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  115648. */
  115649. export class AttachToBoxBehavior implements Behavior<Mesh> {
  115650. private ui;
  115651. /**
  115652. * The name of the behavior
  115653. */
  115654. name: string;
  115655. /**
  115656. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  115657. */
  115658. distanceAwayFromFace: number;
  115659. /**
  115660. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  115661. */
  115662. distanceAwayFromBottomOfFace: number;
  115663. private _faceVectors;
  115664. private _target;
  115665. private _scene;
  115666. private _onRenderObserver;
  115667. private _tmpMatrix;
  115668. private _tmpVector;
  115669. /**
  115670. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  115671. * @param ui The transform node that should be attched to the mesh
  115672. */
  115673. constructor(ui: TransformNode);
  115674. /**
  115675. * Initializes the behavior
  115676. */
  115677. init(): void;
  115678. private _closestFace;
  115679. private _zeroVector;
  115680. private _lookAtTmpMatrix;
  115681. private _lookAtToRef;
  115682. /**
  115683. * Attaches the AttachToBoxBehavior to the passed in mesh
  115684. * @param target The mesh that the specified node will be attached to
  115685. */
  115686. attach(target: Mesh): void;
  115687. /**
  115688. * Detaches the behavior from the mesh
  115689. */
  115690. detach(): void;
  115691. }
  115692. }
  115693. declare module BABYLON {
  115694. /**
  115695. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  115696. */
  115697. export class FadeInOutBehavior implements Behavior<Mesh> {
  115698. /**
  115699. * Time in milliseconds to delay before fading in (Default: 0)
  115700. */
  115701. delay: number;
  115702. /**
  115703. * Time in milliseconds for the mesh to fade in (Default: 300)
  115704. */
  115705. fadeInTime: number;
  115706. private _millisecondsPerFrame;
  115707. private _hovered;
  115708. private _hoverValue;
  115709. private _ownerNode;
  115710. /**
  115711. * Instatiates the FadeInOutBehavior
  115712. */
  115713. constructor();
  115714. /**
  115715. * The name of the behavior
  115716. */
  115717. get name(): string;
  115718. /**
  115719. * Initializes the behavior
  115720. */
  115721. init(): void;
  115722. /**
  115723. * Attaches the fade behavior on the passed in mesh
  115724. * @param ownerNode The mesh that will be faded in/out once attached
  115725. */
  115726. attach(ownerNode: Mesh): void;
  115727. /**
  115728. * Detaches the behavior from the mesh
  115729. */
  115730. detach(): void;
  115731. /**
  115732. * Triggers the mesh to begin fading in or out
  115733. * @param value if the object should fade in or out (true to fade in)
  115734. */
  115735. fadeIn(value: boolean): void;
  115736. private _update;
  115737. private _setAllVisibility;
  115738. }
  115739. }
  115740. declare module BABYLON {
  115741. /**
  115742. * Class containing a set of static utilities functions for managing Pivots
  115743. * @hidden
  115744. */
  115745. export class PivotTools {
  115746. private static _PivotCached;
  115747. private static _OldPivotPoint;
  115748. private static _PivotTranslation;
  115749. private static _PivotTmpVector;
  115750. /** @hidden */
  115751. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  115752. /** @hidden */
  115753. static _RestorePivotPoint(mesh: AbstractMesh): void;
  115754. }
  115755. }
  115756. declare module BABYLON {
  115757. /**
  115758. * Class containing static functions to help procedurally build meshes
  115759. */
  115760. export class PlaneBuilder {
  115761. /**
  115762. * Creates a plane mesh
  115763. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115764. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115765. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115767. * * 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
  115768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115769. * @param name defines the name of the mesh
  115770. * @param options defines the options used to create the mesh
  115771. * @param scene defines the hosting scene
  115772. * @returns the plane mesh
  115773. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115774. */
  115775. static CreatePlane(name: string, options: {
  115776. size?: number;
  115777. width?: number;
  115778. height?: number;
  115779. sideOrientation?: number;
  115780. frontUVs?: Vector4;
  115781. backUVs?: Vector4;
  115782. updatable?: boolean;
  115783. sourcePlane?: Plane;
  115784. }, scene?: Nullable<Scene>): Mesh;
  115785. }
  115786. }
  115787. declare module BABYLON {
  115788. /**
  115789. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  115790. */
  115791. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  115792. private static _AnyMouseID;
  115793. /**
  115794. * Abstract mesh the behavior is set on
  115795. */
  115796. attachedNode: AbstractMesh;
  115797. private _dragPlane;
  115798. private _scene;
  115799. private _pointerObserver;
  115800. private _beforeRenderObserver;
  115801. private static _planeScene;
  115802. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  115803. /**
  115804. * 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)
  115805. */
  115806. maxDragAngle: number;
  115807. /**
  115808. * @hidden
  115809. */
  115810. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  115811. /**
  115812. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115813. */
  115814. currentDraggingPointerID: number;
  115815. /**
  115816. * The last position where the pointer hit the drag plane in world space
  115817. */
  115818. lastDragPosition: Vector3;
  115819. /**
  115820. * If the behavior is currently in a dragging state
  115821. */
  115822. dragging: boolean;
  115823. /**
  115824. * 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)
  115825. */
  115826. dragDeltaRatio: number;
  115827. /**
  115828. * If the drag plane orientation should be updated during the dragging (Default: true)
  115829. */
  115830. updateDragPlane: boolean;
  115831. private _debugMode;
  115832. private _moving;
  115833. /**
  115834. * Fires each time the attached mesh is dragged with the pointer
  115835. * * delta between last drag position and current drag position in world space
  115836. * * dragDistance along the drag axis
  115837. * * dragPlaneNormal normal of the current drag plane used during the drag
  115838. * * dragPlanePoint in world space where the drag intersects the drag plane
  115839. */
  115840. onDragObservable: Observable<{
  115841. delta: Vector3;
  115842. dragPlanePoint: Vector3;
  115843. dragPlaneNormal: Vector3;
  115844. dragDistance: number;
  115845. pointerId: number;
  115846. }>;
  115847. /**
  115848. * Fires each time a drag begins (eg. mouse down on mesh)
  115849. */
  115850. onDragStartObservable: Observable<{
  115851. dragPlanePoint: Vector3;
  115852. pointerId: number;
  115853. }>;
  115854. /**
  115855. * Fires each time a drag ends (eg. mouse release after drag)
  115856. */
  115857. onDragEndObservable: Observable<{
  115858. dragPlanePoint: Vector3;
  115859. pointerId: number;
  115860. }>;
  115861. /**
  115862. * If the attached mesh should be moved when dragged
  115863. */
  115864. moveAttached: boolean;
  115865. /**
  115866. * If the drag behavior will react to drag events (Default: true)
  115867. */
  115868. enabled: boolean;
  115869. /**
  115870. * If pointer events should start and release the drag (Default: true)
  115871. */
  115872. startAndReleaseDragOnPointerEvents: boolean;
  115873. /**
  115874. * If camera controls should be detached during the drag
  115875. */
  115876. detachCameraControls: boolean;
  115877. /**
  115878. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  115879. */
  115880. useObjectOrientationForDragging: boolean;
  115881. private _options;
  115882. /**
  115883. * Gets the options used by the behavior
  115884. */
  115885. get options(): {
  115886. dragAxis?: Vector3;
  115887. dragPlaneNormal?: Vector3;
  115888. };
  115889. /**
  115890. * Sets the options used by the behavior
  115891. */
  115892. set options(options: {
  115893. dragAxis?: Vector3;
  115894. dragPlaneNormal?: Vector3;
  115895. });
  115896. /**
  115897. * Creates a pointer drag behavior that can be attached to a mesh
  115898. * @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)
  115899. */
  115900. constructor(options?: {
  115901. dragAxis?: Vector3;
  115902. dragPlaneNormal?: Vector3;
  115903. });
  115904. /**
  115905. * Predicate to determine if it is valid to move the object to a new position when it is moved
  115906. */
  115907. validateDrag: (targetPosition: Vector3) => boolean;
  115908. /**
  115909. * The name of the behavior
  115910. */
  115911. get name(): string;
  115912. /**
  115913. * Initializes the behavior
  115914. */
  115915. init(): void;
  115916. private _tmpVector;
  115917. private _alternatePickedPoint;
  115918. private _worldDragAxis;
  115919. private _targetPosition;
  115920. private _attachedElement;
  115921. /**
  115922. * Attaches the drag behavior the passed in mesh
  115923. * @param ownerNode The mesh that will be dragged around once attached
  115924. * @param predicate Predicate to use for pick filtering
  115925. */
  115926. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  115927. /**
  115928. * Force relase the drag action by code.
  115929. */
  115930. releaseDrag(): void;
  115931. private _startDragRay;
  115932. private _lastPointerRay;
  115933. /**
  115934. * Simulates the start of a pointer drag event on the behavior
  115935. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  115936. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  115937. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  115938. */
  115939. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  115940. private _startDrag;
  115941. private _dragDelta;
  115942. private _moveDrag;
  115943. private _pickWithRayOnDragPlane;
  115944. private _pointA;
  115945. private _pointB;
  115946. private _pointC;
  115947. private _lineA;
  115948. private _lineB;
  115949. private _localAxis;
  115950. private _lookAt;
  115951. private _updateDragPlanePosition;
  115952. /**
  115953. * Detaches the behavior from the mesh
  115954. */
  115955. detach(): void;
  115956. }
  115957. }
  115958. declare module BABYLON {
  115959. /**
  115960. * A behavior that when attached to a mesh will allow the mesh to be scaled
  115961. */
  115962. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  115963. private _dragBehaviorA;
  115964. private _dragBehaviorB;
  115965. private _startDistance;
  115966. private _initialScale;
  115967. private _targetScale;
  115968. private _ownerNode;
  115969. private _sceneRenderObserver;
  115970. /**
  115971. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  115972. */
  115973. constructor();
  115974. /**
  115975. * The name of the behavior
  115976. */
  115977. get name(): string;
  115978. /**
  115979. * Initializes the behavior
  115980. */
  115981. init(): void;
  115982. private _getCurrentDistance;
  115983. /**
  115984. * Attaches the scale behavior the passed in mesh
  115985. * @param ownerNode The mesh that will be scaled around once attached
  115986. */
  115987. attach(ownerNode: Mesh): void;
  115988. /**
  115989. * Detaches the behavior from the mesh
  115990. */
  115991. detach(): void;
  115992. }
  115993. }
  115994. declare module BABYLON {
  115995. /**
  115996. * 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
  115997. */
  115998. export class SixDofDragBehavior implements Behavior<Mesh> {
  115999. private static _virtualScene;
  116000. private _ownerNode;
  116001. private _sceneRenderObserver;
  116002. private _scene;
  116003. private _targetPosition;
  116004. private _virtualOriginMesh;
  116005. private _virtualDragMesh;
  116006. private _pointerObserver;
  116007. private _moving;
  116008. private _startingOrientation;
  116009. private _attachedElement;
  116010. /**
  116011. * 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)
  116012. */
  116013. private zDragFactor;
  116014. /**
  116015. * If the object should rotate to face the drag origin
  116016. */
  116017. rotateDraggedObject: boolean;
  116018. /**
  116019. * If the behavior is currently in a dragging state
  116020. */
  116021. dragging: boolean;
  116022. /**
  116023. * 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)
  116024. */
  116025. dragDeltaRatio: number;
  116026. /**
  116027. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  116028. */
  116029. currentDraggingPointerID: number;
  116030. /**
  116031. * If camera controls should be detached during the drag
  116032. */
  116033. detachCameraControls: boolean;
  116034. /**
  116035. * Fires each time a drag starts
  116036. */
  116037. onDragStartObservable: Observable<{}>;
  116038. /**
  116039. * Fires each time a drag ends (eg. mouse release after drag)
  116040. */
  116041. onDragEndObservable: Observable<{}>;
  116042. /**
  116043. * 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
  116044. */
  116045. constructor();
  116046. /**
  116047. * The name of the behavior
  116048. */
  116049. get name(): string;
  116050. /**
  116051. * Initializes the behavior
  116052. */
  116053. init(): void;
  116054. /**
  116055. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  116056. */
  116057. private get _pointerCamera();
  116058. /**
  116059. * Attaches the scale behavior the passed in mesh
  116060. * @param ownerNode The mesh that will be scaled around once attached
  116061. */
  116062. attach(ownerNode: Mesh): void;
  116063. /**
  116064. * Detaches the behavior from the mesh
  116065. */
  116066. detach(): void;
  116067. }
  116068. }
  116069. declare module BABYLON {
  116070. /**
  116071. * Class used to apply inverse kinematics to bones
  116072. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  116073. */
  116074. export class BoneIKController {
  116075. private static _tmpVecs;
  116076. private static _tmpQuat;
  116077. private static _tmpMats;
  116078. /**
  116079. * Gets or sets the target mesh
  116080. */
  116081. targetMesh: AbstractMesh;
  116082. /** Gets or sets the mesh used as pole */
  116083. poleTargetMesh: AbstractMesh;
  116084. /**
  116085. * Gets or sets the bone used as pole
  116086. */
  116087. poleTargetBone: Nullable<Bone>;
  116088. /**
  116089. * Gets or sets the target position
  116090. */
  116091. targetPosition: Vector3;
  116092. /**
  116093. * Gets or sets the pole target position
  116094. */
  116095. poleTargetPosition: Vector3;
  116096. /**
  116097. * Gets or sets the pole target local offset
  116098. */
  116099. poleTargetLocalOffset: Vector3;
  116100. /**
  116101. * Gets or sets the pole angle
  116102. */
  116103. poleAngle: number;
  116104. /**
  116105. * Gets or sets the mesh associated with the controller
  116106. */
  116107. mesh: AbstractMesh;
  116108. /**
  116109. * 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)
  116110. */
  116111. slerpAmount: number;
  116112. private _bone1Quat;
  116113. private _bone1Mat;
  116114. private _bone2Ang;
  116115. private _bone1;
  116116. private _bone2;
  116117. private _bone1Length;
  116118. private _bone2Length;
  116119. private _maxAngle;
  116120. private _maxReach;
  116121. private _rightHandedSystem;
  116122. private _bendAxis;
  116123. private _slerping;
  116124. private _adjustRoll;
  116125. /**
  116126. * Gets or sets maximum allowed angle
  116127. */
  116128. get maxAngle(): number;
  116129. set maxAngle(value: number);
  116130. /**
  116131. * Creates a new BoneIKController
  116132. * @param mesh defines the mesh to control
  116133. * @param bone defines the bone to control
  116134. * @param options defines options to set up the controller
  116135. */
  116136. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  116137. targetMesh?: AbstractMesh;
  116138. poleTargetMesh?: AbstractMesh;
  116139. poleTargetBone?: Bone;
  116140. poleTargetLocalOffset?: Vector3;
  116141. poleAngle?: number;
  116142. bendAxis?: Vector3;
  116143. maxAngle?: number;
  116144. slerpAmount?: number;
  116145. });
  116146. private _setMaxAngle;
  116147. /**
  116148. * Force the controller to update the bones
  116149. */
  116150. update(): void;
  116151. }
  116152. }
  116153. declare module BABYLON {
  116154. /**
  116155. * Class used to make a bone look toward a point in space
  116156. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  116157. */
  116158. export class BoneLookController {
  116159. private static _tmpVecs;
  116160. private static _tmpQuat;
  116161. private static _tmpMats;
  116162. /**
  116163. * The target Vector3 that the bone will look at
  116164. */
  116165. target: Vector3;
  116166. /**
  116167. * The mesh that the bone is attached to
  116168. */
  116169. mesh: AbstractMesh;
  116170. /**
  116171. * The bone that will be looking to the target
  116172. */
  116173. bone: Bone;
  116174. /**
  116175. * The up axis of the coordinate system that is used when the bone is rotated
  116176. */
  116177. upAxis: Vector3;
  116178. /**
  116179. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  116180. */
  116181. upAxisSpace: Space;
  116182. /**
  116183. * Used to make an adjustment to the yaw of the bone
  116184. */
  116185. adjustYaw: number;
  116186. /**
  116187. * Used to make an adjustment to the pitch of the bone
  116188. */
  116189. adjustPitch: number;
  116190. /**
  116191. * Used to make an adjustment to the roll of the bone
  116192. */
  116193. adjustRoll: number;
  116194. /**
  116195. * 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)
  116196. */
  116197. slerpAmount: number;
  116198. private _minYaw;
  116199. private _maxYaw;
  116200. private _minPitch;
  116201. private _maxPitch;
  116202. private _minYawSin;
  116203. private _minYawCos;
  116204. private _maxYawSin;
  116205. private _maxYawCos;
  116206. private _midYawConstraint;
  116207. private _minPitchTan;
  116208. private _maxPitchTan;
  116209. private _boneQuat;
  116210. private _slerping;
  116211. private _transformYawPitch;
  116212. private _transformYawPitchInv;
  116213. private _firstFrameSkipped;
  116214. private _yawRange;
  116215. private _fowardAxis;
  116216. /**
  116217. * Gets or sets the minimum yaw angle that the bone can look to
  116218. */
  116219. get minYaw(): number;
  116220. set minYaw(value: number);
  116221. /**
  116222. * Gets or sets the maximum yaw angle that the bone can look to
  116223. */
  116224. get maxYaw(): number;
  116225. set maxYaw(value: number);
  116226. /**
  116227. * Gets or sets the minimum pitch angle that the bone can look to
  116228. */
  116229. get minPitch(): number;
  116230. set minPitch(value: number);
  116231. /**
  116232. * Gets or sets the maximum pitch angle that the bone can look to
  116233. */
  116234. get maxPitch(): number;
  116235. set maxPitch(value: number);
  116236. /**
  116237. * Create a BoneLookController
  116238. * @param mesh the mesh that the bone belongs to
  116239. * @param bone the bone that will be looking to the target
  116240. * @param target the target Vector3 to look at
  116241. * @param options optional settings:
  116242. * * maxYaw: the maximum angle the bone will yaw to
  116243. * * minYaw: the minimum angle the bone will yaw to
  116244. * * maxPitch: the maximum angle the bone will pitch to
  116245. * * minPitch: the minimum angle the bone will yaw to
  116246. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  116247. * * upAxis: the up axis of the coordinate system
  116248. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  116249. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  116250. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  116251. * * adjustYaw: used to make an adjustment to the yaw of the bone
  116252. * * adjustPitch: used to make an adjustment to the pitch of the bone
  116253. * * adjustRoll: used to make an adjustment to the roll of the bone
  116254. **/
  116255. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  116256. maxYaw?: number;
  116257. minYaw?: number;
  116258. maxPitch?: number;
  116259. minPitch?: number;
  116260. slerpAmount?: number;
  116261. upAxis?: Vector3;
  116262. upAxisSpace?: Space;
  116263. yawAxis?: Vector3;
  116264. pitchAxis?: Vector3;
  116265. adjustYaw?: number;
  116266. adjustPitch?: number;
  116267. adjustRoll?: number;
  116268. });
  116269. /**
  116270. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  116271. */
  116272. update(): void;
  116273. private _getAngleDiff;
  116274. private _getAngleBetween;
  116275. private _isAngleBetween;
  116276. }
  116277. }
  116278. declare module BABYLON {
  116279. /**
  116280. * Manage the gamepad inputs to control an arc rotate camera.
  116281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116282. */
  116283. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  116284. /**
  116285. * Defines the camera the input is attached to.
  116286. */
  116287. camera: ArcRotateCamera;
  116288. /**
  116289. * Defines the gamepad the input is gathering event from.
  116290. */
  116291. gamepad: Nullable<Gamepad>;
  116292. /**
  116293. * Defines the gamepad rotation sensiblity.
  116294. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116295. */
  116296. gamepadRotationSensibility: number;
  116297. /**
  116298. * Defines the gamepad move sensiblity.
  116299. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116300. */
  116301. gamepadMoveSensibility: number;
  116302. private _yAxisScale;
  116303. /**
  116304. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  116305. */
  116306. get invertYAxis(): boolean;
  116307. set invertYAxis(value: boolean);
  116308. private _onGamepadConnectedObserver;
  116309. private _onGamepadDisconnectedObserver;
  116310. /**
  116311. * Attach the input controls to a specific dom element to get the input from.
  116312. * @param element Defines the element the controls should be listened from
  116313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116314. */
  116315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116316. /**
  116317. * Detach the current controls from the specified dom element.
  116318. * @param element Defines the element to stop listening the inputs from
  116319. */
  116320. detachControl(element: Nullable<HTMLElement>): void;
  116321. /**
  116322. * Update the current camera state depending on the inputs that have been used this frame.
  116323. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116324. */
  116325. checkInputs(): void;
  116326. /**
  116327. * Gets the class name of the current intput.
  116328. * @returns the class name
  116329. */
  116330. getClassName(): string;
  116331. /**
  116332. * Get the friendly name associated with the input class.
  116333. * @returns the input friendly name
  116334. */
  116335. getSimpleName(): string;
  116336. }
  116337. }
  116338. declare module BABYLON {
  116339. interface ArcRotateCameraInputsManager {
  116340. /**
  116341. * Add orientation input support to the input manager.
  116342. * @returns the current input manager
  116343. */
  116344. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  116345. }
  116346. /**
  116347. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  116348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116349. */
  116350. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  116351. /**
  116352. * Defines the camera the input is attached to.
  116353. */
  116354. camera: ArcRotateCamera;
  116355. /**
  116356. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  116357. */
  116358. alphaCorrection: number;
  116359. /**
  116360. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  116361. */
  116362. gammaCorrection: number;
  116363. private _alpha;
  116364. private _gamma;
  116365. private _dirty;
  116366. private _deviceOrientationHandler;
  116367. /**
  116368. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  116369. */
  116370. constructor();
  116371. /**
  116372. * Attach the input controls to a specific dom element to get the input from.
  116373. * @param element Defines the element the controls should be listened from
  116374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116375. */
  116376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116377. /** @hidden */
  116378. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  116379. /**
  116380. * Update the current camera state depending on the inputs that have been used this frame.
  116381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116382. */
  116383. checkInputs(): void;
  116384. /**
  116385. * Detach the current controls from the specified dom element.
  116386. * @param element Defines the element to stop listening the inputs from
  116387. */
  116388. detachControl(element: Nullable<HTMLElement>): void;
  116389. /**
  116390. * Gets the class name of the current intput.
  116391. * @returns the class name
  116392. */
  116393. getClassName(): string;
  116394. /**
  116395. * Get the friendly name associated with the input class.
  116396. * @returns the input friendly name
  116397. */
  116398. getSimpleName(): string;
  116399. }
  116400. }
  116401. declare module BABYLON {
  116402. /**
  116403. * Listen to mouse events to control the camera.
  116404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116405. */
  116406. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  116407. /**
  116408. * Defines the camera the input is attached to.
  116409. */
  116410. camera: FlyCamera;
  116411. /**
  116412. * Defines if touch is enabled. (Default is true.)
  116413. */
  116414. touchEnabled: boolean;
  116415. /**
  116416. * Defines the buttons associated with the input to handle camera rotation.
  116417. */
  116418. buttons: number[];
  116419. /**
  116420. * Assign buttons for Yaw control.
  116421. */
  116422. buttonsYaw: number[];
  116423. /**
  116424. * Assign buttons for Pitch control.
  116425. */
  116426. buttonsPitch: number[];
  116427. /**
  116428. * Assign buttons for Roll control.
  116429. */
  116430. buttonsRoll: number[];
  116431. /**
  116432. * Detect if any button is being pressed while mouse is moved.
  116433. * -1 = Mouse locked.
  116434. * 0 = Left button.
  116435. * 1 = Middle Button.
  116436. * 2 = Right Button.
  116437. */
  116438. activeButton: number;
  116439. /**
  116440. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  116441. * Higher values reduce its sensitivity.
  116442. */
  116443. angularSensibility: number;
  116444. private _mousemoveCallback;
  116445. private _observer;
  116446. private _rollObserver;
  116447. private previousPosition;
  116448. private noPreventDefault;
  116449. private element;
  116450. /**
  116451. * Listen to mouse events to control the camera.
  116452. * @param touchEnabled Define if touch is enabled. (Default is true.)
  116453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116454. */
  116455. constructor(touchEnabled?: boolean);
  116456. /**
  116457. * Attach the mouse control to the HTML DOM element.
  116458. * @param element Defines the element that listens to the input events.
  116459. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  116460. */
  116461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116462. /**
  116463. * Detach the current controls from the specified dom element.
  116464. * @param element Defines the element to stop listening the inputs from
  116465. */
  116466. detachControl(element: Nullable<HTMLElement>): void;
  116467. /**
  116468. * Gets the class name of the current input.
  116469. * @returns the class name.
  116470. */
  116471. getClassName(): string;
  116472. /**
  116473. * Get the friendly name associated with the input class.
  116474. * @returns the input's friendly name.
  116475. */
  116476. getSimpleName(): string;
  116477. private _pointerInput;
  116478. private _onMouseMove;
  116479. /**
  116480. * Rotate camera by mouse offset.
  116481. */
  116482. private rotateCamera;
  116483. }
  116484. }
  116485. declare module BABYLON {
  116486. /**
  116487. * Default Inputs manager for the FlyCamera.
  116488. * It groups all the default supported inputs for ease of use.
  116489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116490. */
  116491. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  116492. /**
  116493. * Instantiates a new FlyCameraInputsManager.
  116494. * @param camera Defines the camera the inputs belong to.
  116495. */
  116496. constructor(camera: FlyCamera);
  116497. /**
  116498. * Add keyboard input support to the input manager.
  116499. * @returns the new FlyCameraKeyboardMoveInput().
  116500. */
  116501. addKeyboard(): FlyCameraInputsManager;
  116502. /**
  116503. * Add mouse input support to the input manager.
  116504. * @param touchEnabled Enable touch screen support.
  116505. * @returns the new FlyCameraMouseInput().
  116506. */
  116507. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  116508. }
  116509. }
  116510. declare module BABYLON {
  116511. /**
  116512. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116513. * such as in a 3D Space Shooter or a Flight Simulator.
  116514. */
  116515. export class FlyCamera extends TargetCamera {
  116516. /**
  116517. * Define the collision ellipsoid of the camera.
  116518. * This is helpful for simulating a camera body, like a player's body.
  116519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  116520. */
  116521. ellipsoid: Vector3;
  116522. /**
  116523. * Define an offset for the position of the ellipsoid around the camera.
  116524. * This can be helpful if the camera is attached away from the player's body center,
  116525. * such as at its head.
  116526. */
  116527. ellipsoidOffset: Vector3;
  116528. /**
  116529. * Enable or disable collisions of the camera with the rest of the scene objects.
  116530. */
  116531. checkCollisions: boolean;
  116532. /**
  116533. * Enable or disable gravity on the camera.
  116534. */
  116535. applyGravity: boolean;
  116536. /**
  116537. * Define the current direction the camera is moving to.
  116538. */
  116539. cameraDirection: Vector3;
  116540. /**
  116541. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  116542. * This overrides and empties cameraRotation.
  116543. */
  116544. rotationQuaternion: Quaternion;
  116545. /**
  116546. * Track Roll to maintain the wanted Rolling when looking around.
  116547. */
  116548. _trackRoll: number;
  116549. /**
  116550. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  116551. */
  116552. rollCorrect: number;
  116553. /**
  116554. * Mimic a banked turn, Rolling the camera when Yawing.
  116555. * It's recommended to use rollCorrect = 10 for faster banking correction.
  116556. */
  116557. bankedTurn: boolean;
  116558. /**
  116559. * Limit in radians for how much Roll banking will add. (Default: 90°)
  116560. */
  116561. bankedTurnLimit: number;
  116562. /**
  116563. * Value of 0 disables the banked Roll.
  116564. * Value of 1 is equal to the Yaw angle in radians.
  116565. */
  116566. bankedTurnMultiplier: number;
  116567. /**
  116568. * The inputs manager loads all the input sources, such as keyboard and mouse.
  116569. */
  116570. inputs: FlyCameraInputsManager;
  116571. /**
  116572. * Gets the input sensibility for mouse input.
  116573. * Higher values reduce sensitivity.
  116574. */
  116575. get angularSensibility(): number;
  116576. /**
  116577. * Sets the input sensibility for a mouse input.
  116578. * Higher values reduce sensitivity.
  116579. */
  116580. set angularSensibility(value: number);
  116581. /**
  116582. * Get the keys for camera movement forward.
  116583. */
  116584. get keysForward(): number[];
  116585. /**
  116586. * Set the keys for camera movement forward.
  116587. */
  116588. set keysForward(value: number[]);
  116589. /**
  116590. * Get the keys for camera movement backward.
  116591. */
  116592. get keysBackward(): number[];
  116593. set keysBackward(value: number[]);
  116594. /**
  116595. * Get the keys for camera movement up.
  116596. */
  116597. get keysUp(): number[];
  116598. /**
  116599. * Set the keys for camera movement up.
  116600. */
  116601. set keysUp(value: number[]);
  116602. /**
  116603. * Get the keys for camera movement down.
  116604. */
  116605. get keysDown(): number[];
  116606. /**
  116607. * Set the keys for camera movement down.
  116608. */
  116609. set keysDown(value: number[]);
  116610. /**
  116611. * Get the keys for camera movement left.
  116612. */
  116613. get keysLeft(): number[];
  116614. /**
  116615. * Set the keys for camera movement left.
  116616. */
  116617. set keysLeft(value: number[]);
  116618. /**
  116619. * Set the keys for camera movement right.
  116620. */
  116621. get keysRight(): number[];
  116622. /**
  116623. * Set the keys for camera movement right.
  116624. */
  116625. set keysRight(value: number[]);
  116626. /**
  116627. * Event raised when the camera collides with a mesh in the scene.
  116628. */
  116629. onCollide: (collidedMesh: AbstractMesh) => void;
  116630. private _collider;
  116631. private _needMoveForGravity;
  116632. private _oldPosition;
  116633. private _diffPosition;
  116634. private _newPosition;
  116635. /** @hidden */
  116636. _localDirection: Vector3;
  116637. /** @hidden */
  116638. _transformedDirection: Vector3;
  116639. /**
  116640. * Instantiates a FlyCamera.
  116641. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116642. * such as in a 3D Space Shooter or a Flight Simulator.
  116643. * @param name Define the name of the camera in the scene.
  116644. * @param position Define the starting position of the camera in the scene.
  116645. * @param scene Define the scene the camera belongs to.
  116646. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  116647. */
  116648. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  116649. /**
  116650. * Attach a control to the HTML DOM element.
  116651. * @param element Defines the element that listens to the input events.
  116652. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  116653. */
  116654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116655. /**
  116656. * Detach a control from the HTML DOM element.
  116657. * The camera will stop reacting to that input.
  116658. * @param element Defines the element that listens to the input events.
  116659. */
  116660. detachControl(element: HTMLElement): void;
  116661. private _collisionMask;
  116662. /**
  116663. * Get the mask that the camera ignores in collision events.
  116664. */
  116665. get collisionMask(): number;
  116666. /**
  116667. * Set the mask that the camera ignores in collision events.
  116668. */
  116669. set collisionMask(mask: number);
  116670. /** @hidden */
  116671. _collideWithWorld(displacement: Vector3): void;
  116672. /** @hidden */
  116673. private _onCollisionPositionChange;
  116674. /** @hidden */
  116675. _checkInputs(): void;
  116676. /** @hidden */
  116677. _decideIfNeedsToMove(): boolean;
  116678. /** @hidden */
  116679. _updatePosition(): void;
  116680. /**
  116681. * Restore the Roll to its target value at the rate specified.
  116682. * @param rate - Higher means slower restoring.
  116683. * @hidden
  116684. */
  116685. restoreRoll(rate: number): void;
  116686. /**
  116687. * Destroy the camera and release the current resources held by it.
  116688. */
  116689. dispose(): void;
  116690. /**
  116691. * Get the current object class name.
  116692. * @returns the class name.
  116693. */
  116694. getClassName(): string;
  116695. }
  116696. }
  116697. declare module BABYLON {
  116698. /**
  116699. * Listen to keyboard events to control the camera.
  116700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116701. */
  116702. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  116703. /**
  116704. * Defines the camera the input is attached to.
  116705. */
  116706. camera: FlyCamera;
  116707. /**
  116708. * The list of keyboard keys used to control the forward move of the camera.
  116709. */
  116710. keysForward: number[];
  116711. /**
  116712. * The list of keyboard keys used to control the backward move of the camera.
  116713. */
  116714. keysBackward: number[];
  116715. /**
  116716. * The list of keyboard keys used to control the forward move of the camera.
  116717. */
  116718. keysUp: number[];
  116719. /**
  116720. * The list of keyboard keys used to control the backward move of the camera.
  116721. */
  116722. keysDown: number[];
  116723. /**
  116724. * The list of keyboard keys used to control the right strafe move of the camera.
  116725. */
  116726. keysRight: number[];
  116727. /**
  116728. * The list of keyboard keys used to control the left strafe move of the camera.
  116729. */
  116730. keysLeft: number[];
  116731. private _keys;
  116732. private _onCanvasBlurObserver;
  116733. private _onKeyboardObserver;
  116734. private _engine;
  116735. private _scene;
  116736. /**
  116737. * Attach the input controls to a specific dom element to get the input from.
  116738. * @param element Defines the element the controls should be listened from
  116739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116740. */
  116741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116742. /**
  116743. * Detach the current controls from the specified dom element.
  116744. * @param element Defines the element to stop listening the inputs from
  116745. */
  116746. detachControl(element: Nullable<HTMLElement>): void;
  116747. /**
  116748. * Gets the class name of the current intput.
  116749. * @returns the class name
  116750. */
  116751. getClassName(): string;
  116752. /** @hidden */
  116753. _onLostFocus(e: FocusEvent): void;
  116754. /**
  116755. * Get the friendly name associated with the input class.
  116756. * @returns the input friendly name
  116757. */
  116758. getSimpleName(): string;
  116759. /**
  116760. * Update the current camera state depending on the inputs that have been used this frame.
  116761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116762. */
  116763. checkInputs(): void;
  116764. }
  116765. }
  116766. declare module BABYLON {
  116767. /**
  116768. * Manage the mouse wheel inputs to control a follow camera.
  116769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116770. */
  116771. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  116772. /**
  116773. * Defines the camera the input is attached to.
  116774. */
  116775. camera: FollowCamera;
  116776. /**
  116777. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  116778. */
  116779. axisControlRadius: boolean;
  116780. /**
  116781. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  116782. */
  116783. axisControlHeight: boolean;
  116784. /**
  116785. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  116786. */
  116787. axisControlRotation: boolean;
  116788. /**
  116789. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  116790. * relation to mouseWheel events.
  116791. */
  116792. wheelPrecision: number;
  116793. /**
  116794. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  116795. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  116796. */
  116797. wheelDeltaPercentage: number;
  116798. private _wheel;
  116799. private _observer;
  116800. /**
  116801. * Attach the input controls to a specific dom element to get the input from.
  116802. * @param element Defines the element the controls should be listened from
  116803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116804. */
  116805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116806. /**
  116807. * Detach the current controls from the specified dom element.
  116808. * @param element Defines the element to stop listening the inputs from
  116809. */
  116810. detachControl(element: Nullable<HTMLElement>): void;
  116811. /**
  116812. * Gets the class name of the current intput.
  116813. * @returns the class name
  116814. */
  116815. getClassName(): string;
  116816. /**
  116817. * Get the friendly name associated with the input class.
  116818. * @returns the input friendly name
  116819. */
  116820. getSimpleName(): string;
  116821. }
  116822. }
  116823. declare module BABYLON {
  116824. /**
  116825. * Manage the pointers inputs to control an follow camera.
  116826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116827. */
  116828. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  116829. /**
  116830. * Defines the camera the input is attached to.
  116831. */
  116832. camera: FollowCamera;
  116833. /**
  116834. * Gets the class name of the current input.
  116835. * @returns the class name
  116836. */
  116837. getClassName(): string;
  116838. /**
  116839. * Defines the pointer angular sensibility along the X axis or how fast is
  116840. * the camera rotating.
  116841. * A negative number will reverse the axis direction.
  116842. */
  116843. angularSensibilityX: number;
  116844. /**
  116845. * Defines the pointer angular sensibility along the Y axis or how fast is
  116846. * the camera rotating.
  116847. * A negative number will reverse the axis direction.
  116848. */
  116849. angularSensibilityY: number;
  116850. /**
  116851. * Defines the pointer pinch precision or how fast is the camera zooming.
  116852. * A negative number will reverse the axis direction.
  116853. */
  116854. pinchPrecision: number;
  116855. /**
  116856. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  116857. * from 0.
  116858. * It defines the percentage of current camera.radius to use as delta when
  116859. * pinch zoom is used.
  116860. */
  116861. pinchDeltaPercentage: number;
  116862. /**
  116863. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  116864. */
  116865. axisXControlRadius: boolean;
  116866. /**
  116867. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  116868. */
  116869. axisXControlHeight: boolean;
  116870. /**
  116871. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  116872. */
  116873. axisXControlRotation: boolean;
  116874. /**
  116875. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  116876. */
  116877. axisYControlRadius: boolean;
  116878. /**
  116879. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  116880. */
  116881. axisYControlHeight: boolean;
  116882. /**
  116883. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  116884. */
  116885. axisYControlRotation: boolean;
  116886. /**
  116887. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  116888. */
  116889. axisPinchControlRadius: boolean;
  116890. /**
  116891. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  116892. */
  116893. axisPinchControlHeight: boolean;
  116894. /**
  116895. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  116896. */
  116897. axisPinchControlRotation: boolean;
  116898. /**
  116899. * Log error messages if basic misconfiguration has occurred.
  116900. */
  116901. warningEnable: boolean;
  116902. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  116903. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  116904. private _warningCounter;
  116905. private _warning;
  116906. }
  116907. }
  116908. declare module BABYLON {
  116909. /**
  116910. * Default Inputs manager for the FollowCamera.
  116911. * It groups all the default supported inputs for ease of use.
  116912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116913. */
  116914. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  116915. /**
  116916. * Instantiates a new FollowCameraInputsManager.
  116917. * @param camera Defines the camera the inputs belong to
  116918. */
  116919. constructor(camera: FollowCamera);
  116920. /**
  116921. * Add keyboard input support to the input manager.
  116922. * @returns the current input manager
  116923. */
  116924. addKeyboard(): FollowCameraInputsManager;
  116925. /**
  116926. * Add mouse wheel input support to the input manager.
  116927. * @returns the current input manager
  116928. */
  116929. addMouseWheel(): FollowCameraInputsManager;
  116930. /**
  116931. * Add pointers input support to the input manager.
  116932. * @returns the current input manager
  116933. */
  116934. addPointers(): FollowCameraInputsManager;
  116935. /**
  116936. * Add orientation input support to the input manager.
  116937. * @returns the current input manager
  116938. */
  116939. addVRDeviceOrientation(): FollowCameraInputsManager;
  116940. }
  116941. }
  116942. declare module BABYLON {
  116943. /**
  116944. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  116945. * an arc rotate version arcFollowCamera are available.
  116946. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116947. */
  116948. export class FollowCamera extends TargetCamera {
  116949. /**
  116950. * Distance the follow camera should follow an object at
  116951. */
  116952. radius: number;
  116953. /**
  116954. * Minimum allowed distance of the camera to the axis of rotation
  116955. * (The camera can not get closer).
  116956. * This can help limiting how the Camera is able to move in the scene.
  116957. */
  116958. lowerRadiusLimit: Nullable<number>;
  116959. /**
  116960. * Maximum allowed distance of the camera to the axis of rotation
  116961. * (The camera can not get further).
  116962. * This can help limiting how the Camera is able to move in the scene.
  116963. */
  116964. upperRadiusLimit: Nullable<number>;
  116965. /**
  116966. * Define a rotation offset between the camera and the object it follows
  116967. */
  116968. rotationOffset: number;
  116969. /**
  116970. * Minimum allowed angle to camera position relative to target object.
  116971. * This can help limiting how the Camera is able to move in the scene.
  116972. */
  116973. lowerRotationOffsetLimit: Nullable<number>;
  116974. /**
  116975. * Maximum allowed angle to camera position relative to target object.
  116976. * This can help limiting how the Camera is able to move in the scene.
  116977. */
  116978. upperRotationOffsetLimit: Nullable<number>;
  116979. /**
  116980. * Define a height offset between the camera and the object it follows.
  116981. * It can help following an object from the top (like a car chaing a plane)
  116982. */
  116983. heightOffset: number;
  116984. /**
  116985. * Minimum allowed height of camera position relative to target object.
  116986. * This can help limiting how the Camera is able to move in the scene.
  116987. */
  116988. lowerHeightOffsetLimit: Nullable<number>;
  116989. /**
  116990. * Maximum allowed height of camera position relative to target object.
  116991. * This can help limiting how the Camera is able to move in the scene.
  116992. */
  116993. upperHeightOffsetLimit: Nullable<number>;
  116994. /**
  116995. * Define how fast the camera can accelerate to follow it s target.
  116996. */
  116997. cameraAcceleration: number;
  116998. /**
  116999. * Define the speed limit of the camera following an object.
  117000. */
  117001. maxCameraSpeed: number;
  117002. /**
  117003. * Define the target of the camera.
  117004. */
  117005. lockedTarget: Nullable<AbstractMesh>;
  117006. /**
  117007. * Defines the input associated with the camera.
  117008. */
  117009. inputs: FollowCameraInputsManager;
  117010. /**
  117011. * Instantiates the follow camera.
  117012. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  117013. * @param name Define the name of the camera in the scene
  117014. * @param position Define the position of the camera
  117015. * @param scene Define the scene the camera belong to
  117016. * @param lockedTarget Define the target of the camera
  117017. */
  117018. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  117019. private _follow;
  117020. /**
  117021. * Attached controls to the current camera.
  117022. * @param element Defines the element the controls should be listened from
  117023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117024. */
  117025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117026. /**
  117027. * Detach the current controls from the camera.
  117028. * The camera will stop reacting to inputs.
  117029. * @param element Defines the element to stop listening the inputs from
  117030. */
  117031. detachControl(element: HTMLElement): void;
  117032. /** @hidden */
  117033. _checkInputs(): void;
  117034. private _checkLimits;
  117035. /**
  117036. * Gets the camera class name.
  117037. * @returns the class name
  117038. */
  117039. getClassName(): string;
  117040. }
  117041. /**
  117042. * Arc Rotate version of the follow camera.
  117043. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  117044. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  117045. */
  117046. export class ArcFollowCamera extends TargetCamera {
  117047. /** The longitudinal angle of the camera */
  117048. alpha: number;
  117049. /** The latitudinal angle of the camera */
  117050. beta: number;
  117051. /** The radius of the camera from its target */
  117052. radius: number;
  117053. /** Define the camera target (the messh it should follow) */
  117054. target: Nullable<AbstractMesh>;
  117055. private _cartesianCoordinates;
  117056. /**
  117057. * Instantiates a new ArcFollowCamera
  117058. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  117059. * @param name Define the name of the camera
  117060. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  117061. * @param beta Define the rotation angle of the camera around the elevation axis
  117062. * @param radius Define the radius of the camera from its target point
  117063. * @param target Define the target of the camera
  117064. * @param scene Define the scene the camera belongs to
  117065. */
  117066. constructor(name: string,
  117067. /** The longitudinal angle of the camera */
  117068. alpha: number,
  117069. /** The latitudinal angle of the camera */
  117070. beta: number,
  117071. /** The radius of the camera from its target */
  117072. radius: number,
  117073. /** Define the camera target (the messh it should follow) */
  117074. target: Nullable<AbstractMesh>, scene: Scene);
  117075. private _follow;
  117076. /** @hidden */
  117077. _checkInputs(): void;
  117078. /**
  117079. * Returns the class name of the object.
  117080. * It is mostly used internally for serialization purposes.
  117081. */
  117082. getClassName(): string;
  117083. }
  117084. }
  117085. declare module BABYLON {
  117086. /**
  117087. * Manage the keyboard inputs to control the movement of a follow camera.
  117088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117089. */
  117090. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  117091. /**
  117092. * Defines the camera the input is attached to.
  117093. */
  117094. camera: FollowCamera;
  117095. /**
  117096. * Defines the list of key codes associated with the up action (increase heightOffset)
  117097. */
  117098. keysHeightOffsetIncr: number[];
  117099. /**
  117100. * Defines the list of key codes associated with the down action (decrease heightOffset)
  117101. */
  117102. keysHeightOffsetDecr: number[];
  117103. /**
  117104. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  117105. */
  117106. keysHeightOffsetModifierAlt: boolean;
  117107. /**
  117108. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  117109. */
  117110. keysHeightOffsetModifierCtrl: boolean;
  117111. /**
  117112. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  117113. */
  117114. keysHeightOffsetModifierShift: boolean;
  117115. /**
  117116. * Defines the list of key codes associated with the left action (increase rotationOffset)
  117117. */
  117118. keysRotationOffsetIncr: number[];
  117119. /**
  117120. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  117121. */
  117122. keysRotationOffsetDecr: number[];
  117123. /**
  117124. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  117125. */
  117126. keysRotationOffsetModifierAlt: boolean;
  117127. /**
  117128. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  117129. */
  117130. keysRotationOffsetModifierCtrl: boolean;
  117131. /**
  117132. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  117133. */
  117134. keysRotationOffsetModifierShift: boolean;
  117135. /**
  117136. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  117137. */
  117138. keysRadiusIncr: number[];
  117139. /**
  117140. * Defines the list of key codes associated with the zoom-out action (increase radius)
  117141. */
  117142. keysRadiusDecr: number[];
  117143. /**
  117144. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  117145. */
  117146. keysRadiusModifierAlt: boolean;
  117147. /**
  117148. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  117149. */
  117150. keysRadiusModifierCtrl: boolean;
  117151. /**
  117152. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  117153. */
  117154. keysRadiusModifierShift: boolean;
  117155. /**
  117156. * Defines the rate of change of heightOffset.
  117157. */
  117158. heightSensibility: number;
  117159. /**
  117160. * Defines the rate of change of rotationOffset.
  117161. */
  117162. rotationSensibility: number;
  117163. /**
  117164. * Defines the rate of change of radius.
  117165. */
  117166. radiusSensibility: number;
  117167. private _keys;
  117168. private _ctrlPressed;
  117169. private _altPressed;
  117170. private _shiftPressed;
  117171. private _onCanvasBlurObserver;
  117172. private _onKeyboardObserver;
  117173. private _engine;
  117174. private _scene;
  117175. /**
  117176. * Attach the input controls to a specific dom element to get the input from.
  117177. * @param element Defines the element the controls should be listened from
  117178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117179. */
  117180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117181. /**
  117182. * Detach the current controls from the specified dom element.
  117183. * @param element Defines the element to stop listening the inputs from
  117184. */
  117185. detachControl(element: Nullable<HTMLElement>): void;
  117186. /**
  117187. * Update the current camera state depending on the inputs that have been used this frame.
  117188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117189. */
  117190. checkInputs(): void;
  117191. /**
  117192. * Gets the class name of the current input.
  117193. * @returns the class name
  117194. */
  117195. getClassName(): string;
  117196. /**
  117197. * Get the friendly name associated with the input class.
  117198. * @returns the input friendly name
  117199. */
  117200. getSimpleName(): string;
  117201. /**
  117202. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117203. * allow modification of the heightOffset value.
  117204. */
  117205. private _modifierHeightOffset;
  117206. /**
  117207. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117208. * allow modification of the rotationOffset value.
  117209. */
  117210. private _modifierRotationOffset;
  117211. /**
  117212. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117213. * allow modification of the radius value.
  117214. */
  117215. private _modifierRadius;
  117216. }
  117217. }
  117218. declare module BABYLON {
  117219. interface FreeCameraInputsManager {
  117220. /**
  117221. * @hidden
  117222. */
  117223. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  117224. /**
  117225. * Add orientation input support to the input manager.
  117226. * @returns the current input manager
  117227. */
  117228. addDeviceOrientation(): FreeCameraInputsManager;
  117229. }
  117230. /**
  117231. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  117232. * Screen rotation is taken into account.
  117233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117234. */
  117235. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  117236. private _camera;
  117237. private _screenOrientationAngle;
  117238. private _constantTranform;
  117239. private _screenQuaternion;
  117240. private _alpha;
  117241. private _beta;
  117242. private _gamma;
  117243. /**
  117244. * Can be used to detect if a device orientation sensor is available on a device
  117245. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  117246. * @returns a promise that will resolve on orientation change
  117247. */
  117248. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  117249. /**
  117250. * @hidden
  117251. */
  117252. _onDeviceOrientationChangedObservable: Observable<void>;
  117253. /**
  117254. * Instantiates a new input
  117255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117256. */
  117257. constructor();
  117258. /**
  117259. * Define the camera controlled by the input.
  117260. */
  117261. get camera(): FreeCamera;
  117262. set camera(camera: FreeCamera);
  117263. /**
  117264. * Attach the input controls to a specific dom element to get the input from.
  117265. * @param element Defines the element the controls should be listened from
  117266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117267. */
  117268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117269. private _orientationChanged;
  117270. private _deviceOrientation;
  117271. /**
  117272. * Detach the current controls from the specified dom element.
  117273. * @param element Defines the element to stop listening the inputs from
  117274. */
  117275. detachControl(element: Nullable<HTMLElement>): void;
  117276. /**
  117277. * Update the current camera state depending on the inputs that have been used this frame.
  117278. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117279. */
  117280. checkInputs(): void;
  117281. /**
  117282. * Gets the class name of the current intput.
  117283. * @returns the class name
  117284. */
  117285. getClassName(): string;
  117286. /**
  117287. * Get the friendly name associated with the input class.
  117288. * @returns the input friendly name
  117289. */
  117290. getSimpleName(): string;
  117291. }
  117292. }
  117293. declare module BABYLON {
  117294. /**
  117295. * Manage the gamepad inputs to control a free camera.
  117296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117297. */
  117298. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  117299. /**
  117300. * Define the camera the input is attached to.
  117301. */
  117302. camera: FreeCamera;
  117303. /**
  117304. * Define the Gamepad controlling the input
  117305. */
  117306. gamepad: Nullable<Gamepad>;
  117307. /**
  117308. * Defines the gamepad rotation sensiblity.
  117309. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117310. */
  117311. gamepadAngularSensibility: number;
  117312. /**
  117313. * Defines the gamepad move sensiblity.
  117314. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117315. */
  117316. gamepadMoveSensibility: number;
  117317. private _yAxisScale;
  117318. /**
  117319. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  117320. */
  117321. get invertYAxis(): boolean;
  117322. set invertYAxis(value: boolean);
  117323. private _onGamepadConnectedObserver;
  117324. private _onGamepadDisconnectedObserver;
  117325. private _cameraTransform;
  117326. private _deltaTransform;
  117327. private _vector3;
  117328. private _vector2;
  117329. /**
  117330. * Attach the input controls to a specific dom element to get the input from.
  117331. * @param element Defines the element the controls should be listened from
  117332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117333. */
  117334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117335. /**
  117336. * Detach the current controls from the specified dom element.
  117337. * @param element Defines the element to stop listening the inputs from
  117338. */
  117339. detachControl(element: Nullable<HTMLElement>): void;
  117340. /**
  117341. * Update the current camera state depending on the inputs that have been used this frame.
  117342. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117343. */
  117344. checkInputs(): void;
  117345. /**
  117346. * Gets the class name of the current intput.
  117347. * @returns the class name
  117348. */
  117349. getClassName(): string;
  117350. /**
  117351. * Get the friendly name associated with the input class.
  117352. * @returns the input friendly name
  117353. */
  117354. getSimpleName(): string;
  117355. }
  117356. }
  117357. declare module BABYLON {
  117358. /**
  117359. * Defines the potential axis of a Joystick
  117360. */
  117361. export enum JoystickAxis {
  117362. /** X axis */
  117363. X = 0,
  117364. /** Y axis */
  117365. Y = 1,
  117366. /** Z axis */
  117367. Z = 2
  117368. }
  117369. /**
  117370. * Class used to define virtual joystick (used in touch mode)
  117371. */
  117372. export class VirtualJoystick {
  117373. /**
  117374. * Gets or sets a boolean indicating that left and right values must be inverted
  117375. */
  117376. reverseLeftRight: boolean;
  117377. /**
  117378. * Gets or sets a boolean indicating that up and down values must be inverted
  117379. */
  117380. reverseUpDown: boolean;
  117381. /**
  117382. * Gets the offset value for the position (ie. the change of the position value)
  117383. */
  117384. deltaPosition: Vector3;
  117385. /**
  117386. * Gets a boolean indicating if the virtual joystick was pressed
  117387. */
  117388. pressed: boolean;
  117389. /**
  117390. * Canvas the virtual joystick will render onto, default z-index of this is 5
  117391. */
  117392. static Canvas: Nullable<HTMLCanvasElement>;
  117393. private static _globalJoystickIndex;
  117394. private static vjCanvasContext;
  117395. private static vjCanvasWidth;
  117396. private static vjCanvasHeight;
  117397. private static halfWidth;
  117398. private _action;
  117399. private _axisTargetedByLeftAndRight;
  117400. private _axisTargetedByUpAndDown;
  117401. private _joystickSensibility;
  117402. private _inversedSensibility;
  117403. private _joystickPointerID;
  117404. private _joystickColor;
  117405. private _joystickPointerPos;
  117406. private _joystickPreviousPointerPos;
  117407. private _joystickPointerStartPos;
  117408. private _deltaJoystickVector;
  117409. private _leftJoystick;
  117410. private _touches;
  117411. private _onPointerDownHandlerRef;
  117412. private _onPointerMoveHandlerRef;
  117413. private _onPointerUpHandlerRef;
  117414. private _onResize;
  117415. /**
  117416. * Creates a new virtual joystick
  117417. * @param leftJoystick defines that the joystick is for left hand (false by default)
  117418. */
  117419. constructor(leftJoystick?: boolean);
  117420. /**
  117421. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  117422. * @param newJoystickSensibility defines the new sensibility
  117423. */
  117424. setJoystickSensibility(newJoystickSensibility: number): void;
  117425. private _onPointerDown;
  117426. private _onPointerMove;
  117427. private _onPointerUp;
  117428. /**
  117429. * Change the color of the virtual joystick
  117430. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  117431. */
  117432. setJoystickColor(newColor: string): void;
  117433. /**
  117434. * Defines a callback to call when the joystick is touched
  117435. * @param action defines the callback
  117436. */
  117437. setActionOnTouch(action: () => any): void;
  117438. /**
  117439. * Defines which axis you'd like to control for left & right
  117440. * @param axis defines the axis to use
  117441. */
  117442. setAxisForLeftRight(axis: JoystickAxis): void;
  117443. /**
  117444. * Defines which axis you'd like to control for up & down
  117445. * @param axis defines the axis to use
  117446. */
  117447. setAxisForUpDown(axis: JoystickAxis): void;
  117448. private _drawVirtualJoystick;
  117449. /**
  117450. * Release internal HTML canvas
  117451. */
  117452. releaseCanvas(): void;
  117453. }
  117454. }
  117455. declare module BABYLON {
  117456. interface FreeCameraInputsManager {
  117457. /**
  117458. * Add virtual joystick input support to the input manager.
  117459. * @returns the current input manager
  117460. */
  117461. addVirtualJoystick(): FreeCameraInputsManager;
  117462. }
  117463. /**
  117464. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  117465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117466. */
  117467. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  117468. /**
  117469. * Defines the camera the input is attached to.
  117470. */
  117471. camera: FreeCamera;
  117472. private _leftjoystick;
  117473. private _rightjoystick;
  117474. /**
  117475. * Gets the left stick of the virtual joystick.
  117476. * @returns The virtual Joystick
  117477. */
  117478. getLeftJoystick(): VirtualJoystick;
  117479. /**
  117480. * Gets the right stick of the virtual joystick.
  117481. * @returns The virtual Joystick
  117482. */
  117483. getRightJoystick(): VirtualJoystick;
  117484. /**
  117485. * Update the current camera state depending on the inputs that have been used this frame.
  117486. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117487. */
  117488. checkInputs(): void;
  117489. /**
  117490. * Attach the input controls to a specific dom element to get the input from.
  117491. * @param element Defines the element the controls should be listened from
  117492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117493. */
  117494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117495. /**
  117496. * Detach the current controls from the specified dom element.
  117497. * @param element Defines the element to stop listening the inputs from
  117498. */
  117499. detachControl(element: Nullable<HTMLElement>): void;
  117500. /**
  117501. * Gets the class name of the current intput.
  117502. * @returns the class name
  117503. */
  117504. getClassName(): string;
  117505. /**
  117506. * Get the friendly name associated with the input class.
  117507. * @returns the input friendly name
  117508. */
  117509. getSimpleName(): string;
  117510. }
  117511. }
  117512. declare module BABYLON {
  117513. /**
  117514. * This represents a FPS type of camera controlled by touch.
  117515. * This is like a universal camera minus the Gamepad controls.
  117516. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117517. */
  117518. export class TouchCamera extends FreeCamera {
  117519. /**
  117520. * Defines the touch sensibility for rotation.
  117521. * The higher the faster.
  117522. */
  117523. get touchAngularSensibility(): number;
  117524. set touchAngularSensibility(value: number);
  117525. /**
  117526. * Defines the touch sensibility for move.
  117527. * The higher the faster.
  117528. */
  117529. get touchMoveSensibility(): number;
  117530. set touchMoveSensibility(value: number);
  117531. /**
  117532. * Instantiates a new touch camera.
  117533. * This represents a FPS type of camera controlled by touch.
  117534. * This is like a universal camera minus the Gamepad controls.
  117535. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117536. * @param name Define the name of the camera in the scene
  117537. * @param position Define the start position of the camera in the scene
  117538. * @param scene Define the scene the camera belongs to
  117539. */
  117540. constructor(name: string, position: Vector3, scene: Scene);
  117541. /**
  117542. * Gets the current object class name.
  117543. * @return the class name
  117544. */
  117545. getClassName(): string;
  117546. /** @hidden */
  117547. _setupInputs(): void;
  117548. }
  117549. }
  117550. declare module BABYLON {
  117551. /**
  117552. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  117553. * being tilted forward or back and left or right.
  117554. */
  117555. export class DeviceOrientationCamera extends FreeCamera {
  117556. private _initialQuaternion;
  117557. private _quaternionCache;
  117558. private _tmpDragQuaternion;
  117559. private _disablePointerInputWhenUsingDeviceOrientation;
  117560. /**
  117561. * Creates a new device orientation camera
  117562. * @param name The name of the camera
  117563. * @param position The start position camera
  117564. * @param scene The scene the camera belongs to
  117565. */
  117566. constructor(name: string, position: Vector3, scene: Scene);
  117567. /**
  117568. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  117569. */
  117570. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  117571. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  117572. private _dragFactor;
  117573. /**
  117574. * Enabled turning on the y axis when the orientation sensor is active
  117575. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  117576. */
  117577. enableHorizontalDragging(dragFactor?: number): void;
  117578. /**
  117579. * Gets the current instance class name ("DeviceOrientationCamera").
  117580. * This helps avoiding instanceof at run time.
  117581. * @returns the class name
  117582. */
  117583. getClassName(): string;
  117584. /**
  117585. * @hidden
  117586. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  117587. */
  117588. _checkInputs(): void;
  117589. /**
  117590. * Reset the camera to its default orientation on the specified axis only.
  117591. * @param axis The axis to reset
  117592. */
  117593. resetToCurrentRotation(axis?: Axis): void;
  117594. }
  117595. }
  117596. declare module BABYLON {
  117597. /**
  117598. * Defines supported buttons for XBox360 compatible gamepads
  117599. */
  117600. export enum Xbox360Button {
  117601. /** A */
  117602. A = 0,
  117603. /** B */
  117604. B = 1,
  117605. /** X */
  117606. X = 2,
  117607. /** Y */
  117608. Y = 3,
  117609. /** Left button */
  117610. LB = 4,
  117611. /** Right button */
  117612. RB = 5,
  117613. /** Back */
  117614. Back = 8,
  117615. /** Start */
  117616. Start = 9,
  117617. /** Left stick */
  117618. LeftStick = 10,
  117619. /** Right stick */
  117620. RightStick = 11
  117621. }
  117622. /** Defines values for XBox360 DPad */
  117623. export enum Xbox360Dpad {
  117624. /** Up */
  117625. Up = 12,
  117626. /** Down */
  117627. Down = 13,
  117628. /** Left */
  117629. Left = 14,
  117630. /** Right */
  117631. Right = 15
  117632. }
  117633. /**
  117634. * Defines a XBox360 gamepad
  117635. */
  117636. export class Xbox360Pad extends Gamepad {
  117637. private _leftTrigger;
  117638. private _rightTrigger;
  117639. private _onlefttriggerchanged;
  117640. private _onrighttriggerchanged;
  117641. private _onbuttondown;
  117642. private _onbuttonup;
  117643. private _ondpaddown;
  117644. private _ondpadup;
  117645. /** Observable raised when a button is pressed */
  117646. onButtonDownObservable: Observable<Xbox360Button>;
  117647. /** Observable raised when a button is released */
  117648. onButtonUpObservable: Observable<Xbox360Button>;
  117649. /** Observable raised when a pad is pressed */
  117650. onPadDownObservable: Observable<Xbox360Dpad>;
  117651. /** Observable raised when a pad is released */
  117652. onPadUpObservable: Observable<Xbox360Dpad>;
  117653. private _buttonA;
  117654. private _buttonB;
  117655. private _buttonX;
  117656. private _buttonY;
  117657. private _buttonBack;
  117658. private _buttonStart;
  117659. private _buttonLB;
  117660. private _buttonRB;
  117661. private _buttonLeftStick;
  117662. private _buttonRightStick;
  117663. private _dPadUp;
  117664. private _dPadDown;
  117665. private _dPadLeft;
  117666. private _dPadRight;
  117667. private _isXboxOnePad;
  117668. /**
  117669. * Creates a new XBox360 gamepad object
  117670. * @param id defines the id of this gamepad
  117671. * @param index defines its index
  117672. * @param gamepad defines the internal HTML gamepad object
  117673. * @param xboxOne defines if it is a XBox One gamepad
  117674. */
  117675. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  117676. /**
  117677. * Defines the callback to call when left trigger is pressed
  117678. * @param callback defines the callback to use
  117679. */
  117680. onlefttriggerchanged(callback: (value: number) => void): void;
  117681. /**
  117682. * Defines the callback to call when right trigger is pressed
  117683. * @param callback defines the callback to use
  117684. */
  117685. onrighttriggerchanged(callback: (value: number) => void): void;
  117686. /**
  117687. * Gets the left trigger value
  117688. */
  117689. get leftTrigger(): number;
  117690. /**
  117691. * Sets the left trigger value
  117692. */
  117693. set leftTrigger(newValue: number);
  117694. /**
  117695. * Gets the right trigger value
  117696. */
  117697. get rightTrigger(): number;
  117698. /**
  117699. * Sets the right trigger value
  117700. */
  117701. set rightTrigger(newValue: number);
  117702. /**
  117703. * Defines the callback to call when a button is pressed
  117704. * @param callback defines the callback to use
  117705. */
  117706. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  117707. /**
  117708. * Defines the callback to call when a button is released
  117709. * @param callback defines the callback to use
  117710. */
  117711. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  117712. /**
  117713. * Defines the callback to call when a pad is pressed
  117714. * @param callback defines the callback to use
  117715. */
  117716. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  117717. /**
  117718. * Defines the callback to call when a pad is released
  117719. * @param callback defines the callback to use
  117720. */
  117721. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  117722. private _setButtonValue;
  117723. private _setDPadValue;
  117724. /**
  117725. * Gets the value of the `A` button
  117726. */
  117727. get buttonA(): number;
  117728. /**
  117729. * Sets the value of the `A` button
  117730. */
  117731. set buttonA(value: number);
  117732. /**
  117733. * Gets the value of the `B` button
  117734. */
  117735. get buttonB(): number;
  117736. /**
  117737. * Sets the value of the `B` button
  117738. */
  117739. set buttonB(value: number);
  117740. /**
  117741. * Gets the value of the `X` button
  117742. */
  117743. get buttonX(): number;
  117744. /**
  117745. * Sets the value of the `X` button
  117746. */
  117747. set buttonX(value: number);
  117748. /**
  117749. * Gets the value of the `Y` button
  117750. */
  117751. get buttonY(): number;
  117752. /**
  117753. * Sets the value of the `Y` button
  117754. */
  117755. set buttonY(value: number);
  117756. /**
  117757. * Gets the value of the `Start` button
  117758. */
  117759. get buttonStart(): number;
  117760. /**
  117761. * Sets the value of the `Start` button
  117762. */
  117763. set buttonStart(value: number);
  117764. /**
  117765. * Gets the value of the `Back` button
  117766. */
  117767. get buttonBack(): number;
  117768. /**
  117769. * Sets the value of the `Back` button
  117770. */
  117771. set buttonBack(value: number);
  117772. /**
  117773. * Gets the value of the `Left` button
  117774. */
  117775. get buttonLB(): number;
  117776. /**
  117777. * Sets the value of the `Left` button
  117778. */
  117779. set buttonLB(value: number);
  117780. /**
  117781. * Gets the value of the `Right` button
  117782. */
  117783. get buttonRB(): number;
  117784. /**
  117785. * Sets the value of the `Right` button
  117786. */
  117787. set buttonRB(value: number);
  117788. /**
  117789. * Gets the value of the Left joystick
  117790. */
  117791. get buttonLeftStick(): number;
  117792. /**
  117793. * Sets the value of the Left joystick
  117794. */
  117795. set buttonLeftStick(value: number);
  117796. /**
  117797. * Gets the value of the Right joystick
  117798. */
  117799. get buttonRightStick(): number;
  117800. /**
  117801. * Sets the value of the Right joystick
  117802. */
  117803. set buttonRightStick(value: number);
  117804. /**
  117805. * Gets the value of D-pad up
  117806. */
  117807. get dPadUp(): number;
  117808. /**
  117809. * Sets the value of D-pad up
  117810. */
  117811. set dPadUp(value: number);
  117812. /**
  117813. * Gets the value of D-pad down
  117814. */
  117815. get dPadDown(): number;
  117816. /**
  117817. * Sets the value of D-pad down
  117818. */
  117819. set dPadDown(value: number);
  117820. /**
  117821. * Gets the value of D-pad left
  117822. */
  117823. get dPadLeft(): number;
  117824. /**
  117825. * Sets the value of D-pad left
  117826. */
  117827. set dPadLeft(value: number);
  117828. /**
  117829. * Gets the value of D-pad right
  117830. */
  117831. get dPadRight(): number;
  117832. /**
  117833. * Sets the value of D-pad right
  117834. */
  117835. set dPadRight(value: number);
  117836. /**
  117837. * Force the gamepad to synchronize with device values
  117838. */
  117839. update(): void;
  117840. /**
  117841. * Disposes the gamepad
  117842. */
  117843. dispose(): void;
  117844. }
  117845. }
  117846. declare module BABYLON {
  117847. /**
  117848. * Defines supported buttons for DualShock compatible gamepads
  117849. */
  117850. export enum DualShockButton {
  117851. /** Cross */
  117852. Cross = 0,
  117853. /** Circle */
  117854. Circle = 1,
  117855. /** Square */
  117856. Square = 2,
  117857. /** Triangle */
  117858. Triangle = 3,
  117859. /** L1 */
  117860. L1 = 4,
  117861. /** R1 */
  117862. R1 = 5,
  117863. /** Share */
  117864. Share = 8,
  117865. /** Options */
  117866. Options = 9,
  117867. /** Left stick */
  117868. LeftStick = 10,
  117869. /** Right stick */
  117870. RightStick = 11
  117871. }
  117872. /** Defines values for DualShock DPad */
  117873. export enum DualShockDpad {
  117874. /** Up */
  117875. Up = 12,
  117876. /** Down */
  117877. Down = 13,
  117878. /** Left */
  117879. Left = 14,
  117880. /** Right */
  117881. Right = 15
  117882. }
  117883. /**
  117884. * Defines a DualShock gamepad
  117885. */
  117886. export class DualShockPad extends Gamepad {
  117887. private _leftTrigger;
  117888. private _rightTrigger;
  117889. private _onlefttriggerchanged;
  117890. private _onrighttriggerchanged;
  117891. private _onbuttondown;
  117892. private _onbuttonup;
  117893. private _ondpaddown;
  117894. private _ondpadup;
  117895. /** Observable raised when a button is pressed */
  117896. onButtonDownObservable: Observable<DualShockButton>;
  117897. /** Observable raised when a button is released */
  117898. onButtonUpObservable: Observable<DualShockButton>;
  117899. /** Observable raised when a pad is pressed */
  117900. onPadDownObservable: Observable<DualShockDpad>;
  117901. /** Observable raised when a pad is released */
  117902. onPadUpObservable: Observable<DualShockDpad>;
  117903. private _buttonCross;
  117904. private _buttonCircle;
  117905. private _buttonSquare;
  117906. private _buttonTriangle;
  117907. private _buttonShare;
  117908. private _buttonOptions;
  117909. private _buttonL1;
  117910. private _buttonR1;
  117911. private _buttonLeftStick;
  117912. private _buttonRightStick;
  117913. private _dPadUp;
  117914. private _dPadDown;
  117915. private _dPadLeft;
  117916. private _dPadRight;
  117917. /**
  117918. * Creates a new DualShock gamepad object
  117919. * @param id defines the id of this gamepad
  117920. * @param index defines its index
  117921. * @param gamepad defines the internal HTML gamepad object
  117922. */
  117923. constructor(id: string, index: number, gamepad: any);
  117924. /**
  117925. * Defines the callback to call when left trigger is pressed
  117926. * @param callback defines the callback to use
  117927. */
  117928. onlefttriggerchanged(callback: (value: number) => void): void;
  117929. /**
  117930. * Defines the callback to call when right trigger is pressed
  117931. * @param callback defines the callback to use
  117932. */
  117933. onrighttriggerchanged(callback: (value: number) => void): void;
  117934. /**
  117935. * Gets the left trigger value
  117936. */
  117937. get leftTrigger(): number;
  117938. /**
  117939. * Sets the left trigger value
  117940. */
  117941. set leftTrigger(newValue: number);
  117942. /**
  117943. * Gets the right trigger value
  117944. */
  117945. get rightTrigger(): number;
  117946. /**
  117947. * Sets the right trigger value
  117948. */
  117949. set rightTrigger(newValue: number);
  117950. /**
  117951. * Defines the callback to call when a button is pressed
  117952. * @param callback defines the callback to use
  117953. */
  117954. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  117955. /**
  117956. * Defines the callback to call when a button is released
  117957. * @param callback defines the callback to use
  117958. */
  117959. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  117960. /**
  117961. * Defines the callback to call when a pad is pressed
  117962. * @param callback defines the callback to use
  117963. */
  117964. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  117965. /**
  117966. * Defines the callback to call when a pad is released
  117967. * @param callback defines the callback to use
  117968. */
  117969. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  117970. private _setButtonValue;
  117971. private _setDPadValue;
  117972. /**
  117973. * Gets the value of the `Cross` button
  117974. */
  117975. get buttonCross(): number;
  117976. /**
  117977. * Sets the value of the `Cross` button
  117978. */
  117979. set buttonCross(value: number);
  117980. /**
  117981. * Gets the value of the `Circle` button
  117982. */
  117983. get buttonCircle(): number;
  117984. /**
  117985. * Sets the value of the `Circle` button
  117986. */
  117987. set buttonCircle(value: number);
  117988. /**
  117989. * Gets the value of the `Square` button
  117990. */
  117991. get buttonSquare(): number;
  117992. /**
  117993. * Sets the value of the `Square` button
  117994. */
  117995. set buttonSquare(value: number);
  117996. /**
  117997. * Gets the value of the `Triangle` button
  117998. */
  117999. get buttonTriangle(): number;
  118000. /**
  118001. * Sets the value of the `Triangle` button
  118002. */
  118003. set buttonTriangle(value: number);
  118004. /**
  118005. * Gets the value of the `Options` button
  118006. */
  118007. get buttonOptions(): number;
  118008. /**
  118009. * Sets the value of the `Options` button
  118010. */
  118011. set buttonOptions(value: number);
  118012. /**
  118013. * Gets the value of the `Share` button
  118014. */
  118015. get buttonShare(): number;
  118016. /**
  118017. * Sets the value of the `Share` button
  118018. */
  118019. set buttonShare(value: number);
  118020. /**
  118021. * Gets the value of the `L1` button
  118022. */
  118023. get buttonL1(): number;
  118024. /**
  118025. * Sets the value of the `L1` button
  118026. */
  118027. set buttonL1(value: number);
  118028. /**
  118029. * Gets the value of the `R1` button
  118030. */
  118031. get buttonR1(): number;
  118032. /**
  118033. * Sets the value of the `R1` button
  118034. */
  118035. set buttonR1(value: number);
  118036. /**
  118037. * Gets the value of the Left joystick
  118038. */
  118039. get buttonLeftStick(): number;
  118040. /**
  118041. * Sets the value of the Left joystick
  118042. */
  118043. set buttonLeftStick(value: number);
  118044. /**
  118045. * Gets the value of the Right joystick
  118046. */
  118047. get buttonRightStick(): number;
  118048. /**
  118049. * Sets the value of the Right joystick
  118050. */
  118051. set buttonRightStick(value: number);
  118052. /**
  118053. * Gets the value of D-pad up
  118054. */
  118055. get dPadUp(): number;
  118056. /**
  118057. * Sets the value of D-pad up
  118058. */
  118059. set dPadUp(value: number);
  118060. /**
  118061. * Gets the value of D-pad down
  118062. */
  118063. get dPadDown(): number;
  118064. /**
  118065. * Sets the value of D-pad down
  118066. */
  118067. set dPadDown(value: number);
  118068. /**
  118069. * Gets the value of D-pad left
  118070. */
  118071. get dPadLeft(): number;
  118072. /**
  118073. * Sets the value of D-pad left
  118074. */
  118075. set dPadLeft(value: number);
  118076. /**
  118077. * Gets the value of D-pad right
  118078. */
  118079. get dPadRight(): number;
  118080. /**
  118081. * Sets the value of D-pad right
  118082. */
  118083. set dPadRight(value: number);
  118084. /**
  118085. * Force the gamepad to synchronize with device values
  118086. */
  118087. update(): void;
  118088. /**
  118089. * Disposes the gamepad
  118090. */
  118091. dispose(): void;
  118092. }
  118093. }
  118094. declare module BABYLON {
  118095. /**
  118096. * Manager for handling gamepads
  118097. */
  118098. export class GamepadManager {
  118099. private _scene?;
  118100. private _babylonGamepads;
  118101. private _oneGamepadConnected;
  118102. /** @hidden */
  118103. _isMonitoring: boolean;
  118104. private _gamepadEventSupported;
  118105. private _gamepadSupport?;
  118106. /**
  118107. * observable to be triggered when the gamepad controller has been connected
  118108. */
  118109. onGamepadConnectedObservable: Observable<Gamepad>;
  118110. /**
  118111. * observable to be triggered when the gamepad controller has been disconnected
  118112. */
  118113. onGamepadDisconnectedObservable: Observable<Gamepad>;
  118114. private _onGamepadConnectedEvent;
  118115. private _onGamepadDisconnectedEvent;
  118116. /**
  118117. * Initializes the gamepad manager
  118118. * @param _scene BabylonJS scene
  118119. */
  118120. constructor(_scene?: Scene | undefined);
  118121. /**
  118122. * The gamepads in the game pad manager
  118123. */
  118124. get gamepads(): Gamepad[];
  118125. /**
  118126. * Get the gamepad controllers based on type
  118127. * @param type The type of gamepad controller
  118128. * @returns Nullable gamepad
  118129. */
  118130. getGamepadByType(type?: number): Nullable<Gamepad>;
  118131. /**
  118132. * Disposes the gamepad manager
  118133. */
  118134. dispose(): void;
  118135. private _addNewGamepad;
  118136. private _startMonitoringGamepads;
  118137. private _stopMonitoringGamepads;
  118138. /** @hidden */
  118139. _checkGamepadsStatus(): void;
  118140. private _updateGamepadObjects;
  118141. }
  118142. }
  118143. declare module BABYLON {
  118144. interface Scene {
  118145. /** @hidden */
  118146. _gamepadManager: Nullable<GamepadManager>;
  118147. /**
  118148. * Gets the gamepad manager associated with the scene
  118149. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  118150. */
  118151. gamepadManager: GamepadManager;
  118152. }
  118153. /**
  118154. * Interface representing a free camera inputs manager
  118155. */
  118156. interface FreeCameraInputsManager {
  118157. /**
  118158. * Adds gamepad input support to the FreeCameraInputsManager.
  118159. * @returns the FreeCameraInputsManager
  118160. */
  118161. addGamepad(): FreeCameraInputsManager;
  118162. }
  118163. /**
  118164. * Interface representing an arc rotate camera inputs manager
  118165. */
  118166. interface ArcRotateCameraInputsManager {
  118167. /**
  118168. * Adds gamepad input support to the ArcRotateCamera InputManager.
  118169. * @returns the camera inputs manager
  118170. */
  118171. addGamepad(): ArcRotateCameraInputsManager;
  118172. }
  118173. /**
  118174. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  118175. */
  118176. export class GamepadSystemSceneComponent implements ISceneComponent {
  118177. /**
  118178. * The component name helpfull to identify the component in the list of scene components.
  118179. */
  118180. readonly name: string;
  118181. /**
  118182. * The scene the component belongs to.
  118183. */
  118184. scene: Scene;
  118185. /**
  118186. * Creates a new instance of the component for the given scene
  118187. * @param scene Defines the scene to register the component in
  118188. */
  118189. constructor(scene: Scene);
  118190. /**
  118191. * Registers the component in a given scene
  118192. */
  118193. register(): void;
  118194. /**
  118195. * Rebuilds the elements related to this component in case of
  118196. * context lost for instance.
  118197. */
  118198. rebuild(): void;
  118199. /**
  118200. * Disposes the component and the associated ressources
  118201. */
  118202. dispose(): void;
  118203. private _beforeCameraUpdate;
  118204. }
  118205. }
  118206. declare module BABYLON {
  118207. /**
  118208. * 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,
  118209. * which still works and will still be found in many Playgrounds.
  118210. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118211. */
  118212. export class UniversalCamera extends TouchCamera {
  118213. /**
  118214. * Defines the gamepad rotation sensiblity.
  118215. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  118216. */
  118217. get gamepadAngularSensibility(): number;
  118218. set gamepadAngularSensibility(value: number);
  118219. /**
  118220. * Defines the gamepad move sensiblity.
  118221. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  118222. */
  118223. get gamepadMoveSensibility(): number;
  118224. set gamepadMoveSensibility(value: number);
  118225. /**
  118226. * 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,
  118227. * which still works and will still be found in many Playgrounds.
  118228. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118229. * @param name Define the name of the camera in the scene
  118230. * @param position Define the start position of the camera in the scene
  118231. * @param scene Define the scene the camera belongs to
  118232. */
  118233. constructor(name: string, position: Vector3, scene: Scene);
  118234. /**
  118235. * Gets the current object class name.
  118236. * @return the class name
  118237. */
  118238. getClassName(): string;
  118239. }
  118240. }
  118241. declare module BABYLON {
  118242. /**
  118243. * This represents a FPS type of camera. This is only here for back compat purpose.
  118244. * Please use the UniversalCamera instead as both are identical.
  118245. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118246. */
  118247. export class GamepadCamera extends UniversalCamera {
  118248. /**
  118249. * Instantiates a new Gamepad Camera
  118250. * This represents a FPS type of camera. This is only here for back compat purpose.
  118251. * Please use the UniversalCamera instead as both are identical.
  118252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118253. * @param name Define the name of the camera in the scene
  118254. * @param position Define the start position of the camera in the scene
  118255. * @param scene Define the scene the camera belongs to
  118256. */
  118257. constructor(name: string, position: Vector3, scene: Scene);
  118258. /**
  118259. * Gets the current object class name.
  118260. * @return the class name
  118261. */
  118262. getClassName(): string;
  118263. }
  118264. }
  118265. declare module BABYLON {
  118266. /** @hidden */
  118267. export var passPixelShader: {
  118268. name: string;
  118269. shader: string;
  118270. };
  118271. }
  118272. declare module BABYLON {
  118273. /** @hidden */
  118274. export var passCubePixelShader: {
  118275. name: string;
  118276. shader: string;
  118277. };
  118278. }
  118279. declare module BABYLON {
  118280. /**
  118281. * PassPostProcess which produces an output the same as it's input
  118282. */
  118283. export class PassPostProcess extends PostProcess {
  118284. /**
  118285. * Creates the PassPostProcess
  118286. * @param name The name of the effect.
  118287. * @param options The required width/height ratio to downsize to before computing the render pass.
  118288. * @param camera The camera to apply the render pass to.
  118289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118290. * @param engine The engine which the post process will be applied. (default: current engine)
  118291. * @param reusable If the post process can be reused on the same frame. (default: false)
  118292. * @param textureType The type of texture to be used when performing the post processing.
  118293. * @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)
  118294. */
  118295. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118296. }
  118297. /**
  118298. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118299. */
  118300. export class PassCubePostProcess extends PostProcess {
  118301. private _face;
  118302. /**
  118303. * Gets or sets the cube face to display.
  118304. * * 0 is +X
  118305. * * 1 is -X
  118306. * * 2 is +Y
  118307. * * 3 is -Y
  118308. * * 4 is +Z
  118309. * * 5 is -Z
  118310. */
  118311. get face(): number;
  118312. set face(value: number);
  118313. /**
  118314. * Creates the PassCubePostProcess
  118315. * @param name The name of the effect.
  118316. * @param options The required width/height ratio to downsize to before computing the render pass.
  118317. * @param camera The camera to apply the render pass to.
  118318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118319. * @param engine The engine which the post process will be applied. (default: current engine)
  118320. * @param reusable If the post process can be reused on the same frame. (default: false)
  118321. * @param textureType The type of texture to be used when performing the post processing.
  118322. * @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)
  118323. */
  118324. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118325. }
  118326. }
  118327. declare module BABYLON {
  118328. /** @hidden */
  118329. export var anaglyphPixelShader: {
  118330. name: string;
  118331. shader: string;
  118332. };
  118333. }
  118334. declare module BABYLON {
  118335. /**
  118336. * Postprocess used to generate anaglyphic rendering
  118337. */
  118338. export class AnaglyphPostProcess extends PostProcess {
  118339. private _passedProcess;
  118340. /**
  118341. * Creates a new AnaglyphPostProcess
  118342. * @param name defines postprocess name
  118343. * @param options defines creation options or target ratio scale
  118344. * @param rigCameras defines cameras using this postprocess
  118345. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  118346. * @param engine defines hosting engine
  118347. * @param reusable defines if the postprocess will be reused multiple times per frame
  118348. */
  118349. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  118350. }
  118351. }
  118352. declare module BABYLON {
  118353. /**
  118354. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  118355. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118356. */
  118357. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  118358. /**
  118359. * Creates a new AnaglyphArcRotateCamera
  118360. * @param name defines camera name
  118361. * @param alpha defines alpha angle (in radians)
  118362. * @param beta defines beta angle (in radians)
  118363. * @param radius defines radius
  118364. * @param target defines camera target
  118365. * @param interaxialDistance defines distance between each color axis
  118366. * @param scene defines the hosting scene
  118367. */
  118368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  118369. /**
  118370. * Gets camera class name
  118371. * @returns AnaglyphArcRotateCamera
  118372. */
  118373. getClassName(): string;
  118374. }
  118375. }
  118376. declare module BABYLON {
  118377. /**
  118378. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  118379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118380. */
  118381. export class AnaglyphFreeCamera extends FreeCamera {
  118382. /**
  118383. * Creates a new AnaglyphFreeCamera
  118384. * @param name defines camera name
  118385. * @param position defines initial position
  118386. * @param interaxialDistance defines distance between each color axis
  118387. * @param scene defines the hosting scene
  118388. */
  118389. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118390. /**
  118391. * Gets camera class name
  118392. * @returns AnaglyphFreeCamera
  118393. */
  118394. getClassName(): string;
  118395. }
  118396. }
  118397. declare module BABYLON {
  118398. /**
  118399. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  118400. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118401. */
  118402. export class AnaglyphGamepadCamera extends GamepadCamera {
  118403. /**
  118404. * Creates a new AnaglyphGamepadCamera
  118405. * @param name defines camera name
  118406. * @param position defines initial position
  118407. * @param interaxialDistance defines distance between each color axis
  118408. * @param scene defines the hosting scene
  118409. */
  118410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118411. /**
  118412. * Gets camera class name
  118413. * @returns AnaglyphGamepadCamera
  118414. */
  118415. getClassName(): string;
  118416. }
  118417. }
  118418. declare module BABYLON {
  118419. /**
  118420. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  118421. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118422. */
  118423. export class AnaglyphUniversalCamera extends UniversalCamera {
  118424. /**
  118425. * Creates a new AnaglyphUniversalCamera
  118426. * @param name defines camera name
  118427. * @param position defines initial position
  118428. * @param interaxialDistance defines distance between each color axis
  118429. * @param scene defines the hosting scene
  118430. */
  118431. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118432. /**
  118433. * Gets camera class name
  118434. * @returns AnaglyphUniversalCamera
  118435. */
  118436. getClassName(): string;
  118437. }
  118438. }
  118439. declare module BABYLON {
  118440. /**
  118441. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  118442. * @see http://doc.babylonjs.com/features/cameras
  118443. */
  118444. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  118445. /**
  118446. * Creates a new StereoscopicArcRotateCamera
  118447. * @param name defines camera name
  118448. * @param alpha defines alpha angle (in radians)
  118449. * @param beta defines beta angle (in radians)
  118450. * @param radius defines radius
  118451. * @param target defines camera target
  118452. * @param interaxialDistance defines distance between each color axis
  118453. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118454. * @param scene defines the hosting scene
  118455. */
  118456. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118457. /**
  118458. * Gets camera class name
  118459. * @returns StereoscopicArcRotateCamera
  118460. */
  118461. getClassName(): string;
  118462. }
  118463. }
  118464. declare module BABYLON {
  118465. /**
  118466. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  118467. * @see http://doc.babylonjs.com/features/cameras
  118468. */
  118469. export class StereoscopicFreeCamera extends FreeCamera {
  118470. /**
  118471. * Creates a new StereoscopicFreeCamera
  118472. * @param name defines camera name
  118473. * @param position defines initial position
  118474. * @param interaxialDistance defines distance between each color axis
  118475. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118476. * @param scene defines the hosting scene
  118477. */
  118478. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118479. /**
  118480. * Gets camera class name
  118481. * @returns StereoscopicFreeCamera
  118482. */
  118483. getClassName(): string;
  118484. }
  118485. }
  118486. declare module BABYLON {
  118487. /**
  118488. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  118489. * @see http://doc.babylonjs.com/features/cameras
  118490. */
  118491. export class StereoscopicGamepadCamera extends GamepadCamera {
  118492. /**
  118493. * Creates a new StereoscopicGamepadCamera
  118494. * @param name defines camera name
  118495. * @param position defines initial position
  118496. * @param interaxialDistance defines distance between each color axis
  118497. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118498. * @param scene defines the hosting scene
  118499. */
  118500. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118501. /**
  118502. * Gets camera class name
  118503. * @returns StereoscopicGamepadCamera
  118504. */
  118505. getClassName(): string;
  118506. }
  118507. }
  118508. declare module BABYLON {
  118509. /**
  118510. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  118511. * @see http://doc.babylonjs.com/features/cameras
  118512. */
  118513. export class StereoscopicUniversalCamera extends UniversalCamera {
  118514. /**
  118515. * Creates a new StereoscopicUniversalCamera
  118516. * @param name defines camera name
  118517. * @param position defines initial position
  118518. * @param interaxialDistance defines distance between each color axis
  118519. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118520. * @param scene defines the hosting scene
  118521. */
  118522. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118523. /**
  118524. * Gets camera class name
  118525. * @returns StereoscopicUniversalCamera
  118526. */
  118527. getClassName(): string;
  118528. }
  118529. }
  118530. declare module BABYLON {
  118531. /**
  118532. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  118533. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118534. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118535. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118536. */
  118537. export class VirtualJoysticksCamera extends FreeCamera {
  118538. /**
  118539. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  118540. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118541. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118542. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118543. * @param name Define the name of the camera in the scene
  118544. * @param position Define the start position of the camera in the scene
  118545. * @param scene Define the scene the camera belongs to
  118546. */
  118547. constructor(name: string, position: Vector3, scene: Scene);
  118548. /**
  118549. * Gets the current object class name.
  118550. * @return the class name
  118551. */
  118552. getClassName(): string;
  118553. }
  118554. }
  118555. declare module BABYLON {
  118556. /**
  118557. * This represents all the required metrics to create a VR camera.
  118558. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  118559. */
  118560. export class VRCameraMetrics {
  118561. /**
  118562. * Define the horizontal resolution off the screen.
  118563. */
  118564. hResolution: number;
  118565. /**
  118566. * Define the vertical resolution off the screen.
  118567. */
  118568. vResolution: number;
  118569. /**
  118570. * Define the horizontal screen size.
  118571. */
  118572. hScreenSize: number;
  118573. /**
  118574. * Define the vertical screen size.
  118575. */
  118576. vScreenSize: number;
  118577. /**
  118578. * Define the vertical screen center position.
  118579. */
  118580. vScreenCenter: number;
  118581. /**
  118582. * Define the distance of the eyes to the screen.
  118583. */
  118584. eyeToScreenDistance: number;
  118585. /**
  118586. * Define the distance between both lenses
  118587. */
  118588. lensSeparationDistance: number;
  118589. /**
  118590. * Define the distance between both viewer's eyes.
  118591. */
  118592. interpupillaryDistance: number;
  118593. /**
  118594. * Define the distortion factor of the VR postprocess.
  118595. * Please, touch with care.
  118596. */
  118597. distortionK: number[];
  118598. /**
  118599. * Define the chromatic aberration correction factors for the VR post process.
  118600. */
  118601. chromaAbCorrection: number[];
  118602. /**
  118603. * Define the scale factor of the post process.
  118604. * The smaller the better but the slower.
  118605. */
  118606. postProcessScaleFactor: number;
  118607. /**
  118608. * Define an offset for the lens center.
  118609. */
  118610. lensCenterOffset: number;
  118611. /**
  118612. * Define if the current vr camera should compensate the distortion of the lense or not.
  118613. */
  118614. compensateDistortion: boolean;
  118615. /**
  118616. * Defines if multiview should be enabled when rendering (Default: false)
  118617. */
  118618. multiviewEnabled: boolean;
  118619. /**
  118620. * Gets the rendering aspect ratio based on the provided resolutions.
  118621. */
  118622. get aspectRatio(): number;
  118623. /**
  118624. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  118625. */
  118626. get aspectRatioFov(): number;
  118627. /**
  118628. * @hidden
  118629. */
  118630. get leftHMatrix(): Matrix;
  118631. /**
  118632. * @hidden
  118633. */
  118634. get rightHMatrix(): Matrix;
  118635. /**
  118636. * @hidden
  118637. */
  118638. get leftPreViewMatrix(): Matrix;
  118639. /**
  118640. * @hidden
  118641. */
  118642. get rightPreViewMatrix(): Matrix;
  118643. /**
  118644. * Get the default VRMetrics based on the most generic setup.
  118645. * @returns the default vr metrics
  118646. */
  118647. static GetDefault(): VRCameraMetrics;
  118648. }
  118649. }
  118650. declare module BABYLON {
  118651. /** @hidden */
  118652. export var vrDistortionCorrectionPixelShader: {
  118653. name: string;
  118654. shader: string;
  118655. };
  118656. }
  118657. declare module BABYLON {
  118658. /**
  118659. * VRDistortionCorrectionPostProcess used for mobile VR
  118660. */
  118661. export class VRDistortionCorrectionPostProcess extends PostProcess {
  118662. private _isRightEye;
  118663. private _distortionFactors;
  118664. private _postProcessScaleFactor;
  118665. private _lensCenterOffset;
  118666. private _scaleIn;
  118667. private _scaleFactor;
  118668. private _lensCenter;
  118669. /**
  118670. * Initializes the VRDistortionCorrectionPostProcess
  118671. * @param name The name of the effect.
  118672. * @param camera The camera to apply the render pass to.
  118673. * @param isRightEye If this is for the right eye distortion
  118674. * @param vrMetrics All the required metrics for the VR camera
  118675. */
  118676. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  118677. }
  118678. }
  118679. declare module BABYLON {
  118680. /**
  118681. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  118682. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118683. */
  118684. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  118685. /**
  118686. * Creates a new VRDeviceOrientationArcRotateCamera
  118687. * @param name defines camera name
  118688. * @param alpha defines the camera rotation along the logitudinal axis
  118689. * @param beta defines the camera rotation along the latitudinal axis
  118690. * @param radius defines the camera distance from its target
  118691. * @param target defines the camera target
  118692. * @param scene defines the scene the camera belongs to
  118693. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118694. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118695. */
  118696. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118697. /**
  118698. * Gets camera class name
  118699. * @returns VRDeviceOrientationArcRotateCamera
  118700. */
  118701. getClassName(): string;
  118702. }
  118703. }
  118704. declare module BABYLON {
  118705. /**
  118706. * Camera used to simulate VR rendering (based on FreeCamera)
  118707. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118708. */
  118709. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  118710. /**
  118711. * Creates a new VRDeviceOrientationFreeCamera
  118712. * @param name defines camera name
  118713. * @param position defines the start position of the camera
  118714. * @param scene defines the scene the camera belongs to
  118715. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118716. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118717. */
  118718. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118719. /**
  118720. * Gets camera class name
  118721. * @returns VRDeviceOrientationFreeCamera
  118722. */
  118723. getClassName(): string;
  118724. }
  118725. }
  118726. declare module BABYLON {
  118727. /**
  118728. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  118729. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118730. */
  118731. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  118732. /**
  118733. * Creates a new VRDeviceOrientationGamepadCamera
  118734. * @param name defines camera name
  118735. * @param position defines the start position of the camera
  118736. * @param scene defines the scene the camera belongs to
  118737. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118738. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118739. */
  118740. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118741. /**
  118742. * Gets camera class name
  118743. * @returns VRDeviceOrientationGamepadCamera
  118744. */
  118745. getClassName(): string;
  118746. }
  118747. }
  118748. declare module BABYLON {
  118749. /** @hidden */
  118750. export var imageProcessingPixelShader: {
  118751. name: string;
  118752. shader: string;
  118753. };
  118754. }
  118755. declare module BABYLON {
  118756. /**
  118757. * ImageProcessingPostProcess
  118758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  118759. */
  118760. export class ImageProcessingPostProcess extends PostProcess {
  118761. /**
  118762. * Default configuration related to image processing available in the PBR Material.
  118763. */
  118764. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118765. /**
  118766. * Gets the image processing configuration used either in this material.
  118767. */
  118768. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118769. /**
  118770. * Sets the Default image processing configuration used either in the this material.
  118771. *
  118772. * If sets to null, the scene one is in use.
  118773. */
  118774. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  118775. /**
  118776. * Keep track of the image processing observer to allow dispose and replace.
  118777. */
  118778. private _imageProcessingObserver;
  118779. /**
  118780. * Attaches a new image processing configuration to the PBR Material.
  118781. * @param configuration
  118782. */
  118783. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  118784. /**
  118785. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118786. */
  118787. get colorCurves(): Nullable<ColorCurves>;
  118788. /**
  118789. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118790. */
  118791. set colorCurves(value: Nullable<ColorCurves>);
  118792. /**
  118793. * Gets wether the color curves effect is enabled.
  118794. */
  118795. get colorCurvesEnabled(): boolean;
  118796. /**
  118797. * Sets wether the color curves effect is enabled.
  118798. */
  118799. set colorCurvesEnabled(value: boolean);
  118800. /**
  118801. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118802. */
  118803. get colorGradingTexture(): Nullable<BaseTexture>;
  118804. /**
  118805. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118806. */
  118807. set colorGradingTexture(value: Nullable<BaseTexture>);
  118808. /**
  118809. * Gets wether the color grading effect is enabled.
  118810. */
  118811. get colorGradingEnabled(): boolean;
  118812. /**
  118813. * Gets wether the color grading effect is enabled.
  118814. */
  118815. set colorGradingEnabled(value: boolean);
  118816. /**
  118817. * Gets exposure used in the effect.
  118818. */
  118819. get exposure(): number;
  118820. /**
  118821. * Sets exposure used in the effect.
  118822. */
  118823. set exposure(value: number);
  118824. /**
  118825. * Gets wether tonemapping is enabled or not.
  118826. */
  118827. get toneMappingEnabled(): boolean;
  118828. /**
  118829. * Sets wether tonemapping is enabled or not
  118830. */
  118831. set toneMappingEnabled(value: boolean);
  118832. /**
  118833. * Gets the type of tone mapping effect.
  118834. */
  118835. get toneMappingType(): number;
  118836. /**
  118837. * Sets the type of tone mapping effect.
  118838. */
  118839. set toneMappingType(value: number);
  118840. /**
  118841. * Gets contrast used in the effect.
  118842. */
  118843. get contrast(): number;
  118844. /**
  118845. * Sets contrast used in the effect.
  118846. */
  118847. set contrast(value: number);
  118848. /**
  118849. * Gets Vignette stretch size.
  118850. */
  118851. get vignetteStretch(): number;
  118852. /**
  118853. * Sets Vignette stretch size.
  118854. */
  118855. set vignetteStretch(value: number);
  118856. /**
  118857. * Gets Vignette centre X Offset.
  118858. */
  118859. get vignetteCentreX(): number;
  118860. /**
  118861. * Sets Vignette centre X Offset.
  118862. */
  118863. set vignetteCentreX(value: number);
  118864. /**
  118865. * Gets Vignette centre Y Offset.
  118866. */
  118867. get vignetteCentreY(): number;
  118868. /**
  118869. * Sets Vignette centre Y Offset.
  118870. */
  118871. set vignetteCentreY(value: number);
  118872. /**
  118873. * Gets Vignette weight or intensity of the vignette effect.
  118874. */
  118875. get vignetteWeight(): number;
  118876. /**
  118877. * Sets Vignette weight or intensity of the vignette effect.
  118878. */
  118879. set vignetteWeight(value: number);
  118880. /**
  118881. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118882. * if vignetteEnabled is set to true.
  118883. */
  118884. get vignetteColor(): Color4;
  118885. /**
  118886. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118887. * if vignetteEnabled is set to true.
  118888. */
  118889. set vignetteColor(value: Color4);
  118890. /**
  118891. * Gets Camera field of view used by the Vignette effect.
  118892. */
  118893. get vignetteCameraFov(): number;
  118894. /**
  118895. * Sets Camera field of view used by the Vignette effect.
  118896. */
  118897. set vignetteCameraFov(value: number);
  118898. /**
  118899. * Gets the vignette blend mode allowing different kind of effect.
  118900. */
  118901. get vignetteBlendMode(): number;
  118902. /**
  118903. * Sets the vignette blend mode allowing different kind of effect.
  118904. */
  118905. set vignetteBlendMode(value: number);
  118906. /**
  118907. * Gets wether the vignette effect is enabled.
  118908. */
  118909. get vignetteEnabled(): boolean;
  118910. /**
  118911. * Sets wether the vignette effect is enabled.
  118912. */
  118913. set vignetteEnabled(value: boolean);
  118914. private _fromLinearSpace;
  118915. /**
  118916. * Gets wether the input of the processing is in Gamma or Linear Space.
  118917. */
  118918. get fromLinearSpace(): boolean;
  118919. /**
  118920. * Sets wether the input of the processing is in Gamma or Linear Space.
  118921. */
  118922. set fromLinearSpace(value: boolean);
  118923. /**
  118924. * Defines cache preventing GC.
  118925. */
  118926. private _defines;
  118927. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  118928. /**
  118929. * "ImageProcessingPostProcess"
  118930. * @returns "ImageProcessingPostProcess"
  118931. */
  118932. getClassName(): string;
  118933. protected _updateParameters(): void;
  118934. dispose(camera?: Camera): void;
  118935. }
  118936. }
  118937. declare module BABYLON {
  118938. /**
  118939. * Class containing static functions to help procedurally build meshes
  118940. */
  118941. export class GroundBuilder {
  118942. /**
  118943. * Creates a ground mesh
  118944. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118945. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118947. * @param name defines the name of the mesh
  118948. * @param options defines the options used to create the mesh
  118949. * @param scene defines the hosting scene
  118950. * @returns the ground mesh
  118951. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118952. */
  118953. static CreateGround(name: string, options: {
  118954. width?: number;
  118955. height?: number;
  118956. subdivisions?: number;
  118957. subdivisionsX?: number;
  118958. subdivisionsY?: number;
  118959. updatable?: boolean;
  118960. }, scene: any): Mesh;
  118961. /**
  118962. * Creates a tiled ground mesh
  118963. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118964. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118965. * * 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
  118966. * * 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
  118967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118968. * @param name defines the name of the mesh
  118969. * @param options defines the options used to create the mesh
  118970. * @param scene defines the hosting scene
  118971. * @returns the tiled ground mesh
  118972. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118973. */
  118974. static CreateTiledGround(name: string, options: {
  118975. xmin: number;
  118976. zmin: number;
  118977. xmax: number;
  118978. zmax: number;
  118979. subdivisions?: {
  118980. w: number;
  118981. h: number;
  118982. };
  118983. precision?: {
  118984. w: number;
  118985. h: number;
  118986. };
  118987. updatable?: boolean;
  118988. }, scene?: Nullable<Scene>): Mesh;
  118989. /**
  118990. * Creates a ground mesh from a height map
  118991. * * The parameter `url` sets the URL of the height map image resource.
  118992. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118993. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118994. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118995. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118996. * * 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.
  118997. * * 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).
  118998. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119000. * @param name defines the name of the mesh
  119001. * @param url defines the url to the height map
  119002. * @param options defines the options used to create the mesh
  119003. * @param scene defines the hosting scene
  119004. * @returns the ground mesh
  119005. * @see https://doc.babylonjs.com/babylon101/height_map
  119006. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  119007. */
  119008. static CreateGroundFromHeightMap(name: string, url: string, options: {
  119009. width?: number;
  119010. height?: number;
  119011. subdivisions?: number;
  119012. minHeight?: number;
  119013. maxHeight?: number;
  119014. colorFilter?: Color3;
  119015. alphaFilter?: number;
  119016. updatable?: boolean;
  119017. onReady?: (mesh: GroundMesh) => void;
  119018. }, scene?: Nullable<Scene>): GroundMesh;
  119019. }
  119020. }
  119021. declare module BABYLON {
  119022. /**
  119023. * Class containing static functions to help procedurally build meshes
  119024. */
  119025. export class TorusBuilder {
  119026. /**
  119027. * Creates a torus mesh
  119028. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  119029. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  119030. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  119031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119032. * * 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
  119033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119034. * @param name defines the name of the mesh
  119035. * @param options defines the options used to create the mesh
  119036. * @param scene defines the hosting scene
  119037. * @returns the torus mesh
  119038. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  119039. */
  119040. static CreateTorus(name: string, options: {
  119041. diameter?: number;
  119042. thickness?: number;
  119043. tessellation?: number;
  119044. updatable?: boolean;
  119045. sideOrientation?: number;
  119046. frontUVs?: Vector4;
  119047. backUVs?: Vector4;
  119048. }, scene: any): Mesh;
  119049. }
  119050. }
  119051. declare module BABYLON {
  119052. /**
  119053. * Class containing static functions to help procedurally build meshes
  119054. */
  119055. export class CylinderBuilder {
  119056. /**
  119057. * Creates a cylinder or a cone mesh
  119058. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  119059. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119060. * * 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.
  119061. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119062. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119063. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119064. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119065. * * 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).
  119066. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119067. * * 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).
  119068. * * 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
  119069. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119070. * * 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
  119071. * * 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.
  119072. * * If `enclose` is false, a ring surface is one element.
  119073. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119074. * * 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
  119075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119076. * * 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
  119077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119078. * @param name defines the name of the mesh
  119079. * @param options defines the options used to create the mesh
  119080. * @param scene defines the hosting scene
  119081. * @returns the cylinder mesh
  119082. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119083. */
  119084. static CreateCylinder(name: string, options: {
  119085. height?: number;
  119086. diameterTop?: number;
  119087. diameterBottom?: number;
  119088. diameter?: number;
  119089. tessellation?: number;
  119090. subdivisions?: number;
  119091. arc?: number;
  119092. faceColors?: Color4[];
  119093. faceUV?: Vector4[];
  119094. updatable?: boolean;
  119095. hasRings?: boolean;
  119096. enclose?: boolean;
  119097. cap?: number;
  119098. sideOrientation?: number;
  119099. frontUVs?: Vector4;
  119100. backUVs?: Vector4;
  119101. }, scene: any): Mesh;
  119102. }
  119103. }
  119104. declare module BABYLON {
  119105. /**
  119106. * States of the webXR experience
  119107. */
  119108. export enum WebXRState {
  119109. /**
  119110. * Transitioning to being in XR mode
  119111. */
  119112. ENTERING_XR = 0,
  119113. /**
  119114. * Transitioning to non XR mode
  119115. */
  119116. EXITING_XR = 1,
  119117. /**
  119118. * In XR mode and presenting
  119119. */
  119120. IN_XR = 2,
  119121. /**
  119122. * Not entered XR mode
  119123. */
  119124. NOT_IN_XR = 3
  119125. }
  119126. /**
  119127. * Abstraction of the XR render target
  119128. */
  119129. export interface WebXRRenderTarget extends IDisposable {
  119130. /**
  119131. * xrpresent context of the canvas which can be used to display/mirror xr content
  119132. */
  119133. canvasContext: WebGLRenderingContext;
  119134. /**
  119135. * xr layer for the canvas
  119136. */
  119137. xrLayer: Nullable<XRWebGLLayer>;
  119138. /**
  119139. * Initializes the xr layer for the session
  119140. * @param xrSession xr session
  119141. * @returns a promise that will resolve once the XR Layer has been created
  119142. */
  119143. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  119144. }
  119145. }
  119146. declare module BABYLON {
  119147. /**
  119148. * COnfiguration object for WebXR output canvas
  119149. */
  119150. export class WebXRManagedOutputCanvasOptions {
  119151. /**
  119152. * An optional canvas in case you wish to create it yourself and provide it here.
  119153. * If not provided, a new canvas will be created
  119154. */
  119155. canvasElement?: HTMLCanvasElement;
  119156. /**
  119157. * Options for this XR Layer output
  119158. */
  119159. canvasOptions?: XRWebGLLayerOptions;
  119160. /**
  119161. * CSS styling for a newly created canvas (if not provided)
  119162. */
  119163. newCanvasCssStyle?: string;
  119164. /**
  119165. * Get the default values of the configuration object
  119166. * @returns default values of this configuration object
  119167. */
  119168. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  119169. }
  119170. /**
  119171. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  119172. */
  119173. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  119174. private _options;
  119175. private _canvas;
  119176. private _engine;
  119177. /**
  119178. * Rendering context of the canvas which can be used to display/mirror xr content
  119179. */
  119180. canvasContext: WebGLRenderingContext;
  119181. /**
  119182. * xr layer for the canvas
  119183. */
  119184. xrLayer: Nullable<XRWebGLLayer>;
  119185. /**
  119186. * Initializes the canvas to be added/removed upon entering/exiting xr
  119187. * @param _xrSessionManager The XR Session manager
  119188. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  119189. */
  119190. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  119191. /**
  119192. * Disposes of the object
  119193. */
  119194. dispose(): void;
  119195. /**
  119196. * Initializes the xr layer for the session
  119197. * @param xrSession xr session
  119198. * @returns a promise that will resolve once the XR Layer has been created
  119199. */
  119200. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  119201. private _addCanvas;
  119202. private _removeCanvas;
  119203. private _setManagedOutputCanvas;
  119204. }
  119205. }
  119206. declare module BABYLON {
  119207. /**
  119208. * Manages an XRSession to work with Babylon's engine
  119209. * @see https://doc.babylonjs.com/how_to/webxr
  119210. */
  119211. export class WebXRSessionManager implements IDisposable {
  119212. /** The scene which the session should be created for */
  119213. scene: Scene;
  119214. private _referenceSpace;
  119215. private _rttProvider;
  119216. private _sessionEnded;
  119217. private _xrNavigator;
  119218. private baseLayer;
  119219. /**
  119220. * The base reference space from which the session started. good if you want to reset your
  119221. * reference space
  119222. */
  119223. baseReferenceSpace: XRReferenceSpace;
  119224. /**
  119225. * Current XR frame
  119226. */
  119227. currentFrame: Nullable<XRFrame>;
  119228. /** WebXR timestamp updated every frame */
  119229. currentTimestamp: number;
  119230. /**
  119231. * Used just in case of a failure to initialize an immersive session.
  119232. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  119233. */
  119234. defaultHeightCompensation: number;
  119235. /**
  119236. * Fires every time a new xrFrame arrives which can be used to update the camera
  119237. */
  119238. onXRFrameObservable: Observable<XRFrame>;
  119239. /**
  119240. * Fires when the reference space changed
  119241. */
  119242. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  119243. /**
  119244. * Fires when the xr session is ended either by the device or manually done
  119245. */
  119246. onXRSessionEnded: Observable<any>;
  119247. /**
  119248. * Fires when the xr session is ended either by the device or manually done
  119249. */
  119250. onXRSessionInit: Observable<XRSession>;
  119251. /**
  119252. * Underlying xr session
  119253. */
  119254. session: XRSession;
  119255. /**
  119256. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  119257. * or get the offset the player is currently at.
  119258. */
  119259. viewerReferenceSpace: XRReferenceSpace;
  119260. /**
  119261. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  119262. * @param scene The scene which the session should be created for
  119263. */
  119264. constructor(
  119265. /** The scene which the session should be created for */
  119266. scene: Scene);
  119267. /**
  119268. * The current reference space used in this session. This reference space can constantly change!
  119269. * It is mainly used to offset the camera's position.
  119270. */
  119271. get referenceSpace(): XRReferenceSpace;
  119272. /**
  119273. * Set a new reference space and triggers the observable
  119274. */
  119275. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  119276. /**
  119277. * Disposes of the session manager
  119278. */
  119279. dispose(): void;
  119280. /**
  119281. * Stops the xrSession and restores the render loop
  119282. * @returns Promise which resolves after it exits XR
  119283. */
  119284. exitXRAsync(): Promise<void>;
  119285. /**
  119286. * Gets the correct render target texture to be rendered this frame for this eye
  119287. * @param eye the eye for which to get the render target
  119288. * @returns the render target for the specified eye
  119289. */
  119290. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  119291. /**
  119292. * Creates a WebXRRenderTarget object for the XR session
  119293. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  119294. * @param options optional options to provide when creating a new render target
  119295. * @returns a WebXR render target to which the session can render
  119296. */
  119297. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  119298. /**
  119299. * Initializes the manager
  119300. * After initialization enterXR can be called to start an XR session
  119301. * @returns Promise which resolves after it is initialized
  119302. */
  119303. initializeAsync(): Promise<void>;
  119304. /**
  119305. * Initializes an xr session
  119306. * @param xrSessionMode mode to initialize
  119307. * @param xrSessionInit defines optional and required values to pass to the session builder
  119308. * @returns a promise which will resolve once the session has been initialized
  119309. */
  119310. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  119311. /**
  119312. * Checks if a session would be supported for the creation options specified
  119313. * @param sessionMode session mode to check if supported eg. immersive-vr
  119314. * @returns A Promise that resolves to true if supported and false if not
  119315. */
  119316. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119317. /**
  119318. * Resets the reference space to the one started the session
  119319. */
  119320. resetReferenceSpace(): void;
  119321. /**
  119322. * Starts rendering to the xr layer
  119323. */
  119324. runXRRenderLoop(): void;
  119325. /**
  119326. * Sets the reference space on the xr session
  119327. * @param referenceSpaceType space to set
  119328. * @returns a promise that will resolve once the reference space has been set
  119329. */
  119330. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  119331. /**
  119332. * Updates the render state of the session
  119333. * @param state state to set
  119334. * @returns a promise that resolves once the render state has been updated
  119335. */
  119336. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  119337. /**
  119338. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  119339. * @param sessionMode defines the session to test
  119340. * @returns a promise with boolean as final value
  119341. */
  119342. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119343. private _createRenderTargetTexture;
  119344. }
  119345. }
  119346. declare module BABYLON {
  119347. /**
  119348. * WebXR Camera which holds the views for the xrSession
  119349. * @see https://doc.babylonjs.com/how_to/webxr_camera
  119350. */
  119351. export class WebXRCamera extends FreeCamera {
  119352. private _xrSessionManager;
  119353. private _firstFrame;
  119354. private _referenceQuaternion;
  119355. private _referencedPosition;
  119356. private _xrInvPositionCache;
  119357. private _xrInvQuaternionCache;
  119358. /**
  119359. * Should position compensation execute on first frame.
  119360. * This is used when copying the position from a native (non XR) camera
  119361. */
  119362. compensateOnFirstFrame: boolean;
  119363. /**
  119364. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  119365. * @param name the name of the camera
  119366. * @param scene the scene to add the camera to
  119367. * @param _xrSessionManager a constructed xr session manager
  119368. */
  119369. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  119370. /**
  119371. * Return the user's height, unrelated to the current ground.
  119372. * This will be the y position of this camera, when ground level is 0.
  119373. */
  119374. get realWorldHeight(): number;
  119375. /** @hidden */
  119376. _updateForDualEyeDebugging(): void;
  119377. /**
  119378. * Sets this camera's transformation based on a non-vr camera
  119379. * @param otherCamera the non-vr camera to copy the transformation from
  119380. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  119381. */
  119382. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  119383. /**
  119384. * Gets the current instance class name ("WebXRCamera").
  119385. * @returns the class name
  119386. */
  119387. getClassName(): string;
  119388. private _updateFromXRSession;
  119389. private _updateNumberOfRigCameras;
  119390. private _updateReferenceSpace;
  119391. private _updateReferenceSpaceOffset;
  119392. }
  119393. }
  119394. declare module BABYLON {
  119395. /**
  119396. * Defining the interface required for a (webxr) feature
  119397. */
  119398. export interface IWebXRFeature extends IDisposable {
  119399. /**
  119400. * Is this feature attached
  119401. */
  119402. attached: boolean;
  119403. /**
  119404. * Should auto-attach be disabled?
  119405. */
  119406. disableAutoAttach: boolean;
  119407. /**
  119408. * Attach the feature to the session
  119409. * Will usually be called by the features manager
  119410. *
  119411. * @param force should attachment be forced (even when already attached)
  119412. * @returns true if successful.
  119413. */
  119414. attach(force?: boolean): boolean;
  119415. /**
  119416. * Detach the feature from the session
  119417. * Will usually be called by the features manager
  119418. *
  119419. * @returns true if successful.
  119420. */
  119421. detach(): boolean;
  119422. }
  119423. /**
  119424. * A list of the currently available features without referencing them
  119425. */
  119426. export class WebXRFeatureName {
  119427. /**
  119428. * The name of the anchor system feature
  119429. */
  119430. static ANCHOR_SYSTEM: string;
  119431. /**
  119432. * The name of the background remover feature
  119433. */
  119434. static BACKGROUND_REMOVER: string;
  119435. /**
  119436. * The name of the hit test feature
  119437. */
  119438. static HIT_TEST: string;
  119439. /**
  119440. * physics impostors for xr controllers feature
  119441. */
  119442. static PHYSICS_CONTROLLERS: string;
  119443. /**
  119444. * The name of the plane detection feature
  119445. */
  119446. static PLANE_DETECTION: string;
  119447. /**
  119448. * The name of the pointer selection feature
  119449. */
  119450. static POINTER_SELECTION: string;
  119451. /**
  119452. * The name of the teleportation feature
  119453. */
  119454. static TELEPORTATION: string;
  119455. }
  119456. /**
  119457. * Defining the constructor of a feature. Used to register the modules.
  119458. */
  119459. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  119460. /**
  119461. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  119462. * It is mainly used in AR sessions.
  119463. *
  119464. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  119465. */
  119466. export class WebXRFeaturesManager implements IDisposable {
  119467. private _xrSessionManager;
  119468. private static readonly _AvailableFeatures;
  119469. private _features;
  119470. /**
  119471. * constructs a new features manages.
  119472. *
  119473. * @param _xrSessionManager an instance of WebXRSessionManager
  119474. */
  119475. constructor(_xrSessionManager: WebXRSessionManager);
  119476. /**
  119477. * Used to register a module. After calling this function a developer can use this feature in the scene.
  119478. * Mainly used internally.
  119479. *
  119480. * @param featureName the name of the feature to register
  119481. * @param constructorFunction the function used to construct the module
  119482. * @param version the (babylon) version of the module
  119483. * @param stable is that a stable version of this module
  119484. */
  119485. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  119486. /**
  119487. * Returns a constructor of a specific feature.
  119488. *
  119489. * @param featureName the name of the feature to construct
  119490. * @param version the version of the feature to load
  119491. * @param xrSessionManager the xrSessionManager. Used to construct the module
  119492. * @param options optional options provided to the module.
  119493. * @returns a function that, when called, will return a new instance of this feature
  119494. */
  119495. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  119496. /**
  119497. * Can be used to return the list of features currently registered
  119498. *
  119499. * @returns an Array of available features
  119500. */
  119501. static GetAvailableFeatures(): string[];
  119502. /**
  119503. * Gets the versions available for a specific feature
  119504. * @param featureName the name of the feature
  119505. * @returns an array with the available versions
  119506. */
  119507. static GetAvailableVersions(featureName: string): string[];
  119508. /**
  119509. * Return the latest unstable version of this feature
  119510. * @param featureName the name of the feature to search
  119511. * @returns the version number. if not found will return -1
  119512. */
  119513. static GetLatestVersionOfFeature(featureName: string): number;
  119514. /**
  119515. * Return the latest stable version of this feature
  119516. * @param featureName the name of the feature to search
  119517. * @returns the version number. if not found will return -1
  119518. */
  119519. static GetStableVersionOfFeature(featureName: string): number;
  119520. /**
  119521. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  119522. * Can be used during a session to start a feature
  119523. * @param featureName the name of feature to attach
  119524. */
  119525. attachFeature(featureName: string): void;
  119526. /**
  119527. * Can be used inside a session or when the session ends to detach a specific feature
  119528. * @param featureName the name of the feature to detach
  119529. */
  119530. detachFeature(featureName: string): void;
  119531. /**
  119532. * Used to disable an already-enabled feature
  119533. * The feature will be disposed and will be recreated once enabled.
  119534. * @param featureName the feature to disable
  119535. * @returns true if disable was successful
  119536. */
  119537. disableFeature(featureName: string | {
  119538. Name: string;
  119539. }): boolean;
  119540. /**
  119541. * dispose this features manager
  119542. */
  119543. dispose(): void;
  119544. /**
  119545. * 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.
  119546. * 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.
  119547. *
  119548. * @param featureName the name of the feature to load or the class of the feature
  119549. * @param version optional version to load. if not provided the latest version will be enabled
  119550. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  119551. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  119552. * @returns a new constructed feature or throws an error if feature not found.
  119553. */
  119554. enableFeature(featureName: string | {
  119555. Name: string;
  119556. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  119557. /**
  119558. * get the implementation of an enabled feature.
  119559. * @param featureName the name of the feature to load
  119560. * @returns the feature class, if found
  119561. */
  119562. getEnabledFeature(featureName: string): IWebXRFeature;
  119563. /**
  119564. * Get the list of enabled features
  119565. * @returns an array of enabled features
  119566. */
  119567. getEnabledFeatures(): string[];
  119568. }
  119569. }
  119570. declare module BABYLON {
  119571. /**
  119572. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  119573. * @see https://doc.babylonjs.com/how_to/webxr
  119574. */
  119575. export class WebXRExperienceHelper implements IDisposable {
  119576. private scene;
  119577. private _nonVRCamera;
  119578. private _originalSceneAutoClear;
  119579. private _supported;
  119580. /**
  119581. * Camera used to render xr content
  119582. */
  119583. camera: WebXRCamera;
  119584. /** A features manager for this xr session */
  119585. featuresManager: WebXRFeaturesManager;
  119586. /**
  119587. * Observers registered here will be triggered after the camera's initial transformation is set
  119588. * This can be used to set a different ground level or an extra rotation.
  119589. *
  119590. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  119591. * to the position set after this observable is done executing.
  119592. */
  119593. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  119594. /**
  119595. * Fires when the state of the experience helper has changed
  119596. */
  119597. onStateChangedObservable: Observable<WebXRState>;
  119598. /** Session manager used to keep track of xr session */
  119599. sessionManager: WebXRSessionManager;
  119600. /**
  119601. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  119602. */
  119603. state: WebXRState;
  119604. /**
  119605. * Creates a WebXRExperienceHelper
  119606. * @param scene The scene the helper should be created in
  119607. */
  119608. private constructor();
  119609. /**
  119610. * Creates the experience helper
  119611. * @param scene the scene to attach the experience helper to
  119612. * @returns a promise for the experience helper
  119613. */
  119614. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  119615. /**
  119616. * Disposes of the experience helper
  119617. */
  119618. dispose(): void;
  119619. /**
  119620. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  119621. * @param sessionMode options for the XR session
  119622. * @param referenceSpaceType frame of reference of the XR session
  119623. * @param renderTarget the output canvas that will be used to enter XR mode
  119624. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  119625. * @returns promise that resolves after xr mode has entered
  119626. */
  119627. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  119628. /**
  119629. * Exits XR mode and returns the scene to its original state
  119630. * @returns promise that resolves after xr mode has exited
  119631. */
  119632. exitXRAsync(): Promise<void>;
  119633. private _nonXRToXRCamera;
  119634. private _setState;
  119635. }
  119636. }
  119637. declare module BABYLON {
  119638. /**
  119639. * X-Y values for axes in WebXR
  119640. */
  119641. export interface IWebXRMotionControllerAxesValue {
  119642. /**
  119643. * The value of the x axis
  119644. */
  119645. x: number;
  119646. /**
  119647. * The value of the y-axis
  119648. */
  119649. y: number;
  119650. }
  119651. /**
  119652. * changed / previous values for the values of this component
  119653. */
  119654. export interface IWebXRMotionControllerComponentChangesValues<T> {
  119655. /**
  119656. * current (this frame) value
  119657. */
  119658. current: T;
  119659. /**
  119660. * previous (last change) value
  119661. */
  119662. previous: T;
  119663. }
  119664. /**
  119665. * Represents changes in the component between current frame and last values recorded
  119666. */
  119667. export interface IWebXRMotionControllerComponentChanges {
  119668. /**
  119669. * will be populated with previous and current values if axes changed
  119670. */
  119671. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  119672. /**
  119673. * will be populated with previous and current values if pressed changed
  119674. */
  119675. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119676. /**
  119677. * will be populated with previous and current values if touched changed
  119678. */
  119679. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119680. /**
  119681. * will be populated with previous and current values if value changed
  119682. */
  119683. value?: IWebXRMotionControllerComponentChangesValues<number>;
  119684. }
  119685. /**
  119686. * This class represents a single component (for example button or thumbstick) of a motion controller
  119687. */
  119688. export class WebXRControllerComponent implements IDisposable {
  119689. /**
  119690. * the id of this component
  119691. */
  119692. id: string;
  119693. /**
  119694. * the type of the component
  119695. */
  119696. type: MotionControllerComponentType;
  119697. private _buttonIndex;
  119698. private _axesIndices;
  119699. private _axes;
  119700. private _changes;
  119701. private _currentValue;
  119702. private _hasChanges;
  119703. private _pressed;
  119704. private _touched;
  119705. /**
  119706. * button component type
  119707. */
  119708. static BUTTON_TYPE: MotionControllerComponentType;
  119709. /**
  119710. * squeeze component type
  119711. */
  119712. static SQUEEZE_TYPE: MotionControllerComponentType;
  119713. /**
  119714. * Thumbstick component type
  119715. */
  119716. static THUMBSTICK_TYPE: MotionControllerComponentType;
  119717. /**
  119718. * Touchpad component type
  119719. */
  119720. static TOUCHPAD_TYPE: MotionControllerComponentType;
  119721. /**
  119722. * trigger component type
  119723. */
  119724. static TRIGGER_TYPE: MotionControllerComponentType;
  119725. /**
  119726. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  119727. * the axes data changes
  119728. */
  119729. onAxisValueChangedObservable: Observable<{
  119730. x: number;
  119731. y: number;
  119732. }>;
  119733. /**
  119734. * Observers registered here will be triggered when the state of a button changes
  119735. * State change is either pressed / touched / value
  119736. */
  119737. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  119738. /**
  119739. * Creates a new component for a motion controller.
  119740. * It is created by the motion controller itself
  119741. *
  119742. * @param id the id of this component
  119743. * @param type the type of the component
  119744. * @param _buttonIndex index in the buttons array of the gamepad
  119745. * @param _axesIndices indices of the values in the axes array of the gamepad
  119746. */
  119747. constructor(
  119748. /**
  119749. * the id of this component
  119750. */
  119751. id: string,
  119752. /**
  119753. * the type of the component
  119754. */
  119755. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  119756. /**
  119757. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  119758. */
  119759. get axes(): IWebXRMotionControllerAxesValue;
  119760. /**
  119761. * Get the changes. Elements will be populated only if they changed with their previous and current value
  119762. */
  119763. get changes(): IWebXRMotionControllerComponentChanges;
  119764. /**
  119765. * Return whether or not the component changed the last frame
  119766. */
  119767. get hasChanges(): boolean;
  119768. /**
  119769. * is the button currently pressed
  119770. */
  119771. get pressed(): boolean;
  119772. /**
  119773. * is the button currently touched
  119774. */
  119775. get touched(): boolean;
  119776. /**
  119777. * Get the current value of this component
  119778. */
  119779. get value(): number;
  119780. /**
  119781. * Dispose this component
  119782. */
  119783. dispose(): void;
  119784. /**
  119785. * Are there axes correlating to this component
  119786. * @return true is axes data is available
  119787. */
  119788. isAxes(): boolean;
  119789. /**
  119790. * Is this component a button (hence - pressable)
  119791. * @returns true if can be pressed
  119792. */
  119793. isButton(): boolean;
  119794. /**
  119795. * update this component using the gamepad object it is in. Called on every frame
  119796. * @param nativeController the native gamepad controller object
  119797. */
  119798. update(nativeController: IMinimalMotionControllerObject): void;
  119799. }
  119800. }
  119801. declare module BABYLON {
  119802. /**
  119803. * Class used to represent data loading progression
  119804. */
  119805. export class SceneLoaderProgressEvent {
  119806. /** defines if data length to load can be evaluated */
  119807. readonly lengthComputable: boolean;
  119808. /** defines the loaded data length */
  119809. readonly loaded: number;
  119810. /** defines the data length to load */
  119811. readonly total: number;
  119812. /**
  119813. * Create a new progress event
  119814. * @param lengthComputable defines if data length to load can be evaluated
  119815. * @param loaded defines the loaded data length
  119816. * @param total defines the data length to load
  119817. */
  119818. constructor(
  119819. /** defines if data length to load can be evaluated */
  119820. lengthComputable: boolean,
  119821. /** defines the loaded data length */
  119822. loaded: number,
  119823. /** defines the data length to load */
  119824. total: number);
  119825. /**
  119826. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  119827. * @param event defines the source event
  119828. * @returns a new SceneLoaderProgressEvent
  119829. */
  119830. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  119831. }
  119832. /**
  119833. * Interface used by SceneLoader plugins to define supported file extensions
  119834. */
  119835. export interface ISceneLoaderPluginExtensions {
  119836. /**
  119837. * Defines the list of supported extensions
  119838. */
  119839. [extension: string]: {
  119840. isBinary: boolean;
  119841. };
  119842. }
  119843. /**
  119844. * Interface used by SceneLoader plugin factory
  119845. */
  119846. export interface ISceneLoaderPluginFactory {
  119847. /**
  119848. * Defines the name of the factory
  119849. */
  119850. name: string;
  119851. /**
  119852. * Function called to create a new plugin
  119853. * @return the new plugin
  119854. */
  119855. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  119856. /**
  119857. * The callback that returns true if the data can be directly loaded.
  119858. * @param data string containing the file data
  119859. * @returns if the data can be loaded directly
  119860. */
  119861. canDirectLoad?(data: string): boolean;
  119862. }
  119863. /**
  119864. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  119865. */
  119866. export interface ISceneLoaderPluginBase {
  119867. /**
  119868. * The friendly name of this plugin.
  119869. */
  119870. name: string;
  119871. /**
  119872. * The file extensions supported by this plugin.
  119873. */
  119874. extensions: string | ISceneLoaderPluginExtensions;
  119875. /**
  119876. * The callback called when loading from a url.
  119877. * @param scene scene loading this url
  119878. * @param url url to load
  119879. * @param onSuccess callback called when the file successfully loads
  119880. * @param onProgress callback called while file is loading (if the server supports this mode)
  119881. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119882. * @param onError callback called when the file fails to load
  119883. * @returns a file request object
  119884. */
  119885. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119886. /**
  119887. * The callback called when loading from a file object.
  119888. * @param scene scene loading this file
  119889. * @param file defines the file to load
  119890. * @param onSuccess defines the callback to call when data is loaded
  119891. * @param onProgress defines the callback to call during loading process
  119892. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119893. * @param onError defines the callback to call when an error occurs
  119894. * @returns a file request object
  119895. */
  119896. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119897. /**
  119898. * The callback that returns true if the data can be directly loaded.
  119899. * @param data string containing the file data
  119900. * @returns if the data can be loaded directly
  119901. */
  119902. canDirectLoad?(data: string): boolean;
  119903. /**
  119904. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  119905. * @param scene scene loading this data
  119906. * @param data string containing the data
  119907. * @returns data to pass to the plugin
  119908. */
  119909. directLoad?(scene: Scene, data: string): any;
  119910. /**
  119911. * The callback that allows custom handling of the root url based on the response url.
  119912. * @param rootUrl the original root url
  119913. * @param responseURL the response url if available
  119914. * @returns the new root url
  119915. */
  119916. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  119917. }
  119918. /**
  119919. * Interface used to define a SceneLoader plugin
  119920. */
  119921. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  119922. /**
  119923. * Import meshes into a scene.
  119924. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119925. * @param scene The scene to import into
  119926. * @param data The data to import
  119927. * @param rootUrl The root url for scene and resources
  119928. * @param meshes The meshes array to import into
  119929. * @param particleSystems The particle systems array to import into
  119930. * @param skeletons The skeletons array to import into
  119931. * @param onError The callback when import fails
  119932. * @returns True if successful or false otherwise
  119933. */
  119934. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  119935. /**
  119936. * Load into a scene.
  119937. * @param scene The scene to load into
  119938. * @param data The data to import
  119939. * @param rootUrl The root url for scene and resources
  119940. * @param onError The callback when import fails
  119941. * @returns True if successful or false otherwise
  119942. */
  119943. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  119944. /**
  119945. * Load into an asset container.
  119946. * @param scene The scene to load into
  119947. * @param data The data to import
  119948. * @param rootUrl The root url for scene and resources
  119949. * @param onError The callback when import fails
  119950. * @returns The loaded asset container
  119951. */
  119952. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  119953. }
  119954. /**
  119955. * Interface used to define an async SceneLoader plugin
  119956. */
  119957. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  119958. /**
  119959. * Import meshes into a scene.
  119960. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119961. * @param scene The scene to import into
  119962. * @param data The data to import
  119963. * @param rootUrl The root url for scene and resources
  119964. * @param onProgress The callback when the load progresses
  119965. * @param fileName Defines the name of the file to load
  119966. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  119967. */
  119968. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  119969. meshes: AbstractMesh[];
  119970. particleSystems: IParticleSystem[];
  119971. skeletons: Skeleton[];
  119972. animationGroups: AnimationGroup[];
  119973. }>;
  119974. /**
  119975. * Load into a scene.
  119976. * @param scene The scene to load into
  119977. * @param data The data to import
  119978. * @param rootUrl The root url for scene and resources
  119979. * @param onProgress The callback when the load progresses
  119980. * @param fileName Defines the name of the file to load
  119981. * @returns Nothing
  119982. */
  119983. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  119984. /**
  119985. * Load into an asset container.
  119986. * @param scene The scene to load into
  119987. * @param data The data to import
  119988. * @param rootUrl The root url for scene and resources
  119989. * @param onProgress The callback when the load progresses
  119990. * @param fileName Defines the name of the file to load
  119991. * @returns The loaded asset container
  119992. */
  119993. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  119994. }
  119995. /**
  119996. * Mode that determines how to handle old animation groups before loading new ones.
  119997. */
  119998. export enum SceneLoaderAnimationGroupLoadingMode {
  119999. /**
  120000. * Reset all old animations to initial state then dispose them.
  120001. */
  120002. Clean = 0,
  120003. /**
  120004. * Stop all old animations.
  120005. */
  120006. Stop = 1,
  120007. /**
  120008. * Restart old animations from first frame.
  120009. */
  120010. Sync = 2,
  120011. /**
  120012. * Old animations remains untouched.
  120013. */
  120014. NoSync = 3
  120015. }
  120016. /**
  120017. * Class used to load scene from various file formats using registered plugins
  120018. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  120019. */
  120020. export class SceneLoader {
  120021. /**
  120022. * No logging while loading
  120023. */
  120024. static readonly NO_LOGGING: number;
  120025. /**
  120026. * Minimal logging while loading
  120027. */
  120028. static readonly MINIMAL_LOGGING: number;
  120029. /**
  120030. * Summary logging while loading
  120031. */
  120032. static readonly SUMMARY_LOGGING: number;
  120033. /**
  120034. * Detailled logging while loading
  120035. */
  120036. static readonly DETAILED_LOGGING: number;
  120037. /**
  120038. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  120039. */
  120040. static get ForceFullSceneLoadingForIncremental(): boolean;
  120041. static set ForceFullSceneLoadingForIncremental(value: boolean);
  120042. /**
  120043. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  120044. */
  120045. static get ShowLoadingScreen(): boolean;
  120046. static set ShowLoadingScreen(value: boolean);
  120047. /**
  120048. * Defines the current logging level (while loading the scene)
  120049. * @ignorenaming
  120050. */
  120051. static get loggingLevel(): number;
  120052. static set loggingLevel(value: number);
  120053. /**
  120054. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  120055. */
  120056. static get CleanBoneMatrixWeights(): boolean;
  120057. static set CleanBoneMatrixWeights(value: boolean);
  120058. /**
  120059. * Event raised when a plugin is used to load a scene
  120060. */
  120061. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  120062. private static _registeredPlugins;
  120063. private static _getDefaultPlugin;
  120064. private static _getPluginForExtension;
  120065. private static _getPluginForDirectLoad;
  120066. private static _getPluginForFilename;
  120067. private static _getDirectLoad;
  120068. private static _loadData;
  120069. private static _getFileInfo;
  120070. /**
  120071. * Gets a plugin that can load the given extension
  120072. * @param extension defines the extension to load
  120073. * @returns a plugin or null if none works
  120074. */
  120075. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  120076. /**
  120077. * Gets a boolean indicating that the given extension can be loaded
  120078. * @param extension defines the extension to load
  120079. * @returns true if the extension is supported
  120080. */
  120081. static IsPluginForExtensionAvailable(extension: string): boolean;
  120082. /**
  120083. * Adds a new plugin to the list of registered plugins
  120084. * @param plugin defines the plugin to add
  120085. */
  120086. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  120087. /**
  120088. * Import meshes into a scene
  120089. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120090. * @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)
  120091. * @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)
  120092. * @param scene the instance of BABYLON.Scene to append to
  120093. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  120094. * @param onProgress a callback with a progress event for each file being loaded
  120095. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120096. * @param pluginExtension the extension used to determine the plugin
  120097. * @returns The loaded plugin
  120098. */
  120099. 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>;
  120100. /**
  120101. * Import meshes into a scene
  120102. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120103. * @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)
  120104. * @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)
  120105. * @param scene the instance of BABYLON.Scene to append to
  120106. * @param onProgress a callback with a progress event for each file being loaded
  120107. * @param pluginExtension the extension used to determine the plugin
  120108. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  120109. */
  120110. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  120111. meshes: AbstractMesh[];
  120112. particleSystems: IParticleSystem[];
  120113. skeletons: Skeleton[];
  120114. animationGroups: AnimationGroup[];
  120115. }>;
  120116. /**
  120117. * Load a scene
  120118. * @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)
  120119. * @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)
  120120. * @param engine is the instance of BABYLON.Engine to use to create the scene
  120121. * @param onSuccess a callback with the scene when import succeeds
  120122. * @param onProgress a callback with a progress event for each file being loaded
  120123. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120124. * @param pluginExtension the extension used to determine the plugin
  120125. * @returns The loaded plugin
  120126. */
  120127. 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>;
  120128. /**
  120129. * Load a scene
  120130. * @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)
  120131. * @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)
  120132. * @param engine is the instance of BABYLON.Engine to use to create the scene
  120133. * @param onProgress a callback with a progress event for each file being loaded
  120134. * @param pluginExtension the extension used to determine the plugin
  120135. * @returns The loaded scene
  120136. */
  120137. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  120138. /**
  120139. * Append a scene
  120140. * @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)
  120141. * @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)
  120142. * @param scene is the instance of BABYLON.Scene to append to
  120143. * @param onSuccess a callback with the scene when import succeeds
  120144. * @param onProgress a callback with a progress event for each file being loaded
  120145. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120146. * @param pluginExtension the extension used to determine the plugin
  120147. * @returns The loaded plugin
  120148. */
  120149. 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>;
  120150. /**
  120151. * Append a scene
  120152. * @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)
  120153. * @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)
  120154. * @param scene is the instance of BABYLON.Scene to append to
  120155. * @param onProgress a callback with a progress event for each file being loaded
  120156. * @param pluginExtension the extension used to determine the plugin
  120157. * @returns The given scene
  120158. */
  120159. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  120160. /**
  120161. * Load a scene into an asset container
  120162. * @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)
  120163. * @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)
  120164. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120165. * @param onSuccess a callback with the scene when import succeeds
  120166. * @param onProgress a callback with a progress event for each file being loaded
  120167. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120168. * @param pluginExtension the extension used to determine the plugin
  120169. * @returns The loaded plugin
  120170. */
  120171. 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>;
  120172. /**
  120173. * Load a scene into an asset container
  120174. * @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)
  120175. * @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)
  120176. * @param scene is the instance of Scene to append to
  120177. * @param onProgress a callback with a progress event for each file being loaded
  120178. * @param pluginExtension the extension used to determine the plugin
  120179. * @returns The loaded asset container
  120180. */
  120181. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  120182. /**
  120183. * Import animations from a file into a scene
  120184. * @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)
  120185. * @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)
  120186. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120187. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  120188. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  120189. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  120190. * @param onSuccess a callback with the scene when import succeeds
  120191. * @param onProgress a callback with a progress event for each file being loaded
  120192. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120193. */
  120194. 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;
  120195. /**
  120196. * Import animations from a file into a scene
  120197. * @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)
  120198. * @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)
  120199. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120200. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  120201. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  120202. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  120203. * @param onSuccess a callback with the scene when import succeeds
  120204. * @param onProgress a callback with a progress event for each file being loaded
  120205. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120206. * @returns the updated scene with imported animations
  120207. */
  120208. 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>;
  120209. }
  120210. }
  120211. declare module BABYLON {
  120212. /**
  120213. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  120214. */
  120215. export type MotionControllerHandedness = "none" | "left" | "right";
  120216. /**
  120217. * The type of components available in motion controllers.
  120218. * This is not the name of the component.
  120219. */
  120220. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  120221. /**
  120222. * The state of a controller component
  120223. */
  120224. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  120225. /**
  120226. * The schema of motion controller layout.
  120227. * No object will be initialized using this interface
  120228. * This is used just to define the profile.
  120229. */
  120230. export interface IMotionControllerLayout {
  120231. /**
  120232. * Path to load the assets. Usually relative to the base path
  120233. */
  120234. assetPath: string;
  120235. /**
  120236. * Available components (unsorted)
  120237. */
  120238. components: {
  120239. /**
  120240. * A map of component Ids
  120241. */
  120242. [componentId: string]: {
  120243. /**
  120244. * The type of input the component outputs
  120245. */
  120246. type: MotionControllerComponentType;
  120247. /**
  120248. * The indices of this component in the gamepad object
  120249. */
  120250. gamepadIndices: {
  120251. /**
  120252. * Index of button
  120253. */
  120254. button?: number;
  120255. /**
  120256. * If available, index of x-axis
  120257. */
  120258. xAxis?: number;
  120259. /**
  120260. * If available, index of y-axis
  120261. */
  120262. yAxis?: number;
  120263. };
  120264. /**
  120265. * The mesh's root node name
  120266. */
  120267. rootNodeName: string;
  120268. /**
  120269. * Animation definitions for this model
  120270. */
  120271. visualResponses: {
  120272. [stateKey: string]: {
  120273. /**
  120274. * What property will be animated
  120275. */
  120276. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  120277. /**
  120278. * What states influence this visual response
  120279. */
  120280. states: MotionControllerComponentStateType[];
  120281. /**
  120282. * Type of animation - movement or visibility
  120283. */
  120284. valueNodeProperty: "transform" | "visibility";
  120285. /**
  120286. * Base node name to move. Its position will be calculated according to the min and max nodes
  120287. */
  120288. valueNodeName?: string;
  120289. /**
  120290. * Minimum movement node
  120291. */
  120292. minNodeName?: string;
  120293. /**
  120294. * Max movement node
  120295. */
  120296. maxNodeName?: string;
  120297. };
  120298. };
  120299. /**
  120300. * If touch enabled, what is the name of node to display user feedback
  120301. */
  120302. touchPointNodeName?: string;
  120303. };
  120304. };
  120305. /**
  120306. * Is it xr standard mapping or not
  120307. */
  120308. gamepadMapping: "" | "xr-standard";
  120309. /**
  120310. * Base root node of this entire model
  120311. */
  120312. rootNodeName: string;
  120313. /**
  120314. * Defines the main button component id
  120315. */
  120316. selectComponentId: string;
  120317. }
  120318. /**
  120319. * A definition for the layout map in the input profile
  120320. */
  120321. export interface IMotionControllerLayoutMap {
  120322. /**
  120323. * Layouts with handedness type as a key
  120324. */
  120325. [handedness: string]: IMotionControllerLayout;
  120326. }
  120327. /**
  120328. * The XR Input profile schema
  120329. * Profiles can be found here:
  120330. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  120331. */
  120332. export interface IMotionControllerProfile {
  120333. /**
  120334. * fallback profiles for this profileId
  120335. */
  120336. fallbackProfileIds: string[];
  120337. /**
  120338. * The layout map, with handedness as key
  120339. */
  120340. layouts: IMotionControllerLayoutMap;
  120341. /**
  120342. * The id of this profile
  120343. * correlates to the profile(s) in the xrInput.profiles array
  120344. */
  120345. profileId: string;
  120346. }
  120347. /**
  120348. * A helper-interface for the 3 meshes needed for controller button animation
  120349. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  120350. */
  120351. export interface IMotionControllerButtonMeshMap {
  120352. /**
  120353. * the mesh that defines the pressed value mesh position.
  120354. * This is used to find the max-position of this button
  120355. */
  120356. pressedMesh: AbstractMesh;
  120357. /**
  120358. * the mesh that defines the unpressed value mesh position.
  120359. * This is used to find the min (or initial) position of this button
  120360. */
  120361. unpressedMesh: AbstractMesh;
  120362. /**
  120363. * The mesh that will be changed when value changes
  120364. */
  120365. valueMesh: AbstractMesh;
  120366. }
  120367. /**
  120368. * A helper-interface for the 3 meshes needed for controller axis animation.
  120369. * This will be expanded when touchpad animations are fully supported
  120370. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  120371. */
  120372. export interface IMotionControllerMeshMap {
  120373. /**
  120374. * the mesh that defines the maximum value mesh position.
  120375. */
  120376. maxMesh?: AbstractMesh;
  120377. /**
  120378. * the mesh that defines the minimum value mesh position.
  120379. */
  120380. minMesh?: AbstractMesh;
  120381. /**
  120382. * The mesh that will be changed when axis value changes
  120383. */
  120384. valueMesh: AbstractMesh;
  120385. }
  120386. /**
  120387. * The elements needed for change-detection of the gamepad objects in motion controllers
  120388. */
  120389. export interface IMinimalMotionControllerObject {
  120390. /**
  120391. * Available axes of this controller
  120392. */
  120393. axes: number[];
  120394. /**
  120395. * An array of available buttons
  120396. */
  120397. buttons: Array<{
  120398. /**
  120399. * Value of the button/trigger
  120400. */
  120401. value: number;
  120402. /**
  120403. * If the button/trigger is currently touched
  120404. */
  120405. touched: boolean;
  120406. /**
  120407. * If the button/trigger is currently pressed
  120408. */
  120409. pressed: boolean;
  120410. }>;
  120411. /**
  120412. * EXPERIMENTAL haptic support.
  120413. */
  120414. hapticActuators?: Array<{
  120415. pulse: (value: number, duration: number) => Promise<boolean>;
  120416. }>;
  120417. }
  120418. /**
  120419. * An Abstract Motion controller
  120420. * This class receives an xrInput and a profile layout and uses those to initialize the components
  120421. * Each component has an observable to check for changes in value and state
  120422. */
  120423. export abstract class WebXRAbstractMotionController implements IDisposable {
  120424. protected scene: Scene;
  120425. protected layout: IMotionControllerLayout;
  120426. /**
  120427. * The gamepad object correlating to this controller
  120428. */
  120429. gamepadObject: IMinimalMotionControllerObject;
  120430. /**
  120431. * handedness (left/right/none) of this controller
  120432. */
  120433. handedness: MotionControllerHandedness;
  120434. private _initComponent;
  120435. private _modelReady;
  120436. /**
  120437. * A map of components (WebXRControllerComponent) in this motion controller
  120438. * Components have a ComponentType and can also have both button and axis definitions
  120439. */
  120440. readonly components: {
  120441. [id: string]: WebXRControllerComponent;
  120442. };
  120443. /**
  120444. * Disable the model's animation. Can be set at any time.
  120445. */
  120446. disableAnimation: boolean;
  120447. /**
  120448. * Observers registered here will be triggered when the model of this controller is done loading
  120449. */
  120450. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  120451. /**
  120452. * The profile id of this motion controller
  120453. */
  120454. abstract profileId: string;
  120455. /**
  120456. * The root mesh of the model. It is null if the model was not yet initialized
  120457. */
  120458. rootMesh: Nullable<AbstractMesh>;
  120459. /**
  120460. * constructs a new abstract motion controller
  120461. * @param scene the scene to which the model of the controller will be added
  120462. * @param layout The profile layout to load
  120463. * @param gamepadObject The gamepad object correlating to this controller
  120464. * @param handedness handedness (left/right/none) of this controller
  120465. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  120466. */
  120467. constructor(scene: Scene, layout: IMotionControllerLayout,
  120468. /**
  120469. * The gamepad object correlating to this controller
  120470. */
  120471. gamepadObject: IMinimalMotionControllerObject,
  120472. /**
  120473. * handedness (left/right/none) of this controller
  120474. */
  120475. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  120476. /**
  120477. * Dispose this controller, the model mesh and all its components
  120478. */
  120479. dispose(): void;
  120480. /**
  120481. * Returns all components of specific type
  120482. * @param type the type to search for
  120483. * @return an array of components with this type
  120484. */
  120485. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  120486. /**
  120487. * get a component based an its component id as defined in layout.components
  120488. * @param id the id of the component
  120489. * @returns the component correlates to the id or undefined if not found
  120490. */
  120491. getComponent(id: string): WebXRControllerComponent;
  120492. /**
  120493. * Get the list of components available in this motion controller
  120494. * @returns an array of strings correlating to available components
  120495. */
  120496. getComponentIds(): string[];
  120497. /**
  120498. * Get the first component of specific type
  120499. * @param type type of component to find
  120500. * @return a controller component or null if not found
  120501. */
  120502. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  120503. /**
  120504. * Get the main (Select) component of this controller as defined in the layout
  120505. * @returns the main component of this controller
  120506. */
  120507. getMainComponent(): WebXRControllerComponent;
  120508. /**
  120509. * Loads the model correlating to this controller
  120510. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  120511. * @returns A promise fulfilled with the result of the model loading
  120512. */
  120513. loadModel(): Promise<boolean>;
  120514. /**
  120515. * Update this model using the current XRFrame
  120516. * @param xrFrame the current xr frame to use and update the model
  120517. */
  120518. updateFromXRFrame(xrFrame: XRFrame): void;
  120519. /**
  120520. * Backwards compatibility due to a deeply-integrated typo
  120521. */
  120522. get handness(): XREye;
  120523. /**
  120524. * Pulse (vibrate) this controller
  120525. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  120526. * Consecutive calls to this function will cancel the last pulse call
  120527. *
  120528. * @param value the strength of the pulse in 0.0...1.0 range
  120529. * @param duration Duration of the pulse in milliseconds
  120530. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  120531. * @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
  120532. */
  120533. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  120534. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120535. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120536. /**
  120537. * Moves the axis on the controller mesh based on its current state
  120538. * @param axis the index of the axis
  120539. * @param axisValue the value of the axis which determines the meshes new position
  120540. * @hidden
  120541. */
  120542. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  120543. /**
  120544. * Update the model itself with the current frame data
  120545. * @param xrFrame the frame to use for updating the model mesh
  120546. */
  120547. protected updateModel(xrFrame: XRFrame): void;
  120548. /**
  120549. * Get the filename and path for this controller's model
  120550. * @returns a map of filename and path
  120551. */
  120552. protected abstract _getFilenameAndPath(): {
  120553. filename: string;
  120554. path: string;
  120555. };
  120556. /**
  120557. * This function is called before the mesh is loaded. It checks for loading constraints.
  120558. * For example, this function can check if the GLB loader is available
  120559. * If this function returns false, the generic controller will be loaded instead
  120560. * @returns Is the client ready to load the mesh
  120561. */
  120562. protected abstract _getModelLoadingConstraints(): boolean;
  120563. /**
  120564. * This function will be called after the model was successfully loaded and can be used
  120565. * for mesh transformations before it is available for the user
  120566. * @param meshes the loaded meshes
  120567. */
  120568. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  120569. /**
  120570. * Set the root mesh for this controller. Important for the WebXR controller class
  120571. * @param meshes the loaded meshes
  120572. */
  120573. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  120574. /**
  120575. * A function executed each frame that updates the mesh (if needed)
  120576. * @param xrFrame the current xrFrame
  120577. */
  120578. protected abstract _updateModel(xrFrame: XRFrame): void;
  120579. private _getGenericFilenameAndPath;
  120580. private _getGenericParentMesh;
  120581. }
  120582. }
  120583. declare module BABYLON {
  120584. /**
  120585. * A generic trigger-only motion controller for WebXR
  120586. */
  120587. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  120588. /**
  120589. * Static version of the profile id of this controller
  120590. */
  120591. static ProfileId: string;
  120592. profileId: string;
  120593. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  120594. protected _getFilenameAndPath(): {
  120595. filename: string;
  120596. path: string;
  120597. };
  120598. protected _getModelLoadingConstraints(): boolean;
  120599. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  120600. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120601. protected _updateModel(): void;
  120602. }
  120603. }
  120604. declare module BABYLON {
  120605. /**
  120606. * Class containing static functions to help procedurally build meshes
  120607. */
  120608. export class SphereBuilder {
  120609. /**
  120610. * Creates a sphere mesh
  120611. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120612. * * 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`)
  120613. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120614. * * 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
  120615. * * 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)
  120616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120617. * * 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
  120618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120619. * @param name defines the name of the mesh
  120620. * @param options defines the options used to create the mesh
  120621. * @param scene defines the hosting scene
  120622. * @returns the sphere mesh
  120623. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120624. */
  120625. static CreateSphere(name: string, options: {
  120626. segments?: number;
  120627. diameter?: number;
  120628. diameterX?: number;
  120629. diameterY?: number;
  120630. diameterZ?: number;
  120631. arc?: number;
  120632. slice?: number;
  120633. sideOrientation?: number;
  120634. frontUVs?: Vector4;
  120635. backUVs?: Vector4;
  120636. updatable?: boolean;
  120637. }, scene?: Nullable<Scene>): Mesh;
  120638. }
  120639. }
  120640. declare module BABYLON {
  120641. /**
  120642. * A profiled motion controller has its profile loaded from an online repository.
  120643. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  120644. */
  120645. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  120646. private _repositoryUrl;
  120647. private _buttonMeshMapping;
  120648. private _touchDots;
  120649. /**
  120650. * The profile ID of this controller. Will be populated when the controller initializes.
  120651. */
  120652. profileId: string;
  120653. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  120654. dispose(): void;
  120655. protected _getFilenameAndPath(): {
  120656. filename: string;
  120657. path: string;
  120658. };
  120659. protected _getModelLoadingConstraints(): boolean;
  120660. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  120661. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120662. protected _updateModel(_xrFrame: XRFrame): void;
  120663. }
  120664. }
  120665. declare module BABYLON {
  120666. /**
  120667. * A construction function type to create a new controller based on an xrInput object
  120668. */
  120669. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  120670. /**
  120671. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  120672. *
  120673. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  120674. * it should be replaced with auto-loaded controllers.
  120675. *
  120676. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  120677. */
  120678. export class WebXRMotionControllerManager {
  120679. private static _AvailableControllers;
  120680. private static _Fallbacks;
  120681. private static _ProfileLoadingPromises;
  120682. private static _ProfilesList;
  120683. /**
  120684. * The base URL of the online controller repository. Can be changed at any time.
  120685. */
  120686. static BaseRepositoryUrl: string;
  120687. /**
  120688. * Which repository gets priority - local or online
  120689. */
  120690. static PrioritizeOnlineRepository: boolean;
  120691. /**
  120692. * Use the online repository, or use only locally-defined controllers
  120693. */
  120694. static UseOnlineRepository: boolean;
  120695. /**
  120696. * Clear the cache used for profile loading and reload when requested again
  120697. */
  120698. static ClearProfilesCache(): void;
  120699. /**
  120700. * Register the default fallbacks.
  120701. * This function is called automatically when this file is imported.
  120702. */
  120703. static DefaultFallbacks(): void;
  120704. /**
  120705. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  120706. * @param profileId the profile to which a fallback needs to be found
  120707. * @return an array with corresponding fallback profiles
  120708. */
  120709. static FindFallbackWithProfileId(profileId: string): string[];
  120710. /**
  120711. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  120712. * The order of search:
  120713. *
  120714. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  120715. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  120716. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  120717. * 4) return the generic trigger controller if none were found
  120718. *
  120719. * @param xrInput the xrInput to which a new controller is initialized
  120720. * @param scene the scene to which the model will be added
  120721. * @param forceProfile force a certain profile for this controller
  120722. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  120723. */
  120724. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  120725. /**
  120726. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  120727. *
  120728. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  120729. *
  120730. * @param type the profile type to register
  120731. * @param constructFunction the function to be called when loading this profile
  120732. */
  120733. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  120734. /**
  120735. * Register a fallback to a specific profile.
  120736. * @param profileId the profileId that will receive the fallbacks
  120737. * @param fallbacks A list of fallback profiles
  120738. */
  120739. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  120740. /**
  120741. * Will update the list of profiles available in the repository
  120742. * @return a promise that resolves to a map of profiles available online
  120743. */
  120744. static UpdateProfilesList(): Promise<{
  120745. [profile: string]: string;
  120746. }>;
  120747. private static _LoadProfileFromRepository;
  120748. private static _LoadProfilesFromAvailableControllers;
  120749. }
  120750. }
  120751. declare module BABYLON {
  120752. /**
  120753. * Configuration options for the WebXR controller creation
  120754. */
  120755. export interface IWebXRControllerOptions {
  120756. /**
  120757. * Should the controller mesh be animated when a user interacts with it
  120758. * The pressed buttons / thumbstick and touchpad animations will be disabled
  120759. */
  120760. disableMotionControllerAnimation?: boolean;
  120761. /**
  120762. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  120763. */
  120764. doNotLoadControllerMesh?: boolean;
  120765. /**
  120766. * Force a specific controller type for this controller.
  120767. * This can be used when creating your own profile or when testing different controllers
  120768. */
  120769. forceControllerProfile?: string;
  120770. /**
  120771. * Defines a rendering group ID for meshes that will be loaded.
  120772. * This is for the default controllers only.
  120773. */
  120774. renderingGroupId?: number;
  120775. }
  120776. /**
  120777. * Represents an XR controller
  120778. */
  120779. export class WebXRInputSource {
  120780. private _scene;
  120781. /** The underlying input source for the controller */
  120782. inputSource: XRInputSource;
  120783. private _options;
  120784. private _tmpQuaternion;
  120785. private _tmpVector;
  120786. private _uniqueId;
  120787. /**
  120788. * 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
  120789. */
  120790. grip?: AbstractMesh;
  120791. /**
  120792. * If available, this is the gamepad object related to this controller.
  120793. * Using this object it is possible to get click events and trackpad changes of the
  120794. * webxr controller that is currently being used.
  120795. */
  120796. motionController?: WebXRAbstractMotionController;
  120797. /**
  120798. * Event that fires when the controller is removed/disposed.
  120799. * The object provided as event data is this controller, after associated assets were disposed.
  120800. * uniqueId is still available.
  120801. */
  120802. onDisposeObservable: Observable<WebXRInputSource>;
  120803. /**
  120804. * Will be triggered when the mesh associated with the motion controller is done loading.
  120805. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  120806. * A shortened version of controller -> motion controller -> on mesh loaded.
  120807. */
  120808. onMeshLoadedObservable: Observable<AbstractMesh>;
  120809. /**
  120810. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  120811. */
  120812. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  120813. /**
  120814. * Pointer which can be used to select objects or attach a visible laser to
  120815. */
  120816. pointer: AbstractMesh;
  120817. /**
  120818. * Creates the controller
  120819. * @see https://doc.babylonjs.com/how_to/webxr
  120820. * @param _scene the scene which the controller should be associated to
  120821. * @param inputSource the underlying input source for the controller
  120822. * @param _options options for this controller creation
  120823. */
  120824. constructor(_scene: Scene,
  120825. /** The underlying input source for the controller */
  120826. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  120827. /**
  120828. * Get this controllers unique id
  120829. */
  120830. get uniqueId(): string;
  120831. /**
  120832. * Disposes of the object
  120833. */
  120834. dispose(): void;
  120835. /**
  120836. * Gets a world space ray coming from the pointer or grip
  120837. * @param result the resulting ray
  120838. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  120839. */
  120840. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  120841. /**
  120842. * Updates the controller pose based on the given XRFrame
  120843. * @param xrFrame xr frame to update the pose with
  120844. * @param referenceSpace reference space to use
  120845. */
  120846. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  120847. }
  120848. }
  120849. declare module BABYLON {
  120850. /**
  120851. * The schema for initialization options of the XR Input class
  120852. */
  120853. export interface IWebXRInputOptions {
  120854. /**
  120855. * If set to true no model will be automatically loaded
  120856. */
  120857. doNotLoadControllerMeshes?: boolean;
  120858. /**
  120859. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  120860. * If not found, the xr input profile data will be used.
  120861. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  120862. */
  120863. forceInputProfile?: string;
  120864. /**
  120865. * Do not send a request to the controller repository to load the profile.
  120866. *
  120867. * Instead, use the controllers available in babylon itself.
  120868. */
  120869. disableOnlineControllerRepository?: boolean;
  120870. /**
  120871. * A custom URL for the controllers repository
  120872. */
  120873. customControllersRepositoryURL?: string;
  120874. /**
  120875. * Should the controller model's components not move according to the user input
  120876. */
  120877. disableControllerAnimation?: boolean;
  120878. /**
  120879. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  120880. */
  120881. controllerOptions?: IWebXRControllerOptions;
  120882. }
  120883. /**
  120884. * XR input used to track XR inputs such as controllers/rays
  120885. */
  120886. export class WebXRInput implements IDisposable {
  120887. /**
  120888. * the xr session manager for this session
  120889. */
  120890. xrSessionManager: WebXRSessionManager;
  120891. /**
  120892. * the WebXR camera for this session. Mainly used for teleportation
  120893. */
  120894. xrCamera: WebXRCamera;
  120895. private readonly options;
  120896. /**
  120897. * XR controllers being tracked
  120898. */
  120899. controllers: Array<WebXRInputSource>;
  120900. private _frameObserver;
  120901. private _sessionEndedObserver;
  120902. private _sessionInitObserver;
  120903. /**
  120904. * Event when a controller has been connected/added
  120905. */
  120906. onControllerAddedObservable: Observable<WebXRInputSource>;
  120907. /**
  120908. * Event when a controller has been removed/disconnected
  120909. */
  120910. onControllerRemovedObservable: Observable<WebXRInputSource>;
  120911. /**
  120912. * Initializes the WebXRInput
  120913. * @param xrSessionManager the xr session manager for this session
  120914. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  120915. * @param options = initialization options for this xr input
  120916. */
  120917. constructor(
  120918. /**
  120919. * the xr session manager for this session
  120920. */
  120921. xrSessionManager: WebXRSessionManager,
  120922. /**
  120923. * the WebXR camera for this session. Mainly used for teleportation
  120924. */
  120925. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  120926. private _onInputSourcesChange;
  120927. private _addAndRemoveControllers;
  120928. /**
  120929. * Disposes of the object
  120930. */
  120931. dispose(): void;
  120932. }
  120933. }
  120934. declare module BABYLON {
  120935. /**
  120936. * This is the base class for all WebXR features.
  120937. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  120938. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  120939. */
  120940. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  120941. protected _xrSessionManager: WebXRSessionManager;
  120942. private _attached;
  120943. private _removeOnDetach;
  120944. /**
  120945. * Should auto-attach be disabled?
  120946. */
  120947. disableAutoAttach: boolean;
  120948. /**
  120949. * Construct a new (abstract) WebXR feature
  120950. * @param _xrSessionManager the xr session manager for this feature
  120951. */
  120952. constructor(_xrSessionManager: WebXRSessionManager);
  120953. /**
  120954. * Is this feature attached
  120955. */
  120956. get attached(): boolean;
  120957. /**
  120958. * attach this feature
  120959. *
  120960. * @param force should attachment be forced (even when already attached)
  120961. * @returns true if successful, false is failed or already attached
  120962. */
  120963. attach(force?: boolean): boolean;
  120964. /**
  120965. * detach this feature.
  120966. *
  120967. * @returns true if successful, false if failed or already detached
  120968. */
  120969. detach(): boolean;
  120970. /**
  120971. * Dispose this feature and all of the resources attached
  120972. */
  120973. dispose(): void;
  120974. /**
  120975. * This is used to register callbacks that will automatically be removed when detach is called.
  120976. * @param observable the observable to which the observer will be attached
  120977. * @param callback the callback to register
  120978. */
  120979. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  120980. /**
  120981. * Code in this function will be executed on each xrFrame received from the browser.
  120982. * This function will not execute after the feature is detached.
  120983. * @param _xrFrame the current frame
  120984. */
  120985. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  120986. }
  120987. }
  120988. declare module BABYLON {
  120989. /**
  120990. * Renders a layer on top of an existing scene
  120991. */
  120992. export class UtilityLayerRenderer implements IDisposable {
  120993. /** the original scene that will be rendered on top of */
  120994. originalScene: Scene;
  120995. private _pointerCaptures;
  120996. private _lastPointerEvents;
  120997. private static _DefaultUtilityLayer;
  120998. private static _DefaultKeepDepthUtilityLayer;
  120999. private _sharedGizmoLight;
  121000. private _renderCamera;
  121001. /**
  121002. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  121003. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  121004. * @returns the camera that is used when rendering the utility layer
  121005. */
  121006. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  121007. /**
  121008. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  121009. * @param cam the camera that should be used when rendering the utility layer
  121010. */
  121011. setRenderCamera(cam: Nullable<Camera>): void;
  121012. /**
  121013. * @hidden
  121014. * Light which used by gizmos to get light shading
  121015. */
  121016. _getSharedGizmoLight(): HemisphericLight;
  121017. /**
  121018. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  121019. */
  121020. pickUtilitySceneFirst: boolean;
  121021. /**
  121022. * 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)
  121023. */
  121024. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  121025. /**
  121026. * 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)
  121027. */
  121028. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  121029. /**
  121030. * The scene that is rendered on top of the original scene
  121031. */
  121032. utilityLayerScene: Scene;
  121033. /**
  121034. * If the utility layer should automatically be rendered on top of existing scene
  121035. */
  121036. shouldRender: boolean;
  121037. /**
  121038. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  121039. */
  121040. onlyCheckPointerDownEvents: boolean;
  121041. /**
  121042. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  121043. */
  121044. processAllEvents: boolean;
  121045. /**
  121046. * Observable raised when the pointer move from the utility layer scene to the main scene
  121047. */
  121048. onPointerOutObservable: Observable<number>;
  121049. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  121050. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  121051. private _afterRenderObserver;
  121052. private _sceneDisposeObserver;
  121053. private _originalPointerObserver;
  121054. /**
  121055. * Instantiates a UtilityLayerRenderer
  121056. * @param originalScene the original scene that will be rendered on top of
  121057. * @param handleEvents boolean indicating if the utility layer should handle events
  121058. */
  121059. constructor(
  121060. /** the original scene that will be rendered on top of */
  121061. originalScene: Scene, handleEvents?: boolean);
  121062. private _notifyObservers;
  121063. /**
  121064. * Renders the utility layers scene on top of the original scene
  121065. */
  121066. render(): void;
  121067. /**
  121068. * Disposes of the renderer
  121069. */
  121070. dispose(): void;
  121071. private _updateCamera;
  121072. }
  121073. }
  121074. declare module BABYLON {
  121075. /**
  121076. * Options interface for the pointer selection module
  121077. */
  121078. export interface IWebXRControllerPointerSelectionOptions {
  121079. /**
  121080. * if provided, this scene will be used to render meshes.
  121081. */
  121082. customUtilityLayerScene?: Scene;
  121083. /**
  121084. * 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)
  121085. * If not disabled, the last picked point will be used to execute a pointer up event
  121086. * If disabled, pointer up event will be triggered right after the pointer down event.
  121087. * Used in screen and gaze target ray mode only
  121088. */
  121089. disablePointerUpOnTouchOut: boolean;
  121090. /**
  121091. * For gaze mode (time to select instead of press)
  121092. */
  121093. forceGazeMode: boolean;
  121094. /**
  121095. * 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
  121096. * to start a new countdown to the pointer down event.
  121097. * Defaults to 1.
  121098. */
  121099. gazeModePointerMovedFactor?: number;
  121100. /**
  121101. * Different button type to use instead of the main component
  121102. */
  121103. overrideButtonId?: string;
  121104. /**
  121105. * use this rendering group id for the meshes (optional)
  121106. */
  121107. renderingGroupId?: number;
  121108. /**
  121109. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  121110. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  121111. * 3000 means 3 seconds between pointing at something and selecting it
  121112. */
  121113. timeToSelect?: number;
  121114. /**
  121115. * Should meshes created here be added to a utility layer or the main scene
  121116. */
  121117. useUtilityLayer?: boolean;
  121118. /**
  121119. * the xr input to use with this pointer selection
  121120. */
  121121. xrInput: WebXRInput;
  121122. }
  121123. /**
  121124. * A module that will enable pointer selection for motion controllers of XR Input Sources
  121125. */
  121126. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  121127. private readonly _options;
  121128. private static _idCounter;
  121129. private _attachController;
  121130. private _controllers;
  121131. private _scene;
  121132. private _tmpVectorForPickCompare;
  121133. /**
  121134. * The module's name
  121135. */
  121136. static readonly Name: string;
  121137. /**
  121138. * The (Babylon) version of this module.
  121139. * This is an integer representing the implementation version.
  121140. * This number does not correspond to the WebXR specs version
  121141. */
  121142. static readonly Version: number;
  121143. /**
  121144. * Disable lighting on the laser pointer (so it will always be visible)
  121145. */
  121146. disablePointerLighting: boolean;
  121147. /**
  121148. * Disable lighting on the selection mesh (so it will always be visible)
  121149. */
  121150. disableSelectionMeshLighting: boolean;
  121151. /**
  121152. * Should the laser pointer be displayed
  121153. */
  121154. displayLaserPointer: boolean;
  121155. /**
  121156. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  121157. */
  121158. displaySelectionMesh: boolean;
  121159. /**
  121160. * This color will be set to the laser pointer when selection is triggered
  121161. */
  121162. laserPointerPickedColor: Color3;
  121163. /**
  121164. * Default color of the laser pointer
  121165. */
  121166. lasterPointerDefaultColor: Color3;
  121167. /**
  121168. * default color of the selection ring
  121169. */
  121170. selectionMeshDefaultColor: Color3;
  121171. /**
  121172. * This color will be applied to the selection ring when selection is triggered
  121173. */
  121174. selectionMeshPickedColor: Color3;
  121175. /**
  121176. * Optional filter to be used for ray selection. This predicate shares behavior with
  121177. * scene.pointerMovePredicate which takes priority if it is also assigned.
  121178. */
  121179. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121180. /**
  121181. * constructs a new background remover module
  121182. * @param _xrSessionManager the session manager for this module
  121183. * @param _options read-only options to be used in this module
  121184. */
  121185. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  121186. /**
  121187. * attach this feature
  121188. * Will usually be called by the features manager
  121189. *
  121190. * @returns true if successful.
  121191. */
  121192. attach(): boolean;
  121193. /**
  121194. * detach this feature.
  121195. * Will usually be called by the features manager
  121196. *
  121197. * @returns true if successful.
  121198. */
  121199. detach(): boolean;
  121200. /**
  121201. * Will get the mesh under a specific pointer.
  121202. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  121203. * @param controllerId the controllerId to check
  121204. * @returns The mesh under pointer or null if no mesh is under the pointer
  121205. */
  121206. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  121207. /**
  121208. * Get the xr controller that correlates to the pointer id in the pointer event
  121209. *
  121210. * @param id the pointer id to search for
  121211. * @returns the controller that correlates to this id or null if not found
  121212. */
  121213. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  121214. protected _onXRFrame(_xrFrame: XRFrame): void;
  121215. private _attachGazeMode;
  121216. private _attachScreenRayMode;
  121217. private _attachTrackedPointerRayMode;
  121218. private _convertNormalToDirectionOfRay;
  121219. private _detachController;
  121220. private _generateNewMeshPair;
  121221. private _pickingMoved;
  121222. private _updatePointerDistance;
  121223. }
  121224. }
  121225. declare module BABYLON {
  121226. /**
  121227. * Button which can be used to enter a different mode of XR
  121228. */
  121229. export class WebXREnterExitUIButton {
  121230. /** button element */
  121231. element: HTMLElement;
  121232. /** XR initialization options for the button */
  121233. sessionMode: XRSessionMode;
  121234. /** Reference space type */
  121235. referenceSpaceType: XRReferenceSpaceType;
  121236. /**
  121237. * Creates a WebXREnterExitUIButton
  121238. * @param element button element
  121239. * @param sessionMode XR initialization session mode
  121240. * @param referenceSpaceType the type of reference space to be used
  121241. */
  121242. constructor(
  121243. /** button element */
  121244. element: HTMLElement,
  121245. /** XR initialization options for the button */
  121246. sessionMode: XRSessionMode,
  121247. /** Reference space type */
  121248. referenceSpaceType: XRReferenceSpaceType);
  121249. /**
  121250. * Extendable function which can be used to update the button's visuals when the state changes
  121251. * @param activeButton the current active button in the UI
  121252. */
  121253. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  121254. }
  121255. /**
  121256. * Options to create the webXR UI
  121257. */
  121258. export class WebXREnterExitUIOptions {
  121259. /**
  121260. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  121261. */
  121262. customButtons?: Array<WebXREnterExitUIButton>;
  121263. /**
  121264. * A reference space type to use when creating the default button.
  121265. * Default is local-floor
  121266. */
  121267. referenceSpaceType?: XRReferenceSpaceType;
  121268. /**
  121269. * Context to enter xr with
  121270. */
  121271. renderTarget?: Nullable<WebXRRenderTarget>;
  121272. /**
  121273. * A session mode to use when creating the default button.
  121274. * Default is immersive-vr
  121275. */
  121276. sessionMode?: XRSessionMode;
  121277. /**
  121278. * A list of optional features to init the session with
  121279. */
  121280. optionalFeatures?: string[];
  121281. }
  121282. /**
  121283. * UI to allow the user to enter/exit XR mode
  121284. */
  121285. export class WebXREnterExitUI implements IDisposable {
  121286. private scene;
  121287. /** version of the options passed to this UI */
  121288. options: WebXREnterExitUIOptions;
  121289. private _activeButton;
  121290. private _buttons;
  121291. private _overlay;
  121292. /**
  121293. * Fired every time the active button is changed.
  121294. *
  121295. * When xr is entered via a button that launches xr that button will be the callback parameter
  121296. *
  121297. * When exiting xr the callback parameter will be null)
  121298. */
  121299. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  121300. /**
  121301. *
  121302. * @param scene babylon scene object to use
  121303. * @param options (read-only) version of the options passed to this UI
  121304. */
  121305. private constructor();
  121306. /**
  121307. * Creates UI to allow the user to enter/exit XR mode
  121308. * @param scene the scene to add the ui to
  121309. * @param helper the xr experience helper to enter/exit xr with
  121310. * @param options options to configure the UI
  121311. * @returns the created ui
  121312. */
  121313. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  121314. /**
  121315. * Disposes of the XR UI component
  121316. */
  121317. dispose(): void;
  121318. private _updateButtons;
  121319. }
  121320. }
  121321. declare module BABYLON {
  121322. /**
  121323. * Class containing static functions to help procedurally build meshes
  121324. */
  121325. export class LinesBuilder {
  121326. /**
  121327. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121328. * * 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
  121329. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121330. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121331. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121332. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121333. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121334. * * 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
  121335. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121338. * @param name defines the name of the new line system
  121339. * @param options defines the options used to create the line system
  121340. * @param scene defines the hosting scene
  121341. * @returns a new line system mesh
  121342. */
  121343. static CreateLineSystem(name: string, options: {
  121344. lines: Vector3[][];
  121345. updatable?: boolean;
  121346. instance?: Nullable<LinesMesh>;
  121347. colors?: Nullable<Color4[][]>;
  121348. useVertexAlpha?: boolean;
  121349. }, scene: Nullable<Scene>): LinesMesh;
  121350. /**
  121351. * Creates a line mesh
  121352. * 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
  121353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121354. * * The parameter `points` is an array successive Vector3
  121355. * * 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
  121356. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121357. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121358. * * When updating an instance, remember that only point positions can change, not the number of points
  121359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121361. * @param name defines the name of the new line system
  121362. * @param options defines the options used to create the line system
  121363. * @param scene defines the hosting scene
  121364. * @returns a new line mesh
  121365. */
  121366. static CreateLines(name: string, options: {
  121367. points: Vector3[];
  121368. updatable?: boolean;
  121369. instance?: Nullable<LinesMesh>;
  121370. colors?: Color4[];
  121371. useVertexAlpha?: boolean;
  121372. }, scene?: Nullable<Scene>): LinesMesh;
  121373. /**
  121374. * Creates a dashed line mesh
  121375. * * 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
  121376. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121377. * * The parameter `points` is an array successive Vector3
  121378. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121379. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121380. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121381. * * 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
  121382. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121383. * * When updating an instance, remember that only point positions can change, not the number of points
  121384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121385. * @param name defines the name of the mesh
  121386. * @param options defines the options used to create the mesh
  121387. * @param scene defines the hosting scene
  121388. * @returns the dashed line mesh
  121389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121390. */
  121391. static CreateDashedLines(name: string, options: {
  121392. points: Vector3[];
  121393. dashSize?: number;
  121394. gapSize?: number;
  121395. dashNb?: number;
  121396. updatable?: boolean;
  121397. instance?: LinesMesh;
  121398. useVertexAlpha?: boolean;
  121399. }, scene?: Nullable<Scene>): LinesMesh;
  121400. }
  121401. }
  121402. declare module BABYLON {
  121403. /**
  121404. * The options container for the teleportation module
  121405. */
  121406. export interface IWebXRTeleportationOptions {
  121407. /**
  121408. * if provided, this scene will be used to render meshes.
  121409. */
  121410. customUtilityLayerScene?: Scene;
  121411. /**
  121412. * Values to configure the default target mesh
  121413. */
  121414. defaultTargetMeshOptions?: {
  121415. /**
  121416. * Fill color of the teleportation area
  121417. */
  121418. teleportationFillColor?: string;
  121419. /**
  121420. * Border color for the teleportation area
  121421. */
  121422. teleportationBorderColor?: string;
  121423. /**
  121424. * Disable the mesh's animation sequence
  121425. */
  121426. disableAnimation?: boolean;
  121427. /**
  121428. * Disable lighting on the material or the ring and arrow
  121429. */
  121430. disableLighting?: boolean;
  121431. /**
  121432. * Override the default material of the torus and arrow
  121433. */
  121434. torusArrowMaterial?: Material;
  121435. };
  121436. /**
  121437. * A list of meshes to use as floor meshes.
  121438. * Meshes can be added and removed after initializing the feature using the
  121439. * addFloorMesh and removeFloorMesh functions
  121440. * If empty, rotation will still work
  121441. */
  121442. floorMeshes?: AbstractMesh[];
  121443. /**
  121444. * use this rendering group id for the meshes (optional)
  121445. */
  121446. renderingGroupId?: number;
  121447. /**
  121448. * Should teleportation move only to snap points
  121449. */
  121450. snapPointsOnly?: boolean;
  121451. /**
  121452. * An array of points to which the teleportation will snap to.
  121453. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  121454. */
  121455. snapPositions?: Vector3[];
  121456. /**
  121457. * How close should the teleportation ray be in order to snap to position.
  121458. * Default to 0.8 units (meters)
  121459. */
  121460. snapToPositionRadius?: number;
  121461. /**
  121462. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  121463. * If you want to support rotation, make sure your mesh has a direction indicator.
  121464. *
  121465. * When left untouched, the default mesh will be initialized.
  121466. */
  121467. teleportationTargetMesh?: AbstractMesh;
  121468. /**
  121469. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  121470. */
  121471. timeToTeleport?: number;
  121472. /**
  121473. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  121474. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  121475. */
  121476. useMainComponentOnly?: boolean;
  121477. /**
  121478. * Should meshes created here be added to a utility layer or the main scene
  121479. */
  121480. useUtilityLayer?: boolean;
  121481. /**
  121482. * Babylon XR Input class for controller
  121483. */
  121484. xrInput: WebXRInput;
  121485. }
  121486. /**
  121487. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  121488. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  121489. * the input of the attached controllers.
  121490. */
  121491. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  121492. private _options;
  121493. private _controllers;
  121494. private _currentTeleportationControllerId;
  121495. private _floorMeshes;
  121496. private _quadraticBezierCurve;
  121497. private _selectionFeature;
  121498. private _snapToPositions;
  121499. private _snappedToPoint;
  121500. private _teleportationRingMaterial?;
  121501. private _tmpRay;
  121502. private _tmpVector;
  121503. /**
  121504. * The module's name
  121505. */
  121506. static readonly Name: string;
  121507. /**
  121508. * The (Babylon) version of this module.
  121509. * This is an integer representing the implementation version.
  121510. * This number does not correspond to the webxr specs version
  121511. */
  121512. static readonly Version: number;
  121513. /**
  121514. * Is movement backwards enabled
  121515. */
  121516. backwardsMovementEnabled: boolean;
  121517. /**
  121518. * Distance to travel when moving backwards
  121519. */
  121520. backwardsTeleportationDistance: number;
  121521. /**
  121522. * The distance from the user to the inspection point in the direction of the controller
  121523. * A higher number will allow the user to move further
  121524. * defaults to 5 (meters, in xr units)
  121525. */
  121526. parabolicCheckRadius: number;
  121527. /**
  121528. * Should the module support parabolic ray on top of direct ray
  121529. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  121530. * Very helpful when moving between floors / different heights
  121531. */
  121532. parabolicRayEnabled: boolean;
  121533. /**
  121534. * How much rotation should be applied when rotating right and left
  121535. */
  121536. rotationAngle: number;
  121537. /**
  121538. * Is rotation enabled when moving forward?
  121539. * Disabling this feature will prevent the user from deciding the direction when teleporting
  121540. */
  121541. rotationEnabled: boolean;
  121542. /**
  121543. * constructs a new anchor system
  121544. * @param _xrSessionManager an instance of WebXRSessionManager
  121545. * @param _options configuration object for this feature
  121546. */
  121547. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  121548. /**
  121549. * Get the snapPointsOnly flag
  121550. */
  121551. get snapPointsOnly(): boolean;
  121552. /**
  121553. * Sets the snapPointsOnly flag
  121554. * @param snapToPoints should teleportation be exclusively to snap points
  121555. */
  121556. set snapPointsOnly(snapToPoints: boolean);
  121557. /**
  121558. * Add a new mesh to the floor meshes array
  121559. * @param mesh the mesh to use as floor mesh
  121560. */
  121561. addFloorMesh(mesh: AbstractMesh): void;
  121562. /**
  121563. * Add a new snap-to point to fix teleportation to this position
  121564. * @param newSnapPoint The new Snap-To point
  121565. */
  121566. addSnapPoint(newSnapPoint: Vector3): void;
  121567. attach(): boolean;
  121568. detach(): boolean;
  121569. dispose(): void;
  121570. /**
  121571. * Remove a mesh from the floor meshes array
  121572. * @param mesh the mesh to remove
  121573. */
  121574. removeFloorMesh(mesh: AbstractMesh): void;
  121575. /**
  121576. * Remove a mesh from the floor meshes array using its name
  121577. * @param name the mesh name to remove
  121578. */
  121579. removeFloorMeshByName(name: string): void;
  121580. /**
  121581. * 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
  121582. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  121583. * @returns was the point found and removed or not
  121584. */
  121585. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  121586. /**
  121587. * This function sets a selection feature that will be disabled when
  121588. * the forward ray is shown and will be reattached when hidden.
  121589. * This is used to remove the selection rays when moving.
  121590. * @param selectionFeature the feature to disable when forward movement is enabled
  121591. */
  121592. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  121593. protected _onXRFrame(_xrFrame: XRFrame): void;
  121594. private _attachController;
  121595. private _createDefaultTargetMesh;
  121596. private _detachController;
  121597. private _findClosestSnapPointWithRadius;
  121598. private _setTargetMeshPosition;
  121599. private _setTargetMeshVisibility;
  121600. private _showParabolicPath;
  121601. private _teleportForward;
  121602. }
  121603. }
  121604. declare module BABYLON {
  121605. /**
  121606. * Options for the default xr helper
  121607. */
  121608. export class WebXRDefaultExperienceOptions {
  121609. /**
  121610. * Enable or disable default UI to enter XR
  121611. */
  121612. disableDefaultUI?: boolean;
  121613. /**
  121614. * Should teleportation not initialize. defaults to false.
  121615. */
  121616. disableTeleportation?: boolean;
  121617. /**
  121618. * Floor meshes that will be used for teleport
  121619. */
  121620. floorMeshes?: Array<AbstractMesh>;
  121621. /**
  121622. * If set to true, the first frame will not be used to reset position
  121623. * The first frame is mainly used when copying transformation from the old camera
  121624. * Mainly used in AR
  121625. */
  121626. ignoreNativeCameraTransformation?: boolean;
  121627. /**
  121628. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  121629. */
  121630. inputOptions?: IWebXRInputOptions;
  121631. /**
  121632. * optional configuration for the output canvas
  121633. */
  121634. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  121635. /**
  121636. * optional UI options. This can be used among other to change session mode and reference space type
  121637. */
  121638. uiOptions?: WebXREnterExitUIOptions;
  121639. /**
  121640. * When loading teleportation and pointer select, use stable versions instead of latest.
  121641. */
  121642. useStablePlugins?: boolean;
  121643. /**
  121644. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  121645. */
  121646. renderingGroupId?: number;
  121647. /**
  121648. * A list of optional features to init the session with
  121649. * If set to true, all features we support will be added
  121650. */
  121651. optionalFeatures?: boolean | string[];
  121652. }
  121653. /**
  121654. * Default experience which provides a similar setup to the previous webVRExperience
  121655. */
  121656. export class WebXRDefaultExperience {
  121657. /**
  121658. * Base experience
  121659. */
  121660. baseExperience: WebXRExperienceHelper;
  121661. /**
  121662. * Enables ui for entering/exiting xr
  121663. */
  121664. enterExitUI: WebXREnterExitUI;
  121665. /**
  121666. * Input experience extension
  121667. */
  121668. input: WebXRInput;
  121669. /**
  121670. * Enables laser pointer and selection
  121671. */
  121672. pointerSelection: WebXRControllerPointerSelection;
  121673. /**
  121674. * Default target xr should render to
  121675. */
  121676. renderTarget: WebXRRenderTarget;
  121677. /**
  121678. * Enables teleportation
  121679. */
  121680. teleportation: WebXRMotionControllerTeleportation;
  121681. private constructor();
  121682. /**
  121683. * Creates the default xr experience
  121684. * @param scene scene
  121685. * @param options options for basic configuration
  121686. * @returns resulting WebXRDefaultExperience
  121687. */
  121688. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121689. /**
  121690. * DIsposes of the experience helper
  121691. */
  121692. dispose(): void;
  121693. }
  121694. }
  121695. declare module BABYLON {
  121696. /**
  121697. * Options to modify the vr teleportation behavior.
  121698. */
  121699. export interface VRTeleportationOptions {
  121700. /**
  121701. * The name of the mesh which should be used as the teleportation floor. (default: null)
  121702. */
  121703. floorMeshName?: string;
  121704. /**
  121705. * A list of meshes to be used as the teleportation floor. (default: empty)
  121706. */
  121707. floorMeshes?: Mesh[];
  121708. /**
  121709. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  121710. */
  121711. teleportationMode?: number;
  121712. /**
  121713. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  121714. */
  121715. teleportationTime?: number;
  121716. /**
  121717. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  121718. */
  121719. teleportationSpeed?: number;
  121720. /**
  121721. * The easing function used in the animation or null for Linear. (default CircleEase)
  121722. */
  121723. easingFunction?: EasingFunction;
  121724. }
  121725. /**
  121726. * Options to modify the vr experience helper's behavior.
  121727. */
  121728. export interface VRExperienceHelperOptions extends WebVROptions {
  121729. /**
  121730. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  121731. */
  121732. createDeviceOrientationCamera?: boolean;
  121733. /**
  121734. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  121735. */
  121736. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  121737. /**
  121738. * Uses the main button on the controller to toggle the laser casted. (default: true)
  121739. */
  121740. laserToggle?: boolean;
  121741. /**
  121742. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  121743. */
  121744. floorMeshes?: Mesh[];
  121745. /**
  121746. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  121747. */
  121748. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  121749. /**
  121750. * Defines if WebXR should be used instead of WebVR (if available)
  121751. */
  121752. useXR?: boolean;
  121753. }
  121754. /**
  121755. * Event containing information after VR has been entered
  121756. */
  121757. export class OnAfterEnteringVRObservableEvent {
  121758. /**
  121759. * If entering vr was successful
  121760. */
  121761. success: boolean;
  121762. }
  121763. /**
  121764. * Helps to quickly add VR support to an existing scene.
  121765. * See http://doc.babylonjs.com/how_to/webvr_helper
  121766. */
  121767. export class VRExperienceHelper {
  121768. /** Options to modify the vr experience helper's behavior. */
  121769. webVROptions: VRExperienceHelperOptions;
  121770. private _scene;
  121771. private _position;
  121772. private _btnVR;
  121773. private _btnVRDisplayed;
  121774. private _webVRsupported;
  121775. private _webVRready;
  121776. private _webVRrequesting;
  121777. private _webVRpresenting;
  121778. private _hasEnteredVR;
  121779. private _fullscreenVRpresenting;
  121780. private _inputElement;
  121781. private _webVRCamera;
  121782. private _vrDeviceOrientationCamera;
  121783. private _deviceOrientationCamera;
  121784. private _existingCamera;
  121785. private _onKeyDown;
  121786. private _onVrDisplayPresentChange;
  121787. private _onVRDisplayChanged;
  121788. private _onVRRequestPresentStart;
  121789. private _onVRRequestPresentComplete;
  121790. /**
  121791. * 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)
  121792. */
  121793. enableGazeEvenWhenNoPointerLock: boolean;
  121794. /**
  121795. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  121796. */
  121797. exitVROnDoubleTap: boolean;
  121798. /**
  121799. * Observable raised right before entering VR.
  121800. */
  121801. onEnteringVRObservable: Observable<VRExperienceHelper>;
  121802. /**
  121803. * Observable raised when entering VR has completed.
  121804. */
  121805. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  121806. /**
  121807. * Observable raised when exiting VR.
  121808. */
  121809. onExitingVRObservable: Observable<VRExperienceHelper>;
  121810. /**
  121811. * Observable raised when controller mesh is loaded.
  121812. */
  121813. onControllerMeshLoadedObservable: Observable<WebVRController>;
  121814. /** Return this.onEnteringVRObservable
  121815. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  121816. */
  121817. get onEnteringVR(): Observable<VRExperienceHelper>;
  121818. /** Return this.onExitingVRObservable
  121819. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  121820. */
  121821. get onExitingVR(): Observable<VRExperienceHelper>;
  121822. /** Return this.onControllerMeshLoadedObservable
  121823. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  121824. */
  121825. get onControllerMeshLoaded(): Observable<WebVRController>;
  121826. private _rayLength;
  121827. private _useCustomVRButton;
  121828. private _teleportationRequested;
  121829. private _teleportActive;
  121830. private _floorMeshName;
  121831. private _floorMeshesCollection;
  121832. private _teleportationMode;
  121833. private _teleportationTime;
  121834. private _teleportationSpeed;
  121835. private _teleportationEasing;
  121836. private _rotationAllowed;
  121837. private _teleportBackwardsVector;
  121838. private _teleportationTarget;
  121839. private _isDefaultTeleportationTarget;
  121840. private _postProcessMove;
  121841. private _teleportationFillColor;
  121842. private _teleportationBorderColor;
  121843. private _rotationAngle;
  121844. private _haloCenter;
  121845. private _cameraGazer;
  121846. private _padSensibilityUp;
  121847. private _padSensibilityDown;
  121848. private _leftController;
  121849. private _rightController;
  121850. private _gazeColor;
  121851. private _laserColor;
  121852. private _pickedLaserColor;
  121853. private _pickedGazeColor;
  121854. /**
  121855. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  121856. */
  121857. onNewMeshSelected: Observable<AbstractMesh>;
  121858. /**
  121859. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  121860. * This observable will provide the mesh and the controller used to select the mesh
  121861. */
  121862. onMeshSelectedWithController: Observable<{
  121863. mesh: AbstractMesh;
  121864. controller: WebVRController;
  121865. }>;
  121866. /**
  121867. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  121868. */
  121869. onNewMeshPicked: Observable<PickingInfo>;
  121870. private _circleEase;
  121871. /**
  121872. * Observable raised before camera teleportation
  121873. */
  121874. onBeforeCameraTeleport: Observable<Vector3>;
  121875. /**
  121876. * Observable raised after camera teleportation
  121877. */
  121878. onAfterCameraTeleport: Observable<Vector3>;
  121879. /**
  121880. * Observable raised when current selected mesh gets unselected
  121881. */
  121882. onSelectedMeshUnselected: Observable<AbstractMesh>;
  121883. private _raySelectionPredicate;
  121884. /**
  121885. * To be optionaly changed by user to define custom ray selection
  121886. */
  121887. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121888. /**
  121889. * To be optionaly changed by user to define custom selection logic (after ray selection)
  121890. */
  121891. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  121892. /**
  121893. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  121894. */
  121895. teleportationEnabled: boolean;
  121896. private _defaultHeight;
  121897. private _teleportationInitialized;
  121898. private _interactionsEnabled;
  121899. private _interactionsRequested;
  121900. private _displayGaze;
  121901. private _displayLaserPointer;
  121902. /**
  121903. * The mesh used to display where the user is going to teleport.
  121904. */
  121905. get teleportationTarget(): Mesh;
  121906. /**
  121907. * Sets the mesh to be used to display where the user is going to teleport.
  121908. */
  121909. set teleportationTarget(value: Mesh);
  121910. /**
  121911. * 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
  121912. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  121913. * See http://doc.babylonjs.com/resources/baking_transformations
  121914. */
  121915. get gazeTrackerMesh(): Mesh;
  121916. set gazeTrackerMesh(value: Mesh);
  121917. /**
  121918. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  121919. */
  121920. updateGazeTrackerScale: boolean;
  121921. /**
  121922. * If the gaze trackers color should be updated when selecting meshes
  121923. */
  121924. updateGazeTrackerColor: boolean;
  121925. /**
  121926. * If the controller laser color should be updated when selecting meshes
  121927. */
  121928. updateControllerLaserColor: boolean;
  121929. /**
  121930. * The gaze tracking mesh corresponding to the left controller
  121931. */
  121932. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  121933. /**
  121934. * The gaze tracking mesh corresponding to the right controller
  121935. */
  121936. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  121937. /**
  121938. * If the ray of the gaze should be displayed.
  121939. */
  121940. get displayGaze(): boolean;
  121941. /**
  121942. * Sets if the ray of the gaze should be displayed.
  121943. */
  121944. set displayGaze(value: boolean);
  121945. /**
  121946. * If the ray of the LaserPointer should be displayed.
  121947. */
  121948. get displayLaserPointer(): boolean;
  121949. /**
  121950. * Sets if the ray of the LaserPointer should be displayed.
  121951. */
  121952. set displayLaserPointer(value: boolean);
  121953. /**
  121954. * The deviceOrientationCamera used as the camera when not in VR.
  121955. */
  121956. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  121957. /**
  121958. * Based on the current WebVR support, returns the current VR camera used.
  121959. */
  121960. get currentVRCamera(): Nullable<Camera>;
  121961. /**
  121962. * The webVRCamera which is used when in VR.
  121963. */
  121964. get webVRCamera(): WebVRFreeCamera;
  121965. /**
  121966. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  121967. */
  121968. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  121969. /**
  121970. * The html button that is used to trigger entering into VR.
  121971. */
  121972. get vrButton(): Nullable<HTMLButtonElement>;
  121973. private get _teleportationRequestInitiated();
  121974. /**
  121975. * Defines whether or not Pointer lock should be requested when switching to
  121976. * full screen.
  121977. */
  121978. requestPointerLockOnFullScreen: boolean;
  121979. /**
  121980. * If asking to force XR, this will be populated with the default xr experience
  121981. */
  121982. xr: WebXRDefaultExperience;
  121983. /**
  121984. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  121985. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  121986. */
  121987. xrTestDone: boolean;
  121988. /**
  121989. * Instantiates a VRExperienceHelper.
  121990. * Helps to quickly add VR support to an existing scene.
  121991. * @param scene The scene the VRExperienceHelper belongs to.
  121992. * @param webVROptions Options to modify the vr experience helper's behavior.
  121993. */
  121994. constructor(scene: Scene,
  121995. /** Options to modify the vr experience helper's behavior. */
  121996. webVROptions?: VRExperienceHelperOptions);
  121997. private completeVRInit;
  121998. private _onDefaultMeshLoaded;
  121999. private _onResize;
  122000. private _onFullscreenChange;
  122001. /**
  122002. * Gets a value indicating if we are currently in VR mode.
  122003. */
  122004. get isInVRMode(): boolean;
  122005. private onVrDisplayPresentChange;
  122006. private onVRDisplayChanged;
  122007. private moveButtonToBottomRight;
  122008. private displayVRButton;
  122009. private updateButtonVisibility;
  122010. private _cachedAngularSensibility;
  122011. /**
  122012. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  122013. * Otherwise, will use the fullscreen API.
  122014. */
  122015. enterVR(): void;
  122016. /**
  122017. * Attempt to exit VR, or fullscreen.
  122018. */
  122019. exitVR(): void;
  122020. /**
  122021. * The position of the vr experience helper.
  122022. */
  122023. get position(): Vector3;
  122024. /**
  122025. * Sets the position of the vr experience helper.
  122026. */
  122027. set position(value: Vector3);
  122028. /**
  122029. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  122030. */
  122031. enableInteractions(): void;
  122032. private get _noControllerIsActive();
  122033. private beforeRender;
  122034. private _isTeleportationFloor;
  122035. /**
  122036. * Adds a floor mesh to be used for teleportation.
  122037. * @param floorMesh the mesh to be used for teleportation.
  122038. */
  122039. addFloorMesh(floorMesh: Mesh): void;
  122040. /**
  122041. * Removes a floor mesh from being used for teleportation.
  122042. * @param floorMesh the mesh to be removed.
  122043. */
  122044. removeFloorMesh(floorMesh: Mesh): void;
  122045. /**
  122046. * Enables interactions and teleportation using the VR controllers and gaze.
  122047. * @param vrTeleportationOptions options to modify teleportation behavior.
  122048. */
  122049. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  122050. private _onNewGamepadConnected;
  122051. private _tryEnableInteractionOnController;
  122052. private _onNewGamepadDisconnected;
  122053. private _enableInteractionOnController;
  122054. private _checkTeleportWithRay;
  122055. private _checkRotate;
  122056. private _checkTeleportBackwards;
  122057. private _enableTeleportationOnController;
  122058. private _createTeleportationCircles;
  122059. private _displayTeleportationTarget;
  122060. private _hideTeleportationTarget;
  122061. private _rotateCamera;
  122062. private _moveTeleportationSelectorTo;
  122063. private _workingVector;
  122064. private _workingQuaternion;
  122065. private _workingMatrix;
  122066. /**
  122067. * Time Constant Teleportation Mode
  122068. */
  122069. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  122070. /**
  122071. * Speed Constant Teleportation Mode
  122072. */
  122073. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  122074. /**
  122075. * Teleports the users feet to the desired location
  122076. * @param location The location where the user's feet should be placed
  122077. */
  122078. teleportCamera(location: Vector3): void;
  122079. private _convertNormalToDirectionOfRay;
  122080. private _castRayAndSelectObject;
  122081. private _notifySelectedMeshUnselected;
  122082. /**
  122083. * Permanently set new colors for the laser pointer
  122084. * @param color the new laser color
  122085. * @param pickedColor the new laser color when picked mesh detected
  122086. */
  122087. setLaserColor(color: Color3, pickedColor?: Color3): void;
  122088. /**
  122089. * Set lighting enabled / disabled on the laser pointer of both controllers
  122090. * @param enabled should the lighting be enabled on the laser pointer
  122091. */
  122092. setLaserLightingState(enabled?: boolean): void;
  122093. /**
  122094. * Permanently set new colors for the gaze pointer
  122095. * @param color the new gaze color
  122096. * @param pickedColor the new gaze color when picked mesh detected
  122097. */
  122098. setGazeColor(color: Color3, pickedColor?: Color3): void;
  122099. /**
  122100. * Sets the color of the laser ray from the vr controllers.
  122101. * @param color new color for the ray.
  122102. */
  122103. changeLaserColor(color: Color3): void;
  122104. /**
  122105. * Sets the color of the ray from the vr headsets gaze.
  122106. * @param color new color for the ray.
  122107. */
  122108. changeGazeColor(color: Color3): void;
  122109. /**
  122110. * Exits VR and disposes of the vr experience helper
  122111. */
  122112. dispose(): void;
  122113. /**
  122114. * Gets the name of the VRExperienceHelper class
  122115. * @returns "VRExperienceHelper"
  122116. */
  122117. getClassName(): string;
  122118. }
  122119. }
  122120. declare module BABYLON {
  122121. /**
  122122. * Contains an array of blocks representing the octree
  122123. */
  122124. export interface IOctreeContainer<T> {
  122125. /**
  122126. * Blocks within the octree
  122127. */
  122128. blocks: Array<OctreeBlock<T>>;
  122129. }
  122130. /**
  122131. * Class used to store a cell in an octree
  122132. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122133. */
  122134. export class OctreeBlock<T> {
  122135. /**
  122136. * Gets the content of the current block
  122137. */
  122138. entries: T[];
  122139. /**
  122140. * Gets the list of block children
  122141. */
  122142. blocks: Array<OctreeBlock<T>>;
  122143. private _depth;
  122144. private _maxDepth;
  122145. private _capacity;
  122146. private _minPoint;
  122147. private _maxPoint;
  122148. private _boundingVectors;
  122149. private _creationFunc;
  122150. /**
  122151. * Creates a new block
  122152. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  122153. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  122154. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  122155. * @param depth defines the current depth of this block in the octree
  122156. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  122157. * @param creationFunc defines a callback to call when an element is added to the block
  122158. */
  122159. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  122160. /**
  122161. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  122162. */
  122163. get capacity(): number;
  122164. /**
  122165. * Gets the minimum vector (in world space) of the block's bounding box
  122166. */
  122167. get minPoint(): Vector3;
  122168. /**
  122169. * Gets the maximum vector (in world space) of the block's bounding box
  122170. */
  122171. get maxPoint(): Vector3;
  122172. /**
  122173. * Add a new element to this block
  122174. * @param entry defines the element to add
  122175. */
  122176. addEntry(entry: T): void;
  122177. /**
  122178. * Remove an element from this block
  122179. * @param entry defines the element to remove
  122180. */
  122181. removeEntry(entry: T): void;
  122182. /**
  122183. * Add an array of elements to this block
  122184. * @param entries defines the array of elements to add
  122185. */
  122186. addEntries(entries: T[]): void;
  122187. /**
  122188. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  122189. * @param frustumPlanes defines the frustum planes to test
  122190. * @param selection defines the array to store current content if selection is positive
  122191. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122192. */
  122193. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  122194. /**
  122195. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  122196. * @param sphereCenter defines the bounding sphere center
  122197. * @param sphereRadius defines the bounding sphere radius
  122198. * @param selection defines the array to store current content if selection is positive
  122199. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122200. */
  122201. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  122202. /**
  122203. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  122204. * @param ray defines the ray to test with
  122205. * @param selection defines the array to store current content if selection is positive
  122206. */
  122207. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  122208. /**
  122209. * Subdivide the content into child blocks (this block will then be empty)
  122210. */
  122211. createInnerBlocks(): void;
  122212. /**
  122213. * @hidden
  122214. */
  122215. 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;
  122216. }
  122217. }
  122218. declare module BABYLON {
  122219. /**
  122220. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  122221. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122222. */
  122223. export class Octree<T> {
  122224. /** 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.) */
  122225. maxDepth: number;
  122226. /**
  122227. * Blocks within the octree containing objects
  122228. */
  122229. blocks: Array<OctreeBlock<T>>;
  122230. /**
  122231. * Content stored in the octree
  122232. */
  122233. dynamicContent: T[];
  122234. private _maxBlockCapacity;
  122235. private _selectionContent;
  122236. private _creationFunc;
  122237. /**
  122238. * Creates a octree
  122239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122240. * @param creationFunc function to be used to instatiate the octree
  122241. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  122242. * @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.)
  122243. */
  122244. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  122245. /** 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.) */
  122246. maxDepth?: number);
  122247. /**
  122248. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  122249. * @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);
  122250. * @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);
  122251. * @param entries meshes to be added to the octree blocks
  122252. */
  122253. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  122254. /**
  122255. * Adds a mesh to the octree
  122256. * @param entry Mesh to add to the octree
  122257. */
  122258. addMesh(entry: T): void;
  122259. /**
  122260. * Remove an element from the octree
  122261. * @param entry defines the element to remove
  122262. */
  122263. removeMesh(entry: T): void;
  122264. /**
  122265. * Selects an array of meshes within the frustum
  122266. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  122267. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  122268. * @returns array of meshes within the frustum
  122269. */
  122270. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  122271. /**
  122272. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  122273. * @param sphereCenter defines the bounding sphere center
  122274. * @param sphereRadius defines the bounding sphere radius
  122275. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122276. * @returns an array of objects that intersect the sphere
  122277. */
  122278. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  122279. /**
  122280. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  122281. * @param ray defines the ray to test with
  122282. * @returns array of intersected objects
  122283. */
  122284. intersectsRay(ray: Ray): SmartArray<T>;
  122285. /**
  122286. * Adds a mesh into the octree block if it intersects the block
  122287. */
  122288. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  122289. /**
  122290. * Adds a submesh into the octree block if it intersects the block
  122291. */
  122292. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  122293. }
  122294. }
  122295. declare module BABYLON {
  122296. interface Scene {
  122297. /**
  122298. * @hidden
  122299. * Backing Filed
  122300. */
  122301. _selectionOctree: Octree<AbstractMesh>;
  122302. /**
  122303. * Gets the octree used to boost mesh selection (picking)
  122304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122305. */
  122306. selectionOctree: Octree<AbstractMesh>;
  122307. /**
  122308. * Creates or updates the octree used to boost selection (picking)
  122309. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122310. * @param maxCapacity defines the maximum capacity per leaf
  122311. * @param maxDepth defines the maximum depth of the octree
  122312. * @returns an octree of AbstractMesh
  122313. */
  122314. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  122315. }
  122316. interface AbstractMesh {
  122317. /**
  122318. * @hidden
  122319. * Backing Field
  122320. */
  122321. _submeshesOctree: Octree<SubMesh>;
  122322. /**
  122323. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  122324. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  122325. * @param maxCapacity defines the maximum size of each block (64 by default)
  122326. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  122327. * @returns the new octree
  122328. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  122329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122330. */
  122331. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  122332. }
  122333. /**
  122334. * Defines the octree scene component responsible to manage any octrees
  122335. * in a given scene.
  122336. */
  122337. export class OctreeSceneComponent {
  122338. /**
  122339. * The component name help to identify the component in the list of scene components.
  122340. */
  122341. readonly name: string;
  122342. /**
  122343. * The scene the component belongs to.
  122344. */
  122345. scene: Scene;
  122346. /**
  122347. * Indicates if the meshes have been checked to make sure they are isEnabled()
  122348. */
  122349. readonly checksIsEnabled: boolean;
  122350. /**
  122351. * Creates a new instance of the component for the given scene
  122352. * @param scene Defines the scene to register the component in
  122353. */
  122354. constructor(scene: Scene);
  122355. /**
  122356. * Registers the component in a given scene
  122357. */
  122358. register(): void;
  122359. /**
  122360. * Return the list of active meshes
  122361. * @returns the list of active meshes
  122362. */
  122363. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  122364. /**
  122365. * Return the list of active sub meshes
  122366. * @param mesh The mesh to get the candidates sub meshes from
  122367. * @returns the list of active sub meshes
  122368. */
  122369. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  122370. private _tempRay;
  122371. /**
  122372. * Return the list of sub meshes intersecting with a given local ray
  122373. * @param mesh defines the mesh to find the submesh for
  122374. * @param localRay defines the ray in local space
  122375. * @returns the list of intersecting sub meshes
  122376. */
  122377. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  122378. /**
  122379. * Return the list of sub meshes colliding with a collider
  122380. * @param mesh defines the mesh to find the submesh for
  122381. * @param collider defines the collider to evaluate the collision against
  122382. * @returns the list of colliding sub meshes
  122383. */
  122384. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  122385. /**
  122386. * Rebuilds the elements related to this component in case of
  122387. * context lost for instance.
  122388. */
  122389. rebuild(): void;
  122390. /**
  122391. * Disposes the component and the associated ressources.
  122392. */
  122393. dispose(): void;
  122394. }
  122395. }
  122396. declare module BABYLON {
  122397. /**
  122398. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  122399. */
  122400. export class Gizmo implements IDisposable {
  122401. /** The utility layer the gizmo will be added to */
  122402. gizmoLayer: UtilityLayerRenderer;
  122403. /**
  122404. * The root mesh of the gizmo
  122405. */
  122406. _rootMesh: Mesh;
  122407. private _attachedMesh;
  122408. /**
  122409. * Ratio for the scale of the gizmo (Default: 1)
  122410. */
  122411. scaleRatio: number;
  122412. /**
  122413. * If a custom mesh has been set (Default: false)
  122414. */
  122415. protected _customMeshSet: boolean;
  122416. /**
  122417. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  122418. * * When set, interactions will be enabled
  122419. */
  122420. get attachedMesh(): Nullable<AbstractMesh>;
  122421. set attachedMesh(value: Nullable<AbstractMesh>);
  122422. /**
  122423. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122424. * @param mesh The mesh to replace the default mesh of the gizmo
  122425. */
  122426. setCustomMesh(mesh: Mesh): void;
  122427. /**
  122428. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  122429. */
  122430. updateGizmoRotationToMatchAttachedMesh: boolean;
  122431. /**
  122432. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  122433. */
  122434. updateGizmoPositionToMatchAttachedMesh: boolean;
  122435. /**
  122436. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  122437. */
  122438. updateScale: boolean;
  122439. protected _interactionsEnabled: boolean;
  122440. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122441. private _beforeRenderObserver;
  122442. private _tempVector;
  122443. /**
  122444. * Creates a gizmo
  122445. * @param gizmoLayer The utility layer the gizmo will be added to
  122446. */
  122447. constructor(
  122448. /** The utility layer the gizmo will be added to */
  122449. gizmoLayer?: UtilityLayerRenderer);
  122450. /**
  122451. * Updates the gizmo to match the attached mesh's position/rotation
  122452. */
  122453. protected _update(): void;
  122454. /**
  122455. * Disposes of the gizmo
  122456. */
  122457. dispose(): void;
  122458. }
  122459. }
  122460. declare module BABYLON {
  122461. /**
  122462. * Single plane drag gizmo
  122463. */
  122464. export class PlaneDragGizmo extends Gizmo {
  122465. /**
  122466. * Drag behavior responsible for the gizmos dragging interactions
  122467. */
  122468. dragBehavior: PointerDragBehavior;
  122469. private _pointerObserver;
  122470. /**
  122471. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122472. */
  122473. snapDistance: number;
  122474. /**
  122475. * Event that fires each time the gizmo snaps to a new location.
  122476. * * snapDistance is the the change in distance
  122477. */
  122478. onSnapObservable: Observable<{
  122479. snapDistance: number;
  122480. }>;
  122481. private _plane;
  122482. private _coloredMaterial;
  122483. private _hoverMaterial;
  122484. private _isEnabled;
  122485. private _parent;
  122486. /** @hidden */
  122487. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  122488. /** @hidden */
  122489. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122490. /**
  122491. * Creates a PlaneDragGizmo
  122492. * @param gizmoLayer The utility layer the gizmo will be added to
  122493. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  122494. * @param color The color of the gizmo
  122495. */
  122496. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122497. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122498. /**
  122499. * If the gizmo is enabled
  122500. */
  122501. set isEnabled(value: boolean);
  122502. get isEnabled(): boolean;
  122503. /**
  122504. * Disposes of the gizmo
  122505. */
  122506. dispose(): void;
  122507. }
  122508. }
  122509. declare module BABYLON {
  122510. /**
  122511. * Gizmo that enables dragging a mesh along 3 axis
  122512. */
  122513. export class PositionGizmo extends Gizmo {
  122514. /**
  122515. * Internal gizmo used for interactions on the x axis
  122516. */
  122517. xGizmo: AxisDragGizmo;
  122518. /**
  122519. * Internal gizmo used for interactions on the y axis
  122520. */
  122521. yGizmo: AxisDragGizmo;
  122522. /**
  122523. * Internal gizmo used for interactions on the z axis
  122524. */
  122525. zGizmo: AxisDragGizmo;
  122526. /**
  122527. * Internal gizmo used for interactions on the yz plane
  122528. */
  122529. xPlaneGizmo: PlaneDragGizmo;
  122530. /**
  122531. * Internal gizmo used for interactions on the xz plane
  122532. */
  122533. yPlaneGizmo: PlaneDragGizmo;
  122534. /**
  122535. * Internal gizmo used for interactions on the xy plane
  122536. */
  122537. zPlaneGizmo: PlaneDragGizmo;
  122538. /**
  122539. * private variables
  122540. */
  122541. private _meshAttached;
  122542. private _updateGizmoRotationToMatchAttachedMesh;
  122543. private _snapDistance;
  122544. private _scaleRatio;
  122545. /** Fires an event when any of it's sub gizmos are dragged */
  122546. onDragStartObservable: Observable<unknown>;
  122547. /** Fires an event when any of it's sub gizmos are released from dragging */
  122548. onDragEndObservable: Observable<unknown>;
  122549. /**
  122550. * If set to true, planar drag is enabled
  122551. */
  122552. private _planarGizmoEnabled;
  122553. get attachedMesh(): Nullable<AbstractMesh>;
  122554. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122555. /**
  122556. * Creates a PositionGizmo
  122557. * @param gizmoLayer The utility layer the gizmo will be added to
  122558. */
  122559. constructor(gizmoLayer?: UtilityLayerRenderer);
  122560. /**
  122561. * If the planar drag gizmo is enabled
  122562. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  122563. */
  122564. set planarGizmoEnabled(value: boolean);
  122565. get planarGizmoEnabled(): boolean;
  122566. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122567. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122568. /**
  122569. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122570. */
  122571. set snapDistance(value: number);
  122572. get snapDistance(): number;
  122573. /**
  122574. * Ratio for the scale of the gizmo (Default: 1)
  122575. */
  122576. set scaleRatio(value: number);
  122577. get scaleRatio(): number;
  122578. /**
  122579. * Disposes of the gizmo
  122580. */
  122581. dispose(): void;
  122582. /**
  122583. * CustomMeshes are not supported by this gizmo
  122584. * @param mesh The mesh to replace the default mesh of the gizmo
  122585. */
  122586. setCustomMesh(mesh: Mesh): void;
  122587. }
  122588. }
  122589. declare module BABYLON {
  122590. /**
  122591. * Single axis drag gizmo
  122592. */
  122593. export class AxisDragGizmo extends Gizmo {
  122594. /**
  122595. * Drag behavior responsible for the gizmos dragging interactions
  122596. */
  122597. dragBehavior: PointerDragBehavior;
  122598. private _pointerObserver;
  122599. /**
  122600. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122601. */
  122602. snapDistance: number;
  122603. /**
  122604. * Event that fires each time the gizmo snaps to a new location.
  122605. * * snapDistance is the the change in distance
  122606. */
  122607. onSnapObservable: Observable<{
  122608. snapDistance: number;
  122609. }>;
  122610. private _isEnabled;
  122611. private _parent;
  122612. private _arrow;
  122613. private _coloredMaterial;
  122614. private _hoverMaterial;
  122615. /** @hidden */
  122616. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  122617. /** @hidden */
  122618. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122619. /**
  122620. * Creates an AxisDragGizmo
  122621. * @param gizmoLayer The utility layer the gizmo will be added to
  122622. * @param dragAxis The axis which the gizmo will be able to drag on
  122623. * @param color The color of the gizmo
  122624. */
  122625. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122626. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122627. /**
  122628. * If the gizmo is enabled
  122629. */
  122630. set isEnabled(value: boolean);
  122631. get isEnabled(): boolean;
  122632. /**
  122633. * Disposes of the gizmo
  122634. */
  122635. dispose(): void;
  122636. }
  122637. }
  122638. declare module BABYLON.Debug {
  122639. /**
  122640. * The Axes viewer will show 3 axes in a specific point in space
  122641. */
  122642. export class AxesViewer {
  122643. private _xAxis;
  122644. private _yAxis;
  122645. private _zAxis;
  122646. private _scaleLinesFactor;
  122647. private _instanced;
  122648. /**
  122649. * Gets the hosting scene
  122650. */
  122651. scene: Scene;
  122652. /**
  122653. * Gets or sets a number used to scale line length
  122654. */
  122655. scaleLines: number;
  122656. /** Gets the node hierarchy used to render x-axis */
  122657. get xAxis(): TransformNode;
  122658. /** Gets the node hierarchy used to render y-axis */
  122659. get yAxis(): TransformNode;
  122660. /** Gets the node hierarchy used to render z-axis */
  122661. get zAxis(): TransformNode;
  122662. /**
  122663. * Creates a new AxesViewer
  122664. * @param scene defines the hosting scene
  122665. * @param scaleLines defines a number used to scale line length (1 by default)
  122666. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  122667. * @param xAxis defines the node hierarchy used to render the x-axis
  122668. * @param yAxis defines the node hierarchy used to render the y-axis
  122669. * @param zAxis defines the node hierarchy used to render the z-axis
  122670. */
  122671. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  122672. /**
  122673. * Force the viewer to update
  122674. * @param position defines the position of the viewer
  122675. * @param xaxis defines the x axis of the viewer
  122676. * @param yaxis defines the y axis of the viewer
  122677. * @param zaxis defines the z axis of the viewer
  122678. */
  122679. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  122680. /**
  122681. * Creates an instance of this axes viewer.
  122682. * @returns a new axes viewer with instanced meshes
  122683. */
  122684. createInstance(): AxesViewer;
  122685. /** Releases resources */
  122686. dispose(): void;
  122687. private static _SetRenderingGroupId;
  122688. }
  122689. }
  122690. declare module BABYLON.Debug {
  122691. /**
  122692. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  122693. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  122694. */
  122695. export class BoneAxesViewer extends AxesViewer {
  122696. /**
  122697. * Gets or sets the target mesh where to display the axes viewer
  122698. */
  122699. mesh: Nullable<Mesh>;
  122700. /**
  122701. * Gets or sets the target bone where to display the axes viewer
  122702. */
  122703. bone: Nullable<Bone>;
  122704. /** Gets current position */
  122705. pos: Vector3;
  122706. /** Gets direction of X axis */
  122707. xaxis: Vector3;
  122708. /** Gets direction of Y axis */
  122709. yaxis: Vector3;
  122710. /** Gets direction of Z axis */
  122711. zaxis: Vector3;
  122712. /**
  122713. * Creates a new BoneAxesViewer
  122714. * @param scene defines the hosting scene
  122715. * @param bone defines the target bone
  122716. * @param mesh defines the target mesh
  122717. * @param scaleLines defines a scaling factor for line length (1 by default)
  122718. */
  122719. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  122720. /**
  122721. * Force the viewer to update
  122722. */
  122723. update(): void;
  122724. /** Releases resources */
  122725. dispose(): void;
  122726. }
  122727. }
  122728. declare module BABYLON {
  122729. /**
  122730. * Interface used to define scene explorer extensibility option
  122731. */
  122732. export interface IExplorerExtensibilityOption {
  122733. /**
  122734. * Define the option label
  122735. */
  122736. label: string;
  122737. /**
  122738. * Defines the action to execute on click
  122739. */
  122740. action: (entity: any) => void;
  122741. }
  122742. /**
  122743. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  122744. */
  122745. export interface IExplorerExtensibilityGroup {
  122746. /**
  122747. * Defines a predicate to test if a given type mut be extended
  122748. */
  122749. predicate: (entity: any) => boolean;
  122750. /**
  122751. * Gets the list of options added to a type
  122752. */
  122753. entries: IExplorerExtensibilityOption[];
  122754. }
  122755. /**
  122756. * Interface used to define the options to use to create the Inspector
  122757. */
  122758. export interface IInspectorOptions {
  122759. /**
  122760. * Display in overlay mode (default: false)
  122761. */
  122762. overlay?: boolean;
  122763. /**
  122764. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  122765. */
  122766. globalRoot?: HTMLElement;
  122767. /**
  122768. * Display the Scene explorer
  122769. */
  122770. showExplorer?: boolean;
  122771. /**
  122772. * Display the property inspector
  122773. */
  122774. showInspector?: boolean;
  122775. /**
  122776. * Display in embed mode (both panes on the right)
  122777. */
  122778. embedMode?: boolean;
  122779. /**
  122780. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  122781. */
  122782. handleResize?: boolean;
  122783. /**
  122784. * Allow the panes to popup (default: true)
  122785. */
  122786. enablePopup?: boolean;
  122787. /**
  122788. * Allow the panes to be closed by users (default: true)
  122789. */
  122790. enableClose?: boolean;
  122791. /**
  122792. * Optional list of extensibility entries
  122793. */
  122794. explorerExtensibility?: IExplorerExtensibilityGroup[];
  122795. /**
  122796. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  122797. */
  122798. inspectorURL?: string;
  122799. /**
  122800. * Optional initial tab (default to DebugLayerTab.Properties)
  122801. */
  122802. initialTab?: DebugLayerTab;
  122803. }
  122804. interface Scene {
  122805. /**
  122806. * @hidden
  122807. * Backing field
  122808. */
  122809. _debugLayer: DebugLayer;
  122810. /**
  122811. * Gets the debug layer (aka Inspector) associated with the scene
  122812. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122813. */
  122814. debugLayer: DebugLayer;
  122815. }
  122816. /**
  122817. * Enum of inspector action tab
  122818. */
  122819. export enum DebugLayerTab {
  122820. /**
  122821. * Properties tag (default)
  122822. */
  122823. Properties = 0,
  122824. /**
  122825. * Debug tab
  122826. */
  122827. Debug = 1,
  122828. /**
  122829. * Statistics tab
  122830. */
  122831. Statistics = 2,
  122832. /**
  122833. * Tools tab
  122834. */
  122835. Tools = 3,
  122836. /**
  122837. * Settings tab
  122838. */
  122839. Settings = 4
  122840. }
  122841. /**
  122842. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122843. * what is happening in your scene
  122844. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122845. */
  122846. export class DebugLayer {
  122847. /**
  122848. * Define the url to get the inspector script from.
  122849. * By default it uses the babylonjs CDN.
  122850. * @ignoreNaming
  122851. */
  122852. static InspectorURL: string;
  122853. private _scene;
  122854. private BJSINSPECTOR;
  122855. private _onPropertyChangedObservable?;
  122856. /**
  122857. * Observable triggered when a property is changed through the inspector.
  122858. */
  122859. get onPropertyChangedObservable(): any;
  122860. /**
  122861. * Instantiates a new debug layer.
  122862. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122863. * what is happening in your scene
  122864. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122865. * @param scene Defines the scene to inspect
  122866. */
  122867. constructor(scene: Scene);
  122868. /** Creates the inspector window. */
  122869. private _createInspector;
  122870. /**
  122871. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  122872. * @param entity defines the entity to select
  122873. * @param lineContainerTitle defines the specific block to highlight
  122874. */
  122875. select(entity: any, lineContainerTitle?: string): void;
  122876. /** Get the inspector from bundle or global */
  122877. private _getGlobalInspector;
  122878. /**
  122879. * Get if the inspector is visible or not.
  122880. * @returns true if visible otherwise, false
  122881. */
  122882. isVisible(): boolean;
  122883. /**
  122884. * Hide the inspector and close its window.
  122885. */
  122886. hide(): void;
  122887. /**
  122888. * Update the scene in the inspector
  122889. */
  122890. setAsActiveScene(): void;
  122891. /**
  122892. * Launch the debugLayer.
  122893. * @param config Define the configuration of the inspector
  122894. * @return a promise fulfilled when the debug layer is visible
  122895. */
  122896. show(config?: IInspectorOptions): Promise<DebugLayer>;
  122897. }
  122898. }
  122899. declare module BABYLON {
  122900. /**
  122901. * Class containing static functions to help procedurally build meshes
  122902. */
  122903. export class BoxBuilder {
  122904. /**
  122905. * Creates a box mesh
  122906. * * The parameter `size` sets the size (float) of each box side (default 1)
  122907. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122908. * * 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)
  122909. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122911. * * 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
  122912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122913. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122914. * @param name defines the name of the mesh
  122915. * @param options defines the options used to create the mesh
  122916. * @param scene defines the hosting scene
  122917. * @returns the box mesh
  122918. */
  122919. static CreateBox(name: string, options: {
  122920. size?: number;
  122921. width?: number;
  122922. height?: number;
  122923. depth?: number;
  122924. faceUV?: Vector4[];
  122925. faceColors?: Color4[];
  122926. sideOrientation?: number;
  122927. frontUVs?: Vector4;
  122928. backUVs?: Vector4;
  122929. wrap?: boolean;
  122930. topBaseAt?: number;
  122931. bottomBaseAt?: number;
  122932. updatable?: boolean;
  122933. }, scene?: Nullable<Scene>): Mesh;
  122934. }
  122935. }
  122936. declare module BABYLON.Debug {
  122937. /**
  122938. * Used to show the physics impostor around the specific mesh
  122939. */
  122940. export class PhysicsViewer {
  122941. /** @hidden */
  122942. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  122943. /** @hidden */
  122944. protected _meshes: Array<Nullable<AbstractMesh>>;
  122945. /** @hidden */
  122946. protected _scene: Nullable<Scene>;
  122947. /** @hidden */
  122948. protected _numMeshes: number;
  122949. /** @hidden */
  122950. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  122951. private _renderFunction;
  122952. private _utilityLayer;
  122953. private _debugBoxMesh;
  122954. private _debugSphereMesh;
  122955. private _debugCylinderMesh;
  122956. private _debugMaterial;
  122957. private _debugMeshMeshes;
  122958. /**
  122959. * Creates a new PhysicsViewer
  122960. * @param scene defines the hosting scene
  122961. */
  122962. constructor(scene: Scene);
  122963. /** @hidden */
  122964. protected _updateDebugMeshes(): void;
  122965. /**
  122966. * Renders a specified physic impostor
  122967. * @param impostor defines the impostor to render
  122968. * @param targetMesh defines the mesh represented by the impostor
  122969. * @returns the new debug mesh used to render the impostor
  122970. */
  122971. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  122972. /**
  122973. * Hides a specified physic impostor
  122974. * @param impostor defines the impostor to hide
  122975. */
  122976. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  122977. private _getDebugMaterial;
  122978. private _getDebugBoxMesh;
  122979. private _getDebugSphereMesh;
  122980. private _getDebugCylinderMesh;
  122981. private _getDebugMeshMesh;
  122982. private _getDebugMesh;
  122983. /** Releases all resources */
  122984. dispose(): void;
  122985. }
  122986. }
  122987. declare module BABYLON {
  122988. /**
  122989. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122990. * in order to better appreciate the issue one might have.
  122991. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122992. */
  122993. export class RayHelper {
  122994. /**
  122995. * Defines the ray we are currently tryin to visualize.
  122996. */
  122997. ray: Nullable<Ray>;
  122998. private _renderPoints;
  122999. private _renderLine;
  123000. private _renderFunction;
  123001. private _scene;
  123002. private _updateToMeshFunction;
  123003. private _attachedToMesh;
  123004. private _meshSpaceDirection;
  123005. private _meshSpaceOrigin;
  123006. /**
  123007. * Helper function to create a colored helper in a scene in one line.
  123008. * @param ray Defines the ray we are currently tryin to visualize
  123009. * @param scene Defines the scene the ray is used in
  123010. * @param color Defines the color we want to see the ray in
  123011. * @returns The newly created ray helper.
  123012. */
  123013. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  123014. /**
  123015. * Instantiate a new ray helper.
  123016. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  123017. * in order to better appreciate the issue one might have.
  123018. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  123019. * @param ray Defines the ray we are currently tryin to visualize
  123020. */
  123021. constructor(ray: Ray);
  123022. /**
  123023. * Shows the ray we are willing to debug.
  123024. * @param scene Defines the scene the ray needs to be rendered in
  123025. * @param color Defines the color the ray needs to be rendered in
  123026. */
  123027. show(scene: Scene, color?: Color3): void;
  123028. /**
  123029. * Hides the ray we are debugging.
  123030. */
  123031. hide(): void;
  123032. private _render;
  123033. /**
  123034. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  123035. * @param mesh Defines the mesh we want the helper attached to
  123036. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  123037. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  123038. * @param length Defines the length of the ray
  123039. */
  123040. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  123041. /**
  123042. * Detach the ray helper from the mesh it has previously been attached to.
  123043. */
  123044. detachFromMesh(): void;
  123045. private _updateToMesh;
  123046. /**
  123047. * Dispose the helper and release its associated resources.
  123048. */
  123049. dispose(): void;
  123050. }
  123051. }
  123052. declare module BABYLON.Debug {
  123053. /**
  123054. * Class used to render a debug view of a given skeleton
  123055. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  123056. */
  123057. export class SkeletonViewer {
  123058. /** defines the skeleton to render */
  123059. skeleton: Skeleton;
  123060. /** defines the mesh attached to the skeleton */
  123061. mesh: AbstractMesh;
  123062. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  123063. autoUpdateBonesMatrices: boolean;
  123064. /** defines the rendering group id to use with the viewer */
  123065. renderingGroupId: number;
  123066. /** Gets or sets the color used to render the skeleton */
  123067. color: Color3;
  123068. private _scene;
  123069. private _debugLines;
  123070. private _debugMesh;
  123071. private _isEnabled;
  123072. private _renderFunction;
  123073. private _utilityLayer;
  123074. /**
  123075. * Returns the mesh used to render the bones
  123076. */
  123077. get debugMesh(): Nullable<LinesMesh>;
  123078. /**
  123079. * Creates a new SkeletonViewer
  123080. * @param skeleton defines the skeleton to render
  123081. * @param mesh defines the mesh attached to the skeleton
  123082. * @param scene defines the hosting scene
  123083. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  123084. * @param renderingGroupId defines the rendering group id to use with the viewer
  123085. */
  123086. constructor(
  123087. /** defines the skeleton to render */
  123088. skeleton: Skeleton,
  123089. /** defines the mesh attached to the skeleton */
  123090. mesh: AbstractMesh, scene: Scene,
  123091. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  123092. autoUpdateBonesMatrices?: boolean,
  123093. /** defines the rendering group id to use with the viewer */
  123094. renderingGroupId?: number);
  123095. /** Gets or sets a boolean indicating if the viewer is enabled */
  123096. set isEnabled(value: boolean);
  123097. get isEnabled(): boolean;
  123098. private _getBonePosition;
  123099. private _getLinesForBonesWithLength;
  123100. private _getLinesForBonesNoLength;
  123101. /** Update the viewer to sync with current skeleton state */
  123102. update(): void;
  123103. /** Release associated resources */
  123104. dispose(): void;
  123105. }
  123106. }
  123107. declare module BABYLON {
  123108. /**
  123109. * This class will take all inputs from Keyboard, Pointer, and
  123110. * any Gamepads and provide a polling system that all devices
  123111. * will use. This class assumes that there will only be one
  123112. * pointer device and one keyboard.
  123113. */
  123114. export class DeviceInputSystem implements IDisposable {
  123115. /** POINTER_DEVICE */
  123116. static readonly POINTER_DEVICE: string;
  123117. /** KEYBOARD_DEVICE */
  123118. static readonly KEYBOARD_DEVICE: string;
  123119. /**
  123120. * Observable to be triggered when a device is connected
  123121. */
  123122. onDeviceConnectedObservable: Observable<string>;
  123123. /**
  123124. * Observable to be triggered when a device is disconnected
  123125. */
  123126. onDeviceDisconnectedObservable: Observable<string>;
  123127. private _inputs;
  123128. private _gamepads;
  123129. private _keyboardActive;
  123130. private _pointerActive;
  123131. private _elementToAttachTo;
  123132. private _keyboardDownEvent;
  123133. private _keyboardUpEvent;
  123134. private _pointerMoveEvent;
  123135. private _pointerDownEvent;
  123136. private _pointerUpEvent;
  123137. private _gamepadConnectedEvent;
  123138. private _gamepadDisconnectedEvent;
  123139. private static _MAX_KEYCODES;
  123140. private static _MAX_POINTER_INPUTS;
  123141. /**
  123142. * Default Constructor
  123143. * @param engine - engine to pull input element from
  123144. */
  123145. constructor(engine: Engine);
  123146. /**
  123147. * Checks for current device input value, given an id and input index
  123148. * @param deviceName Id of connected device
  123149. * @param inputIndex Index of device input
  123150. * @returns Current value of input
  123151. */
  123152. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  123153. /**
  123154. * Dispose of all the eventlisteners and clears the observables
  123155. */
  123156. dispose(): void;
  123157. /**
  123158. * Add device and inputs to device map
  123159. * @param deviceName Assigned name of device (may be SN)
  123160. * @param numberOfInputs Number of input entries to create for given device
  123161. */
  123162. private _registerDevice;
  123163. /**
  123164. * Given a specific device name, remove that device from the device map
  123165. * @param deviceName Name of device to be removed
  123166. */
  123167. private _unregisterDevice;
  123168. /**
  123169. * Handle all actions that come from keyboard interaction
  123170. */
  123171. private _handleKeyActions;
  123172. /**
  123173. * Handle all actions that come from pointer interaction
  123174. */
  123175. private _handlePointerActions;
  123176. /**
  123177. * Handle all actions that come from gamepad interaction
  123178. */
  123179. private _handleGamepadActions;
  123180. /**
  123181. * Update all non-event based devices with each frame
  123182. */
  123183. private _updateDevice;
  123184. }
  123185. }
  123186. declare module BABYLON {
  123187. /**
  123188. * Options to create the null engine
  123189. */
  123190. export class NullEngineOptions {
  123191. /**
  123192. * Render width (Default: 512)
  123193. */
  123194. renderWidth: number;
  123195. /**
  123196. * Render height (Default: 256)
  123197. */
  123198. renderHeight: number;
  123199. /**
  123200. * Texture size (Default: 512)
  123201. */
  123202. textureSize: number;
  123203. /**
  123204. * If delta time between frames should be constant
  123205. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123206. */
  123207. deterministicLockstep: boolean;
  123208. /**
  123209. * Maximum about of steps between frames (Default: 4)
  123210. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123211. */
  123212. lockstepMaxSteps: number;
  123213. }
  123214. /**
  123215. * The null engine class provides support for headless version of babylon.js.
  123216. * This can be used in server side scenario or for testing purposes
  123217. */
  123218. export class NullEngine extends Engine {
  123219. private _options;
  123220. /**
  123221. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  123222. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123223. * @returns true if engine is in deterministic lock step mode
  123224. */
  123225. isDeterministicLockStep(): boolean;
  123226. /**
  123227. * Gets the max steps when engine is running in deterministic lock step
  123228. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123229. * @returns the max steps
  123230. */
  123231. getLockstepMaxSteps(): number;
  123232. /**
  123233. * Gets the current hardware scaling level.
  123234. * By default the hardware scaling level is computed from the window device ratio.
  123235. * 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.
  123236. * @returns a number indicating the current hardware scaling level
  123237. */
  123238. getHardwareScalingLevel(): number;
  123239. constructor(options?: NullEngineOptions);
  123240. /**
  123241. * Creates a vertex buffer
  123242. * @param vertices the data for the vertex buffer
  123243. * @returns the new WebGL static buffer
  123244. */
  123245. createVertexBuffer(vertices: FloatArray): DataBuffer;
  123246. /**
  123247. * Creates a new index buffer
  123248. * @param indices defines the content of the index buffer
  123249. * @param updatable defines if the index buffer must be updatable
  123250. * @returns a new webGL buffer
  123251. */
  123252. createIndexBuffer(indices: IndicesArray): DataBuffer;
  123253. /**
  123254. * Clear the current render buffer or the current render target (if any is set up)
  123255. * @param color defines the color to use
  123256. * @param backBuffer defines if the back buffer must be cleared
  123257. * @param depth defines if the depth buffer must be cleared
  123258. * @param stencil defines if the stencil buffer must be cleared
  123259. */
  123260. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  123261. /**
  123262. * Gets the current render width
  123263. * @param useScreen defines if screen size must be used (or the current render target if any)
  123264. * @returns a number defining the current render width
  123265. */
  123266. getRenderWidth(useScreen?: boolean): number;
  123267. /**
  123268. * Gets the current render height
  123269. * @param useScreen defines if screen size must be used (or the current render target if any)
  123270. * @returns a number defining the current render height
  123271. */
  123272. getRenderHeight(useScreen?: boolean): number;
  123273. /**
  123274. * Set the WebGL's viewport
  123275. * @param viewport defines the viewport element to be used
  123276. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  123277. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  123278. */
  123279. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  123280. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  123281. /**
  123282. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  123283. * @param pipelineContext defines the pipeline context to use
  123284. * @param uniformsNames defines the list of uniform names
  123285. * @returns an array of webGL uniform locations
  123286. */
  123287. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  123288. /**
  123289. * Gets the lsit of active attributes for a given webGL program
  123290. * @param pipelineContext defines the pipeline context to use
  123291. * @param attributesNames defines the list of attribute names to get
  123292. * @returns an array of indices indicating the offset of each attribute
  123293. */
  123294. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  123295. /**
  123296. * Binds an effect to the webGL context
  123297. * @param effect defines the effect to bind
  123298. */
  123299. bindSamplers(effect: Effect): void;
  123300. /**
  123301. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  123302. * @param effect defines the effect to activate
  123303. */
  123304. enableEffect(effect: Effect): void;
  123305. /**
  123306. * Set various states to the webGL context
  123307. * @param culling defines backface culling state
  123308. * @param zOffset defines the value to apply to zOffset (0 by default)
  123309. * @param force defines if states must be applied even if cache is up to date
  123310. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  123311. */
  123312. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  123313. /**
  123314. * Set the value of an uniform to an array of int32
  123315. * @param uniform defines the webGL uniform location where to store the value
  123316. * @param array defines the array of int32 to store
  123317. */
  123318. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  123319. /**
  123320. * Set the value of an uniform to an array of int32 (stored as vec2)
  123321. * @param uniform defines the webGL uniform location where to store the value
  123322. * @param array defines the array of int32 to store
  123323. */
  123324. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  123325. /**
  123326. * Set the value of an uniform to an array of int32 (stored as vec3)
  123327. * @param uniform defines the webGL uniform location where to store the value
  123328. * @param array defines the array of int32 to store
  123329. */
  123330. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  123331. /**
  123332. * Set the value of an uniform to an array of int32 (stored as vec4)
  123333. * @param uniform defines the webGL uniform location where to store the value
  123334. * @param array defines the array of int32 to store
  123335. */
  123336. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  123337. /**
  123338. * Set the value of an uniform to an array of float32
  123339. * @param uniform defines the webGL uniform location where to store the value
  123340. * @param array defines the array of float32 to store
  123341. */
  123342. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  123343. /**
  123344. * Set the value of an uniform to an array of float32 (stored as vec2)
  123345. * @param uniform defines the webGL uniform location where to store the value
  123346. * @param array defines the array of float32 to store
  123347. */
  123348. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  123349. /**
  123350. * Set the value of an uniform to an array of float32 (stored as vec3)
  123351. * @param uniform defines the webGL uniform location where to store the value
  123352. * @param array defines the array of float32 to store
  123353. */
  123354. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  123355. /**
  123356. * Set the value of an uniform to an array of float32 (stored as vec4)
  123357. * @param uniform defines the webGL uniform location where to store the value
  123358. * @param array defines the array of float32 to store
  123359. */
  123360. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  123361. /**
  123362. * Set the value of an uniform to an array of number
  123363. * @param uniform defines the webGL uniform location where to store the value
  123364. * @param array defines the array of number to store
  123365. */
  123366. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  123367. /**
  123368. * Set the value of an uniform to an array of number (stored as vec2)
  123369. * @param uniform defines the webGL uniform location where to store the value
  123370. * @param array defines the array of number to store
  123371. */
  123372. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  123373. /**
  123374. * Set the value of an uniform to an array of number (stored as vec3)
  123375. * @param uniform defines the webGL uniform location where to store the value
  123376. * @param array defines the array of number to store
  123377. */
  123378. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  123379. /**
  123380. * Set the value of an uniform to an array of number (stored as vec4)
  123381. * @param uniform defines the webGL uniform location where to store the value
  123382. * @param array defines the array of number to store
  123383. */
  123384. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  123385. /**
  123386. * Set the value of an uniform to an array of float32 (stored as matrices)
  123387. * @param uniform defines the webGL uniform location where to store the value
  123388. * @param matrices defines the array of float32 to store
  123389. */
  123390. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  123391. /**
  123392. * Set the value of an uniform to a matrix (3x3)
  123393. * @param uniform defines the webGL uniform location where to store the value
  123394. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  123395. */
  123396. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123397. /**
  123398. * Set the value of an uniform to a matrix (2x2)
  123399. * @param uniform defines the webGL uniform location where to store the value
  123400. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  123401. */
  123402. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123403. /**
  123404. * Set the value of an uniform to a number (float)
  123405. * @param uniform defines the webGL uniform location where to store the value
  123406. * @param value defines the float number to store
  123407. */
  123408. setFloat(uniform: WebGLUniformLocation, value: number): void;
  123409. /**
  123410. * Set the value of an uniform to a vec2
  123411. * @param uniform defines the webGL uniform location where to store the value
  123412. * @param x defines the 1st component of the value
  123413. * @param y defines the 2nd component of the value
  123414. */
  123415. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  123416. /**
  123417. * Set the value of an uniform to a vec3
  123418. * @param uniform defines the webGL uniform location where to store the value
  123419. * @param x defines the 1st component of the value
  123420. * @param y defines the 2nd component of the value
  123421. * @param z defines the 3rd component of the value
  123422. */
  123423. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  123424. /**
  123425. * Set the value of an uniform to a boolean
  123426. * @param uniform defines the webGL uniform location where to store the value
  123427. * @param bool defines the boolean to store
  123428. */
  123429. setBool(uniform: WebGLUniformLocation, bool: number): void;
  123430. /**
  123431. * Set the value of an uniform to a vec4
  123432. * @param uniform defines the webGL uniform location where to store the value
  123433. * @param x defines the 1st component of the value
  123434. * @param y defines the 2nd component of the value
  123435. * @param z defines the 3rd component of the value
  123436. * @param w defines the 4th component of the value
  123437. */
  123438. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  123439. /**
  123440. * Sets the current alpha mode
  123441. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  123442. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  123443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  123444. */
  123445. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  123446. /**
  123447. * Bind webGl buffers directly to the webGL context
  123448. * @param vertexBuffers defines the vertex buffer to bind
  123449. * @param indexBuffer defines the index buffer to bind
  123450. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  123451. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  123452. * @param effect defines the effect associated with the vertex buffer
  123453. */
  123454. bindBuffers(vertexBuffers: {
  123455. [key: string]: VertexBuffer;
  123456. }, indexBuffer: DataBuffer, effect: Effect): void;
  123457. /**
  123458. * Force the entire cache to be cleared
  123459. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  123460. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  123461. */
  123462. wipeCaches(bruteForce?: boolean): void;
  123463. /**
  123464. * Send a draw order
  123465. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  123466. * @param indexStart defines the starting index
  123467. * @param indexCount defines the number of index to draw
  123468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123469. */
  123470. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  123471. /**
  123472. * Draw a list of indexed primitives
  123473. * @param fillMode defines the primitive to use
  123474. * @param indexStart defines the starting index
  123475. * @param indexCount defines the number of index to draw
  123476. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123477. */
  123478. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  123479. /**
  123480. * Draw a list of unindexed primitives
  123481. * @param fillMode defines the primitive to use
  123482. * @param verticesStart defines the index of first vertex to draw
  123483. * @param verticesCount defines the count of vertices to draw
  123484. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123485. */
  123486. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  123487. /** @hidden */
  123488. _createTexture(): WebGLTexture;
  123489. /** @hidden */
  123490. _releaseTexture(texture: InternalTexture): void;
  123491. /**
  123492. * Usually called from Texture.ts.
  123493. * Passed information to create a WebGLTexture
  123494. * @param urlArg defines a value which contains one of the following:
  123495. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  123496. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  123497. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  123498. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  123499. * @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)
  123500. * @param scene needed for loading to the correct scene
  123501. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  123502. * @param onLoad optional callback to be called upon successful completion
  123503. * @param onError optional callback to be called upon failure
  123504. * @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
  123505. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  123506. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  123507. * @param forcedExtension defines the extension to use to pick the right loader
  123508. * @param mimeType defines an optional mime type
  123509. * @returns a InternalTexture for assignment back into BABYLON.Texture
  123510. */
  123511. 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;
  123512. /**
  123513. * Creates a new render target texture
  123514. * @param size defines the size of the texture
  123515. * @param options defines the options used to create the texture
  123516. * @returns a new render target texture stored in an InternalTexture
  123517. */
  123518. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  123519. /**
  123520. * Update the sampling mode of a given texture
  123521. * @param samplingMode defines the required sampling mode
  123522. * @param texture defines the texture to update
  123523. */
  123524. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  123525. /**
  123526. * Binds the frame buffer to the specified texture.
  123527. * @param texture The texture to render to or null for the default canvas
  123528. * @param faceIndex The face of the texture to render to in case of cube texture
  123529. * @param requiredWidth The width of the target to render to
  123530. * @param requiredHeight The height of the target to render to
  123531. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  123532. * @param lodLevel defines le lod level to bind to the frame buffer
  123533. */
  123534. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  123535. /**
  123536. * Unbind the current render target texture from the webGL context
  123537. * @param texture defines the render target texture to unbind
  123538. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123539. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123540. */
  123541. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  123542. /**
  123543. * Creates a dynamic vertex buffer
  123544. * @param vertices the data for the dynamic vertex buffer
  123545. * @returns the new WebGL dynamic buffer
  123546. */
  123547. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  123548. /**
  123549. * Update the content of a dynamic texture
  123550. * @param texture defines the texture to update
  123551. * @param canvas defines the canvas containing the source
  123552. * @param invertY defines if data must be stored with Y axis inverted
  123553. * @param premulAlpha defines if alpha is stored as premultiplied
  123554. * @param format defines the format of the data
  123555. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  123556. */
  123557. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  123558. /**
  123559. * Gets a boolean indicating if all created effects are ready
  123560. * @returns true if all effects are ready
  123561. */
  123562. areAllEffectsReady(): boolean;
  123563. /**
  123564. * @hidden
  123565. * Get the current error code of the webGL context
  123566. * @returns the error code
  123567. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  123568. */
  123569. getError(): number;
  123570. /** @hidden */
  123571. _getUnpackAlignement(): number;
  123572. /** @hidden */
  123573. _unpackFlipY(value: boolean): void;
  123574. /**
  123575. * Update a dynamic index buffer
  123576. * @param indexBuffer defines the target index buffer
  123577. * @param indices defines the data to update
  123578. * @param offset defines the offset in the target index buffer where update should start
  123579. */
  123580. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  123581. /**
  123582. * Updates a dynamic vertex buffer.
  123583. * @param vertexBuffer the vertex buffer to update
  123584. * @param vertices the data used to update the vertex buffer
  123585. * @param byteOffset the byte offset of the data (optional)
  123586. * @param byteLength the byte length of the data (optional)
  123587. */
  123588. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  123589. /** @hidden */
  123590. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  123591. /** @hidden */
  123592. _bindTexture(channel: number, texture: InternalTexture): void;
  123593. protected _deleteBuffer(buffer: WebGLBuffer): void;
  123594. /**
  123595. * 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
  123596. */
  123597. releaseEffects(): void;
  123598. displayLoadingUI(): void;
  123599. hideLoadingUI(): void;
  123600. /** @hidden */
  123601. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123602. /** @hidden */
  123603. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123604. /** @hidden */
  123605. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123606. /** @hidden */
  123607. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  123608. }
  123609. }
  123610. declare module BABYLON {
  123611. /**
  123612. * @hidden
  123613. **/
  123614. export class _TimeToken {
  123615. _startTimeQuery: Nullable<WebGLQuery>;
  123616. _endTimeQuery: Nullable<WebGLQuery>;
  123617. _timeElapsedQuery: Nullable<WebGLQuery>;
  123618. _timeElapsedQueryEnded: boolean;
  123619. }
  123620. }
  123621. declare module BABYLON {
  123622. /** @hidden */
  123623. export class _OcclusionDataStorage {
  123624. /** @hidden */
  123625. occlusionInternalRetryCounter: number;
  123626. /** @hidden */
  123627. isOcclusionQueryInProgress: boolean;
  123628. /** @hidden */
  123629. isOccluded: boolean;
  123630. /** @hidden */
  123631. occlusionRetryCount: number;
  123632. /** @hidden */
  123633. occlusionType: number;
  123634. /** @hidden */
  123635. occlusionQueryAlgorithmType: number;
  123636. }
  123637. interface Engine {
  123638. /**
  123639. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  123640. * @return the new query
  123641. */
  123642. createQuery(): WebGLQuery;
  123643. /**
  123644. * Delete and release a webGL query
  123645. * @param query defines the query to delete
  123646. * @return the current engine
  123647. */
  123648. deleteQuery(query: WebGLQuery): Engine;
  123649. /**
  123650. * Check if a given query has resolved and got its value
  123651. * @param query defines the query to check
  123652. * @returns true if the query got its value
  123653. */
  123654. isQueryResultAvailable(query: WebGLQuery): boolean;
  123655. /**
  123656. * Gets the value of a given query
  123657. * @param query defines the query to check
  123658. * @returns the value of the query
  123659. */
  123660. getQueryResult(query: WebGLQuery): number;
  123661. /**
  123662. * Initiates an occlusion query
  123663. * @param algorithmType defines the algorithm to use
  123664. * @param query defines the query to use
  123665. * @returns the current engine
  123666. * @see http://doc.babylonjs.com/features/occlusionquery
  123667. */
  123668. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  123669. /**
  123670. * Ends an occlusion query
  123671. * @see http://doc.babylonjs.com/features/occlusionquery
  123672. * @param algorithmType defines the algorithm to use
  123673. * @returns the current engine
  123674. */
  123675. endOcclusionQuery(algorithmType: number): Engine;
  123676. /**
  123677. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  123678. * Please note that only one query can be issued at a time
  123679. * @returns a time token used to track the time span
  123680. */
  123681. startTimeQuery(): Nullable<_TimeToken>;
  123682. /**
  123683. * Ends a time query
  123684. * @param token defines the token used to measure the time span
  123685. * @returns the time spent (in ns)
  123686. */
  123687. endTimeQuery(token: _TimeToken): int;
  123688. /** @hidden */
  123689. _currentNonTimestampToken: Nullable<_TimeToken>;
  123690. /** @hidden */
  123691. _createTimeQuery(): WebGLQuery;
  123692. /** @hidden */
  123693. _deleteTimeQuery(query: WebGLQuery): void;
  123694. /** @hidden */
  123695. _getGlAlgorithmType(algorithmType: number): number;
  123696. /** @hidden */
  123697. _getTimeQueryResult(query: WebGLQuery): any;
  123698. /** @hidden */
  123699. _getTimeQueryAvailability(query: WebGLQuery): any;
  123700. }
  123701. interface AbstractMesh {
  123702. /**
  123703. * Backing filed
  123704. * @hidden
  123705. */
  123706. __occlusionDataStorage: _OcclusionDataStorage;
  123707. /**
  123708. * Access property
  123709. * @hidden
  123710. */
  123711. _occlusionDataStorage: _OcclusionDataStorage;
  123712. /**
  123713. * 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.
  123714. * The default value is -1 which means don't break the query and wait till the result
  123715. * @see http://doc.babylonjs.com/features/occlusionquery
  123716. */
  123717. occlusionRetryCount: number;
  123718. /**
  123719. * 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:
  123720. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  123721. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  123722. * * 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.
  123723. * @see http://doc.babylonjs.com/features/occlusionquery
  123724. */
  123725. occlusionType: number;
  123726. /**
  123727. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  123728. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  123729. * * 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.
  123730. * @see http://doc.babylonjs.com/features/occlusionquery
  123731. */
  123732. occlusionQueryAlgorithmType: number;
  123733. /**
  123734. * 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
  123735. * @see http://doc.babylonjs.com/features/occlusionquery
  123736. */
  123737. isOccluded: boolean;
  123738. /**
  123739. * Flag to check the progress status of the query
  123740. * @see http://doc.babylonjs.com/features/occlusionquery
  123741. */
  123742. isOcclusionQueryInProgress: boolean;
  123743. }
  123744. }
  123745. declare module BABYLON {
  123746. /** @hidden */
  123747. export var _forceTransformFeedbackToBundle: boolean;
  123748. interface Engine {
  123749. /**
  123750. * Creates a webGL transform feedback object
  123751. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  123752. * @returns the webGL transform feedback object
  123753. */
  123754. createTransformFeedback(): WebGLTransformFeedback;
  123755. /**
  123756. * Delete a webGL transform feedback object
  123757. * @param value defines the webGL transform feedback object to delete
  123758. */
  123759. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  123760. /**
  123761. * Bind a webGL transform feedback object to the webgl context
  123762. * @param value defines the webGL transform feedback object to bind
  123763. */
  123764. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  123765. /**
  123766. * Begins a transform feedback operation
  123767. * @param usePoints defines if points or triangles must be used
  123768. */
  123769. beginTransformFeedback(usePoints: boolean): void;
  123770. /**
  123771. * Ends a transform feedback operation
  123772. */
  123773. endTransformFeedback(): void;
  123774. /**
  123775. * Specify the varyings to use with transform feedback
  123776. * @param program defines the associated webGL program
  123777. * @param value defines the list of strings representing the varying names
  123778. */
  123779. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  123780. /**
  123781. * Bind a webGL buffer for a transform feedback operation
  123782. * @param value defines the webGL buffer to bind
  123783. */
  123784. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  123785. }
  123786. }
  123787. declare module BABYLON {
  123788. /**
  123789. * Creation options of the multi render target texture.
  123790. */
  123791. export interface IMultiRenderTargetOptions {
  123792. /**
  123793. * Define if the texture needs to create mip maps after render.
  123794. */
  123795. generateMipMaps?: boolean;
  123796. /**
  123797. * Define the types of all the draw buffers we want to create
  123798. */
  123799. types?: number[];
  123800. /**
  123801. * Define the sampling modes of all the draw buffers we want to create
  123802. */
  123803. samplingModes?: number[];
  123804. /**
  123805. * Define if a depth buffer is required
  123806. */
  123807. generateDepthBuffer?: boolean;
  123808. /**
  123809. * Define if a stencil buffer is required
  123810. */
  123811. generateStencilBuffer?: boolean;
  123812. /**
  123813. * Define if a depth texture is required instead of a depth buffer
  123814. */
  123815. generateDepthTexture?: boolean;
  123816. /**
  123817. * Define the number of desired draw buffers
  123818. */
  123819. textureCount?: number;
  123820. /**
  123821. * Define if aspect ratio should be adapted to the texture or stay the scene one
  123822. */
  123823. doNotChangeAspectRatio?: boolean;
  123824. /**
  123825. * Define the default type of the buffers we are creating
  123826. */
  123827. defaultType?: number;
  123828. }
  123829. /**
  123830. * A multi render target, like a render target provides the ability to render to a texture.
  123831. * Unlike the render target, it can render to several draw buffers in one draw.
  123832. * This is specially interesting in deferred rendering or for any effects requiring more than
  123833. * just one color from a single pass.
  123834. */
  123835. export class MultiRenderTarget extends RenderTargetTexture {
  123836. private _internalTextures;
  123837. private _textures;
  123838. private _multiRenderTargetOptions;
  123839. /**
  123840. * Get if draw buffers are currently supported by the used hardware and browser.
  123841. */
  123842. get isSupported(): boolean;
  123843. /**
  123844. * Get the list of textures generated by the multi render target.
  123845. */
  123846. get textures(): Texture[];
  123847. /**
  123848. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  123849. */
  123850. get depthTexture(): Texture;
  123851. /**
  123852. * Set the wrapping mode on U of all the textures we are rendering to.
  123853. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123854. */
  123855. set wrapU(wrap: number);
  123856. /**
  123857. * Set the wrapping mode on V of all the textures we are rendering to.
  123858. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123859. */
  123860. set wrapV(wrap: number);
  123861. /**
  123862. * Instantiate a new multi render target texture.
  123863. * A multi render target, like a render target provides the ability to render to a texture.
  123864. * Unlike the render target, it can render to several draw buffers in one draw.
  123865. * This is specially interesting in deferred rendering or for any effects requiring more than
  123866. * just one color from a single pass.
  123867. * @param name Define the name of the texture
  123868. * @param size Define the size of the buffers to render to
  123869. * @param count Define the number of target we are rendering into
  123870. * @param scene Define the scene the texture belongs to
  123871. * @param options Define the options used to create the multi render target
  123872. */
  123873. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  123874. /** @hidden */
  123875. _rebuild(): void;
  123876. private _createInternalTextures;
  123877. private _createTextures;
  123878. /**
  123879. * Define the number of samples used if MSAA is enabled.
  123880. */
  123881. get samples(): number;
  123882. set samples(value: number);
  123883. /**
  123884. * Resize all the textures in the multi render target.
  123885. * Be carrefull as it will recreate all the data in the new texture.
  123886. * @param size Define the new size
  123887. */
  123888. resize(size: any): void;
  123889. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123890. /**
  123891. * Dispose the render targets and their associated resources
  123892. */
  123893. dispose(): void;
  123894. /**
  123895. * Release all the underlying texture used as draw buffers.
  123896. */
  123897. releaseInternalTextures(): void;
  123898. }
  123899. }
  123900. declare module BABYLON {
  123901. interface ThinEngine {
  123902. /**
  123903. * Unbind a list of render target textures from the webGL context
  123904. * This is used only when drawBuffer extension or webGL2 are active
  123905. * @param textures defines the render target textures to unbind
  123906. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123907. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123908. */
  123909. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  123910. /**
  123911. * Create a multi render target texture
  123912. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  123913. * @param size defines the size of the texture
  123914. * @param options defines the creation options
  123915. * @returns the cube texture as an InternalTexture
  123916. */
  123917. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  123918. /**
  123919. * Update the sample count for a given multiple render target texture
  123920. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123921. * @param textures defines the textures to update
  123922. * @param samples defines the sample count to set
  123923. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123924. */
  123925. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  123926. }
  123927. }
  123928. declare module BABYLON {
  123929. /**
  123930. * Class used to define an additional view for the engine
  123931. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123932. */
  123933. export class EngineView {
  123934. /** Defines the canvas where to render the view */
  123935. target: HTMLCanvasElement;
  123936. /** Defines an optional camera used to render the view (will use active camera else) */
  123937. camera?: Camera;
  123938. }
  123939. interface Engine {
  123940. /**
  123941. * Gets or sets the HTML element to use for attaching events
  123942. */
  123943. inputElement: Nullable<HTMLElement>;
  123944. /**
  123945. * Gets the current engine view
  123946. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123947. */
  123948. activeView: Nullable<EngineView>;
  123949. /** Gets or sets the list of views */
  123950. views: EngineView[];
  123951. /**
  123952. * Register a new child canvas
  123953. * @param canvas defines the canvas to register
  123954. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  123955. * @returns the associated view
  123956. */
  123957. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  123958. /**
  123959. * Remove a registered child canvas
  123960. * @param canvas defines the canvas to remove
  123961. * @returns the current engine
  123962. */
  123963. unRegisterView(canvas: HTMLCanvasElement): Engine;
  123964. }
  123965. }
  123966. declare module BABYLON {
  123967. interface Engine {
  123968. /** @hidden */
  123969. _excludedCompressedTextures: string[];
  123970. /** @hidden */
  123971. _textureFormatInUse: string;
  123972. /**
  123973. * Gets the list of texture formats supported
  123974. */
  123975. readonly texturesSupported: Array<string>;
  123976. /**
  123977. * Gets the texture format in use
  123978. */
  123979. readonly textureFormatInUse: Nullable<string>;
  123980. /**
  123981. * Set the compressed texture extensions or file names to skip.
  123982. *
  123983. * @param skippedFiles defines the list of those texture files you want to skip
  123984. * Example: [".dds", ".env", "myfile.png"]
  123985. */
  123986. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  123987. /**
  123988. * Set the compressed texture format to use, based on the formats you have, and the formats
  123989. * supported by the hardware / browser.
  123990. *
  123991. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  123992. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  123993. * to API arguments needed to compressed textures. This puts the burden on the container
  123994. * generator to house the arcane code for determining these for current & future formats.
  123995. *
  123996. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123997. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123998. *
  123999. * Note: The result of this call is not taken into account when a texture is base64.
  124000. *
  124001. * @param formatsAvailable defines the list of those format families you have created
  124002. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  124003. *
  124004. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  124005. * @returns The extension selected.
  124006. */
  124007. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  124008. }
  124009. }
  124010. declare module BABYLON {
  124011. /**
  124012. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  124013. */
  124014. export interface CubeMapInfo {
  124015. /**
  124016. * The pixel array for the front face.
  124017. * This is stored in format, left to right, up to down format.
  124018. */
  124019. front: Nullable<ArrayBufferView>;
  124020. /**
  124021. * The pixel array for the back face.
  124022. * This is stored in format, left to right, up to down format.
  124023. */
  124024. back: Nullable<ArrayBufferView>;
  124025. /**
  124026. * The pixel array for the left face.
  124027. * This is stored in format, left to right, up to down format.
  124028. */
  124029. left: Nullable<ArrayBufferView>;
  124030. /**
  124031. * The pixel array for the right face.
  124032. * This is stored in format, left to right, up to down format.
  124033. */
  124034. right: Nullable<ArrayBufferView>;
  124035. /**
  124036. * The pixel array for the up face.
  124037. * This is stored in format, left to right, up to down format.
  124038. */
  124039. up: Nullable<ArrayBufferView>;
  124040. /**
  124041. * The pixel array for the down face.
  124042. * This is stored in format, left to right, up to down format.
  124043. */
  124044. down: Nullable<ArrayBufferView>;
  124045. /**
  124046. * The size of the cubemap stored.
  124047. *
  124048. * Each faces will be size * size pixels.
  124049. */
  124050. size: number;
  124051. /**
  124052. * The format of the texture.
  124053. *
  124054. * RGBA, RGB.
  124055. */
  124056. format: number;
  124057. /**
  124058. * The type of the texture data.
  124059. *
  124060. * UNSIGNED_INT, FLOAT.
  124061. */
  124062. type: number;
  124063. /**
  124064. * Specifies whether the texture is in gamma space.
  124065. */
  124066. gammaSpace: boolean;
  124067. }
  124068. /**
  124069. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  124070. */
  124071. export class PanoramaToCubeMapTools {
  124072. private static FACE_LEFT;
  124073. private static FACE_RIGHT;
  124074. private static FACE_FRONT;
  124075. private static FACE_BACK;
  124076. private static FACE_DOWN;
  124077. private static FACE_UP;
  124078. /**
  124079. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  124080. *
  124081. * @param float32Array The source data.
  124082. * @param inputWidth The width of the input panorama.
  124083. * @param inputHeight The height of the input panorama.
  124084. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  124085. * @return The cubemap data
  124086. */
  124087. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  124088. private static CreateCubemapTexture;
  124089. private static CalcProjectionSpherical;
  124090. }
  124091. }
  124092. declare module BABYLON {
  124093. /**
  124094. * Helper class dealing with the extraction of spherical polynomial dataArray
  124095. * from a cube map.
  124096. */
  124097. export class CubeMapToSphericalPolynomialTools {
  124098. private static FileFaces;
  124099. /**
  124100. * Converts a texture to the according Spherical Polynomial data.
  124101. * This extracts the first 3 orders only as they are the only one used in the lighting.
  124102. *
  124103. * @param texture The texture to extract the information from.
  124104. * @return The Spherical Polynomial data.
  124105. */
  124106. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  124107. /**
  124108. * Converts a cubemap to the according Spherical Polynomial data.
  124109. * This extracts the first 3 orders only as they are the only one used in the lighting.
  124110. *
  124111. * @param cubeInfo The Cube map to extract the information from.
  124112. * @return The Spherical Polynomial data.
  124113. */
  124114. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  124115. }
  124116. }
  124117. declare module BABYLON {
  124118. interface BaseTexture {
  124119. /**
  124120. * Get the polynomial representation of the texture data.
  124121. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  124122. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  124123. */
  124124. sphericalPolynomial: Nullable<SphericalPolynomial>;
  124125. }
  124126. }
  124127. declare module BABYLON {
  124128. /** @hidden */
  124129. export var rgbdEncodePixelShader: {
  124130. name: string;
  124131. shader: string;
  124132. };
  124133. }
  124134. declare module BABYLON {
  124135. /** @hidden */
  124136. export var rgbdDecodePixelShader: {
  124137. name: string;
  124138. shader: string;
  124139. };
  124140. }
  124141. declare module BABYLON {
  124142. /**
  124143. * Raw texture data and descriptor sufficient for WebGL texture upload
  124144. */
  124145. export interface EnvironmentTextureInfo {
  124146. /**
  124147. * Version of the environment map
  124148. */
  124149. version: number;
  124150. /**
  124151. * Width of image
  124152. */
  124153. width: number;
  124154. /**
  124155. * Irradiance information stored in the file.
  124156. */
  124157. irradiance: any;
  124158. /**
  124159. * Specular information stored in the file.
  124160. */
  124161. specular: any;
  124162. }
  124163. /**
  124164. * Defines One Image in the file. It requires only the position in the file
  124165. * as well as the length.
  124166. */
  124167. interface BufferImageData {
  124168. /**
  124169. * Length of the image data.
  124170. */
  124171. length: number;
  124172. /**
  124173. * Position of the data from the null terminator delimiting the end of the JSON.
  124174. */
  124175. position: number;
  124176. }
  124177. /**
  124178. * Defines the specular data enclosed in the file.
  124179. * This corresponds to the version 1 of the data.
  124180. */
  124181. export interface EnvironmentTextureSpecularInfoV1 {
  124182. /**
  124183. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  124184. */
  124185. specularDataPosition?: number;
  124186. /**
  124187. * This contains all the images data needed to reconstruct the cubemap.
  124188. */
  124189. mipmaps: Array<BufferImageData>;
  124190. /**
  124191. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  124192. */
  124193. lodGenerationScale: number;
  124194. }
  124195. /**
  124196. * Sets of helpers addressing the serialization and deserialization of environment texture
  124197. * stored in a BabylonJS env file.
  124198. * Those files are usually stored as .env files.
  124199. */
  124200. export class EnvironmentTextureTools {
  124201. /**
  124202. * Magic number identifying the env file.
  124203. */
  124204. private static _MagicBytes;
  124205. /**
  124206. * Gets the environment info from an env file.
  124207. * @param data The array buffer containing the .env bytes.
  124208. * @returns the environment file info (the json header) if successfully parsed.
  124209. */
  124210. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  124211. /**
  124212. * Creates an environment texture from a loaded cube texture.
  124213. * @param texture defines the cube texture to convert in env file
  124214. * @return a promise containing the environment data if succesfull.
  124215. */
  124216. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  124217. /**
  124218. * Creates a JSON representation of the spherical data.
  124219. * @param texture defines the texture containing the polynomials
  124220. * @return the JSON representation of the spherical info
  124221. */
  124222. private static _CreateEnvTextureIrradiance;
  124223. /**
  124224. * Creates the ArrayBufferViews used for initializing environment texture image data.
  124225. * @param data the image data
  124226. * @param info parameters that determine what views will be created for accessing the underlying buffer
  124227. * @return the views described by info providing access to the underlying buffer
  124228. */
  124229. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  124230. /**
  124231. * Uploads the texture info contained in the env file to the GPU.
  124232. * @param texture defines the internal texture to upload to
  124233. * @param data defines the data to load
  124234. * @param info defines the texture info retrieved through the GetEnvInfo method
  124235. * @returns a promise
  124236. */
  124237. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  124238. private static _OnImageReadyAsync;
  124239. /**
  124240. * Uploads the levels of image data to the GPU.
  124241. * @param texture defines the internal texture to upload to
  124242. * @param imageData defines the array buffer views of image data [mipmap][face]
  124243. * @returns a promise
  124244. */
  124245. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  124246. /**
  124247. * Uploads spherical polynomials information to the texture.
  124248. * @param texture defines the texture we are trying to upload the information to
  124249. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  124250. */
  124251. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  124252. /** @hidden */
  124253. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  124254. }
  124255. }
  124256. declare module BABYLON {
  124257. /**
  124258. * Contains position and normal vectors for a vertex
  124259. */
  124260. export class PositionNormalVertex {
  124261. /** the position of the vertex (defaut: 0,0,0) */
  124262. position: Vector3;
  124263. /** the normal of the vertex (defaut: 0,1,0) */
  124264. normal: Vector3;
  124265. /**
  124266. * Creates a PositionNormalVertex
  124267. * @param position the position of the vertex (defaut: 0,0,0)
  124268. * @param normal the normal of the vertex (defaut: 0,1,0)
  124269. */
  124270. constructor(
  124271. /** the position of the vertex (defaut: 0,0,0) */
  124272. position?: Vector3,
  124273. /** the normal of the vertex (defaut: 0,1,0) */
  124274. normal?: Vector3);
  124275. /**
  124276. * Clones the PositionNormalVertex
  124277. * @returns the cloned PositionNormalVertex
  124278. */
  124279. clone(): PositionNormalVertex;
  124280. }
  124281. /**
  124282. * Contains position, normal and uv vectors for a vertex
  124283. */
  124284. export class PositionNormalTextureVertex {
  124285. /** the position of the vertex (defaut: 0,0,0) */
  124286. position: Vector3;
  124287. /** the normal of the vertex (defaut: 0,1,0) */
  124288. normal: Vector3;
  124289. /** the uv of the vertex (default: 0,0) */
  124290. uv: Vector2;
  124291. /**
  124292. * Creates a PositionNormalTextureVertex
  124293. * @param position the position of the vertex (defaut: 0,0,0)
  124294. * @param normal the normal of the vertex (defaut: 0,1,0)
  124295. * @param uv the uv of the vertex (default: 0,0)
  124296. */
  124297. constructor(
  124298. /** the position of the vertex (defaut: 0,0,0) */
  124299. position?: Vector3,
  124300. /** the normal of the vertex (defaut: 0,1,0) */
  124301. normal?: Vector3,
  124302. /** the uv of the vertex (default: 0,0) */
  124303. uv?: Vector2);
  124304. /**
  124305. * Clones the PositionNormalTextureVertex
  124306. * @returns the cloned PositionNormalTextureVertex
  124307. */
  124308. clone(): PositionNormalTextureVertex;
  124309. }
  124310. }
  124311. declare module BABYLON {
  124312. /** @hidden */
  124313. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  124314. private _genericAttributeLocation;
  124315. private _varyingLocationCount;
  124316. private _varyingLocationMap;
  124317. private _replacements;
  124318. private _textureCount;
  124319. private _uniforms;
  124320. lineProcessor(line: string): string;
  124321. attributeProcessor(attribute: string): string;
  124322. varyingProcessor(varying: string, isFragment: boolean): string;
  124323. uniformProcessor(uniform: string): string;
  124324. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  124325. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  124326. }
  124327. }
  124328. declare module BABYLON {
  124329. /**
  124330. * Container for accessors for natively-stored mesh data buffers.
  124331. */
  124332. class NativeDataBuffer extends DataBuffer {
  124333. /**
  124334. * Accessor value used to identify/retrieve a natively-stored index buffer.
  124335. */
  124336. nativeIndexBuffer?: any;
  124337. /**
  124338. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  124339. */
  124340. nativeVertexBuffer?: any;
  124341. }
  124342. /** @hidden */
  124343. class NativeTexture extends InternalTexture {
  124344. getInternalTexture(): InternalTexture;
  124345. getViewCount(): number;
  124346. }
  124347. /** @hidden */
  124348. export class NativeEngine extends Engine {
  124349. private readonly _native;
  124350. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  124351. private readonly INVALID_HANDLE;
  124352. getHardwareScalingLevel(): number;
  124353. constructor();
  124354. dispose(): void;
  124355. /**
  124356. * Can be used to override the current requestAnimationFrame requester.
  124357. * @hidden
  124358. */
  124359. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  124360. /**
  124361. * Override default engine behavior.
  124362. * @param color
  124363. * @param backBuffer
  124364. * @param depth
  124365. * @param stencil
  124366. */
  124367. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  124368. /**
  124369. * Gets host document
  124370. * @returns the host document object
  124371. */
  124372. getHostDocument(): Nullable<Document>;
  124373. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  124374. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  124375. createVertexBuffer(data: DataArray): NativeDataBuffer;
  124376. recordVertexArrayObject(vertexBuffers: {
  124377. [key: string]: VertexBuffer;
  124378. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  124379. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124380. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124381. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  124382. /**
  124383. * Draw a list of indexed primitives
  124384. * @param fillMode defines the primitive to use
  124385. * @param indexStart defines the starting index
  124386. * @param indexCount defines the number of index to draw
  124387. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124388. */
  124389. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  124390. /**
  124391. * Draw a list of unindexed primitives
  124392. * @param fillMode defines the primitive to use
  124393. * @param verticesStart defines the index of first vertex to draw
  124394. * @param verticesCount defines the count of vertices to draw
  124395. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124396. */
  124397. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124398. createPipelineContext(): IPipelineContext;
  124399. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  124400. /** @hidden */
  124401. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  124402. /** @hidden */
  124403. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  124404. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124405. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124406. protected _setProgram(program: WebGLProgram): void;
  124407. _releaseEffect(effect: Effect): void;
  124408. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  124409. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  124410. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  124411. bindSamplers(effect: Effect): void;
  124412. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  124413. getRenderWidth(useScreen?: boolean): number;
  124414. getRenderHeight(useScreen?: boolean): number;
  124415. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  124416. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  124417. /**
  124418. * Set the z offset to apply to current rendering
  124419. * @param value defines the offset to apply
  124420. */
  124421. setZOffset(value: number): void;
  124422. /**
  124423. * Gets the current value of the zOffset
  124424. * @returns the current zOffset state
  124425. */
  124426. getZOffset(): number;
  124427. /**
  124428. * Enable or disable depth buffering
  124429. * @param enable defines the state to set
  124430. */
  124431. setDepthBuffer(enable: boolean): void;
  124432. /**
  124433. * Gets a boolean indicating if depth writing is enabled
  124434. * @returns the current depth writing state
  124435. */
  124436. getDepthWrite(): boolean;
  124437. /**
  124438. * Enable or disable depth writing
  124439. * @param enable defines the state to set
  124440. */
  124441. setDepthWrite(enable: boolean): void;
  124442. /**
  124443. * Enable or disable color writing
  124444. * @param enable defines the state to set
  124445. */
  124446. setColorWrite(enable: boolean): void;
  124447. /**
  124448. * Gets a boolean indicating if color writing is enabled
  124449. * @returns the current color writing state
  124450. */
  124451. getColorWrite(): boolean;
  124452. /**
  124453. * Sets alpha constants used by some alpha blending modes
  124454. * @param r defines the red component
  124455. * @param g defines the green component
  124456. * @param b defines the blue component
  124457. * @param a defines the alpha component
  124458. */
  124459. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  124460. /**
  124461. * Sets the current alpha mode
  124462. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  124463. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  124464. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124465. */
  124466. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  124467. /**
  124468. * Gets the current alpha mode
  124469. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124470. * @returns the current alpha mode
  124471. */
  124472. getAlphaMode(): number;
  124473. setInt(uniform: WebGLUniformLocation, int: number): void;
  124474. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  124475. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  124476. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  124477. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  124478. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  124479. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  124480. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  124481. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  124482. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  124483. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  124484. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  124485. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  124486. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  124487. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124488. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124489. setFloat(uniform: WebGLUniformLocation, value: number): void;
  124490. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  124491. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  124492. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  124493. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  124494. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  124495. wipeCaches(bruteForce?: boolean): void;
  124496. _createTexture(): WebGLTexture;
  124497. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  124498. /**
  124499. * Usually called from Texture.ts.
  124500. * Passed information to create a WebGLTexture
  124501. * @param url defines a value which contains one of the following:
  124502. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  124503. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  124504. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  124505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  124506. * @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)
  124507. * @param scene needed for loading to the correct scene
  124508. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  124509. * @param onLoad optional callback to be called upon successful completion
  124510. * @param onError optional callback to be called upon failure
  124511. * @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
  124512. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  124513. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  124514. * @param forcedExtension defines the extension to use to pick the right loader
  124515. * @param mimeType defines an optional mime type
  124516. * @returns a InternalTexture for assignment back into BABYLON.Texture
  124517. */
  124518. 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;
  124519. /**
  124520. * Creates a cube texture
  124521. * @param rootUrl defines the url where the files to load is located
  124522. * @param scene defines the current scene
  124523. * @param files defines the list of files to load (1 per face)
  124524. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  124525. * @param onLoad defines an optional callback raised when the texture is loaded
  124526. * @param onError defines an optional callback raised if there is an issue to load the texture
  124527. * @param format defines the format of the data
  124528. * @param forcedExtension defines the extension to use to pick the right loader
  124529. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  124530. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  124531. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  124532. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  124533. * @returns the cube texture as an InternalTexture
  124534. */
  124535. 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;
  124536. private _getSamplingFilter;
  124537. private static _GetNativeTextureFormat;
  124538. createRenderTargetTexture(size: number | {
  124539. width: number;
  124540. height: number;
  124541. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  124542. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  124543. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  124544. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  124545. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  124546. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  124547. /**
  124548. * Updates a dynamic vertex buffer.
  124549. * @param vertexBuffer the vertex buffer to update
  124550. * @param data the data used to update the vertex buffer
  124551. * @param byteOffset the byte offset of the data (optional)
  124552. * @param byteLength the byte length of the data (optional)
  124553. */
  124554. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  124555. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  124556. private _updateAnisotropicLevel;
  124557. private _getAddressMode;
  124558. /** @hidden */
  124559. _bindTexture(channel: number, texture: InternalTexture): void;
  124560. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  124561. releaseEffects(): void;
  124562. /** @hidden */
  124563. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124564. /** @hidden */
  124565. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124566. /** @hidden */
  124567. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124568. /** @hidden */
  124569. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  124570. }
  124571. }
  124572. declare module BABYLON {
  124573. /**
  124574. * Gather the list of clipboard event types as constants.
  124575. */
  124576. export class ClipboardEventTypes {
  124577. /**
  124578. * The clipboard event is fired when a copy command is active (pressed).
  124579. */
  124580. static readonly COPY: number;
  124581. /**
  124582. * The clipboard event is fired when a cut command is active (pressed).
  124583. */
  124584. static readonly CUT: number;
  124585. /**
  124586. * The clipboard event is fired when a paste command is active (pressed).
  124587. */
  124588. static readonly PASTE: number;
  124589. }
  124590. /**
  124591. * This class is used to store clipboard related info for the onClipboardObservable event.
  124592. */
  124593. export class ClipboardInfo {
  124594. /**
  124595. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124596. */
  124597. type: number;
  124598. /**
  124599. * Defines the related dom event
  124600. */
  124601. event: ClipboardEvent;
  124602. /**
  124603. *Creates an instance of ClipboardInfo.
  124604. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  124605. * @param event Defines the related dom event
  124606. */
  124607. constructor(
  124608. /**
  124609. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124610. */
  124611. type: number,
  124612. /**
  124613. * Defines the related dom event
  124614. */
  124615. event: ClipboardEvent);
  124616. /**
  124617. * Get the clipboard event's type from the keycode.
  124618. * @param keyCode Defines the keyCode for the current keyboard event.
  124619. * @return {number}
  124620. */
  124621. static GetTypeFromCharacter(keyCode: number): number;
  124622. }
  124623. }
  124624. declare module BABYLON {
  124625. /**
  124626. * Google Daydream controller
  124627. */
  124628. export class DaydreamController extends WebVRController {
  124629. /**
  124630. * Base Url for the controller model.
  124631. */
  124632. static MODEL_BASE_URL: string;
  124633. /**
  124634. * File name for the controller model.
  124635. */
  124636. static MODEL_FILENAME: string;
  124637. /**
  124638. * Gamepad Id prefix used to identify Daydream Controller.
  124639. */
  124640. static readonly GAMEPAD_ID_PREFIX: string;
  124641. /**
  124642. * Creates a new DaydreamController from a gamepad
  124643. * @param vrGamepad the gamepad that the controller should be created from
  124644. */
  124645. constructor(vrGamepad: any);
  124646. /**
  124647. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124648. * @param scene scene in which to add meshes
  124649. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124650. */
  124651. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124652. /**
  124653. * Called once for each button that changed state since the last frame
  124654. * @param buttonIdx Which button index changed
  124655. * @param state New state of the button
  124656. * @param changes Which properties on the state changed since last frame
  124657. */
  124658. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124659. }
  124660. }
  124661. declare module BABYLON {
  124662. /**
  124663. * Gear VR Controller
  124664. */
  124665. export class GearVRController extends WebVRController {
  124666. /**
  124667. * Base Url for the controller model.
  124668. */
  124669. static MODEL_BASE_URL: string;
  124670. /**
  124671. * File name for the controller model.
  124672. */
  124673. static MODEL_FILENAME: string;
  124674. /**
  124675. * Gamepad Id prefix used to identify this controller.
  124676. */
  124677. static readonly GAMEPAD_ID_PREFIX: string;
  124678. private readonly _buttonIndexToObservableNameMap;
  124679. /**
  124680. * Creates a new GearVRController from a gamepad
  124681. * @param vrGamepad the gamepad that the controller should be created from
  124682. */
  124683. constructor(vrGamepad: any);
  124684. /**
  124685. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124686. * @param scene scene in which to add meshes
  124687. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124688. */
  124689. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124690. /**
  124691. * Called once for each button that changed state since the last frame
  124692. * @param buttonIdx Which button index changed
  124693. * @param state New state of the button
  124694. * @param changes Which properties on the state changed since last frame
  124695. */
  124696. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124697. }
  124698. }
  124699. declare module BABYLON {
  124700. /**
  124701. * Generic Controller
  124702. */
  124703. export class GenericController extends WebVRController {
  124704. /**
  124705. * Base Url for the controller model.
  124706. */
  124707. static readonly MODEL_BASE_URL: string;
  124708. /**
  124709. * File name for the controller model.
  124710. */
  124711. static readonly MODEL_FILENAME: string;
  124712. /**
  124713. * Creates a new GenericController from a gamepad
  124714. * @param vrGamepad the gamepad that the controller should be created from
  124715. */
  124716. constructor(vrGamepad: any);
  124717. /**
  124718. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124719. * @param scene scene in which to add meshes
  124720. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124721. */
  124722. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124723. /**
  124724. * Called once for each button that changed state since the last frame
  124725. * @param buttonIdx Which button index changed
  124726. * @param state New state of the button
  124727. * @param changes Which properties on the state changed since last frame
  124728. */
  124729. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124730. }
  124731. }
  124732. declare module BABYLON {
  124733. /**
  124734. * Oculus Touch Controller
  124735. */
  124736. export class OculusTouchController extends WebVRController {
  124737. /**
  124738. * Base Url for the controller model.
  124739. */
  124740. static MODEL_BASE_URL: string;
  124741. /**
  124742. * File name for the left controller model.
  124743. */
  124744. static MODEL_LEFT_FILENAME: string;
  124745. /**
  124746. * File name for the right controller model.
  124747. */
  124748. static MODEL_RIGHT_FILENAME: string;
  124749. /**
  124750. * Base Url for the Quest controller model.
  124751. */
  124752. static QUEST_MODEL_BASE_URL: string;
  124753. /**
  124754. * @hidden
  124755. * If the controllers are running on a device that needs the updated Quest controller models
  124756. */
  124757. static _IsQuest: boolean;
  124758. /**
  124759. * Fired when the secondary trigger on this controller is modified
  124760. */
  124761. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  124762. /**
  124763. * Fired when the thumb rest on this controller is modified
  124764. */
  124765. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  124766. /**
  124767. * Creates a new OculusTouchController from a gamepad
  124768. * @param vrGamepad the gamepad that the controller should be created from
  124769. */
  124770. constructor(vrGamepad: any);
  124771. /**
  124772. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124773. * @param scene scene in which to add meshes
  124774. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124775. */
  124776. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124777. /**
  124778. * Fired when the A button on this controller is modified
  124779. */
  124780. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124781. /**
  124782. * Fired when the B button on this controller is modified
  124783. */
  124784. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124785. /**
  124786. * Fired when the X button on this controller is modified
  124787. */
  124788. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124789. /**
  124790. * Fired when the Y button on this controller is modified
  124791. */
  124792. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124793. /**
  124794. * Called once for each button that changed state since the last frame
  124795. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  124796. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  124797. * 2) secondary trigger (same)
  124798. * 3) A (right) X (left), touch, pressed = value
  124799. * 4) B / Y
  124800. * 5) thumb rest
  124801. * @param buttonIdx Which button index changed
  124802. * @param state New state of the button
  124803. * @param changes Which properties on the state changed since last frame
  124804. */
  124805. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124806. }
  124807. }
  124808. declare module BABYLON {
  124809. /**
  124810. * Vive Controller
  124811. */
  124812. export class ViveController extends WebVRController {
  124813. /**
  124814. * Base Url for the controller model.
  124815. */
  124816. static MODEL_BASE_URL: string;
  124817. /**
  124818. * File name for the controller model.
  124819. */
  124820. static MODEL_FILENAME: string;
  124821. /**
  124822. * Creates a new ViveController from a gamepad
  124823. * @param vrGamepad the gamepad that the controller should be created from
  124824. */
  124825. constructor(vrGamepad: any);
  124826. /**
  124827. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124828. * @param scene scene in which to add meshes
  124829. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124830. */
  124831. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124832. /**
  124833. * Fired when the left button on this controller is modified
  124834. */
  124835. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124836. /**
  124837. * Fired when the right button on this controller is modified
  124838. */
  124839. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124840. /**
  124841. * Fired when the menu button on this controller is modified
  124842. */
  124843. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124844. /**
  124845. * Called once for each button that changed state since the last frame
  124846. * Vive mapping:
  124847. * 0: touchpad
  124848. * 1: trigger
  124849. * 2: left AND right buttons
  124850. * 3: menu button
  124851. * @param buttonIdx Which button index changed
  124852. * @param state New state of the button
  124853. * @param changes Which properties on the state changed since last frame
  124854. */
  124855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124856. }
  124857. }
  124858. declare module BABYLON {
  124859. /**
  124860. * Defines the WindowsMotionController object that the state of the windows motion controller
  124861. */
  124862. export class WindowsMotionController extends WebVRController {
  124863. /**
  124864. * The base url used to load the left and right controller models
  124865. */
  124866. static MODEL_BASE_URL: string;
  124867. /**
  124868. * The name of the left controller model file
  124869. */
  124870. static MODEL_LEFT_FILENAME: string;
  124871. /**
  124872. * The name of the right controller model file
  124873. */
  124874. static MODEL_RIGHT_FILENAME: string;
  124875. /**
  124876. * The controller name prefix for this controller type
  124877. */
  124878. static readonly GAMEPAD_ID_PREFIX: string;
  124879. /**
  124880. * The controller id pattern for this controller type
  124881. */
  124882. private static readonly GAMEPAD_ID_PATTERN;
  124883. private _loadedMeshInfo;
  124884. protected readonly _mapping: {
  124885. buttons: string[];
  124886. buttonMeshNames: {
  124887. trigger: string;
  124888. menu: string;
  124889. grip: string;
  124890. thumbstick: string;
  124891. trackpad: string;
  124892. };
  124893. buttonObservableNames: {
  124894. trigger: string;
  124895. menu: string;
  124896. grip: string;
  124897. thumbstick: string;
  124898. trackpad: string;
  124899. };
  124900. axisMeshNames: string[];
  124901. pointingPoseMeshName: string;
  124902. };
  124903. /**
  124904. * Fired when the trackpad on this controller is clicked
  124905. */
  124906. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124907. /**
  124908. * Fired when the trackpad on this controller is modified
  124909. */
  124910. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124911. /**
  124912. * The current x and y values of this controller's trackpad
  124913. */
  124914. trackpad: StickValues;
  124915. /**
  124916. * Creates a new WindowsMotionController from a gamepad
  124917. * @param vrGamepad the gamepad that the controller should be created from
  124918. */
  124919. constructor(vrGamepad: any);
  124920. /**
  124921. * Fired when the trigger on this controller is modified
  124922. */
  124923. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124924. /**
  124925. * Fired when the menu button on this controller is modified
  124926. */
  124927. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124928. /**
  124929. * Fired when the grip button on this controller is modified
  124930. */
  124931. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124932. /**
  124933. * Fired when the thumbstick button on this controller is modified
  124934. */
  124935. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124936. /**
  124937. * Fired when the touchpad button on this controller is modified
  124938. */
  124939. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124940. /**
  124941. * Fired when the touchpad values on this controller are modified
  124942. */
  124943. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  124944. protected _updateTrackpad(): void;
  124945. /**
  124946. * Called once per frame by the engine.
  124947. */
  124948. update(): void;
  124949. /**
  124950. * Called once for each button that changed state since the last frame
  124951. * @param buttonIdx Which button index changed
  124952. * @param state New state of the button
  124953. * @param changes Which properties on the state changed since last frame
  124954. */
  124955. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124956. /**
  124957. * Moves the buttons on the controller mesh based on their current state
  124958. * @param buttonName the name of the button to move
  124959. * @param buttonValue the value of the button which determines the buttons new position
  124960. */
  124961. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  124962. /**
  124963. * Moves the axis on the controller mesh based on its current state
  124964. * @param axis the index of the axis
  124965. * @param axisValue the value of the axis which determines the meshes new position
  124966. * @hidden
  124967. */
  124968. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  124969. /**
  124970. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124971. * @param scene scene in which to add meshes
  124972. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124973. */
  124974. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  124975. /**
  124976. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  124977. * can be transformed by button presses and axes values, based on this._mapping.
  124978. *
  124979. * @param scene scene in which the meshes exist
  124980. * @param meshes list of meshes that make up the controller model to process
  124981. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  124982. */
  124983. private processModel;
  124984. private createMeshInfo;
  124985. /**
  124986. * Gets the ray of the controller in the direction the controller is pointing
  124987. * @param length the length the resulting ray should be
  124988. * @returns a ray in the direction the controller is pointing
  124989. */
  124990. getForwardRay(length?: number): Ray;
  124991. /**
  124992. * Disposes of the controller
  124993. */
  124994. dispose(): void;
  124995. }
  124996. /**
  124997. * This class represents a new windows motion controller in XR.
  124998. */
  124999. export class XRWindowsMotionController extends WindowsMotionController {
  125000. /**
  125001. * Changing the original WIndowsMotionController mapping to fir the new mapping
  125002. */
  125003. protected readonly _mapping: {
  125004. buttons: string[];
  125005. buttonMeshNames: {
  125006. trigger: string;
  125007. menu: string;
  125008. grip: string;
  125009. thumbstick: string;
  125010. trackpad: string;
  125011. };
  125012. buttonObservableNames: {
  125013. trigger: string;
  125014. menu: string;
  125015. grip: string;
  125016. thumbstick: string;
  125017. trackpad: string;
  125018. };
  125019. axisMeshNames: string[];
  125020. pointingPoseMeshName: string;
  125021. };
  125022. /**
  125023. * Construct a new XR-Based windows motion controller
  125024. *
  125025. * @param gamepadInfo the gamepad object from the browser
  125026. */
  125027. constructor(gamepadInfo: any);
  125028. /**
  125029. * holds the thumbstick values (X,Y)
  125030. */
  125031. thumbstickValues: StickValues;
  125032. /**
  125033. * Fired when the thumbstick on this controller is clicked
  125034. */
  125035. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  125036. /**
  125037. * Fired when the thumbstick on this controller is modified
  125038. */
  125039. onThumbstickValuesChangedObservable: Observable<StickValues>;
  125040. /**
  125041. * Fired when the touchpad button on this controller is modified
  125042. */
  125043. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  125044. /**
  125045. * Fired when the touchpad values on this controller are modified
  125046. */
  125047. onTrackpadValuesChangedObservable: Observable<StickValues>;
  125048. /**
  125049. * Fired when the thumbstick button on this controller is modified
  125050. * here to prevent breaking changes
  125051. */
  125052. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  125053. /**
  125054. * updating the thumbstick(!) and not the trackpad.
  125055. * This is named this way due to the difference between WebVR and XR and to avoid
  125056. * changing the parent class.
  125057. */
  125058. protected _updateTrackpad(): void;
  125059. /**
  125060. * Disposes the class with joy
  125061. */
  125062. dispose(): void;
  125063. }
  125064. }
  125065. declare module BABYLON {
  125066. /**
  125067. * Class containing static functions to help procedurally build meshes
  125068. */
  125069. export class PolyhedronBuilder {
  125070. /**
  125071. * Creates a polyhedron mesh
  125072. * * 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
  125073. * * The parameter `size` (positive float, default 1) sets the polygon size
  125074. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125075. * * 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`
  125076. * * 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
  125077. * * 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)`)
  125078. * * 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
  125079. * * 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
  125080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125081. * * 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
  125082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125083. * @param name defines the name of the mesh
  125084. * @param options defines the options used to create the mesh
  125085. * @param scene defines the hosting scene
  125086. * @returns the polyhedron mesh
  125087. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125088. */
  125089. static CreatePolyhedron(name: string, options: {
  125090. type?: number;
  125091. size?: number;
  125092. sizeX?: number;
  125093. sizeY?: number;
  125094. sizeZ?: number;
  125095. custom?: any;
  125096. faceUV?: Vector4[];
  125097. faceColors?: Color4[];
  125098. flat?: boolean;
  125099. updatable?: boolean;
  125100. sideOrientation?: number;
  125101. frontUVs?: Vector4;
  125102. backUVs?: Vector4;
  125103. }, scene?: Nullable<Scene>): Mesh;
  125104. }
  125105. }
  125106. declare module BABYLON {
  125107. /**
  125108. * Gizmo that enables scaling a mesh along 3 axis
  125109. */
  125110. export class ScaleGizmo extends Gizmo {
  125111. /**
  125112. * Internal gizmo used for interactions on the x axis
  125113. */
  125114. xGizmo: AxisScaleGizmo;
  125115. /**
  125116. * Internal gizmo used for interactions on the y axis
  125117. */
  125118. yGizmo: AxisScaleGizmo;
  125119. /**
  125120. * Internal gizmo used for interactions on the z axis
  125121. */
  125122. zGizmo: AxisScaleGizmo;
  125123. /**
  125124. * Internal gizmo used to scale all axis equally
  125125. */
  125126. uniformScaleGizmo: AxisScaleGizmo;
  125127. private _meshAttached;
  125128. private _updateGizmoRotationToMatchAttachedMesh;
  125129. private _snapDistance;
  125130. private _scaleRatio;
  125131. private _uniformScalingMesh;
  125132. private _octahedron;
  125133. private _sensitivity;
  125134. /** Fires an event when any of it's sub gizmos are dragged */
  125135. onDragStartObservable: Observable<unknown>;
  125136. /** Fires an event when any of it's sub gizmos are released from dragging */
  125137. onDragEndObservable: Observable<unknown>;
  125138. get attachedMesh(): Nullable<AbstractMesh>;
  125139. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125140. /**
  125141. * Creates a ScaleGizmo
  125142. * @param gizmoLayer The utility layer the gizmo will be added to
  125143. */
  125144. constructor(gizmoLayer?: UtilityLayerRenderer);
  125145. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125146. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125147. /**
  125148. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125149. */
  125150. set snapDistance(value: number);
  125151. get snapDistance(): number;
  125152. /**
  125153. * Ratio for the scale of the gizmo (Default: 1)
  125154. */
  125155. set scaleRatio(value: number);
  125156. get scaleRatio(): number;
  125157. /**
  125158. * Sensitivity factor for dragging (Default: 1)
  125159. */
  125160. set sensitivity(value: number);
  125161. get sensitivity(): number;
  125162. /**
  125163. * Disposes of the gizmo
  125164. */
  125165. dispose(): void;
  125166. }
  125167. }
  125168. declare module BABYLON {
  125169. /**
  125170. * Single axis scale gizmo
  125171. */
  125172. export class AxisScaleGizmo extends Gizmo {
  125173. /**
  125174. * Drag behavior responsible for the gizmos dragging interactions
  125175. */
  125176. dragBehavior: PointerDragBehavior;
  125177. private _pointerObserver;
  125178. /**
  125179. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125180. */
  125181. snapDistance: number;
  125182. /**
  125183. * Event that fires each time the gizmo snaps to a new location.
  125184. * * snapDistance is the the change in distance
  125185. */
  125186. onSnapObservable: Observable<{
  125187. snapDistance: number;
  125188. }>;
  125189. /**
  125190. * If the scaling operation should be done on all axis (default: false)
  125191. */
  125192. uniformScaling: boolean;
  125193. /**
  125194. * Custom sensitivity value for the drag strength
  125195. */
  125196. sensitivity: number;
  125197. private _isEnabled;
  125198. private _parent;
  125199. private _arrow;
  125200. private _coloredMaterial;
  125201. private _hoverMaterial;
  125202. /**
  125203. * Creates an AxisScaleGizmo
  125204. * @param gizmoLayer The utility layer the gizmo will be added to
  125205. * @param dragAxis The axis which the gizmo will be able to scale on
  125206. * @param color The color of the gizmo
  125207. */
  125208. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  125209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125210. /**
  125211. * If the gizmo is enabled
  125212. */
  125213. set isEnabled(value: boolean);
  125214. get isEnabled(): boolean;
  125215. /**
  125216. * Disposes of the gizmo
  125217. */
  125218. dispose(): void;
  125219. /**
  125220. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  125221. * @param mesh The mesh to replace the default mesh of the gizmo
  125222. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  125223. */
  125224. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  125225. }
  125226. }
  125227. declare module BABYLON {
  125228. /**
  125229. * Bounding box gizmo
  125230. */
  125231. export class BoundingBoxGizmo extends Gizmo {
  125232. private _lineBoundingBox;
  125233. private _rotateSpheresParent;
  125234. private _scaleBoxesParent;
  125235. private _boundingDimensions;
  125236. private _renderObserver;
  125237. private _pointerObserver;
  125238. private _scaleDragSpeed;
  125239. private _tmpQuaternion;
  125240. private _tmpVector;
  125241. private _tmpRotationMatrix;
  125242. /**
  125243. * 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)
  125244. */
  125245. ignoreChildren: boolean;
  125246. /**
  125247. * 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)
  125248. */
  125249. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  125250. /**
  125251. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  125252. */
  125253. rotationSphereSize: number;
  125254. /**
  125255. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  125256. */
  125257. scaleBoxSize: number;
  125258. /**
  125259. * 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)
  125260. */
  125261. fixedDragMeshScreenSize: boolean;
  125262. /**
  125263. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  125264. */
  125265. fixedDragMeshScreenSizeDistanceFactor: number;
  125266. /**
  125267. * Fired when a rotation sphere or scale box is dragged
  125268. */
  125269. onDragStartObservable: Observable<{}>;
  125270. /**
  125271. * Fired when a scale box is dragged
  125272. */
  125273. onScaleBoxDragObservable: Observable<{}>;
  125274. /**
  125275. * Fired when a scale box drag is ended
  125276. */
  125277. onScaleBoxDragEndObservable: Observable<{}>;
  125278. /**
  125279. * Fired when a rotation sphere is dragged
  125280. */
  125281. onRotationSphereDragObservable: Observable<{}>;
  125282. /**
  125283. * Fired when a rotation sphere drag is ended
  125284. */
  125285. onRotationSphereDragEndObservable: Observable<{}>;
  125286. /**
  125287. * 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)
  125288. */
  125289. scalePivot: Nullable<Vector3>;
  125290. /**
  125291. * Mesh used as a pivot to rotate the attached mesh
  125292. */
  125293. private _anchorMesh;
  125294. private _existingMeshScale;
  125295. private _dragMesh;
  125296. private pointerDragBehavior;
  125297. private coloredMaterial;
  125298. private hoverColoredMaterial;
  125299. /**
  125300. * Sets the color of the bounding box gizmo
  125301. * @param color the color to set
  125302. */
  125303. setColor(color: Color3): void;
  125304. /**
  125305. * Creates an BoundingBoxGizmo
  125306. * @param gizmoLayer The utility layer the gizmo will be added to
  125307. * @param color The color of the gizmo
  125308. */
  125309. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  125310. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125311. private _selectNode;
  125312. /**
  125313. * Updates the bounding box information for the Gizmo
  125314. */
  125315. updateBoundingBox(): void;
  125316. private _updateRotationSpheres;
  125317. private _updateScaleBoxes;
  125318. /**
  125319. * Enables rotation on the specified axis and disables rotation on the others
  125320. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  125321. */
  125322. setEnabledRotationAxis(axis: string): void;
  125323. /**
  125324. * Enables/disables scaling
  125325. * @param enable if scaling should be enabled
  125326. * @param homogeneousScaling defines if scaling should only be homogeneous
  125327. */
  125328. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  125329. private _updateDummy;
  125330. /**
  125331. * Enables a pointer drag behavior on the bounding box of the gizmo
  125332. */
  125333. enableDragBehavior(): void;
  125334. /**
  125335. * Disposes of the gizmo
  125336. */
  125337. dispose(): void;
  125338. /**
  125339. * 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)
  125340. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  125341. * @returns the bounding box mesh with the passed in mesh as a child
  125342. */
  125343. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  125344. /**
  125345. * CustomMeshes are not supported by this gizmo
  125346. * @param mesh The mesh to replace the default mesh of the gizmo
  125347. */
  125348. setCustomMesh(mesh: Mesh): void;
  125349. }
  125350. }
  125351. declare module BABYLON {
  125352. /**
  125353. * Single plane rotation gizmo
  125354. */
  125355. export class PlaneRotationGizmo extends Gizmo {
  125356. /**
  125357. * Drag behavior responsible for the gizmos dragging interactions
  125358. */
  125359. dragBehavior: PointerDragBehavior;
  125360. private _pointerObserver;
  125361. /**
  125362. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  125363. */
  125364. snapDistance: number;
  125365. /**
  125366. * Event that fires each time the gizmo snaps to a new location.
  125367. * * snapDistance is the the change in distance
  125368. */
  125369. onSnapObservable: Observable<{
  125370. snapDistance: number;
  125371. }>;
  125372. private _isEnabled;
  125373. private _parent;
  125374. /**
  125375. * Creates a PlaneRotationGizmo
  125376. * @param gizmoLayer The utility layer the gizmo will be added to
  125377. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  125378. * @param color The color of the gizmo
  125379. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125380. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125381. */
  125382. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  125383. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125384. /**
  125385. * If the gizmo is enabled
  125386. */
  125387. set isEnabled(value: boolean);
  125388. get isEnabled(): boolean;
  125389. /**
  125390. * Disposes of the gizmo
  125391. */
  125392. dispose(): void;
  125393. }
  125394. }
  125395. declare module BABYLON {
  125396. /**
  125397. * Gizmo that enables rotating a mesh along 3 axis
  125398. */
  125399. export class RotationGizmo extends Gizmo {
  125400. /**
  125401. * Internal gizmo used for interactions on the x axis
  125402. */
  125403. xGizmo: PlaneRotationGizmo;
  125404. /**
  125405. * Internal gizmo used for interactions on the y axis
  125406. */
  125407. yGizmo: PlaneRotationGizmo;
  125408. /**
  125409. * Internal gizmo used for interactions on the z axis
  125410. */
  125411. zGizmo: PlaneRotationGizmo;
  125412. /** Fires an event when any of it's sub gizmos are dragged */
  125413. onDragStartObservable: Observable<unknown>;
  125414. /** Fires an event when any of it's sub gizmos are released from dragging */
  125415. onDragEndObservable: Observable<unknown>;
  125416. private _meshAttached;
  125417. get attachedMesh(): Nullable<AbstractMesh>;
  125418. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125419. /**
  125420. * Creates a RotationGizmo
  125421. * @param gizmoLayer The utility layer the gizmo will be added to
  125422. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125423. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125424. */
  125425. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  125426. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125427. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125428. /**
  125429. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125430. */
  125431. set snapDistance(value: number);
  125432. get snapDistance(): number;
  125433. /**
  125434. * Ratio for the scale of the gizmo (Default: 1)
  125435. */
  125436. set scaleRatio(value: number);
  125437. get scaleRatio(): number;
  125438. /**
  125439. * Disposes of the gizmo
  125440. */
  125441. dispose(): void;
  125442. /**
  125443. * CustomMeshes are not supported by this gizmo
  125444. * @param mesh The mesh to replace the default mesh of the gizmo
  125445. */
  125446. setCustomMesh(mesh: Mesh): void;
  125447. }
  125448. }
  125449. declare module BABYLON {
  125450. /**
  125451. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  125452. */
  125453. export class GizmoManager implements IDisposable {
  125454. private scene;
  125455. /**
  125456. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  125457. */
  125458. gizmos: {
  125459. positionGizmo: Nullable<PositionGizmo>;
  125460. rotationGizmo: Nullable<RotationGizmo>;
  125461. scaleGizmo: Nullable<ScaleGizmo>;
  125462. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  125463. };
  125464. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  125465. clearGizmoOnEmptyPointerEvent: boolean;
  125466. /** Fires an event when the manager is attached to a mesh */
  125467. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  125468. private _gizmosEnabled;
  125469. private _pointerObserver;
  125470. private _attachedMesh;
  125471. private _boundingBoxColor;
  125472. private _defaultUtilityLayer;
  125473. private _defaultKeepDepthUtilityLayer;
  125474. /**
  125475. * When bounding box gizmo is enabled, this can be used to track drag/end events
  125476. */
  125477. boundingBoxDragBehavior: SixDofDragBehavior;
  125478. /**
  125479. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  125480. */
  125481. attachableMeshes: Nullable<Array<AbstractMesh>>;
  125482. /**
  125483. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  125484. */
  125485. usePointerToAttachGizmos: boolean;
  125486. /**
  125487. * Utility layer that the bounding box gizmo belongs to
  125488. */
  125489. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  125490. /**
  125491. * Utility layer that all gizmos besides bounding box belong to
  125492. */
  125493. get utilityLayer(): UtilityLayerRenderer;
  125494. /**
  125495. * Instatiates a gizmo manager
  125496. * @param scene the scene to overlay the gizmos on top of
  125497. */
  125498. constructor(scene: Scene);
  125499. /**
  125500. * Attaches a set of gizmos to the specified mesh
  125501. * @param mesh The mesh the gizmo's should be attached to
  125502. */
  125503. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  125504. /**
  125505. * If the position gizmo is enabled
  125506. */
  125507. set positionGizmoEnabled(value: boolean);
  125508. get positionGizmoEnabled(): boolean;
  125509. /**
  125510. * If the rotation gizmo is enabled
  125511. */
  125512. set rotationGizmoEnabled(value: boolean);
  125513. get rotationGizmoEnabled(): boolean;
  125514. /**
  125515. * If the scale gizmo is enabled
  125516. */
  125517. set scaleGizmoEnabled(value: boolean);
  125518. get scaleGizmoEnabled(): boolean;
  125519. /**
  125520. * If the boundingBox gizmo is enabled
  125521. */
  125522. set boundingBoxGizmoEnabled(value: boolean);
  125523. get boundingBoxGizmoEnabled(): boolean;
  125524. /**
  125525. * Disposes of the gizmo manager
  125526. */
  125527. dispose(): void;
  125528. }
  125529. }
  125530. declare module BABYLON {
  125531. /**
  125532. * A directional light is defined by a direction (what a surprise!).
  125533. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  125534. * 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.
  125535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125536. */
  125537. export class DirectionalLight extends ShadowLight {
  125538. private _shadowFrustumSize;
  125539. /**
  125540. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  125541. */
  125542. get shadowFrustumSize(): number;
  125543. /**
  125544. * Specifies a fix frustum size for the shadow generation.
  125545. */
  125546. set shadowFrustumSize(value: number);
  125547. private _shadowOrthoScale;
  125548. /**
  125549. * Gets the shadow projection scale against the optimal computed one.
  125550. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125551. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125552. */
  125553. get shadowOrthoScale(): number;
  125554. /**
  125555. * Sets the shadow projection scale against the optimal computed one.
  125556. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125557. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125558. */
  125559. set shadowOrthoScale(value: number);
  125560. /**
  125561. * Automatically compute the projection matrix to best fit (including all the casters)
  125562. * on each frame.
  125563. */
  125564. autoUpdateExtends: boolean;
  125565. /**
  125566. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  125567. * on each frame. autoUpdateExtends must be set to true for this to work
  125568. */
  125569. autoCalcShadowZBounds: boolean;
  125570. private _orthoLeft;
  125571. private _orthoRight;
  125572. private _orthoTop;
  125573. private _orthoBottom;
  125574. /**
  125575. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  125576. * The directional light is emitted from everywhere in the given direction.
  125577. * It can cast shadows.
  125578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125579. * @param name The friendly name of the light
  125580. * @param direction The direction of the light
  125581. * @param scene The scene the light belongs to
  125582. */
  125583. constructor(name: string, direction: Vector3, scene: Scene);
  125584. /**
  125585. * Returns the string "DirectionalLight".
  125586. * @return The class name
  125587. */
  125588. getClassName(): string;
  125589. /**
  125590. * Returns the integer 1.
  125591. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125592. */
  125593. getTypeID(): number;
  125594. /**
  125595. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  125596. * Returns the DirectionalLight Shadow projection matrix.
  125597. */
  125598. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125599. /**
  125600. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  125601. * Returns the DirectionalLight Shadow projection matrix.
  125602. */
  125603. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  125604. /**
  125605. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  125606. * Returns the DirectionalLight Shadow projection matrix.
  125607. */
  125608. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125609. protected _buildUniformLayout(): void;
  125610. /**
  125611. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  125612. * @param effect The effect to update
  125613. * @param lightIndex The index of the light in the effect to update
  125614. * @returns The directional light
  125615. */
  125616. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  125617. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  125618. /**
  125619. * Gets the minZ used for shadow according to both the scene and the light.
  125620. *
  125621. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125622. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125623. * @param activeCamera The camera we are returning the min for
  125624. * @returns the depth min z
  125625. */
  125626. getDepthMinZ(activeCamera: Camera): number;
  125627. /**
  125628. * Gets the maxZ used for shadow according to both the scene and the light.
  125629. *
  125630. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125631. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125632. * @param activeCamera The camera we are returning the max for
  125633. * @returns the depth max z
  125634. */
  125635. getDepthMaxZ(activeCamera: Camera): number;
  125636. /**
  125637. * Prepares the list of defines specific to the light type.
  125638. * @param defines the list of defines
  125639. * @param lightIndex defines the index of the light for the effect
  125640. */
  125641. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125642. }
  125643. }
  125644. declare module BABYLON {
  125645. /**
  125646. * Class containing static functions to help procedurally build meshes
  125647. */
  125648. export class HemisphereBuilder {
  125649. /**
  125650. * Creates a hemisphere mesh
  125651. * @param name defines the name of the mesh
  125652. * @param options defines the options used to create the mesh
  125653. * @param scene defines the hosting scene
  125654. * @returns the hemisphere mesh
  125655. */
  125656. static CreateHemisphere(name: string, options: {
  125657. segments?: number;
  125658. diameter?: number;
  125659. sideOrientation?: number;
  125660. }, scene: any): Mesh;
  125661. }
  125662. }
  125663. declare module BABYLON {
  125664. /**
  125665. * A spot light is defined by a position, a direction, an angle, and an exponent.
  125666. * These values define a cone of light starting from the position, emitting toward the direction.
  125667. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  125668. * and the exponent defines the speed of the decay of the light with distance (reach).
  125669. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125670. */
  125671. export class SpotLight extends ShadowLight {
  125672. private _angle;
  125673. private _innerAngle;
  125674. private _cosHalfAngle;
  125675. private _lightAngleScale;
  125676. private _lightAngleOffset;
  125677. /**
  125678. * Gets the cone angle of the spot light in Radians.
  125679. */
  125680. get angle(): number;
  125681. /**
  125682. * Sets the cone angle of the spot light in Radians.
  125683. */
  125684. set angle(value: number);
  125685. /**
  125686. * Only used in gltf falloff mode, this defines the angle where
  125687. * the directional falloff will start before cutting at angle which could be seen
  125688. * as outer angle.
  125689. */
  125690. get innerAngle(): number;
  125691. /**
  125692. * Only used in gltf falloff mode, this defines the angle where
  125693. * the directional falloff will start before cutting at angle which could be seen
  125694. * as outer angle.
  125695. */
  125696. set innerAngle(value: number);
  125697. private _shadowAngleScale;
  125698. /**
  125699. * Allows scaling the angle of the light for shadow generation only.
  125700. */
  125701. get shadowAngleScale(): number;
  125702. /**
  125703. * Allows scaling the angle of the light for shadow generation only.
  125704. */
  125705. set shadowAngleScale(value: number);
  125706. /**
  125707. * The light decay speed with the distance from the emission spot.
  125708. */
  125709. exponent: number;
  125710. private _projectionTextureMatrix;
  125711. /**
  125712. * Allows reading the projecton texture
  125713. */
  125714. get projectionTextureMatrix(): Matrix;
  125715. protected _projectionTextureLightNear: number;
  125716. /**
  125717. * Gets the near clip of the Spotlight for texture projection.
  125718. */
  125719. get projectionTextureLightNear(): number;
  125720. /**
  125721. * Sets the near clip of the Spotlight for texture projection.
  125722. */
  125723. set projectionTextureLightNear(value: number);
  125724. protected _projectionTextureLightFar: number;
  125725. /**
  125726. * Gets the far clip of the Spotlight for texture projection.
  125727. */
  125728. get projectionTextureLightFar(): number;
  125729. /**
  125730. * Sets the far clip of the Spotlight for texture projection.
  125731. */
  125732. set projectionTextureLightFar(value: number);
  125733. protected _projectionTextureUpDirection: Vector3;
  125734. /**
  125735. * Gets the Up vector of the Spotlight for texture projection.
  125736. */
  125737. get projectionTextureUpDirection(): Vector3;
  125738. /**
  125739. * Sets the Up vector of the Spotlight for texture projection.
  125740. */
  125741. set projectionTextureUpDirection(value: Vector3);
  125742. private _projectionTexture;
  125743. /**
  125744. * Gets the projection texture of the light.
  125745. */
  125746. get projectionTexture(): Nullable<BaseTexture>;
  125747. /**
  125748. * Sets the projection texture of the light.
  125749. */
  125750. set projectionTexture(value: Nullable<BaseTexture>);
  125751. private _projectionTextureViewLightDirty;
  125752. private _projectionTextureProjectionLightDirty;
  125753. private _projectionTextureDirty;
  125754. private _projectionTextureViewTargetVector;
  125755. private _projectionTextureViewLightMatrix;
  125756. private _projectionTextureProjectionLightMatrix;
  125757. private _projectionTextureScalingMatrix;
  125758. /**
  125759. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  125760. * It can cast shadows.
  125761. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125762. * @param name The light friendly name
  125763. * @param position The position of the spot light in the scene
  125764. * @param direction The direction of the light in the scene
  125765. * @param angle The cone angle of the light in Radians
  125766. * @param exponent The light decay speed with the distance from the emission spot
  125767. * @param scene The scene the lights belongs to
  125768. */
  125769. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  125770. /**
  125771. * Returns the string "SpotLight".
  125772. * @returns the class name
  125773. */
  125774. getClassName(): string;
  125775. /**
  125776. * Returns the integer 2.
  125777. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125778. */
  125779. getTypeID(): number;
  125780. /**
  125781. * Overrides the direction setter to recompute the projection texture view light Matrix.
  125782. */
  125783. protected _setDirection(value: Vector3): void;
  125784. /**
  125785. * Overrides the position setter to recompute the projection texture view light Matrix.
  125786. */
  125787. protected _setPosition(value: Vector3): void;
  125788. /**
  125789. * 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.
  125790. * Returns the SpotLight.
  125791. */
  125792. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125793. protected _computeProjectionTextureViewLightMatrix(): void;
  125794. protected _computeProjectionTextureProjectionLightMatrix(): void;
  125795. /**
  125796. * Main function for light texture projection matrix computing.
  125797. */
  125798. protected _computeProjectionTextureMatrix(): void;
  125799. protected _buildUniformLayout(): void;
  125800. private _computeAngleValues;
  125801. /**
  125802. * Sets the passed Effect "effect" with the Light textures.
  125803. * @param effect The effect to update
  125804. * @param lightIndex The index of the light in the effect to update
  125805. * @returns The light
  125806. */
  125807. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  125808. /**
  125809. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  125810. * @param effect The effect to update
  125811. * @param lightIndex The index of the light in the effect to update
  125812. * @returns The spot light
  125813. */
  125814. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  125815. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125816. /**
  125817. * Disposes the light and the associated resources.
  125818. */
  125819. dispose(): void;
  125820. /**
  125821. * Prepares the list of defines specific to the light type.
  125822. * @param defines the list of defines
  125823. * @param lightIndex defines the index of the light for the effect
  125824. */
  125825. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125826. }
  125827. }
  125828. declare module BABYLON {
  125829. /**
  125830. * Gizmo that enables viewing a light
  125831. */
  125832. export class LightGizmo extends Gizmo {
  125833. private _lightMesh;
  125834. private _material;
  125835. private _cachedPosition;
  125836. private _cachedForward;
  125837. private _attachedMeshParent;
  125838. /**
  125839. * Creates a LightGizmo
  125840. * @param gizmoLayer The utility layer the gizmo will be added to
  125841. */
  125842. constructor(gizmoLayer?: UtilityLayerRenderer);
  125843. private _light;
  125844. /**
  125845. * The light that the gizmo is attached to
  125846. */
  125847. set light(light: Nullable<Light>);
  125848. get light(): Nullable<Light>;
  125849. /**
  125850. * Gets the material used to render the light gizmo
  125851. */
  125852. get material(): StandardMaterial;
  125853. /**
  125854. * @hidden
  125855. * Updates the gizmo to match the attached mesh's position/rotation
  125856. */
  125857. protected _update(): void;
  125858. private static _Scale;
  125859. /**
  125860. * Creates the lines for a light mesh
  125861. */
  125862. private static _CreateLightLines;
  125863. /**
  125864. * Disposes of the light gizmo
  125865. */
  125866. dispose(): void;
  125867. private static _CreateHemisphericLightMesh;
  125868. private static _CreatePointLightMesh;
  125869. private static _CreateSpotLightMesh;
  125870. private static _CreateDirectionalLightMesh;
  125871. }
  125872. }
  125873. declare module BABYLON {
  125874. /** @hidden */
  125875. export var backgroundFragmentDeclaration: {
  125876. name: string;
  125877. shader: string;
  125878. };
  125879. }
  125880. declare module BABYLON {
  125881. /** @hidden */
  125882. export var backgroundUboDeclaration: {
  125883. name: string;
  125884. shader: string;
  125885. };
  125886. }
  125887. declare module BABYLON {
  125888. /** @hidden */
  125889. export var backgroundPixelShader: {
  125890. name: string;
  125891. shader: string;
  125892. };
  125893. }
  125894. declare module BABYLON {
  125895. /** @hidden */
  125896. export var backgroundVertexDeclaration: {
  125897. name: string;
  125898. shader: string;
  125899. };
  125900. }
  125901. declare module BABYLON {
  125902. /** @hidden */
  125903. export var backgroundVertexShader: {
  125904. name: string;
  125905. shader: string;
  125906. };
  125907. }
  125908. declare module BABYLON {
  125909. /**
  125910. * Background material used to create an efficient environement around your scene.
  125911. */
  125912. export class BackgroundMaterial extends PushMaterial {
  125913. /**
  125914. * Standard reflectance value at parallel view angle.
  125915. */
  125916. static StandardReflectance0: number;
  125917. /**
  125918. * Standard reflectance value at grazing angle.
  125919. */
  125920. static StandardReflectance90: number;
  125921. protected _primaryColor: Color3;
  125922. /**
  125923. * Key light Color (multiply against the environement texture)
  125924. */
  125925. primaryColor: Color3;
  125926. protected __perceptualColor: Nullable<Color3>;
  125927. /**
  125928. * Experimental Internal Use Only.
  125929. *
  125930. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  125931. * This acts as a helper to set the primary color to a more "human friendly" value.
  125932. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  125933. * output color as close as possible from the chosen value.
  125934. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  125935. * part of lighting setup.)
  125936. */
  125937. get _perceptualColor(): Nullable<Color3>;
  125938. set _perceptualColor(value: Nullable<Color3>);
  125939. protected _primaryColorShadowLevel: float;
  125940. /**
  125941. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  125942. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  125943. */
  125944. get primaryColorShadowLevel(): float;
  125945. set primaryColorShadowLevel(value: float);
  125946. protected _primaryColorHighlightLevel: float;
  125947. /**
  125948. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  125949. * The primary color is used at the level chosen to define what the white area would look.
  125950. */
  125951. get primaryColorHighlightLevel(): float;
  125952. set primaryColorHighlightLevel(value: float);
  125953. protected _reflectionTexture: Nullable<BaseTexture>;
  125954. /**
  125955. * Reflection Texture used in the material.
  125956. * Should be author in a specific way for the best result (refer to the documentation).
  125957. */
  125958. reflectionTexture: Nullable<BaseTexture>;
  125959. protected _reflectionBlur: float;
  125960. /**
  125961. * Reflection Texture level of blur.
  125962. *
  125963. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  125964. * texture twice.
  125965. */
  125966. reflectionBlur: float;
  125967. protected _diffuseTexture: Nullable<BaseTexture>;
  125968. /**
  125969. * Diffuse Texture used in the material.
  125970. * Should be author in a specific way for the best result (refer to the documentation).
  125971. */
  125972. diffuseTexture: Nullable<BaseTexture>;
  125973. protected _shadowLights: Nullable<IShadowLight[]>;
  125974. /**
  125975. * Specify the list of lights casting shadow on the material.
  125976. * All scene shadow lights will be included if null.
  125977. */
  125978. shadowLights: Nullable<IShadowLight[]>;
  125979. protected _shadowLevel: float;
  125980. /**
  125981. * Helps adjusting the shadow to a softer level if required.
  125982. * 0 means black shadows and 1 means no shadows.
  125983. */
  125984. shadowLevel: float;
  125985. protected _sceneCenter: Vector3;
  125986. /**
  125987. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  125988. * It is usually zero but might be interesting to modify according to your setup.
  125989. */
  125990. sceneCenter: Vector3;
  125991. protected _opacityFresnel: boolean;
  125992. /**
  125993. * This helps specifying that the material is falling off to the sky box at grazing angle.
  125994. * This helps ensuring a nice transition when the camera goes under the ground.
  125995. */
  125996. opacityFresnel: boolean;
  125997. protected _reflectionFresnel: boolean;
  125998. /**
  125999. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  126000. * This helps adding a mirror texture on the ground.
  126001. */
  126002. reflectionFresnel: boolean;
  126003. protected _reflectionFalloffDistance: number;
  126004. /**
  126005. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  126006. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  126007. */
  126008. reflectionFalloffDistance: number;
  126009. protected _reflectionAmount: number;
  126010. /**
  126011. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  126012. */
  126013. reflectionAmount: number;
  126014. protected _reflectionReflectance0: number;
  126015. /**
  126016. * This specifies the weight of the reflection at grazing angle.
  126017. */
  126018. reflectionReflectance0: number;
  126019. protected _reflectionReflectance90: number;
  126020. /**
  126021. * This specifies the weight of the reflection at a perpendicular point of view.
  126022. */
  126023. reflectionReflectance90: number;
  126024. /**
  126025. * Sets the reflection reflectance fresnel values according to the default standard
  126026. * empirically know to work well :-)
  126027. */
  126028. set reflectionStandardFresnelWeight(value: number);
  126029. protected _useRGBColor: boolean;
  126030. /**
  126031. * Helps to directly use the maps channels instead of their level.
  126032. */
  126033. useRGBColor: boolean;
  126034. protected _enableNoise: boolean;
  126035. /**
  126036. * This helps reducing the banding effect that could occur on the background.
  126037. */
  126038. enableNoise: boolean;
  126039. /**
  126040. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126041. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  126042. * Recommended to be keep at 1.0 except for special cases.
  126043. */
  126044. get fovMultiplier(): number;
  126045. set fovMultiplier(value: number);
  126046. private _fovMultiplier;
  126047. /**
  126048. * Enable the FOV adjustment feature controlled by fovMultiplier.
  126049. */
  126050. useEquirectangularFOV: boolean;
  126051. private _maxSimultaneousLights;
  126052. /**
  126053. * Number of Simultaneous lights allowed on the material.
  126054. */
  126055. maxSimultaneousLights: int;
  126056. /**
  126057. * Default configuration related to image processing available in the Background Material.
  126058. */
  126059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126060. /**
  126061. * Keep track of the image processing observer to allow dispose and replace.
  126062. */
  126063. private _imageProcessingObserver;
  126064. /**
  126065. * Attaches a new image processing configuration to the PBR Material.
  126066. * @param configuration (if null the scene configuration will be use)
  126067. */
  126068. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126069. /**
  126070. * Gets the image processing configuration used either in this material.
  126071. */
  126072. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  126073. /**
  126074. * Sets the Default image processing configuration used either in the this material.
  126075. *
  126076. * If sets to null, the scene one is in use.
  126077. */
  126078. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  126079. /**
  126080. * Gets wether the color curves effect is enabled.
  126081. */
  126082. get cameraColorCurvesEnabled(): boolean;
  126083. /**
  126084. * Sets wether the color curves effect is enabled.
  126085. */
  126086. set cameraColorCurvesEnabled(value: boolean);
  126087. /**
  126088. * Gets wether the color grading effect is enabled.
  126089. */
  126090. get cameraColorGradingEnabled(): boolean;
  126091. /**
  126092. * Gets wether the color grading effect is enabled.
  126093. */
  126094. set cameraColorGradingEnabled(value: boolean);
  126095. /**
  126096. * Gets wether tonemapping is enabled or not.
  126097. */
  126098. get cameraToneMappingEnabled(): boolean;
  126099. /**
  126100. * Sets wether tonemapping is enabled or not
  126101. */
  126102. set cameraToneMappingEnabled(value: boolean);
  126103. /**
  126104. * The camera exposure used on this material.
  126105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126106. * This corresponds to a photographic exposure.
  126107. */
  126108. get cameraExposure(): float;
  126109. /**
  126110. * The camera exposure used on this material.
  126111. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126112. * This corresponds to a photographic exposure.
  126113. */
  126114. set cameraExposure(value: float);
  126115. /**
  126116. * Gets The camera contrast used on this material.
  126117. */
  126118. get cameraContrast(): float;
  126119. /**
  126120. * Sets The camera contrast used on this material.
  126121. */
  126122. set cameraContrast(value: float);
  126123. /**
  126124. * Gets the Color Grading 2D Lookup Texture.
  126125. */
  126126. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126127. /**
  126128. * Sets the Color Grading 2D Lookup Texture.
  126129. */
  126130. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126131. /**
  126132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126134. * 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;
  126135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126136. */
  126137. get cameraColorCurves(): Nullable<ColorCurves>;
  126138. /**
  126139. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126140. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126141. * 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;
  126142. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126143. */
  126144. set cameraColorCurves(value: Nullable<ColorCurves>);
  126145. /**
  126146. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  126147. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  126148. */
  126149. switchToBGR: boolean;
  126150. private _renderTargets;
  126151. private _reflectionControls;
  126152. private _white;
  126153. private _primaryShadowColor;
  126154. private _primaryHighlightColor;
  126155. /**
  126156. * Instantiates a Background Material in the given scene
  126157. * @param name The friendly name of the material
  126158. * @param scene The scene to add the material to
  126159. */
  126160. constructor(name: string, scene: Scene);
  126161. /**
  126162. * Gets a boolean indicating that current material needs to register RTT
  126163. */
  126164. get hasRenderTargetTextures(): boolean;
  126165. /**
  126166. * The entire material has been created in order to prevent overdraw.
  126167. * @returns false
  126168. */
  126169. needAlphaTesting(): boolean;
  126170. /**
  126171. * The entire material has been created in order to prevent overdraw.
  126172. * @returns true if blending is enable
  126173. */
  126174. needAlphaBlending(): boolean;
  126175. /**
  126176. * Checks wether the material is ready to be rendered for a given mesh.
  126177. * @param mesh The mesh to render
  126178. * @param subMesh The submesh to check against
  126179. * @param useInstances Specify wether or not the material is used with instances
  126180. * @returns true if all the dependencies are ready (Textures, Effects...)
  126181. */
  126182. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126183. /**
  126184. * Compute the primary color according to the chosen perceptual color.
  126185. */
  126186. private _computePrimaryColorFromPerceptualColor;
  126187. /**
  126188. * Compute the highlights and shadow colors according to their chosen levels.
  126189. */
  126190. private _computePrimaryColors;
  126191. /**
  126192. * Build the uniform buffer used in the material.
  126193. */
  126194. buildUniformLayout(): void;
  126195. /**
  126196. * Unbind the material.
  126197. */
  126198. unbind(): void;
  126199. /**
  126200. * Bind only the world matrix to the material.
  126201. * @param world The world matrix to bind.
  126202. */
  126203. bindOnlyWorldMatrix(world: Matrix): void;
  126204. /**
  126205. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  126206. * @param world The world matrix to bind.
  126207. * @param subMesh The submesh to bind for.
  126208. */
  126209. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126210. /**
  126211. * Checks to see if a texture is used in the material.
  126212. * @param texture - Base texture to use.
  126213. * @returns - Boolean specifying if a texture is used in the material.
  126214. */
  126215. hasTexture(texture: BaseTexture): boolean;
  126216. /**
  126217. * Dispose the material.
  126218. * @param forceDisposeEffect Force disposal of the associated effect.
  126219. * @param forceDisposeTextures Force disposal of the associated textures.
  126220. */
  126221. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126222. /**
  126223. * Clones the material.
  126224. * @param name The cloned name.
  126225. * @returns The cloned material.
  126226. */
  126227. clone(name: string): BackgroundMaterial;
  126228. /**
  126229. * Serializes the current material to its JSON representation.
  126230. * @returns The JSON representation.
  126231. */
  126232. serialize(): any;
  126233. /**
  126234. * Gets the class name of the material
  126235. * @returns "BackgroundMaterial"
  126236. */
  126237. getClassName(): string;
  126238. /**
  126239. * Parse a JSON input to create back a background material.
  126240. * @param source The JSON data to parse
  126241. * @param scene The scene to create the parsed material in
  126242. * @param rootUrl The root url of the assets the material depends upon
  126243. * @returns the instantiated BackgroundMaterial.
  126244. */
  126245. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  126246. }
  126247. }
  126248. declare module BABYLON {
  126249. /**
  126250. * Represents the different options available during the creation of
  126251. * a Environment helper.
  126252. *
  126253. * This can control the default ground, skybox and image processing setup of your scene.
  126254. */
  126255. export interface IEnvironmentHelperOptions {
  126256. /**
  126257. * Specifies whether or not to create a ground.
  126258. * True by default.
  126259. */
  126260. createGround: boolean;
  126261. /**
  126262. * Specifies the ground size.
  126263. * 15 by default.
  126264. */
  126265. groundSize: number;
  126266. /**
  126267. * The texture used on the ground for the main color.
  126268. * Comes from the BabylonJS CDN by default.
  126269. *
  126270. * Remarks: Can be either a texture or a url.
  126271. */
  126272. groundTexture: string | BaseTexture;
  126273. /**
  126274. * The color mixed in the ground texture by default.
  126275. * BabylonJS clearColor by default.
  126276. */
  126277. groundColor: Color3;
  126278. /**
  126279. * Specifies the ground opacity.
  126280. * 1 by default.
  126281. */
  126282. groundOpacity: number;
  126283. /**
  126284. * Enables the ground to receive shadows.
  126285. * True by default.
  126286. */
  126287. enableGroundShadow: boolean;
  126288. /**
  126289. * Helps preventing the shadow to be fully black on the ground.
  126290. * 0.5 by default.
  126291. */
  126292. groundShadowLevel: number;
  126293. /**
  126294. * Creates a mirror texture attach to the ground.
  126295. * false by default.
  126296. */
  126297. enableGroundMirror: boolean;
  126298. /**
  126299. * Specifies the ground mirror size ratio.
  126300. * 0.3 by default as the default kernel is 64.
  126301. */
  126302. groundMirrorSizeRatio: number;
  126303. /**
  126304. * Specifies the ground mirror blur kernel size.
  126305. * 64 by default.
  126306. */
  126307. groundMirrorBlurKernel: number;
  126308. /**
  126309. * Specifies the ground mirror visibility amount.
  126310. * 1 by default
  126311. */
  126312. groundMirrorAmount: number;
  126313. /**
  126314. * Specifies the ground mirror reflectance weight.
  126315. * This uses the standard weight of the background material to setup the fresnel effect
  126316. * of the mirror.
  126317. * 1 by default.
  126318. */
  126319. groundMirrorFresnelWeight: number;
  126320. /**
  126321. * Specifies the ground mirror Falloff distance.
  126322. * This can helps reducing the size of the reflection.
  126323. * 0 by Default.
  126324. */
  126325. groundMirrorFallOffDistance: number;
  126326. /**
  126327. * Specifies the ground mirror texture type.
  126328. * Unsigned Int by Default.
  126329. */
  126330. groundMirrorTextureType: number;
  126331. /**
  126332. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  126333. * the shown objects.
  126334. */
  126335. groundYBias: number;
  126336. /**
  126337. * Specifies whether or not to create a skybox.
  126338. * True by default.
  126339. */
  126340. createSkybox: boolean;
  126341. /**
  126342. * Specifies the skybox size.
  126343. * 20 by default.
  126344. */
  126345. skyboxSize: number;
  126346. /**
  126347. * The texture used on the skybox for the main color.
  126348. * Comes from the BabylonJS CDN by default.
  126349. *
  126350. * Remarks: Can be either a texture or a url.
  126351. */
  126352. skyboxTexture: string | BaseTexture;
  126353. /**
  126354. * The color mixed in the skybox texture by default.
  126355. * BabylonJS clearColor by default.
  126356. */
  126357. skyboxColor: Color3;
  126358. /**
  126359. * The background rotation around the Y axis of the scene.
  126360. * This helps aligning the key lights of your scene with the background.
  126361. * 0 by default.
  126362. */
  126363. backgroundYRotation: number;
  126364. /**
  126365. * Compute automatically the size of the elements to best fit with the scene.
  126366. */
  126367. sizeAuto: boolean;
  126368. /**
  126369. * Default position of the rootMesh if autoSize is not true.
  126370. */
  126371. rootPosition: Vector3;
  126372. /**
  126373. * Sets up the image processing in the scene.
  126374. * true by default.
  126375. */
  126376. setupImageProcessing: boolean;
  126377. /**
  126378. * The texture used as your environment texture in the scene.
  126379. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  126380. *
  126381. * Remarks: Can be either a texture or a url.
  126382. */
  126383. environmentTexture: string | BaseTexture;
  126384. /**
  126385. * The value of the exposure to apply to the scene.
  126386. * 0.6 by default if setupImageProcessing is true.
  126387. */
  126388. cameraExposure: number;
  126389. /**
  126390. * The value of the contrast to apply to the scene.
  126391. * 1.6 by default if setupImageProcessing is true.
  126392. */
  126393. cameraContrast: number;
  126394. /**
  126395. * Specifies whether or not tonemapping should be enabled in the scene.
  126396. * true by default if setupImageProcessing is true.
  126397. */
  126398. toneMappingEnabled: boolean;
  126399. }
  126400. /**
  126401. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  126402. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  126403. * It also helps with the default setup of your imageProcessing configuration.
  126404. */
  126405. export class EnvironmentHelper {
  126406. /**
  126407. * Default ground texture URL.
  126408. */
  126409. private static _groundTextureCDNUrl;
  126410. /**
  126411. * Default skybox texture URL.
  126412. */
  126413. private static _skyboxTextureCDNUrl;
  126414. /**
  126415. * Default environment texture URL.
  126416. */
  126417. private static _environmentTextureCDNUrl;
  126418. /**
  126419. * Creates the default options for the helper.
  126420. */
  126421. private static _getDefaultOptions;
  126422. private _rootMesh;
  126423. /**
  126424. * Gets the root mesh created by the helper.
  126425. */
  126426. get rootMesh(): Mesh;
  126427. private _skybox;
  126428. /**
  126429. * Gets the skybox created by the helper.
  126430. */
  126431. get skybox(): Nullable<Mesh>;
  126432. private _skyboxTexture;
  126433. /**
  126434. * Gets the skybox texture created by the helper.
  126435. */
  126436. get skyboxTexture(): Nullable<BaseTexture>;
  126437. private _skyboxMaterial;
  126438. /**
  126439. * Gets the skybox material created by the helper.
  126440. */
  126441. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  126442. private _ground;
  126443. /**
  126444. * Gets the ground mesh created by the helper.
  126445. */
  126446. get ground(): Nullable<Mesh>;
  126447. private _groundTexture;
  126448. /**
  126449. * Gets the ground texture created by the helper.
  126450. */
  126451. get groundTexture(): Nullable<BaseTexture>;
  126452. private _groundMirror;
  126453. /**
  126454. * Gets the ground mirror created by the helper.
  126455. */
  126456. get groundMirror(): Nullable<MirrorTexture>;
  126457. /**
  126458. * Gets the ground mirror render list to helps pushing the meshes
  126459. * you wish in the ground reflection.
  126460. */
  126461. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  126462. private _groundMaterial;
  126463. /**
  126464. * Gets the ground material created by the helper.
  126465. */
  126466. get groundMaterial(): Nullable<BackgroundMaterial>;
  126467. /**
  126468. * Stores the creation options.
  126469. */
  126470. private readonly _scene;
  126471. private _options;
  126472. /**
  126473. * This observable will be notified with any error during the creation of the environment,
  126474. * mainly texture creation errors.
  126475. */
  126476. onErrorObservable: Observable<{
  126477. message?: string;
  126478. exception?: any;
  126479. }>;
  126480. /**
  126481. * constructor
  126482. * @param options Defines the options we want to customize the helper
  126483. * @param scene The scene to add the material to
  126484. */
  126485. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  126486. /**
  126487. * Updates the background according to the new options
  126488. * @param options
  126489. */
  126490. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  126491. /**
  126492. * Sets the primary color of all the available elements.
  126493. * @param color the main color to affect to the ground and the background
  126494. */
  126495. setMainColor(color: Color3): void;
  126496. /**
  126497. * Setup the image processing according to the specified options.
  126498. */
  126499. private _setupImageProcessing;
  126500. /**
  126501. * Setup the environment texture according to the specified options.
  126502. */
  126503. private _setupEnvironmentTexture;
  126504. /**
  126505. * Setup the background according to the specified options.
  126506. */
  126507. private _setupBackground;
  126508. /**
  126509. * Get the scene sizes according to the setup.
  126510. */
  126511. private _getSceneSize;
  126512. /**
  126513. * Setup the ground according to the specified options.
  126514. */
  126515. private _setupGround;
  126516. /**
  126517. * Setup the ground material according to the specified options.
  126518. */
  126519. private _setupGroundMaterial;
  126520. /**
  126521. * Setup the ground diffuse texture according to the specified options.
  126522. */
  126523. private _setupGroundDiffuseTexture;
  126524. /**
  126525. * Setup the ground mirror texture according to the specified options.
  126526. */
  126527. private _setupGroundMirrorTexture;
  126528. /**
  126529. * Setup the ground to receive the mirror texture.
  126530. */
  126531. private _setupMirrorInGroundMaterial;
  126532. /**
  126533. * Setup the skybox according to the specified options.
  126534. */
  126535. private _setupSkybox;
  126536. /**
  126537. * Setup the skybox material according to the specified options.
  126538. */
  126539. private _setupSkyboxMaterial;
  126540. /**
  126541. * Setup the skybox reflection texture according to the specified options.
  126542. */
  126543. private _setupSkyboxReflectionTexture;
  126544. private _errorHandler;
  126545. /**
  126546. * Dispose all the elements created by the Helper.
  126547. */
  126548. dispose(): void;
  126549. }
  126550. }
  126551. declare module BABYLON {
  126552. /**
  126553. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  126554. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  126555. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  126556. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126557. */
  126558. export class PhotoDome extends TransformNode {
  126559. /**
  126560. * Define the image as a Monoscopic panoramic 360 image.
  126561. */
  126562. static readonly MODE_MONOSCOPIC: number;
  126563. /**
  126564. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126565. */
  126566. static readonly MODE_TOPBOTTOM: number;
  126567. /**
  126568. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126569. */
  126570. static readonly MODE_SIDEBYSIDE: number;
  126571. private _useDirectMapping;
  126572. /**
  126573. * The texture being displayed on the sphere
  126574. */
  126575. protected _photoTexture: Texture;
  126576. /**
  126577. * Gets or sets the texture being displayed on the sphere
  126578. */
  126579. get photoTexture(): Texture;
  126580. set photoTexture(value: Texture);
  126581. /**
  126582. * Observable raised when an error occured while loading the 360 image
  126583. */
  126584. onLoadErrorObservable: Observable<string>;
  126585. /**
  126586. * The skybox material
  126587. */
  126588. protected _material: BackgroundMaterial;
  126589. /**
  126590. * The surface used for the skybox
  126591. */
  126592. protected _mesh: Mesh;
  126593. /**
  126594. * Gets the mesh used for the skybox.
  126595. */
  126596. get mesh(): Mesh;
  126597. /**
  126598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126599. * Also see the options.resolution property.
  126600. */
  126601. get fovMultiplier(): number;
  126602. set fovMultiplier(value: number);
  126603. private _imageMode;
  126604. /**
  126605. * Gets or set the current video mode for the video. It can be:
  126606. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  126607. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126608. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126609. */
  126610. get imageMode(): number;
  126611. set imageMode(value: number);
  126612. /**
  126613. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  126614. * @param name Element's name, child elements will append suffixes for their own names.
  126615. * @param urlsOfPhoto defines the url of the photo to display
  126616. * @param options defines an object containing optional or exposed sub element properties
  126617. * @param onError defines a callback called when an error occured while loading the texture
  126618. */
  126619. constructor(name: string, urlOfPhoto: string, options: {
  126620. resolution?: number;
  126621. size?: number;
  126622. useDirectMapping?: boolean;
  126623. faceForward?: boolean;
  126624. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  126625. private _onBeforeCameraRenderObserver;
  126626. private _changeImageMode;
  126627. /**
  126628. * Releases resources associated with this node.
  126629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126631. */
  126632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126633. }
  126634. }
  126635. declare module BABYLON {
  126636. /**
  126637. * Class used to host RGBD texture specific utilities
  126638. */
  126639. export class RGBDTextureTools {
  126640. /**
  126641. * Expand the RGBD Texture from RGBD to Half Float if possible.
  126642. * @param texture the texture to expand.
  126643. */
  126644. static ExpandRGBDTexture(texture: Texture): void;
  126645. }
  126646. }
  126647. declare module BABYLON {
  126648. /**
  126649. * Class used to host texture specific utilities
  126650. */
  126651. export class BRDFTextureTools {
  126652. /**
  126653. * Prevents texture cache collision
  126654. */
  126655. private static _instanceNumber;
  126656. /**
  126657. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  126658. * @param scene defines the hosting scene
  126659. * @returns the environment BRDF texture
  126660. */
  126661. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  126662. private static _environmentBRDFBase64Texture;
  126663. }
  126664. }
  126665. declare module BABYLON {
  126666. /**
  126667. * @hidden
  126668. */
  126669. export interface IMaterialClearCoatDefines {
  126670. CLEARCOAT: boolean;
  126671. CLEARCOAT_DEFAULTIOR: boolean;
  126672. CLEARCOAT_TEXTURE: boolean;
  126673. CLEARCOAT_TEXTUREDIRECTUV: number;
  126674. CLEARCOAT_BUMP: boolean;
  126675. CLEARCOAT_BUMPDIRECTUV: number;
  126676. CLEARCOAT_TINT: boolean;
  126677. CLEARCOAT_TINT_TEXTURE: boolean;
  126678. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  126679. /** @hidden */
  126680. _areTexturesDirty: boolean;
  126681. }
  126682. /**
  126683. * Define the code related to the clear coat parameters of the pbr material.
  126684. */
  126685. export class PBRClearCoatConfiguration {
  126686. /**
  126687. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126688. * The default fits with a polyurethane material.
  126689. */
  126690. private static readonly _DefaultIndexOfRefraction;
  126691. private _isEnabled;
  126692. /**
  126693. * Defines if the clear coat is enabled in the material.
  126694. */
  126695. isEnabled: boolean;
  126696. /**
  126697. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  126698. */
  126699. intensity: number;
  126700. /**
  126701. * Defines the clear coat layer roughness.
  126702. */
  126703. roughness: number;
  126704. private _indexOfRefraction;
  126705. /**
  126706. * Defines the index of refraction of the clear coat.
  126707. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126708. * The default fits with a polyurethane material.
  126709. * Changing the default value is more performance intensive.
  126710. */
  126711. indexOfRefraction: number;
  126712. private _texture;
  126713. /**
  126714. * Stores the clear coat values in a texture.
  126715. */
  126716. texture: Nullable<BaseTexture>;
  126717. private _bumpTexture;
  126718. /**
  126719. * Define the clear coat specific bump texture.
  126720. */
  126721. bumpTexture: Nullable<BaseTexture>;
  126722. private _isTintEnabled;
  126723. /**
  126724. * Defines if the clear coat tint is enabled in the material.
  126725. */
  126726. isTintEnabled: boolean;
  126727. /**
  126728. * Defines the clear coat tint of the material.
  126729. * This is only use if tint is enabled
  126730. */
  126731. tintColor: Color3;
  126732. /**
  126733. * Defines the distance at which the tint color should be found in the
  126734. * clear coat media.
  126735. * This is only use if tint is enabled
  126736. */
  126737. tintColorAtDistance: number;
  126738. /**
  126739. * Defines the clear coat layer thickness.
  126740. * This is only use if tint is enabled
  126741. */
  126742. tintThickness: number;
  126743. private _tintTexture;
  126744. /**
  126745. * Stores the clear tint values in a texture.
  126746. * rgb is tint
  126747. * a is a thickness factor
  126748. */
  126749. tintTexture: Nullable<BaseTexture>;
  126750. /** @hidden */
  126751. private _internalMarkAllSubMeshesAsTexturesDirty;
  126752. /** @hidden */
  126753. _markAllSubMeshesAsTexturesDirty(): void;
  126754. /**
  126755. * Instantiate a new istance of clear coat configuration.
  126756. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126757. */
  126758. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126759. /**
  126760. * Gets wehter the submesh is ready to be used or not.
  126761. * @param defines the list of "defines" to update.
  126762. * @param scene defines the scene the material belongs to.
  126763. * @param engine defines the engine the material belongs to.
  126764. * @param disableBumpMap defines wether the material disables bump or not.
  126765. * @returns - boolean indicating that the submesh is ready or not.
  126766. */
  126767. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  126768. /**
  126769. * Checks to see if a texture is used in the material.
  126770. * @param defines the list of "defines" to update.
  126771. * @param scene defines the scene to the material belongs to.
  126772. */
  126773. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  126774. /**
  126775. * Binds the material data.
  126776. * @param uniformBuffer defines the Uniform buffer to fill in.
  126777. * @param scene defines the scene the material belongs to.
  126778. * @param engine defines the engine the material belongs to.
  126779. * @param disableBumpMap defines wether the material disables bump or not.
  126780. * @param isFrozen defines wether the material is frozen or not.
  126781. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126782. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126783. */
  126784. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  126785. /**
  126786. * Checks to see if a texture is used in the material.
  126787. * @param texture - Base texture to use.
  126788. * @returns - Boolean specifying if a texture is used in the material.
  126789. */
  126790. hasTexture(texture: BaseTexture): boolean;
  126791. /**
  126792. * Returns an array of the actively used textures.
  126793. * @param activeTextures Array of BaseTextures
  126794. */
  126795. getActiveTextures(activeTextures: BaseTexture[]): void;
  126796. /**
  126797. * Returns the animatable textures.
  126798. * @param animatables Array of animatable textures.
  126799. */
  126800. getAnimatables(animatables: IAnimatable[]): void;
  126801. /**
  126802. * Disposes the resources of the material.
  126803. * @param forceDisposeTextures - Forces the disposal of all textures.
  126804. */
  126805. dispose(forceDisposeTextures?: boolean): void;
  126806. /**
  126807. * Get the current class name of the texture useful for serialization or dynamic coding.
  126808. * @returns "PBRClearCoatConfiguration"
  126809. */
  126810. getClassName(): string;
  126811. /**
  126812. * Add fallbacks to the effect fallbacks list.
  126813. * @param defines defines the Base texture to use.
  126814. * @param fallbacks defines the current fallback list.
  126815. * @param currentRank defines the current fallback rank.
  126816. * @returns the new fallback rank.
  126817. */
  126818. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126819. /**
  126820. * Add the required uniforms to the current list.
  126821. * @param uniforms defines the current uniform list.
  126822. */
  126823. static AddUniforms(uniforms: string[]): void;
  126824. /**
  126825. * Add the required samplers to the current list.
  126826. * @param samplers defines the current sampler list.
  126827. */
  126828. static AddSamplers(samplers: string[]): void;
  126829. /**
  126830. * Add the required uniforms to the current buffer.
  126831. * @param uniformBuffer defines the current uniform buffer.
  126832. */
  126833. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126834. /**
  126835. * Makes a duplicate of the current configuration into another one.
  126836. * @param clearCoatConfiguration define the config where to copy the info
  126837. */
  126838. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  126839. /**
  126840. * Serializes this clear coat configuration.
  126841. * @returns - An object with the serialized config.
  126842. */
  126843. serialize(): any;
  126844. /**
  126845. * Parses a anisotropy Configuration from a serialized object.
  126846. * @param source - Serialized object.
  126847. * @param scene Defines the scene we are parsing for
  126848. * @param rootUrl Defines the rootUrl to load from
  126849. */
  126850. parse(source: any, scene: Scene, rootUrl: string): void;
  126851. }
  126852. }
  126853. declare module BABYLON {
  126854. /**
  126855. * @hidden
  126856. */
  126857. export interface IMaterialAnisotropicDefines {
  126858. ANISOTROPIC: boolean;
  126859. ANISOTROPIC_TEXTURE: boolean;
  126860. ANISOTROPIC_TEXTUREDIRECTUV: number;
  126861. MAINUV1: boolean;
  126862. _areTexturesDirty: boolean;
  126863. _needUVs: boolean;
  126864. }
  126865. /**
  126866. * Define the code related to the anisotropic parameters of the pbr material.
  126867. */
  126868. export class PBRAnisotropicConfiguration {
  126869. private _isEnabled;
  126870. /**
  126871. * Defines if the anisotropy is enabled in the material.
  126872. */
  126873. isEnabled: boolean;
  126874. /**
  126875. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  126876. */
  126877. intensity: number;
  126878. /**
  126879. * Defines if the effect is along the tangents, bitangents or in between.
  126880. * By default, the effect is "strectching" the highlights along the tangents.
  126881. */
  126882. direction: Vector2;
  126883. private _texture;
  126884. /**
  126885. * Stores the anisotropy values in a texture.
  126886. * rg is direction (like normal from -1 to 1)
  126887. * b is a intensity
  126888. */
  126889. texture: Nullable<BaseTexture>;
  126890. /** @hidden */
  126891. private _internalMarkAllSubMeshesAsTexturesDirty;
  126892. /** @hidden */
  126893. _markAllSubMeshesAsTexturesDirty(): void;
  126894. /**
  126895. * Instantiate a new istance of anisotropy configuration.
  126896. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126897. */
  126898. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126899. /**
  126900. * Specifies that the submesh is ready to be used.
  126901. * @param defines the list of "defines" to update.
  126902. * @param scene defines the scene the material belongs to.
  126903. * @returns - boolean indicating that the submesh is ready or not.
  126904. */
  126905. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  126906. /**
  126907. * Checks to see if a texture is used in the material.
  126908. * @param defines the list of "defines" to update.
  126909. * @param mesh the mesh we are preparing the defines for.
  126910. * @param scene defines the scene the material belongs to.
  126911. */
  126912. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  126913. /**
  126914. * Binds the material data.
  126915. * @param uniformBuffer defines the Uniform buffer to fill in.
  126916. * @param scene defines the scene the material belongs to.
  126917. * @param isFrozen defines wether the material is frozen or not.
  126918. */
  126919. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126920. /**
  126921. * Checks to see if a texture is used in the material.
  126922. * @param texture - Base texture to use.
  126923. * @returns - Boolean specifying if a texture is used in the material.
  126924. */
  126925. hasTexture(texture: BaseTexture): boolean;
  126926. /**
  126927. * Returns an array of the actively used textures.
  126928. * @param activeTextures Array of BaseTextures
  126929. */
  126930. getActiveTextures(activeTextures: BaseTexture[]): void;
  126931. /**
  126932. * Returns the animatable textures.
  126933. * @param animatables Array of animatable textures.
  126934. */
  126935. getAnimatables(animatables: IAnimatable[]): void;
  126936. /**
  126937. * Disposes the resources of the material.
  126938. * @param forceDisposeTextures - Forces the disposal of all textures.
  126939. */
  126940. dispose(forceDisposeTextures?: boolean): void;
  126941. /**
  126942. * Get the current class name of the texture useful for serialization or dynamic coding.
  126943. * @returns "PBRAnisotropicConfiguration"
  126944. */
  126945. getClassName(): string;
  126946. /**
  126947. * Add fallbacks to the effect fallbacks list.
  126948. * @param defines defines the Base texture to use.
  126949. * @param fallbacks defines the current fallback list.
  126950. * @param currentRank defines the current fallback rank.
  126951. * @returns the new fallback rank.
  126952. */
  126953. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126954. /**
  126955. * Add the required uniforms to the current list.
  126956. * @param uniforms defines the current uniform list.
  126957. */
  126958. static AddUniforms(uniforms: string[]): void;
  126959. /**
  126960. * Add the required uniforms to the current buffer.
  126961. * @param uniformBuffer defines the current uniform buffer.
  126962. */
  126963. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126964. /**
  126965. * Add the required samplers to the current list.
  126966. * @param samplers defines the current sampler list.
  126967. */
  126968. static AddSamplers(samplers: string[]): void;
  126969. /**
  126970. * Makes a duplicate of the current configuration into another one.
  126971. * @param anisotropicConfiguration define the config where to copy the info
  126972. */
  126973. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  126974. /**
  126975. * Serializes this anisotropy configuration.
  126976. * @returns - An object with the serialized config.
  126977. */
  126978. serialize(): any;
  126979. /**
  126980. * Parses a anisotropy Configuration from a serialized object.
  126981. * @param source - Serialized object.
  126982. * @param scene Defines the scene we are parsing for
  126983. * @param rootUrl Defines the rootUrl to load from
  126984. */
  126985. parse(source: any, scene: Scene, rootUrl: string): void;
  126986. }
  126987. }
  126988. declare module BABYLON {
  126989. /**
  126990. * @hidden
  126991. */
  126992. export interface IMaterialBRDFDefines {
  126993. BRDF_V_HEIGHT_CORRELATED: boolean;
  126994. MS_BRDF_ENERGY_CONSERVATION: boolean;
  126995. SPHERICAL_HARMONICS: boolean;
  126996. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  126997. /** @hidden */
  126998. _areMiscDirty: boolean;
  126999. }
  127000. /**
  127001. * Define the code related to the BRDF parameters of the pbr material.
  127002. */
  127003. export class PBRBRDFConfiguration {
  127004. /**
  127005. * Default value used for the energy conservation.
  127006. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  127007. */
  127008. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  127009. /**
  127010. * Default value used for the Smith Visibility Height Correlated mode.
  127011. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  127012. */
  127013. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  127014. /**
  127015. * Default value used for the IBL diffuse part.
  127016. * This can help switching back to the polynomials mode globally which is a tiny bit
  127017. * less GPU intensive at the drawback of a lower quality.
  127018. */
  127019. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  127020. /**
  127021. * Default value used for activating energy conservation for the specular workflow.
  127022. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  127023. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  127024. */
  127025. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  127026. private _useEnergyConservation;
  127027. /**
  127028. * Defines if the material uses energy conservation.
  127029. */
  127030. useEnergyConservation: boolean;
  127031. private _useSmithVisibilityHeightCorrelated;
  127032. /**
  127033. * LEGACY Mode set to false
  127034. * Defines if the material uses height smith correlated visibility term.
  127035. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  127036. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  127037. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  127038. * Not relying on height correlated will also disable energy conservation.
  127039. */
  127040. useSmithVisibilityHeightCorrelated: boolean;
  127041. private _useSphericalHarmonics;
  127042. /**
  127043. * LEGACY Mode set to false
  127044. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  127045. * diffuse part of the IBL.
  127046. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  127047. * to the ground truth.
  127048. */
  127049. useSphericalHarmonics: boolean;
  127050. private _useSpecularGlossinessInputEnergyConservation;
  127051. /**
  127052. * Defines if the material uses energy conservation, when the specular workflow is active.
  127053. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  127054. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  127055. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  127056. */
  127057. useSpecularGlossinessInputEnergyConservation: boolean;
  127058. /** @hidden */
  127059. private _internalMarkAllSubMeshesAsMiscDirty;
  127060. /** @hidden */
  127061. _markAllSubMeshesAsMiscDirty(): void;
  127062. /**
  127063. * Instantiate a new istance of clear coat configuration.
  127064. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  127065. */
  127066. constructor(markAllSubMeshesAsMiscDirty: () => void);
  127067. /**
  127068. * Checks to see if a texture is used in the material.
  127069. * @param defines the list of "defines" to update.
  127070. */
  127071. prepareDefines(defines: IMaterialBRDFDefines): void;
  127072. /**
  127073. * Get the current class name of the texture useful for serialization or dynamic coding.
  127074. * @returns "PBRClearCoatConfiguration"
  127075. */
  127076. getClassName(): string;
  127077. /**
  127078. * Makes a duplicate of the current configuration into another one.
  127079. * @param brdfConfiguration define the config where to copy the info
  127080. */
  127081. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  127082. /**
  127083. * Serializes this BRDF configuration.
  127084. * @returns - An object with the serialized config.
  127085. */
  127086. serialize(): any;
  127087. /**
  127088. * Parses a anisotropy Configuration from a serialized object.
  127089. * @param source - Serialized object.
  127090. * @param scene Defines the scene we are parsing for
  127091. * @param rootUrl Defines the rootUrl to load from
  127092. */
  127093. parse(source: any, scene: Scene, rootUrl: string): void;
  127094. }
  127095. }
  127096. declare module BABYLON {
  127097. /**
  127098. * @hidden
  127099. */
  127100. export interface IMaterialSheenDefines {
  127101. SHEEN: boolean;
  127102. SHEEN_TEXTURE: boolean;
  127103. SHEEN_TEXTUREDIRECTUV: number;
  127104. SHEEN_LINKWITHALBEDO: boolean;
  127105. SHEEN_ROUGHNESS: boolean;
  127106. SHEEN_ALBEDOSCALING: boolean;
  127107. /** @hidden */
  127108. _areTexturesDirty: boolean;
  127109. }
  127110. /**
  127111. * Define the code related to the Sheen parameters of the pbr material.
  127112. */
  127113. export class PBRSheenConfiguration {
  127114. private _isEnabled;
  127115. /**
  127116. * Defines if the material uses sheen.
  127117. */
  127118. isEnabled: boolean;
  127119. private _linkSheenWithAlbedo;
  127120. /**
  127121. * Defines if the sheen is linked to the sheen color.
  127122. */
  127123. linkSheenWithAlbedo: boolean;
  127124. /**
  127125. * Defines the sheen intensity.
  127126. */
  127127. intensity: number;
  127128. /**
  127129. * Defines the sheen color.
  127130. */
  127131. color: Color3;
  127132. private _texture;
  127133. /**
  127134. * Stores the sheen tint values in a texture.
  127135. * rgb is tint
  127136. * a is a intensity
  127137. */
  127138. texture: Nullable<BaseTexture>;
  127139. private _roughness;
  127140. /**
  127141. * Defines the sheen roughness.
  127142. * It is not taken into account if linkSheenWithAlbedo is true.
  127143. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  127144. */
  127145. roughness: Nullable<number>;
  127146. private _albedoScaling;
  127147. /**
  127148. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  127149. * It allows the strength of the sheen effect to not depend on the base color of the material,
  127150. * making it easier to setup and tweak the effect
  127151. */
  127152. albedoScaling: boolean;
  127153. /** @hidden */
  127154. private _internalMarkAllSubMeshesAsTexturesDirty;
  127155. /** @hidden */
  127156. _markAllSubMeshesAsTexturesDirty(): void;
  127157. /**
  127158. * Instantiate a new istance of clear coat configuration.
  127159. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127160. */
  127161. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127162. /**
  127163. * Specifies that the submesh is ready to be used.
  127164. * @param defines the list of "defines" to update.
  127165. * @param scene defines the scene the material belongs to.
  127166. * @returns - boolean indicating that the submesh is ready or not.
  127167. */
  127168. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  127169. /**
  127170. * Checks to see if a texture is used in the material.
  127171. * @param defines the list of "defines" to update.
  127172. * @param scene defines the scene the material belongs to.
  127173. */
  127174. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  127175. /**
  127176. * Binds the material data.
  127177. * @param uniformBuffer defines the Uniform buffer to fill in.
  127178. * @param scene defines the scene the material belongs to.
  127179. * @param isFrozen defines wether the material is frozen or not.
  127180. */
  127181. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  127182. /**
  127183. * Checks to see if a texture is used in the material.
  127184. * @param texture - Base texture to use.
  127185. * @returns - Boolean specifying if a texture is used in the material.
  127186. */
  127187. hasTexture(texture: BaseTexture): boolean;
  127188. /**
  127189. * Returns an array of the actively used textures.
  127190. * @param activeTextures Array of BaseTextures
  127191. */
  127192. getActiveTextures(activeTextures: BaseTexture[]): void;
  127193. /**
  127194. * Returns the animatable textures.
  127195. * @param animatables Array of animatable textures.
  127196. */
  127197. getAnimatables(animatables: IAnimatable[]): void;
  127198. /**
  127199. * Disposes the resources of the material.
  127200. * @param forceDisposeTextures - Forces the disposal of all textures.
  127201. */
  127202. dispose(forceDisposeTextures?: boolean): void;
  127203. /**
  127204. * Get the current class name of the texture useful for serialization or dynamic coding.
  127205. * @returns "PBRSheenConfiguration"
  127206. */
  127207. getClassName(): string;
  127208. /**
  127209. * Add fallbacks to the effect fallbacks list.
  127210. * @param defines defines the Base texture to use.
  127211. * @param fallbacks defines the current fallback list.
  127212. * @param currentRank defines the current fallback rank.
  127213. * @returns the new fallback rank.
  127214. */
  127215. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127216. /**
  127217. * Add the required uniforms to the current list.
  127218. * @param uniforms defines the current uniform list.
  127219. */
  127220. static AddUniforms(uniforms: string[]): void;
  127221. /**
  127222. * Add the required uniforms to the current buffer.
  127223. * @param uniformBuffer defines the current uniform buffer.
  127224. */
  127225. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127226. /**
  127227. * Add the required samplers to the current list.
  127228. * @param samplers defines the current sampler list.
  127229. */
  127230. static AddSamplers(samplers: string[]): void;
  127231. /**
  127232. * Makes a duplicate of the current configuration into another one.
  127233. * @param sheenConfiguration define the config where to copy the info
  127234. */
  127235. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  127236. /**
  127237. * Serializes this BRDF configuration.
  127238. * @returns - An object with the serialized config.
  127239. */
  127240. serialize(): any;
  127241. /**
  127242. * Parses a anisotropy Configuration from a serialized object.
  127243. * @param source - Serialized object.
  127244. * @param scene Defines the scene we are parsing for
  127245. * @param rootUrl Defines the rootUrl to load from
  127246. */
  127247. parse(source: any, scene: Scene, rootUrl: string): void;
  127248. }
  127249. }
  127250. declare module BABYLON {
  127251. /**
  127252. * @hidden
  127253. */
  127254. export interface IMaterialSubSurfaceDefines {
  127255. SUBSURFACE: boolean;
  127256. SS_REFRACTION: boolean;
  127257. SS_TRANSLUCENCY: boolean;
  127258. SS_SCATERRING: boolean;
  127259. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127260. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127261. SS_REFRACTIONMAP_3D: boolean;
  127262. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127263. SS_LODINREFRACTIONALPHA: boolean;
  127264. SS_GAMMAREFRACTION: boolean;
  127265. SS_RGBDREFRACTION: boolean;
  127266. SS_LINEARSPECULARREFRACTION: boolean;
  127267. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127268. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127269. /** @hidden */
  127270. _areTexturesDirty: boolean;
  127271. }
  127272. /**
  127273. * Define the code related to the sub surface parameters of the pbr material.
  127274. */
  127275. export class PBRSubSurfaceConfiguration {
  127276. private _isRefractionEnabled;
  127277. /**
  127278. * Defines if the refraction is enabled in the material.
  127279. */
  127280. isRefractionEnabled: boolean;
  127281. private _isTranslucencyEnabled;
  127282. /**
  127283. * Defines if the translucency is enabled in the material.
  127284. */
  127285. isTranslucencyEnabled: boolean;
  127286. private _isScatteringEnabled;
  127287. /**
  127288. * Defines the refraction intensity of the material.
  127289. * The refraction when enabled replaces the Diffuse part of the material.
  127290. * The intensity helps transitionning between diffuse and refraction.
  127291. */
  127292. refractionIntensity: number;
  127293. /**
  127294. * Defines the translucency intensity of the material.
  127295. * When translucency has been enabled, this defines how much of the "translucency"
  127296. * is addded to the diffuse part of the material.
  127297. */
  127298. translucencyIntensity: number;
  127299. /**
  127300. * Defines the scattering intensity of the material.
  127301. * When scattering has been enabled, this defines how much of the "scattered light"
  127302. * is addded to the diffuse part of the material.
  127303. */
  127304. scatteringIntensity: number;
  127305. private _thicknessTexture;
  127306. /**
  127307. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  127308. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  127309. * 0 would mean minimumThickness
  127310. * 1 would mean maximumThickness
  127311. * The other channels might be use as a mask to vary the different effects intensity.
  127312. */
  127313. thicknessTexture: Nullable<BaseTexture>;
  127314. private _refractionTexture;
  127315. /**
  127316. * Defines the texture to use for refraction.
  127317. */
  127318. refractionTexture: Nullable<BaseTexture>;
  127319. private _indexOfRefraction;
  127320. /**
  127321. * Defines the index of refraction used in the material.
  127322. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  127323. */
  127324. indexOfRefraction: number;
  127325. private _invertRefractionY;
  127326. /**
  127327. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  127328. */
  127329. invertRefractionY: boolean;
  127330. private _linkRefractionWithTransparency;
  127331. /**
  127332. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  127333. * Materials half opaque for instance using refraction could benefit from this control.
  127334. */
  127335. linkRefractionWithTransparency: boolean;
  127336. /**
  127337. * Defines the minimum thickness stored in the thickness map.
  127338. * If no thickness map is defined, this value will be used to simulate thickness.
  127339. */
  127340. minimumThickness: number;
  127341. /**
  127342. * Defines the maximum thickness stored in the thickness map.
  127343. */
  127344. maximumThickness: number;
  127345. /**
  127346. * Defines the volume tint of the material.
  127347. * This is used for both translucency and scattering.
  127348. */
  127349. tintColor: Color3;
  127350. /**
  127351. * Defines the distance at which the tint color should be found in the media.
  127352. * This is used for refraction only.
  127353. */
  127354. tintColorAtDistance: number;
  127355. /**
  127356. * Defines how far each channel transmit through the media.
  127357. * It is defined as a color to simplify it selection.
  127358. */
  127359. diffusionDistance: Color3;
  127360. private _useMaskFromThicknessTexture;
  127361. /**
  127362. * Stores the intensity of the different subsurface effects in the thickness texture.
  127363. * * the green channel is the translucency intensity.
  127364. * * the blue channel is the scattering intensity.
  127365. * * the alpha channel is the refraction intensity.
  127366. */
  127367. useMaskFromThicknessTexture: boolean;
  127368. /** @hidden */
  127369. private _internalMarkAllSubMeshesAsTexturesDirty;
  127370. /** @hidden */
  127371. _markAllSubMeshesAsTexturesDirty(): void;
  127372. /**
  127373. * Instantiate a new istance of sub surface configuration.
  127374. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127375. */
  127376. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127377. /**
  127378. * Gets wehter the submesh is ready to be used or not.
  127379. * @param defines the list of "defines" to update.
  127380. * @param scene defines the scene the material belongs to.
  127381. * @returns - boolean indicating that the submesh is ready or not.
  127382. */
  127383. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  127384. /**
  127385. * Checks to see if a texture is used in the material.
  127386. * @param defines the list of "defines" to update.
  127387. * @param scene defines the scene to the material belongs to.
  127388. */
  127389. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  127390. /**
  127391. * Binds the material data.
  127392. * @param uniformBuffer defines the Uniform buffer to fill in.
  127393. * @param scene defines the scene the material belongs to.
  127394. * @param engine defines the engine the material belongs to.
  127395. * @param isFrozen defines wether the material is frozen or not.
  127396. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  127397. */
  127398. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  127399. /**
  127400. * Unbinds the material from the mesh.
  127401. * @param activeEffect defines the effect that should be unbound from.
  127402. * @returns true if unbound, otherwise false
  127403. */
  127404. unbind(activeEffect: Effect): boolean;
  127405. /**
  127406. * Returns the texture used for refraction or null if none is used.
  127407. * @param scene defines the scene the material belongs to.
  127408. * @returns - Refraction texture if present. If no refraction texture and refraction
  127409. * is linked with transparency, returns environment texture. Otherwise, returns null.
  127410. */
  127411. private _getRefractionTexture;
  127412. /**
  127413. * Returns true if alpha blending should be disabled.
  127414. */
  127415. get disableAlphaBlending(): boolean;
  127416. /**
  127417. * Fills the list of render target textures.
  127418. * @param renderTargets the list of render targets to update
  127419. */
  127420. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  127421. /**
  127422. * Checks to see if a texture is used in the material.
  127423. * @param texture - Base texture to use.
  127424. * @returns - Boolean specifying if a texture is used in the material.
  127425. */
  127426. hasTexture(texture: BaseTexture): boolean;
  127427. /**
  127428. * Gets a boolean indicating that current material needs to register RTT
  127429. * @returns true if this uses a render target otherwise false.
  127430. */
  127431. hasRenderTargetTextures(): boolean;
  127432. /**
  127433. * Returns an array of the actively used textures.
  127434. * @param activeTextures Array of BaseTextures
  127435. */
  127436. getActiveTextures(activeTextures: BaseTexture[]): void;
  127437. /**
  127438. * Returns the animatable textures.
  127439. * @param animatables Array of animatable textures.
  127440. */
  127441. getAnimatables(animatables: IAnimatable[]): void;
  127442. /**
  127443. * Disposes the resources of the material.
  127444. * @param forceDisposeTextures - Forces the disposal of all textures.
  127445. */
  127446. dispose(forceDisposeTextures?: boolean): void;
  127447. /**
  127448. * Get the current class name of the texture useful for serialization or dynamic coding.
  127449. * @returns "PBRSubSurfaceConfiguration"
  127450. */
  127451. getClassName(): string;
  127452. /**
  127453. * Add fallbacks to the effect fallbacks list.
  127454. * @param defines defines the Base texture to use.
  127455. * @param fallbacks defines the current fallback list.
  127456. * @param currentRank defines the current fallback rank.
  127457. * @returns the new fallback rank.
  127458. */
  127459. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127460. /**
  127461. * Add the required uniforms to the current list.
  127462. * @param uniforms defines the current uniform list.
  127463. */
  127464. static AddUniforms(uniforms: string[]): void;
  127465. /**
  127466. * Add the required samplers to the current list.
  127467. * @param samplers defines the current sampler list.
  127468. */
  127469. static AddSamplers(samplers: string[]): void;
  127470. /**
  127471. * Add the required uniforms to the current buffer.
  127472. * @param uniformBuffer defines the current uniform buffer.
  127473. */
  127474. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127475. /**
  127476. * Makes a duplicate of the current configuration into another one.
  127477. * @param configuration define the config where to copy the info
  127478. */
  127479. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  127480. /**
  127481. * Serializes this Sub Surface configuration.
  127482. * @returns - An object with the serialized config.
  127483. */
  127484. serialize(): any;
  127485. /**
  127486. * Parses a anisotropy Configuration from a serialized object.
  127487. * @param source - Serialized object.
  127488. * @param scene Defines the scene we are parsing for
  127489. * @param rootUrl Defines the rootUrl to load from
  127490. */
  127491. parse(source: any, scene: Scene, rootUrl: string): void;
  127492. }
  127493. }
  127494. declare module BABYLON {
  127495. /** @hidden */
  127496. export var pbrFragmentDeclaration: {
  127497. name: string;
  127498. shader: string;
  127499. };
  127500. }
  127501. declare module BABYLON {
  127502. /** @hidden */
  127503. export var pbrUboDeclaration: {
  127504. name: string;
  127505. shader: string;
  127506. };
  127507. }
  127508. declare module BABYLON {
  127509. /** @hidden */
  127510. export var pbrFragmentExtraDeclaration: {
  127511. name: string;
  127512. shader: string;
  127513. };
  127514. }
  127515. declare module BABYLON {
  127516. /** @hidden */
  127517. export var pbrFragmentSamplersDeclaration: {
  127518. name: string;
  127519. shader: string;
  127520. };
  127521. }
  127522. declare module BABYLON {
  127523. /** @hidden */
  127524. export var pbrHelperFunctions: {
  127525. name: string;
  127526. shader: string;
  127527. };
  127528. }
  127529. declare module BABYLON {
  127530. /** @hidden */
  127531. export var harmonicsFunctions: {
  127532. name: string;
  127533. shader: string;
  127534. };
  127535. }
  127536. declare module BABYLON {
  127537. /** @hidden */
  127538. export var pbrDirectLightingSetupFunctions: {
  127539. name: string;
  127540. shader: string;
  127541. };
  127542. }
  127543. declare module BABYLON {
  127544. /** @hidden */
  127545. export var pbrDirectLightingFalloffFunctions: {
  127546. name: string;
  127547. shader: string;
  127548. };
  127549. }
  127550. declare module BABYLON {
  127551. /** @hidden */
  127552. export var pbrBRDFFunctions: {
  127553. name: string;
  127554. shader: string;
  127555. };
  127556. }
  127557. declare module BABYLON {
  127558. /** @hidden */
  127559. export var pbrDirectLightingFunctions: {
  127560. name: string;
  127561. shader: string;
  127562. };
  127563. }
  127564. declare module BABYLON {
  127565. /** @hidden */
  127566. export var pbrIBLFunctions: {
  127567. name: string;
  127568. shader: string;
  127569. };
  127570. }
  127571. declare module BABYLON {
  127572. /** @hidden */
  127573. export var pbrBlockAlbedoOpacity: {
  127574. name: string;
  127575. shader: string;
  127576. };
  127577. }
  127578. declare module BABYLON {
  127579. /** @hidden */
  127580. export var pbrBlockReflectivity: {
  127581. name: string;
  127582. shader: string;
  127583. };
  127584. }
  127585. declare module BABYLON {
  127586. /** @hidden */
  127587. export var pbrBlockAmbientOcclusion: {
  127588. name: string;
  127589. shader: string;
  127590. };
  127591. }
  127592. declare module BABYLON {
  127593. /** @hidden */
  127594. export var pbrBlockAlphaFresnel: {
  127595. name: string;
  127596. shader: string;
  127597. };
  127598. }
  127599. declare module BABYLON {
  127600. /** @hidden */
  127601. export var pbrBlockAnisotropic: {
  127602. name: string;
  127603. shader: string;
  127604. };
  127605. }
  127606. declare module BABYLON {
  127607. /** @hidden */
  127608. export var pbrBlockReflection: {
  127609. name: string;
  127610. shader: string;
  127611. };
  127612. }
  127613. declare module BABYLON {
  127614. /** @hidden */
  127615. export var pbrBlockSheen: {
  127616. name: string;
  127617. shader: string;
  127618. };
  127619. }
  127620. declare module BABYLON {
  127621. /** @hidden */
  127622. export var pbrBlockClearcoat: {
  127623. name: string;
  127624. shader: string;
  127625. };
  127626. }
  127627. declare module BABYLON {
  127628. /** @hidden */
  127629. export var pbrBlockSubSurface: {
  127630. name: string;
  127631. shader: string;
  127632. };
  127633. }
  127634. declare module BABYLON {
  127635. /** @hidden */
  127636. export var pbrBlockNormalGeometric: {
  127637. name: string;
  127638. shader: string;
  127639. };
  127640. }
  127641. declare module BABYLON {
  127642. /** @hidden */
  127643. export var pbrBlockNormalFinal: {
  127644. name: string;
  127645. shader: string;
  127646. };
  127647. }
  127648. declare module BABYLON {
  127649. /** @hidden */
  127650. export var pbrBlockGeometryInfo: {
  127651. name: string;
  127652. shader: string;
  127653. };
  127654. }
  127655. declare module BABYLON {
  127656. /** @hidden */
  127657. export var pbrBlockReflectance0: {
  127658. name: string;
  127659. shader: string;
  127660. };
  127661. }
  127662. declare module BABYLON {
  127663. /** @hidden */
  127664. export var pbrBlockReflectance: {
  127665. name: string;
  127666. shader: string;
  127667. };
  127668. }
  127669. declare module BABYLON {
  127670. /** @hidden */
  127671. export var pbrBlockDirectLighting: {
  127672. name: string;
  127673. shader: string;
  127674. };
  127675. }
  127676. declare module BABYLON {
  127677. /** @hidden */
  127678. export var pbrBlockFinalLitComponents: {
  127679. name: string;
  127680. shader: string;
  127681. };
  127682. }
  127683. declare module BABYLON {
  127684. /** @hidden */
  127685. export var pbrBlockFinalUnlitComponents: {
  127686. name: string;
  127687. shader: string;
  127688. };
  127689. }
  127690. declare module BABYLON {
  127691. /** @hidden */
  127692. export var pbrBlockFinalColorComposition: {
  127693. name: string;
  127694. shader: string;
  127695. };
  127696. }
  127697. declare module BABYLON {
  127698. /** @hidden */
  127699. export var pbrBlockImageProcessing: {
  127700. name: string;
  127701. shader: string;
  127702. };
  127703. }
  127704. declare module BABYLON {
  127705. /** @hidden */
  127706. export var pbrDebug: {
  127707. name: string;
  127708. shader: string;
  127709. };
  127710. }
  127711. declare module BABYLON {
  127712. /** @hidden */
  127713. export var pbrPixelShader: {
  127714. name: string;
  127715. shader: string;
  127716. };
  127717. }
  127718. declare module BABYLON {
  127719. /** @hidden */
  127720. export var pbrVertexDeclaration: {
  127721. name: string;
  127722. shader: string;
  127723. };
  127724. }
  127725. declare module BABYLON {
  127726. /** @hidden */
  127727. export var pbrVertexShader: {
  127728. name: string;
  127729. shader: string;
  127730. };
  127731. }
  127732. declare module BABYLON {
  127733. /**
  127734. * Manages the defines for the PBR Material.
  127735. * @hidden
  127736. */
  127737. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  127738. PBR: boolean;
  127739. MAINUV1: boolean;
  127740. MAINUV2: boolean;
  127741. UV1: boolean;
  127742. UV2: boolean;
  127743. ALBEDO: boolean;
  127744. GAMMAALBEDO: boolean;
  127745. ALBEDODIRECTUV: number;
  127746. VERTEXCOLOR: boolean;
  127747. AMBIENT: boolean;
  127748. AMBIENTDIRECTUV: number;
  127749. AMBIENTINGRAYSCALE: boolean;
  127750. OPACITY: boolean;
  127751. VERTEXALPHA: boolean;
  127752. OPACITYDIRECTUV: number;
  127753. OPACITYRGB: boolean;
  127754. ALPHATEST: boolean;
  127755. DEPTHPREPASS: boolean;
  127756. ALPHABLEND: boolean;
  127757. ALPHAFROMALBEDO: boolean;
  127758. ALPHATESTVALUE: string;
  127759. SPECULAROVERALPHA: boolean;
  127760. RADIANCEOVERALPHA: boolean;
  127761. ALPHAFRESNEL: boolean;
  127762. LINEARALPHAFRESNEL: boolean;
  127763. PREMULTIPLYALPHA: boolean;
  127764. EMISSIVE: boolean;
  127765. EMISSIVEDIRECTUV: number;
  127766. REFLECTIVITY: boolean;
  127767. REFLECTIVITYDIRECTUV: number;
  127768. SPECULARTERM: boolean;
  127769. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  127770. MICROSURFACEAUTOMATIC: boolean;
  127771. LODBASEDMICROSFURACE: boolean;
  127772. MICROSURFACEMAP: boolean;
  127773. MICROSURFACEMAPDIRECTUV: number;
  127774. METALLICWORKFLOW: boolean;
  127775. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  127776. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  127777. METALLNESSSTOREINMETALMAPBLUE: boolean;
  127778. AOSTOREINMETALMAPRED: boolean;
  127779. METALLICF0FACTORFROMMETALLICMAP: boolean;
  127780. ENVIRONMENTBRDF: boolean;
  127781. ENVIRONMENTBRDF_RGBD: boolean;
  127782. NORMAL: boolean;
  127783. TANGENT: boolean;
  127784. BUMP: boolean;
  127785. BUMPDIRECTUV: number;
  127786. OBJECTSPACE_NORMALMAP: boolean;
  127787. PARALLAX: boolean;
  127788. PARALLAXOCCLUSION: boolean;
  127789. NORMALXYSCALE: boolean;
  127790. LIGHTMAP: boolean;
  127791. LIGHTMAPDIRECTUV: number;
  127792. USELIGHTMAPASSHADOWMAP: boolean;
  127793. GAMMALIGHTMAP: boolean;
  127794. RGBDLIGHTMAP: boolean;
  127795. REFLECTION: boolean;
  127796. REFLECTIONMAP_3D: boolean;
  127797. REFLECTIONMAP_SPHERICAL: boolean;
  127798. REFLECTIONMAP_PLANAR: boolean;
  127799. REFLECTIONMAP_CUBIC: boolean;
  127800. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  127801. REFLECTIONMAP_PROJECTION: boolean;
  127802. REFLECTIONMAP_SKYBOX: boolean;
  127803. REFLECTIONMAP_EXPLICIT: boolean;
  127804. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  127805. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  127806. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  127807. INVERTCUBICMAP: boolean;
  127808. USESPHERICALFROMREFLECTIONMAP: boolean;
  127809. USEIRRADIANCEMAP: boolean;
  127810. SPHERICAL_HARMONICS: boolean;
  127811. USESPHERICALINVERTEX: boolean;
  127812. REFLECTIONMAP_OPPOSITEZ: boolean;
  127813. LODINREFLECTIONALPHA: boolean;
  127814. GAMMAREFLECTION: boolean;
  127815. RGBDREFLECTION: boolean;
  127816. LINEARSPECULARREFLECTION: boolean;
  127817. RADIANCEOCCLUSION: boolean;
  127818. HORIZONOCCLUSION: boolean;
  127819. INSTANCES: boolean;
  127820. NUM_BONE_INFLUENCERS: number;
  127821. BonesPerMesh: number;
  127822. BONETEXTURE: boolean;
  127823. NONUNIFORMSCALING: boolean;
  127824. MORPHTARGETS: boolean;
  127825. MORPHTARGETS_NORMAL: boolean;
  127826. MORPHTARGETS_TANGENT: boolean;
  127827. MORPHTARGETS_UV: boolean;
  127828. NUM_MORPH_INFLUENCERS: number;
  127829. IMAGEPROCESSING: boolean;
  127830. VIGNETTE: boolean;
  127831. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127832. VIGNETTEBLENDMODEOPAQUE: boolean;
  127833. TONEMAPPING: boolean;
  127834. TONEMAPPING_ACES: boolean;
  127835. CONTRAST: boolean;
  127836. COLORCURVES: boolean;
  127837. COLORGRADING: boolean;
  127838. COLORGRADING3D: boolean;
  127839. SAMPLER3DGREENDEPTH: boolean;
  127840. SAMPLER3DBGRMAP: boolean;
  127841. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127842. EXPOSURE: boolean;
  127843. MULTIVIEW: boolean;
  127844. USEPHYSICALLIGHTFALLOFF: boolean;
  127845. USEGLTFLIGHTFALLOFF: boolean;
  127846. TWOSIDEDLIGHTING: boolean;
  127847. SHADOWFLOAT: boolean;
  127848. CLIPPLANE: boolean;
  127849. CLIPPLANE2: boolean;
  127850. CLIPPLANE3: boolean;
  127851. CLIPPLANE4: boolean;
  127852. CLIPPLANE5: boolean;
  127853. CLIPPLANE6: boolean;
  127854. POINTSIZE: boolean;
  127855. FOG: boolean;
  127856. LOGARITHMICDEPTH: boolean;
  127857. FORCENORMALFORWARD: boolean;
  127858. SPECULARAA: boolean;
  127859. CLEARCOAT: boolean;
  127860. CLEARCOAT_DEFAULTIOR: boolean;
  127861. CLEARCOAT_TEXTURE: boolean;
  127862. CLEARCOAT_TEXTUREDIRECTUV: number;
  127863. CLEARCOAT_BUMP: boolean;
  127864. CLEARCOAT_BUMPDIRECTUV: number;
  127865. CLEARCOAT_TINT: boolean;
  127866. CLEARCOAT_TINT_TEXTURE: boolean;
  127867. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  127868. ANISOTROPIC: boolean;
  127869. ANISOTROPIC_TEXTURE: boolean;
  127870. ANISOTROPIC_TEXTUREDIRECTUV: number;
  127871. BRDF_V_HEIGHT_CORRELATED: boolean;
  127872. MS_BRDF_ENERGY_CONSERVATION: boolean;
  127873. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  127874. SHEEN: boolean;
  127875. SHEEN_TEXTURE: boolean;
  127876. SHEEN_TEXTUREDIRECTUV: number;
  127877. SHEEN_LINKWITHALBEDO: boolean;
  127878. SHEEN_ROUGHNESS: boolean;
  127879. SHEEN_ALBEDOSCALING: boolean;
  127880. SUBSURFACE: boolean;
  127881. SS_REFRACTION: boolean;
  127882. SS_TRANSLUCENCY: boolean;
  127883. SS_SCATERRING: boolean;
  127884. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127885. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127886. SS_REFRACTIONMAP_3D: boolean;
  127887. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127888. SS_LODINREFRACTIONALPHA: boolean;
  127889. SS_GAMMAREFRACTION: boolean;
  127890. SS_RGBDREFRACTION: boolean;
  127891. SS_LINEARSPECULARREFRACTION: boolean;
  127892. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127893. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127894. UNLIT: boolean;
  127895. DEBUGMODE: number;
  127896. /**
  127897. * Initializes the PBR Material defines.
  127898. */
  127899. constructor();
  127900. /**
  127901. * Resets the PBR Material defines.
  127902. */
  127903. reset(): void;
  127904. }
  127905. /**
  127906. * The Physically based material base class of BJS.
  127907. *
  127908. * This offers the main features of a standard PBR material.
  127909. * For more information, please refer to the documentation :
  127910. * https://doc.babylonjs.com/how_to/physically_based_rendering
  127911. */
  127912. export abstract class PBRBaseMaterial extends PushMaterial {
  127913. /**
  127914. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  127915. */
  127916. static readonly PBRMATERIAL_OPAQUE: number;
  127917. /**
  127918. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  127919. */
  127920. static readonly PBRMATERIAL_ALPHATEST: number;
  127921. /**
  127922. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127923. */
  127924. static readonly PBRMATERIAL_ALPHABLEND: number;
  127925. /**
  127926. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127927. * They are also discarded below the alpha cutoff threshold to improve performances.
  127928. */
  127929. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  127930. /**
  127931. * Defines the default value of how much AO map is occluding the analytical lights
  127932. * (point spot...).
  127933. */
  127934. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  127935. /**
  127936. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  127937. */
  127938. static readonly LIGHTFALLOFF_PHYSICAL: number;
  127939. /**
  127940. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  127941. * to enhance interoperability with other engines.
  127942. */
  127943. static readonly LIGHTFALLOFF_GLTF: number;
  127944. /**
  127945. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  127946. * to enhance interoperability with other materials.
  127947. */
  127948. static readonly LIGHTFALLOFF_STANDARD: number;
  127949. /**
  127950. * Intensity of the direct lights e.g. the four lights available in your scene.
  127951. * This impacts both the direct diffuse and specular highlights.
  127952. */
  127953. protected _directIntensity: number;
  127954. /**
  127955. * Intensity of the emissive part of the material.
  127956. * This helps controlling the emissive effect without modifying the emissive color.
  127957. */
  127958. protected _emissiveIntensity: number;
  127959. /**
  127960. * Intensity of the environment e.g. how much the environment will light the object
  127961. * either through harmonics for rough material or through the refelction for shiny ones.
  127962. */
  127963. protected _environmentIntensity: number;
  127964. /**
  127965. * This is a special control allowing the reduction of the specular highlights coming from the
  127966. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  127967. */
  127968. protected _specularIntensity: number;
  127969. /**
  127970. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  127971. */
  127972. private _lightingInfos;
  127973. /**
  127974. * Debug Control allowing disabling the bump map on this material.
  127975. */
  127976. protected _disableBumpMap: boolean;
  127977. /**
  127978. * AKA Diffuse Texture in standard nomenclature.
  127979. */
  127980. protected _albedoTexture: Nullable<BaseTexture>;
  127981. /**
  127982. * AKA Occlusion Texture in other nomenclature.
  127983. */
  127984. protected _ambientTexture: Nullable<BaseTexture>;
  127985. /**
  127986. * AKA Occlusion Texture Intensity in other nomenclature.
  127987. */
  127988. protected _ambientTextureStrength: number;
  127989. /**
  127990. * Defines how much the AO map is occluding the analytical lights (point spot...).
  127991. * 1 means it completely occludes it
  127992. * 0 mean it has no impact
  127993. */
  127994. protected _ambientTextureImpactOnAnalyticalLights: number;
  127995. /**
  127996. * Stores the alpha values in a texture.
  127997. */
  127998. protected _opacityTexture: Nullable<BaseTexture>;
  127999. /**
  128000. * Stores the reflection values in a texture.
  128001. */
  128002. protected _reflectionTexture: Nullable<BaseTexture>;
  128003. /**
  128004. * Stores the emissive values in a texture.
  128005. */
  128006. protected _emissiveTexture: Nullable<BaseTexture>;
  128007. /**
  128008. * AKA Specular texture in other nomenclature.
  128009. */
  128010. protected _reflectivityTexture: Nullable<BaseTexture>;
  128011. /**
  128012. * Used to switch from specular/glossiness to metallic/roughness workflow.
  128013. */
  128014. protected _metallicTexture: Nullable<BaseTexture>;
  128015. /**
  128016. * Specifies the metallic scalar of the metallic/roughness workflow.
  128017. * Can also be used to scale the metalness values of the metallic texture.
  128018. */
  128019. protected _metallic: Nullable<number>;
  128020. /**
  128021. * Specifies the roughness scalar of the metallic/roughness workflow.
  128022. * Can also be used to scale the roughness values of the metallic texture.
  128023. */
  128024. protected _roughness: Nullable<number>;
  128025. /**
  128026. * Specifies the an F0 factor to help configuring the material F0.
  128027. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  128028. * to 0.5 the previously hard coded value stays the same.
  128029. * Can also be used to scale the F0 values of the metallic texture.
  128030. */
  128031. protected _metallicF0Factor: number;
  128032. /**
  128033. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  128034. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  128035. * your expectation as it multiplies with the texture data.
  128036. */
  128037. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  128038. /**
  128039. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  128040. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  128041. */
  128042. protected _microSurfaceTexture: Nullable<BaseTexture>;
  128043. /**
  128044. * Stores surface normal data used to displace a mesh in a texture.
  128045. */
  128046. protected _bumpTexture: Nullable<BaseTexture>;
  128047. /**
  128048. * Stores the pre-calculated light information of a mesh in a texture.
  128049. */
  128050. protected _lightmapTexture: Nullable<BaseTexture>;
  128051. /**
  128052. * The color of a material in ambient lighting.
  128053. */
  128054. protected _ambientColor: Color3;
  128055. /**
  128056. * AKA Diffuse Color in other nomenclature.
  128057. */
  128058. protected _albedoColor: Color3;
  128059. /**
  128060. * AKA Specular Color in other nomenclature.
  128061. */
  128062. protected _reflectivityColor: Color3;
  128063. /**
  128064. * The color applied when light is reflected from a material.
  128065. */
  128066. protected _reflectionColor: Color3;
  128067. /**
  128068. * The color applied when light is emitted from a material.
  128069. */
  128070. protected _emissiveColor: Color3;
  128071. /**
  128072. * AKA Glossiness in other nomenclature.
  128073. */
  128074. protected _microSurface: number;
  128075. /**
  128076. * Specifies that the material will use the light map as a show map.
  128077. */
  128078. protected _useLightmapAsShadowmap: boolean;
  128079. /**
  128080. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128081. * makes the reflect vector face the model (under horizon).
  128082. */
  128083. protected _useHorizonOcclusion: boolean;
  128084. /**
  128085. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128086. * too much the area relying on ambient texture to define their ambient occlusion.
  128087. */
  128088. protected _useRadianceOcclusion: boolean;
  128089. /**
  128090. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128091. */
  128092. protected _useAlphaFromAlbedoTexture: boolean;
  128093. /**
  128094. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  128095. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128096. */
  128097. protected _useSpecularOverAlpha: boolean;
  128098. /**
  128099. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128100. */
  128101. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128102. /**
  128103. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128104. */
  128105. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  128106. /**
  128107. * Specifies if the metallic texture contains the roughness information in its green channel.
  128108. */
  128109. protected _useRoughnessFromMetallicTextureGreen: boolean;
  128110. /**
  128111. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128112. */
  128113. protected _useMetallnessFromMetallicTextureBlue: boolean;
  128114. /**
  128115. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128116. */
  128117. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  128118. /**
  128119. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128120. */
  128121. protected _useAmbientInGrayScale: boolean;
  128122. /**
  128123. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128124. * The material will try to infer what glossiness each pixel should be.
  128125. */
  128126. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  128127. /**
  128128. * Defines the falloff type used in this material.
  128129. * It by default is Physical.
  128130. */
  128131. protected _lightFalloff: number;
  128132. /**
  128133. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128134. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128135. */
  128136. protected _useRadianceOverAlpha: boolean;
  128137. /**
  128138. * Allows using an object space normal map (instead of tangent space).
  128139. */
  128140. protected _useObjectSpaceNormalMap: boolean;
  128141. /**
  128142. * Allows using the bump map in parallax mode.
  128143. */
  128144. protected _useParallax: boolean;
  128145. /**
  128146. * Allows using the bump map in parallax occlusion mode.
  128147. */
  128148. protected _useParallaxOcclusion: boolean;
  128149. /**
  128150. * Controls the scale bias of the parallax mode.
  128151. */
  128152. protected _parallaxScaleBias: number;
  128153. /**
  128154. * If sets to true, disables all the lights affecting the material.
  128155. */
  128156. protected _disableLighting: boolean;
  128157. /**
  128158. * Number of Simultaneous lights allowed on the material.
  128159. */
  128160. protected _maxSimultaneousLights: number;
  128161. /**
  128162. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  128163. */
  128164. protected _invertNormalMapX: boolean;
  128165. /**
  128166. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  128167. */
  128168. protected _invertNormalMapY: boolean;
  128169. /**
  128170. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128171. */
  128172. protected _twoSidedLighting: boolean;
  128173. /**
  128174. * Defines the alpha limits in alpha test mode.
  128175. */
  128176. protected _alphaCutOff: number;
  128177. /**
  128178. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128179. */
  128180. protected _forceAlphaTest: boolean;
  128181. /**
  128182. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128183. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128184. */
  128185. protected _useAlphaFresnel: boolean;
  128186. /**
  128187. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128188. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128189. */
  128190. protected _useLinearAlphaFresnel: boolean;
  128191. /**
  128192. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  128193. * from cos thetav and roughness:
  128194. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  128195. */
  128196. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  128197. /**
  128198. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128199. */
  128200. protected _forceIrradianceInFragment: boolean;
  128201. /**
  128202. * Force normal to face away from face.
  128203. */
  128204. protected _forceNormalForward: boolean;
  128205. /**
  128206. * Enables specular anti aliasing in the PBR shader.
  128207. * It will both interacts on the Geometry for analytical and IBL lighting.
  128208. * It also prefilter the roughness map based on the bump values.
  128209. */
  128210. protected _enableSpecularAntiAliasing: boolean;
  128211. /**
  128212. * Default configuration related to image processing available in the PBR Material.
  128213. */
  128214. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  128215. /**
  128216. * Keep track of the image processing observer to allow dispose and replace.
  128217. */
  128218. private _imageProcessingObserver;
  128219. /**
  128220. * Attaches a new image processing configuration to the PBR Material.
  128221. * @param configuration
  128222. */
  128223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  128224. /**
  128225. * Stores the available render targets.
  128226. */
  128227. private _renderTargets;
  128228. /**
  128229. * Sets the global ambient color for the material used in lighting calculations.
  128230. */
  128231. private _globalAmbientColor;
  128232. /**
  128233. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  128234. */
  128235. private _useLogarithmicDepth;
  128236. /**
  128237. * If set to true, no lighting calculations will be applied.
  128238. */
  128239. private _unlit;
  128240. private _debugMode;
  128241. /**
  128242. * @hidden
  128243. * This is reserved for the inspector.
  128244. * Defines the material debug mode.
  128245. * It helps seeing only some components of the material while troubleshooting.
  128246. */
  128247. debugMode: number;
  128248. /**
  128249. * @hidden
  128250. * This is reserved for the inspector.
  128251. * Specify from where on screen the debug mode should start.
  128252. * The value goes from -1 (full screen) to 1 (not visible)
  128253. * It helps with side by side comparison against the final render
  128254. * This defaults to -1
  128255. */
  128256. private debugLimit;
  128257. /**
  128258. * @hidden
  128259. * This is reserved for the inspector.
  128260. * As the default viewing range might not be enough (if the ambient is really small for instance)
  128261. * You can use the factor to better multiply the final value.
  128262. */
  128263. private debugFactor;
  128264. /**
  128265. * Defines the clear coat layer parameters for the material.
  128266. */
  128267. readonly clearCoat: PBRClearCoatConfiguration;
  128268. /**
  128269. * Defines the anisotropic parameters for the material.
  128270. */
  128271. readonly anisotropy: PBRAnisotropicConfiguration;
  128272. /**
  128273. * Defines the BRDF parameters for the material.
  128274. */
  128275. readonly brdf: PBRBRDFConfiguration;
  128276. /**
  128277. * Defines the Sheen parameters for the material.
  128278. */
  128279. readonly sheen: PBRSheenConfiguration;
  128280. /**
  128281. * Defines the SubSurface parameters for the material.
  128282. */
  128283. readonly subSurface: PBRSubSurfaceConfiguration;
  128284. protected _rebuildInParallel: boolean;
  128285. /**
  128286. * Instantiates a new PBRMaterial instance.
  128287. *
  128288. * @param name The material name
  128289. * @param scene The scene the material will be use in.
  128290. */
  128291. constructor(name: string, scene: Scene);
  128292. /**
  128293. * Gets a boolean indicating that current material needs to register RTT
  128294. */
  128295. get hasRenderTargetTextures(): boolean;
  128296. /**
  128297. * Gets the name of the material class.
  128298. */
  128299. getClassName(): string;
  128300. /**
  128301. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128302. */
  128303. get useLogarithmicDepth(): boolean;
  128304. /**
  128305. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128306. */
  128307. set useLogarithmicDepth(value: boolean);
  128308. /**
  128309. * Returns true if alpha blending should be disabled.
  128310. */
  128311. protected get _disableAlphaBlending(): boolean;
  128312. /**
  128313. * Specifies whether or not this material should be rendered in alpha blend mode.
  128314. */
  128315. needAlphaBlending(): boolean;
  128316. /**
  128317. * Specifies whether or not this material should be rendered in alpha test mode.
  128318. */
  128319. needAlphaTesting(): boolean;
  128320. /**
  128321. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  128322. */
  128323. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  128324. /**
  128325. * Gets the texture used for the alpha test.
  128326. */
  128327. getAlphaTestTexture(): Nullable<BaseTexture>;
  128328. /**
  128329. * Specifies that the submesh is ready to be used.
  128330. * @param mesh - BJS mesh.
  128331. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  128332. * @param useInstances - Specifies that instances should be used.
  128333. * @returns - boolean indicating that the submesh is ready or not.
  128334. */
  128335. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  128336. /**
  128337. * Specifies if the material uses metallic roughness workflow.
  128338. * @returns boolean specifiying if the material uses metallic roughness workflow.
  128339. */
  128340. isMetallicWorkflow(): boolean;
  128341. private _prepareEffect;
  128342. private _prepareDefines;
  128343. /**
  128344. * Force shader compilation
  128345. */
  128346. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  128347. /**
  128348. * Initializes the uniform buffer layout for the shader.
  128349. */
  128350. buildUniformLayout(): void;
  128351. /**
  128352. * Unbinds the material from the mesh
  128353. */
  128354. unbind(): void;
  128355. /**
  128356. * Binds the submesh data.
  128357. * @param world - The world matrix.
  128358. * @param mesh - The BJS mesh.
  128359. * @param subMesh - A submesh of the BJS mesh.
  128360. */
  128361. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  128362. /**
  128363. * Returns the animatable textures.
  128364. * @returns - Array of animatable textures.
  128365. */
  128366. getAnimatables(): IAnimatable[];
  128367. /**
  128368. * Returns the texture used for reflections.
  128369. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  128370. */
  128371. private _getReflectionTexture;
  128372. /**
  128373. * Returns an array of the actively used textures.
  128374. * @returns - Array of BaseTextures
  128375. */
  128376. getActiveTextures(): BaseTexture[];
  128377. /**
  128378. * Checks to see if a texture is used in the material.
  128379. * @param texture - Base texture to use.
  128380. * @returns - Boolean specifying if a texture is used in the material.
  128381. */
  128382. hasTexture(texture: BaseTexture): boolean;
  128383. /**
  128384. * Disposes the resources of the material.
  128385. * @param forceDisposeEffect - Forces the disposal of effects.
  128386. * @param forceDisposeTextures - Forces the disposal of all textures.
  128387. */
  128388. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  128389. }
  128390. }
  128391. declare module BABYLON {
  128392. /**
  128393. * The Physically based material of BJS.
  128394. *
  128395. * This offers the main features of a standard PBR material.
  128396. * For more information, please refer to the documentation :
  128397. * https://doc.babylonjs.com/how_to/physically_based_rendering
  128398. */
  128399. export class PBRMaterial extends PBRBaseMaterial {
  128400. /**
  128401. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  128402. */
  128403. static readonly PBRMATERIAL_OPAQUE: number;
  128404. /**
  128405. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  128406. */
  128407. static readonly PBRMATERIAL_ALPHATEST: number;
  128408. /**
  128409. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128410. */
  128411. static readonly PBRMATERIAL_ALPHABLEND: number;
  128412. /**
  128413. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128414. * They are also discarded below the alpha cutoff threshold to improve performances.
  128415. */
  128416. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  128417. /**
  128418. * Defines the default value of how much AO map is occluding the analytical lights
  128419. * (point spot...).
  128420. */
  128421. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  128422. /**
  128423. * Intensity of the direct lights e.g. the four lights available in your scene.
  128424. * This impacts both the direct diffuse and specular highlights.
  128425. */
  128426. directIntensity: number;
  128427. /**
  128428. * Intensity of the emissive part of the material.
  128429. * This helps controlling the emissive effect without modifying the emissive color.
  128430. */
  128431. emissiveIntensity: number;
  128432. /**
  128433. * Intensity of the environment e.g. how much the environment will light the object
  128434. * either through harmonics for rough material or through the refelction for shiny ones.
  128435. */
  128436. environmentIntensity: number;
  128437. /**
  128438. * This is a special control allowing the reduction of the specular highlights coming from the
  128439. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  128440. */
  128441. specularIntensity: number;
  128442. /**
  128443. * Debug Control allowing disabling the bump map on this material.
  128444. */
  128445. disableBumpMap: boolean;
  128446. /**
  128447. * AKA Diffuse Texture in standard nomenclature.
  128448. */
  128449. albedoTexture: BaseTexture;
  128450. /**
  128451. * AKA Occlusion Texture in other nomenclature.
  128452. */
  128453. ambientTexture: BaseTexture;
  128454. /**
  128455. * AKA Occlusion Texture Intensity in other nomenclature.
  128456. */
  128457. ambientTextureStrength: number;
  128458. /**
  128459. * Defines how much the AO map is occluding the analytical lights (point spot...).
  128460. * 1 means it completely occludes it
  128461. * 0 mean it has no impact
  128462. */
  128463. ambientTextureImpactOnAnalyticalLights: number;
  128464. /**
  128465. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  128466. */
  128467. opacityTexture: BaseTexture;
  128468. /**
  128469. * Stores the reflection values in a texture.
  128470. */
  128471. reflectionTexture: Nullable<BaseTexture>;
  128472. /**
  128473. * Stores the emissive values in a texture.
  128474. */
  128475. emissiveTexture: BaseTexture;
  128476. /**
  128477. * AKA Specular texture in other nomenclature.
  128478. */
  128479. reflectivityTexture: BaseTexture;
  128480. /**
  128481. * Used to switch from specular/glossiness to metallic/roughness workflow.
  128482. */
  128483. metallicTexture: BaseTexture;
  128484. /**
  128485. * Specifies the metallic scalar of the metallic/roughness workflow.
  128486. * Can also be used to scale the metalness values of the metallic texture.
  128487. */
  128488. metallic: Nullable<number>;
  128489. /**
  128490. * Specifies the roughness scalar of the metallic/roughness workflow.
  128491. * Can also be used to scale the roughness values of the metallic texture.
  128492. */
  128493. roughness: Nullable<number>;
  128494. /**
  128495. * Specifies the an F0 factor to help configuring the material F0.
  128496. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  128497. * to 0.5 the previously hard coded value stays the same.
  128498. * Can also be used to scale the F0 values of the metallic texture.
  128499. */
  128500. metallicF0Factor: number;
  128501. /**
  128502. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  128503. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  128504. * your expectation as it multiplies with the texture data.
  128505. */
  128506. useMetallicF0FactorFromMetallicTexture: boolean;
  128507. /**
  128508. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  128509. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  128510. */
  128511. microSurfaceTexture: BaseTexture;
  128512. /**
  128513. * Stores surface normal data used to displace a mesh in a texture.
  128514. */
  128515. bumpTexture: BaseTexture;
  128516. /**
  128517. * Stores the pre-calculated light information of a mesh in a texture.
  128518. */
  128519. lightmapTexture: BaseTexture;
  128520. /**
  128521. * Stores the refracted light information in a texture.
  128522. */
  128523. get refractionTexture(): Nullable<BaseTexture>;
  128524. set refractionTexture(value: Nullable<BaseTexture>);
  128525. /**
  128526. * The color of a material in ambient lighting.
  128527. */
  128528. ambientColor: Color3;
  128529. /**
  128530. * AKA Diffuse Color in other nomenclature.
  128531. */
  128532. albedoColor: Color3;
  128533. /**
  128534. * AKA Specular Color in other nomenclature.
  128535. */
  128536. reflectivityColor: Color3;
  128537. /**
  128538. * The color reflected from the material.
  128539. */
  128540. reflectionColor: Color3;
  128541. /**
  128542. * The color emitted from the material.
  128543. */
  128544. emissiveColor: Color3;
  128545. /**
  128546. * AKA Glossiness in other nomenclature.
  128547. */
  128548. microSurface: number;
  128549. /**
  128550. * source material index of refraction (IOR)' / 'destination material IOR.
  128551. */
  128552. get indexOfRefraction(): number;
  128553. set indexOfRefraction(value: number);
  128554. /**
  128555. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  128556. */
  128557. get invertRefractionY(): boolean;
  128558. set invertRefractionY(value: boolean);
  128559. /**
  128560. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  128561. * Materials half opaque for instance using refraction could benefit from this control.
  128562. */
  128563. get linkRefractionWithTransparency(): boolean;
  128564. set linkRefractionWithTransparency(value: boolean);
  128565. /**
  128566. * If true, the light map contains occlusion information instead of lighting info.
  128567. */
  128568. useLightmapAsShadowmap: boolean;
  128569. /**
  128570. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128571. */
  128572. useAlphaFromAlbedoTexture: boolean;
  128573. /**
  128574. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128575. */
  128576. forceAlphaTest: boolean;
  128577. /**
  128578. * Defines the alpha limits in alpha test mode.
  128579. */
  128580. alphaCutOff: number;
  128581. /**
  128582. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  128583. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128584. */
  128585. useSpecularOverAlpha: boolean;
  128586. /**
  128587. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128588. */
  128589. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128590. /**
  128591. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128592. */
  128593. useRoughnessFromMetallicTextureAlpha: boolean;
  128594. /**
  128595. * Specifies if the metallic texture contains the roughness information in its green channel.
  128596. */
  128597. useRoughnessFromMetallicTextureGreen: boolean;
  128598. /**
  128599. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128600. */
  128601. useMetallnessFromMetallicTextureBlue: boolean;
  128602. /**
  128603. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128604. */
  128605. useAmbientOcclusionFromMetallicTextureRed: boolean;
  128606. /**
  128607. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128608. */
  128609. useAmbientInGrayScale: boolean;
  128610. /**
  128611. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128612. * The material will try to infer what glossiness each pixel should be.
  128613. */
  128614. useAutoMicroSurfaceFromReflectivityMap: boolean;
  128615. /**
  128616. * BJS is using an harcoded light falloff based on a manually sets up range.
  128617. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128618. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128619. */
  128620. get usePhysicalLightFalloff(): boolean;
  128621. /**
  128622. * BJS is using an harcoded light falloff based on a manually sets up range.
  128623. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128624. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128625. */
  128626. set usePhysicalLightFalloff(value: boolean);
  128627. /**
  128628. * In order to support the falloff compatibility with gltf, a special mode has been added
  128629. * to reproduce the gltf light falloff.
  128630. */
  128631. get useGLTFLightFalloff(): boolean;
  128632. /**
  128633. * In order to support the falloff compatibility with gltf, a special mode has been added
  128634. * to reproduce the gltf light falloff.
  128635. */
  128636. set useGLTFLightFalloff(value: boolean);
  128637. /**
  128638. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128639. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128640. */
  128641. useRadianceOverAlpha: boolean;
  128642. /**
  128643. * Allows using an object space normal map (instead of tangent space).
  128644. */
  128645. useObjectSpaceNormalMap: boolean;
  128646. /**
  128647. * Allows using the bump map in parallax mode.
  128648. */
  128649. useParallax: boolean;
  128650. /**
  128651. * Allows using the bump map in parallax occlusion mode.
  128652. */
  128653. useParallaxOcclusion: boolean;
  128654. /**
  128655. * Controls the scale bias of the parallax mode.
  128656. */
  128657. parallaxScaleBias: number;
  128658. /**
  128659. * If sets to true, disables all the lights affecting the material.
  128660. */
  128661. disableLighting: boolean;
  128662. /**
  128663. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128664. */
  128665. forceIrradianceInFragment: boolean;
  128666. /**
  128667. * Number of Simultaneous lights allowed on the material.
  128668. */
  128669. maxSimultaneousLights: number;
  128670. /**
  128671. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128672. */
  128673. invertNormalMapX: boolean;
  128674. /**
  128675. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128676. */
  128677. invertNormalMapY: boolean;
  128678. /**
  128679. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128680. */
  128681. twoSidedLighting: boolean;
  128682. /**
  128683. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128684. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128685. */
  128686. useAlphaFresnel: boolean;
  128687. /**
  128688. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128689. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128690. */
  128691. useLinearAlphaFresnel: boolean;
  128692. /**
  128693. * Let user defines the brdf lookup texture used for IBL.
  128694. * A default 8bit version is embedded but you could point at :
  128695. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  128696. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  128697. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  128698. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  128699. */
  128700. environmentBRDFTexture: Nullable<BaseTexture>;
  128701. /**
  128702. * Force normal to face away from face.
  128703. */
  128704. forceNormalForward: boolean;
  128705. /**
  128706. * Enables specular anti aliasing in the PBR shader.
  128707. * It will both interacts on the Geometry for analytical and IBL lighting.
  128708. * It also prefilter the roughness map based on the bump values.
  128709. */
  128710. enableSpecularAntiAliasing: boolean;
  128711. /**
  128712. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128713. * makes the reflect vector face the model (under horizon).
  128714. */
  128715. useHorizonOcclusion: boolean;
  128716. /**
  128717. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128718. * too much the area relying on ambient texture to define their ambient occlusion.
  128719. */
  128720. useRadianceOcclusion: boolean;
  128721. /**
  128722. * If set to true, no lighting calculations will be applied.
  128723. */
  128724. unlit: boolean;
  128725. /**
  128726. * Gets the image processing configuration used either in this material.
  128727. */
  128728. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  128729. /**
  128730. * Sets the Default image processing configuration used either in the this material.
  128731. *
  128732. * If sets to null, the scene one is in use.
  128733. */
  128734. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  128735. /**
  128736. * Gets wether the color curves effect is enabled.
  128737. */
  128738. get cameraColorCurvesEnabled(): boolean;
  128739. /**
  128740. * Sets wether the color curves effect is enabled.
  128741. */
  128742. set cameraColorCurvesEnabled(value: boolean);
  128743. /**
  128744. * Gets wether the color grading effect is enabled.
  128745. */
  128746. get cameraColorGradingEnabled(): boolean;
  128747. /**
  128748. * Gets wether the color grading effect is enabled.
  128749. */
  128750. set cameraColorGradingEnabled(value: boolean);
  128751. /**
  128752. * Gets wether tonemapping is enabled or not.
  128753. */
  128754. get cameraToneMappingEnabled(): boolean;
  128755. /**
  128756. * Sets wether tonemapping is enabled or not
  128757. */
  128758. set cameraToneMappingEnabled(value: boolean);
  128759. /**
  128760. * The camera exposure used on this material.
  128761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128762. * This corresponds to a photographic exposure.
  128763. */
  128764. get cameraExposure(): number;
  128765. /**
  128766. * The camera exposure used on this material.
  128767. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128768. * This corresponds to a photographic exposure.
  128769. */
  128770. set cameraExposure(value: number);
  128771. /**
  128772. * Gets The camera contrast used on this material.
  128773. */
  128774. get cameraContrast(): number;
  128775. /**
  128776. * Sets The camera contrast used on this material.
  128777. */
  128778. set cameraContrast(value: number);
  128779. /**
  128780. * Gets the Color Grading 2D Lookup Texture.
  128781. */
  128782. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  128783. /**
  128784. * Sets the Color Grading 2D Lookup Texture.
  128785. */
  128786. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  128787. /**
  128788. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128789. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128790. * 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;
  128791. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128792. */
  128793. get cameraColorCurves(): Nullable<ColorCurves>;
  128794. /**
  128795. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128796. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128797. * 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;
  128798. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128799. */
  128800. set cameraColorCurves(value: Nullable<ColorCurves>);
  128801. /**
  128802. * Instantiates a new PBRMaterial instance.
  128803. *
  128804. * @param name The material name
  128805. * @param scene The scene the material will be use in.
  128806. */
  128807. constructor(name: string, scene: Scene);
  128808. /**
  128809. * Returns the name of this material class.
  128810. */
  128811. getClassName(): string;
  128812. /**
  128813. * Makes a duplicate of the current material.
  128814. * @param name - name to use for the new material.
  128815. */
  128816. clone(name: string): PBRMaterial;
  128817. /**
  128818. * Serializes this PBR Material.
  128819. * @returns - An object with the serialized material.
  128820. */
  128821. serialize(): any;
  128822. /**
  128823. * Parses a PBR Material from a serialized object.
  128824. * @param source - Serialized object.
  128825. * @param scene - BJS scene instance.
  128826. * @param rootUrl - url for the scene object
  128827. * @returns - PBRMaterial
  128828. */
  128829. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  128830. }
  128831. }
  128832. declare module BABYLON {
  128833. /**
  128834. * Direct draw surface info
  128835. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  128836. */
  128837. export interface DDSInfo {
  128838. /**
  128839. * Width of the texture
  128840. */
  128841. width: number;
  128842. /**
  128843. * Width of the texture
  128844. */
  128845. height: number;
  128846. /**
  128847. * Number of Mipmaps for the texture
  128848. * @see https://en.wikipedia.org/wiki/Mipmap
  128849. */
  128850. mipmapCount: number;
  128851. /**
  128852. * If the textures format is a known fourCC format
  128853. * @see https://www.fourcc.org/
  128854. */
  128855. isFourCC: boolean;
  128856. /**
  128857. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  128858. */
  128859. isRGB: boolean;
  128860. /**
  128861. * If the texture is a lumincance format
  128862. */
  128863. isLuminance: boolean;
  128864. /**
  128865. * If this is a cube texture
  128866. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  128867. */
  128868. isCube: boolean;
  128869. /**
  128870. * If the texture is a compressed format eg. FOURCC_DXT1
  128871. */
  128872. isCompressed: boolean;
  128873. /**
  128874. * The dxgiFormat of the texture
  128875. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  128876. */
  128877. dxgiFormat: number;
  128878. /**
  128879. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  128880. */
  128881. textureType: number;
  128882. /**
  128883. * Sphericle polynomial created for the dds texture
  128884. */
  128885. sphericalPolynomial?: SphericalPolynomial;
  128886. }
  128887. /**
  128888. * Class used to provide DDS decompression tools
  128889. */
  128890. export class DDSTools {
  128891. /**
  128892. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  128893. */
  128894. static StoreLODInAlphaChannel: boolean;
  128895. /**
  128896. * Gets DDS information from an array buffer
  128897. * @param data defines the array buffer view to read data from
  128898. * @returns the DDS information
  128899. */
  128900. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  128901. private static _FloatView;
  128902. private static _Int32View;
  128903. private static _ToHalfFloat;
  128904. private static _FromHalfFloat;
  128905. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  128906. private static _GetHalfFloatRGBAArrayBuffer;
  128907. private static _GetFloatRGBAArrayBuffer;
  128908. private static _GetFloatAsUIntRGBAArrayBuffer;
  128909. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  128910. private static _GetRGBAArrayBuffer;
  128911. private static _ExtractLongWordOrder;
  128912. private static _GetRGBArrayBuffer;
  128913. private static _GetLuminanceArrayBuffer;
  128914. /**
  128915. * Uploads DDS Levels to a Babylon Texture
  128916. * @hidden
  128917. */
  128918. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  128919. }
  128920. interface ThinEngine {
  128921. /**
  128922. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  128923. * @param rootUrl defines the url where the file to load is located
  128924. * @param scene defines the current scene
  128925. * @param lodScale defines scale to apply to the mip map selection
  128926. * @param lodOffset defines offset to apply to the mip map selection
  128927. * @param onLoad defines an optional callback raised when the texture is loaded
  128928. * @param onError defines an optional callback raised if there is an issue to load the texture
  128929. * @param format defines the format of the data
  128930. * @param forcedExtension defines the extension to use to pick the right loader
  128931. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  128932. * @returns the cube texture as an InternalTexture
  128933. */
  128934. 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;
  128935. }
  128936. }
  128937. declare module BABYLON {
  128938. /**
  128939. * Implementation of the DDS Texture Loader.
  128940. * @hidden
  128941. */
  128942. export class _DDSTextureLoader implements IInternalTextureLoader {
  128943. /**
  128944. * Defines wether the loader supports cascade loading the different faces.
  128945. */
  128946. readonly supportCascades: boolean;
  128947. /**
  128948. * This returns if the loader support the current file information.
  128949. * @param extension defines the file extension of the file being loaded
  128950. * @returns true if the loader can load the specified file
  128951. */
  128952. canLoad(extension: string): boolean;
  128953. /**
  128954. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128955. * @param data contains the texture data
  128956. * @param texture defines the BabylonJS internal texture
  128957. * @param createPolynomials will be true if polynomials have been requested
  128958. * @param onLoad defines the callback to trigger once the texture is ready
  128959. * @param onError defines the callback to trigger in case of error
  128960. */
  128961. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128962. /**
  128963. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128964. * @param data contains the texture data
  128965. * @param texture defines the BabylonJS internal texture
  128966. * @param callback defines the method to call once ready to upload
  128967. */
  128968. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128969. }
  128970. }
  128971. declare module BABYLON {
  128972. /**
  128973. * Implementation of the ENV Texture Loader.
  128974. * @hidden
  128975. */
  128976. export class _ENVTextureLoader implements IInternalTextureLoader {
  128977. /**
  128978. * Defines wether the loader supports cascade loading the different faces.
  128979. */
  128980. readonly supportCascades: boolean;
  128981. /**
  128982. * This returns if the loader support the current file information.
  128983. * @param extension defines the file extension of the file being loaded
  128984. * @returns true if the loader can load the specified file
  128985. */
  128986. canLoad(extension: string): boolean;
  128987. /**
  128988. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128989. * @param data contains the texture data
  128990. * @param texture defines the BabylonJS internal texture
  128991. * @param createPolynomials will be true if polynomials have been requested
  128992. * @param onLoad defines the callback to trigger once the texture is ready
  128993. * @param onError defines the callback to trigger in case of error
  128994. */
  128995. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128996. /**
  128997. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128998. * @param data contains the texture data
  128999. * @param texture defines the BabylonJS internal texture
  129000. * @param callback defines the method to call once ready to upload
  129001. */
  129002. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129003. }
  129004. }
  129005. declare module BABYLON {
  129006. /**
  129007. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129008. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129009. */
  129010. export class KhronosTextureContainer {
  129011. /** contents of the KTX container file */
  129012. data: ArrayBufferView;
  129013. private static HEADER_LEN;
  129014. private static COMPRESSED_2D;
  129015. private static COMPRESSED_3D;
  129016. private static TEX_2D;
  129017. private static TEX_3D;
  129018. /**
  129019. * Gets the openGL type
  129020. */
  129021. glType: number;
  129022. /**
  129023. * Gets the openGL type size
  129024. */
  129025. glTypeSize: number;
  129026. /**
  129027. * Gets the openGL format
  129028. */
  129029. glFormat: number;
  129030. /**
  129031. * Gets the openGL internal format
  129032. */
  129033. glInternalFormat: number;
  129034. /**
  129035. * Gets the base internal format
  129036. */
  129037. glBaseInternalFormat: number;
  129038. /**
  129039. * Gets image width in pixel
  129040. */
  129041. pixelWidth: number;
  129042. /**
  129043. * Gets image height in pixel
  129044. */
  129045. pixelHeight: number;
  129046. /**
  129047. * Gets image depth in pixels
  129048. */
  129049. pixelDepth: number;
  129050. /**
  129051. * Gets the number of array elements
  129052. */
  129053. numberOfArrayElements: number;
  129054. /**
  129055. * Gets the number of faces
  129056. */
  129057. numberOfFaces: number;
  129058. /**
  129059. * Gets the number of mipmap levels
  129060. */
  129061. numberOfMipmapLevels: number;
  129062. /**
  129063. * Gets the bytes of key value data
  129064. */
  129065. bytesOfKeyValueData: number;
  129066. /**
  129067. * Gets the load type
  129068. */
  129069. loadType: number;
  129070. /**
  129071. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  129072. */
  129073. isInvalid: boolean;
  129074. /**
  129075. * Creates a new KhronosTextureContainer
  129076. * @param data contents of the KTX container file
  129077. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  129078. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  129079. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  129080. */
  129081. constructor(
  129082. /** contents of the KTX container file */
  129083. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  129084. /**
  129085. * Uploads KTX content to a Babylon Texture.
  129086. * It is assumed that the texture has already been created & is currently bound
  129087. * @hidden
  129088. */
  129089. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  129090. private _upload2DCompressedLevels;
  129091. /**
  129092. * Checks if the given data starts with a KTX file identifier.
  129093. * @param data the data to check
  129094. * @returns true if the data is a KTX file or false otherwise
  129095. */
  129096. static IsValid(data: ArrayBufferView): boolean;
  129097. }
  129098. }
  129099. declare module BABYLON {
  129100. /**
  129101. * Class for loading KTX2 files
  129102. * !!! Experimental Extension Subject to Changes !!!
  129103. * @hidden
  129104. */
  129105. export class KhronosTextureContainer2 {
  129106. private static _ModulePromise;
  129107. private static _TranscodeFormat;
  129108. constructor(engine: ThinEngine);
  129109. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  129110. private _determineTranscodeFormat;
  129111. /**
  129112. * Checks if the given data starts with a KTX2 file identifier.
  129113. * @param data the data to check
  129114. * @returns true if the data is a KTX2 file or false otherwise
  129115. */
  129116. static IsValid(data: ArrayBufferView): boolean;
  129117. }
  129118. }
  129119. declare module BABYLON {
  129120. /**
  129121. * Implementation of the KTX Texture Loader.
  129122. * @hidden
  129123. */
  129124. export class _KTXTextureLoader implements IInternalTextureLoader {
  129125. /**
  129126. * Defines wether the loader supports cascade loading the different faces.
  129127. */
  129128. readonly supportCascades: boolean;
  129129. /**
  129130. * This returns if the loader support the current file information.
  129131. * @param extension defines the file extension of the file being loaded
  129132. * @returns true if the loader can load the specified file
  129133. */
  129134. canLoad(extension: string): boolean;
  129135. /**
  129136. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129137. * @param data contains the texture data
  129138. * @param texture defines the BabylonJS internal texture
  129139. * @param createPolynomials will be true if polynomials have been requested
  129140. * @param onLoad defines the callback to trigger once the texture is ready
  129141. * @param onError defines the callback to trigger in case of error
  129142. */
  129143. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129144. /**
  129145. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129146. * @param data contains the texture data
  129147. * @param texture defines the BabylonJS internal texture
  129148. * @param callback defines the method to call once ready to upload
  129149. */
  129150. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  129151. }
  129152. }
  129153. declare module BABYLON {
  129154. /** @hidden */
  129155. export var _forceSceneHelpersToBundle: boolean;
  129156. interface Scene {
  129157. /**
  129158. * Creates a default light for the scene.
  129159. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  129160. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  129161. */
  129162. createDefaultLight(replace?: boolean): void;
  129163. /**
  129164. * Creates a default camera for the scene.
  129165. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  129166. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  129167. * @param replace has default false, when true replaces the active camera in the scene
  129168. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  129169. */
  129170. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  129171. /**
  129172. * Creates a default camera and a default light.
  129173. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  129174. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  129175. * @param replace has the default false, when true replaces the active camera/light in the scene
  129176. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  129177. */
  129178. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  129179. /**
  129180. * Creates a new sky box
  129181. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  129182. * @param environmentTexture defines the texture to use as environment texture
  129183. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  129184. * @param scale defines the overall scale of the skybox
  129185. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  129186. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  129187. * @returns a new mesh holding the sky box
  129188. */
  129189. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  129190. /**
  129191. * Creates a new environment
  129192. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  129193. * @param options defines the options you can use to configure the environment
  129194. * @returns the new EnvironmentHelper
  129195. */
  129196. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  129197. /**
  129198. * Creates a new VREXperienceHelper
  129199. * @see http://doc.babylonjs.com/how_to/webvr_helper
  129200. * @param webVROptions defines the options used to create the new VREXperienceHelper
  129201. * @returns a new VREXperienceHelper
  129202. */
  129203. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  129204. /**
  129205. * Creates a new WebXRDefaultExperience
  129206. * @see http://doc.babylonjs.com/how_to/webxr
  129207. * @param options experience options
  129208. * @returns a promise for a new WebXRDefaultExperience
  129209. */
  129210. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129211. }
  129212. }
  129213. declare module BABYLON {
  129214. /**
  129215. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  129216. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  129217. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  129218. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  129219. */
  129220. export class VideoDome extends TransformNode {
  129221. /**
  129222. * Define the video source as a Monoscopic panoramic 360 video.
  129223. */
  129224. static readonly MODE_MONOSCOPIC: number;
  129225. /**
  129226. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  129227. */
  129228. static readonly MODE_TOPBOTTOM: number;
  129229. /**
  129230. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  129231. */
  129232. static readonly MODE_SIDEBYSIDE: number;
  129233. private _halfDome;
  129234. private _useDirectMapping;
  129235. /**
  129236. * The video texture being displayed on the sphere
  129237. */
  129238. protected _videoTexture: VideoTexture;
  129239. /**
  129240. * Gets the video texture being displayed on the sphere
  129241. */
  129242. get videoTexture(): VideoTexture;
  129243. /**
  129244. * The skybox material
  129245. */
  129246. protected _material: BackgroundMaterial;
  129247. /**
  129248. * The surface used for the skybox
  129249. */
  129250. protected _mesh: Mesh;
  129251. /**
  129252. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  129253. */
  129254. private _halfDomeMask;
  129255. /**
  129256. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  129257. * Also see the options.resolution property.
  129258. */
  129259. get fovMultiplier(): number;
  129260. set fovMultiplier(value: number);
  129261. private _videoMode;
  129262. /**
  129263. * Gets or set the current video mode for the video. It can be:
  129264. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  129265. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  129266. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  129267. */
  129268. get videoMode(): number;
  129269. set videoMode(value: number);
  129270. /**
  129271. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  129272. *
  129273. */
  129274. get halfDome(): boolean;
  129275. /**
  129276. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  129277. */
  129278. set halfDome(enabled: boolean);
  129279. /**
  129280. * Oberserver used in Stereoscopic VR Mode.
  129281. */
  129282. private _onBeforeCameraRenderObserver;
  129283. /**
  129284. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  129285. * @param name Element's name, child elements will append suffixes for their own names.
  129286. * @param urlsOrVideo defines the url(s) or the video element to use
  129287. * @param options An object containing optional or exposed sub element properties
  129288. */
  129289. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  129290. resolution?: number;
  129291. clickToPlay?: boolean;
  129292. autoPlay?: boolean;
  129293. loop?: boolean;
  129294. size?: number;
  129295. poster?: string;
  129296. faceForward?: boolean;
  129297. useDirectMapping?: boolean;
  129298. halfDomeMode?: boolean;
  129299. }, scene: Scene);
  129300. private _changeVideoMode;
  129301. /**
  129302. * Releases resources associated with this node.
  129303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  129304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  129305. */
  129306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  129307. }
  129308. }
  129309. declare module BABYLON {
  129310. /**
  129311. * This class can be used to get instrumentation data from a Babylon engine
  129312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129313. */
  129314. export class EngineInstrumentation implements IDisposable {
  129315. /**
  129316. * Define the instrumented engine.
  129317. */
  129318. engine: Engine;
  129319. private _captureGPUFrameTime;
  129320. private _gpuFrameTimeToken;
  129321. private _gpuFrameTime;
  129322. private _captureShaderCompilationTime;
  129323. private _shaderCompilationTime;
  129324. private _onBeginFrameObserver;
  129325. private _onEndFrameObserver;
  129326. private _onBeforeShaderCompilationObserver;
  129327. private _onAfterShaderCompilationObserver;
  129328. /**
  129329. * Gets the perf counter used for GPU frame time
  129330. */
  129331. get gpuFrameTimeCounter(): PerfCounter;
  129332. /**
  129333. * Gets the GPU frame time capture status
  129334. */
  129335. get captureGPUFrameTime(): boolean;
  129336. /**
  129337. * Enable or disable the GPU frame time capture
  129338. */
  129339. set captureGPUFrameTime(value: boolean);
  129340. /**
  129341. * Gets the perf counter used for shader compilation time
  129342. */
  129343. get shaderCompilationTimeCounter(): PerfCounter;
  129344. /**
  129345. * Gets the shader compilation time capture status
  129346. */
  129347. get captureShaderCompilationTime(): boolean;
  129348. /**
  129349. * Enable or disable the shader compilation time capture
  129350. */
  129351. set captureShaderCompilationTime(value: boolean);
  129352. /**
  129353. * Instantiates a new engine instrumentation.
  129354. * This class can be used to get instrumentation data from a Babylon engine
  129355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129356. * @param engine Defines the engine to instrument
  129357. */
  129358. constructor(
  129359. /**
  129360. * Define the instrumented engine.
  129361. */
  129362. engine: Engine);
  129363. /**
  129364. * Dispose and release associated resources.
  129365. */
  129366. dispose(): void;
  129367. }
  129368. }
  129369. declare module BABYLON {
  129370. /**
  129371. * This class can be used to get instrumentation data from a Babylon engine
  129372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129373. */
  129374. export class SceneInstrumentation implements IDisposable {
  129375. /**
  129376. * Defines the scene to instrument
  129377. */
  129378. scene: Scene;
  129379. private _captureActiveMeshesEvaluationTime;
  129380. private _activeMeshesEvaluationTime;
  129381. private _captureRenderTargetsRenderTime;
  129382. private _renderTargetsRenderTime;
  129383. private _captureFrameTime;
  129384. private _frameTime;
  129385. private _captureRenderTime;
  129386. private _renderTime;
  129387. private _captureInterFrameTime;
  129388. private _interFrameTime;
  129389. private _captureParticlesRenderTime;
  129390. private _particlesRenderTime;
  129391. private _captureSpritesRenderTime;
  129392. private _spritesRenderTime;
  129393. private _capturePhysicsTime;
  129394. private _physicsTime;
  129395. private _captureAnimationsTime;
  129396. private _animationsTime;
  129397. private _captureCameraRenderTime;
  129398. private _cameraRenderTime;
  129399. private _onBeforeActiveMeshesEvaluationObserver;
  129400. private _onAfterActiveMeshesEvaluationObserver;
  129401. private _onBeforeRenderTargetsRenderObserver;
  129402. private _onAfterRenderTargetsRenderObserver;
  129403. private _onAfterRenderObserver;
  129404. private _onBeforeDrawPhaseObserver;
  129405. private _onAfterDrawPhaseObserver;
  129406. private _onBeforeAnimationsObserver;
  129407. private _onBeforeParticlesRenderingObserver;
  129408. private _onAfterParticlesRenderingObserver;
  129409. private _onBeforeSpritesRenderingObserver;
  129410. private _onAfterSpritesRenderingObserver;
  129411. private _onBeforePhysicsObserver;
  129412. private _onAfterPhysicsObserver;
  129413. private _onAfterAnimationsObserver;
  129414. private _onBeforeCameraRenderObserver;
  129415. private _onAfterCameraRenderObserver;
  129416. /**
  129417. * Gets the perf counter used for active meshes evaluation time
  129418. */
  129419. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  129420. /**
  129421. * Gets the active meshes evaluation time capture status
  129422. */
  129423. get captureActiveMeshesEvaluationTime(): boolean;
  129424. /**
  129425. * Enable or disable the active meshes evaluation time capture
  129426. */
  129427. set captureActiveMeshesEvaluationTime(value: boolean);
  129428. /**
  129429. * Gets the perf counter used for render targets render time
  129430. */
  129431. get renderTargetsRenderTimeCounter(): PerfCounter;
  129432. /**
  129433. * Gets the render targets render time capture status
  129434. */
  129435. get captureRenderTargetsRenderTime(): boolean;
  129436. /**
  129437. * Enable or disable the render targets render time capture
  129438. */
  129439. set captureRenderTargetsRenderTime(value: boolean);
  129440. /**
  129441. * Gets the perf counter used for particles render time
  129442. */
  129443. get particlesRenderTimeCounter(): PerfCounter;
  129444. /**
  129445. * Gets the particles render time capture status
  129446. */
  129447. get captureParticlesRenderTime(): boolean;
  129448. /**
  129449. * Enable or disable the particles render time capture
  129450. */
  129451. set captureParticlesRenderTime(value: boolean);
  129452. /**
  129453. * Gets the perf counter used for sprites render time
  129454. */
  129455. get spritesRenderTimeCounter(): PerfCounter;
  129456. /**
  129457. * Gets the sprites render time capture status
  129458. */
  129459. get captureSpritesRenderTime(): boolean;
  129460. /**
  129461. * Enable or disable the sprites render time capture
  129462. */
  129463. set captureSpritesRenderTime(value: boolean);
  129464. /**
  129465. * Gets the perf counter used for physics time
  129466. */
  129467. get physicsTimeCounter(): PerfCounter;
  129468. /**
  129469. * Gets the physics time capture status
  129470. */
  129471. get capturePhysicsTime(): boolean;
  129472. /**
  129473. * Enable or disable the physics time capture
  129474. */
  129475. set capturePhysicsTime(value: boolean);
  129476. /**
  129477. * Gets the perf counter used for animations time
  129478. */
  129479. get animationsTimeCounter(): PerfCounter;
  129480. /**
  129481. * Gets the animations time capture status
  129482. */
  129483. get captureAnimationsTime(): boolean;
  129484. /**
  129485. * Enable or disable the animations time capture
  129486. */
  129487. set captureAnimationsTime(value: boolean);
  129488. /**
  129489. * Gets the perf counter used for frame time capture
  129490. */
  129491. get frameTimeCounter(): PerfCounter;
  129492. /**
  129493. * Gets the frame time capture status
  129494. */
  129495. get captureFrameTime(): boolean;
  129496. /**
  129497. * Enable or disable the frame time capture
  129498. */
  129499. set captureFrameTime(value: boolean);
  129500. /**
  129501. * Gets the perf counter used for inter-frames time capture
  129502. */
  129503. get interFrameTimeCounter(): PerfCounter;
  129504. /**
  129505. * Gets the inter-frames time capture status
  129506. */
  129507. get captureInterFrameTime(): boolean;
  129508. /**
  129509. * Enable or disable the inter-frames time capture
  129510. */
  129511. set captureInterFrameTime(value: boolean);
  129512. /**
  129513. * Gets the perf counter used for render time capture
  129514. */
  129515. get renderTimeCounter(): PerfCounter;
  129516. /**
  129517. * Gets the render time capture status
  129518. */
  129519. get captureRenderTime(): boolean;
  129520. /**
  129521. * Enable or disable the render time capture
  129522. */
  129523. set captureRenderTime(value: boolean);
  129524. /**
  129525. * Gets the perf counter used for camera render time capture
  129526. */
  129527. get cameraRenderTimeCounter(): PerfCounter;
  129528. /**
  129529. * Gets the camera render time capture status
  129530. */
  129531. get captureCameraRenderTime(): boolean;
  129532. /**
  129533. * Enable or disable the camera render time capture
  129534. */
  129535. set captureCameraRenderTime(value: boolean);
  129536. /**
  129537. * Gets the perf counter used for draw calls
  129538. */
  129539. get drawCallsCounter(): PerfCounter;
  129540. /**
  129541. * Instantiates a new scene instrumentation.
  129542. * This class can be used to get instrumentation data from a Babylon engine
  129543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129544. * @param scene Defines the scene to instrument
  129545. */
  129546. constructor(
  129547. /**
  129548. * Defines the scene to instrument
  129549. */
  129550. scene: Scene);
  129551. /**
  129552. * Dispose and release associated resources.
  129553. */
  129554. dispose(): void;
  129555. }
  129556. }
  129557. declare module BABYLON {
  129558. /** @hidden */
  129559. export var glowMapGenerationPixelShader: {
  129560. name: string;
  129561. shader: string;
  129562. };
  129563. }
  129564. declare module BABYLON {
  129565. /** @hidden */
  129566. export var glowMapGenerationVertexShader: {
  129567. name: string;
  129568. shader: string;
  129569. };
  129570. }
  129571. declare module BABYLON {
  129572. /**
  129573. * Effect layer options. This helps customizing the behaviour
  129574. * of the effect layer.
  129575. */
  129576. export interface IEffectLayerOptions {
  129577. /**
  129578. * Multiplication factor apply to the canvas size to compute the render target size
  129579. * used to generated the objects (the smaller the faster).
  129580. */
  129581. mainTextureRatio: number;
  129582. /**
  129583. * Enforces a fixed size texture to ensure effect stability across devices.
  129584. */
  129585. mainTextureFixedSize?: number;
  129586. /**
  129587. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  129588. */
  129589. alphaBlendingMode: number;
  129590. /**
  129591. * The camera attached to the layer.
  129592. */
  129593. camera: Nullable<Camera>;
  129594. /**
  129595. * The rendering group to draw the layer in.
  129596. */
  129597. renderingGroupId: number;
  129598. }
  129599. /**
  129600. * The effect layer Helps adding post process effect blended with the main pass.
  129601. *
  129602. * This can be for instance use to generate glow or higlight effects on the scene.
  129603. *
  129604. * The effect layer class can not be used directly and is intented to inherited from to be
  129605. * customized per effects.
  129606. */
  129607. export abstract class EffectLayer {
  129608. private _vertexBuffers;
  129609. private _indexBuffer;
  129610. private _cachedDefines;
  129611. private _effectLayerMapGenerationEffect;
  129612. private _effectLayerOptions;
  129613. private _mergeEffect;
  129614. protected _scene: Scene;
  129615. protected _engine: Engine;
  129616. protected _maxSize: number;
  129617. protected _mainTextureDesiredSize: ISize;
  129618. protected _mainTexture: RenderTargetTexture;
  129619. protected _shouldRender: boolean;
  129620. protected _postProcesses: PostProcess[];
  129621. protected _textures: BaseTexture[];
  129622. protected _emissiveTextureAndColor: {
  129623. texture: Nullable<BaseTexture>;
  129624. color: Color4;
  129625. };
  129626. /**
  129627. * The name of the layer
  129628. */
  129629. name: string;
  129630. /**
  129631. * The clear color of the texture used to generate the glow map.
  129632. */
  129633. neutralColor: Color4;
  129634. /**
  129635. * Specifies whether the highlight layer is enabled or not.
  129636. */
  129637. isEnabled: boolean;
  129638. /**
  129639. * Gets the camera attached to the layer.
  129640. */
  129641. get camera(): Nullable<Camera>;
  129642. /**
  129643. * Gets the rendering group id the layer should render in.
  129644. */
  129645. get renderingGroupId(): number;
  129646. set renderingGroupId(renderingGroupId: number);
  129647. /**
  129648. * An event triggered when the effect layer has been disposed.
  129649. */
  129650. onDisposeObservable: Observable<EffectLayer>;
  129651. /**
  129652. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  129653. */
  129654. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  129655. /**
  129656. * An event triggered when the generated texture is being merged in the scene.
  129657. */
  129658. onBeforeComposeObservable: Observable<EffectLayer>;
  129659. /**
  129660. * An event triggered when the mesh is rendered into the effect render target.
  129661. */
  129662. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  129663. /**
  129664. * An event triggered after the mesh has been rendered into the effect render target.
  129665. */
  129666. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  129667. /**
  129668. * An event triggered when the generated texture has been merged in the scene.
  129669. */
  129670. onAfterComposeObservable: Observable<EffectLayer>;
  129671. /**
  129672. * An event triggered when the efffect layer changes its size.
  129673. */
  129674. onSizeChangedObservable: Observable<EffectLayer>;
  129675. /** @hidden */
  129676. static _SceneComponentInitialization: (scene: Scene) => void;
  129677. /**
  129678. * Instantiates a new effect Layer and references it in the scene.
  129679. * @param name The name of the layer
  129680. * @param scene The scene to use the layer in
  129681. */
  129682. constructor(
  129683. /** The Friendly of the effect in the scene */
  129684. name: string, scene: Scene);
  129685. /**
  129686. * Get the effect name of the layer.
  129687. * @return The effect name
  129688. */
  129689. abstract getEffectName(): string;
  129690. /**
  129691. * Checks for the readiness of the element composing the layer.
  129692. * @param subMesh the mesh to check for
  129693. * @param useInstances specify whether or not to use instances to render the mesh
  129694. * @return true if ready otherwise, false
  129695. */
  129696. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129697. /**
  129698. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129699. * @returns true if the effect requires stencil during the main canvas render pass.
  129700. */
  129701. abstract needStencil(): boolean;
  129702. /**
  129703. * Create the merge effect. This is the shader use to blit the information back
  129704. * to the main canvas at the end of the scene rendering.
  129705. * @returns The effect containing the shader used to merge the effect on the main canvas
  129706. */
  129707. protected abstract _createMergeEffect(): Effect;
  129708. /**
  129709. * Creates the render target textures and post processes used in the effect layer.
  129710. */
  129711. protected abstract _createTextureAndPostProcesses(): void;
  129712. /**
  129713. * Implementation specific of rendering the generating effect on the main canvas.
  129714. * @param effect The effect used to render through
  129715. */
  129716. protected abstract _internalRender(effect: Effect): void;
  129717. /**
  129718. * Sets the required values for both the emissive texture and and the main color.
  129719. */
  129720. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129721. /**
  129722. * Free any resources and references associated to a mesh.
  129723. * Internal use
  129724. * @param mesh The mesh to free.
  129725. */
  129726. abstract _disposeMesh(mesh: Mesh): void;
  129727. /**
  129728. * Serializes this layer (Glow or Highlight for example)
  129729. * @returns a serialized layer object
  129730. */
  129731. abstract serialize?(): any;
  129732. /**
  129733. * Initializes the effect layer with the required options.
  129734. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  129735. */
  129736. protected _init(options: Partial<IEffectLayerOptions>): void;
  129737. /**
  129738. * Generates the index buffer of the full screen quad blending to the main canvas.
  129739. */
  129740. private _generateIndexBuffer;
  129741. /**
  129742. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  129743. */
  129744. private _generateVertexBuffer;
  129745. /**
  129746. * Sets the main texture desired size which is the closest power of two
  129747. * of the engine canvas size.
  129748. */
  129749. private _setMainTextureSize;
  129750. /**
  129751. * Creates the main texture for the effect layer.
  129752. */
  129753. protected _createMainTexture(): void;
  129754. /**
  129755. * Adds specific effects defines.
  129756. * @param defines The defines to add specifics to.
  129757. */
  129758. protected _addCustomEffectDefines(defines: string[]): void;
  129759. /**
  129760. * Checks for the readiness of the element composing the layer.
  129761. * @param subMesh the mesh to check for
  129762. * @param useInstances specify whether or not to use instances to render the mesh
  129763. * @param emissiveTexture the associated emissive texture used to generate the glow
  129764. * @return true if ready otherwise, false
  129765. */
  129766. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  129767. /**
  129768. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  129769. */
  129770. render(): void;
  129771. /**
  129772. * Determine if a given mesh will be used in the current effect.
  129773. * @param mesh mesh to test
  129774. * @returns true if the mesh will be used
  129775. */
  129776. hasMesh(mesh: AbstractMesh): boolean;
  129777. /**
  129778. * Returns true if the layer contains information to display, otherwise false.
  129779. * @returns true if the glow layer should be rendered
  129780. */
  129781. shouldRender(): boolean;
  129782. /**
  129783. * Returns true if the mesh should render, otherwise false.
  129784. * @param mesh The mesh to render
  129785. * @returns true if it should render otherwise false
  129786. */
  129787. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  129788. /**
  129789. * Returns true if the mesh can be rendered, otherwise false.
  129790. * @param mesh The mesh to render
  129791. * @param material The material used on the mesh
  129792. * @returns true if it can be rendered otherwise false
  129793. */
  129794. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129795. /**
  129796. * Returns true if the mesh should render, otherwise false.
  129797. * @param mesh The mesh to render
  129798. * @returns true if it should render otherwise false
  129799. */
  129800. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  129801. /**
  129802. * Renders the submesh passed in parameter to the generation map.
  129803. */
  129804. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  129805. /**
  129806. * Defines whether the current material of the mesh should be use to render the effect.
  129807. * @param mesh defines the current mesh to render
  129808. */
  129809. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129810. /**
  129811. * Rebuild the required buffers.
  129812. * @hidden Internal use only.
  129813. */
  129814. _rebuild(): void;
  129815. /**
  129816. * Dispose only the render target textures and post process.
  129817. */
  129818. private _disposeTextureAndPostProcesses;
  129819. /**
  129820. * Dispose the highlight layer and free resources.
  129821. */
  129822. dispose(): void;
  129823. /**
  129824. * Gets the class name of the effect layer
  129825. * @returns the string with the class name of the effect layer
  129826. */
  129827. getClassName(): string;
  129828. /**
  129829. * Creates an effect layer from parsed effect layer data
  129830. * @param parsedEffectLayer defines effect layer data
  129831. * @param scene defines the current scene
  129832. * @param rootUrl defines the root URL containing the effect layer information
  129833. * @returns a parsed effect Layer
  129834. */
  129835. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  129836. }
  129837. }
  129838. declare module BABYLON {
  129839. interface AbstractScene {
  129840. /**
  129841. * The list of effect layers (highlights/glow) added to the scene
  129842. * @see http://doc.babylonjs.com/how_to/highlight_layer
  129843. * @see http://doc.babylonjs.com/how_to/glow_layer
  129844. */
  129845. effectLayers: Array<EffectLayer>;
  129846. /**
  129847. * Removes the given effect layer from this scene.
  129848. * @param toRemove defines the effect layer to remove
  129849. * @returns the index of the removed effect layer
  129850. */
  129851. removeEffectLayer(toRemove: EffectLayer): number;
  129852. /**
  129853. * Adds the given effect layer to this scene
  129854. * @param newEffectLayer defines the effect layer to add
  129855. */
  129856. addEffectLayer(newEffectLayer: EffectLayer): void;
  129857. }
  129858. /**
  129859. * Defines the layer scene component responsible to manage any effect layers
  129860. * in a given scene.
  129861. */
  129862. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  129863. /**
  129864. * The component name helpfull to identify the component in the list of scene components.
  129865. */
  129866. readonly name: string;
  129867. /**
  129868. * The scene the component belongs to.
  129869. */
  129870. scene: Scene;
  129871. private _engine;
  129872. private _renderEffects;
  129873. private _needStencil;
  129874. private _previousStencilState;
  129875. /**
  129876. * Creates a new instance of the component for the given scene
  129877. * @param scene Defines the scene to register the component in
  129878. */
  129879. constructor(scene: Scene);
  129880. /**
  129881. * Registers the component in a given scene
  129882. */
  129883. register(): void;
  129884. /**
  129885. * Rebuilds the elements related to this component in case of
  129886. * context lost for instance.
  129887. */
  129888. rebuild(): void;
  129889. /**
  129890. * Serializes the component data to the specified json object
  129891. * @param serializationObject The object to serialize to
  129892. */
  129893. serialize(serializationObject: any): void;
  129894. /**
  129895. * Adds all the elements from the container to the scene
  129896. * @param container the container holding the elements
  129897. */
  129898. addFromContainer(container: AbstractScene): void;
  129899. /**
  129900. * Removes all the elements in the container from the scene
  129901. * @param container contains the elements to remove
  129902. * @param dispose if the removed element should be disposed (default: false)
  129903. */
  129904. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129905. /**
  129906. * Disposes the component and the associated ressources.
  129907. */
  129908. dispose(): void;
  129909. private _isReadyForMesh;
  129910. private _renderMainTexture;
  129911. private _setStencil;
  129912. private _setStencilBack;
  129913. private _draw;
  129914. private _drawCamera;
  129915. private _drawRenderingGroup;
  129916. }
  129917. }
  129918. declare module BABYLON {
  129919. /** @hidden */
  129920. export var glowMapMergePixelShader: {
  129921. name: string;
  129922. shader: string;
  129923. };
  129924. }
  129925. declare module BABYLON {
  129926. /** @hidden */
  129927. export var glowMapMergeVertexShader: {
  129928. name: string;
  129929. shader: string;
  129930. };
  129931. }
  129932. declare module BABYLON {
  129933. interface AbstractScene {
  129934. /**
  129935. * Return a the first highlight layer of the scene with a given name.
  129936. * @param name The name of the highlight layer to look for.
  129937. * @return The highlight layer if found otherwise null.
  129938. */
  129939. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  129940. }
  129941. /**
  129942. * Glow layer options. This helps customizing the behaviour
  129943. * of the glow layer.
  129944. */
  129945. export interface IGlowLayerOptions {
  129946. /**
  129947. * Multiplication factor apply to the canvas size to compute the render target size
  129948. * used to generated the glowing objects (the smaller the faster).
  129949. */
  129950. mainTextureRatio: number;
  129951. /**
  129952. * Enforces a fixed size texture to ensure resize independant blur.
  129953. */
  129954. mainTextureFixedSize?: number;
  129955. /**
  129956. * How big is the kernel of the blur texture.
  129957. */
  129958. blurKernelSize: number;
  129959. /**
  129960. * The camera attached to the layer.
  129961. */
  129962. camera: Nullable<Camera>;
  129963. /**
  129964. * Enable MSAA by chosing the number of samples.
  129965. */
  129966. mainTextureSamples?: number;
  129967. /**
  129968. * The rendering group to draw the layer in.
  129969. */
  129970. renderingGroupId: number;
  129971. }
  129972. /**
  129973. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  129974. *
  129975. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  129976. *
  129977. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  129978. */
  129979. export class GlowLayer extends EffectLayer {
  129980. /**
  129981. * Effect Name of the layer.
  129982. */
  129983. static readonly EffectName: string;
  129984. /**
  129985. * The default blur kernel size used for the glow.
  129986. */
  129987. static DefaultBlurKernelSize: number;
  129988. /**
  129989. * The default texture size ratio used for the glow.
  129990. */
  129991. static DefaultTextureRatio: number;
  129992. /**
  129993. * Sets the kernel size of the blur.
  129994. */
  129995. set blurKernelSize(value: number);
  129996. /**
  129997. * Gets the kernel size of the blur.
  129998. */
  129999. get blurKernelSize(): number;
  130000. /**
  130001. * Sets the glow intensity.
  130002. */
  130003. set intensity(value: number);
  130004. /**
  130005. * Gets the glow intensity.
  130006. */
  130007. get intensity(): number;
  130008. private _options;
  130009. private _intensity;
  130010. private _horizontalBlurPostprocess1;
  130011. private _verticalBlurPostprocess1;
  130012. private _horizontalBlurPostprocess2;
  130013. private _verticalBlurPostprocess2;
  130014. private _blurTexture1;
  130015. private _blurTexture2;
  130016. private _postProcesses1;
  130017. private _postProcesses2;
  130018. private _includedOnlyMeshes;
  130019. private _excludedMeshes;
  130020. private _meshesUsingTheirOwnMaterials;
  130021. /**
  130022. * Callback used to let the user override the color selection on a per mesh basis
  130023. */
  130024. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  130025. /**
  130026. * Callback used to let the user override the texture selection on a per mesh basis
  130027. */
  130028. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  130029. /**
  130030. * Instantiates a new glow Layer and references it to the scene.
  130031. * @param name The name of the layer
  130032. * @param scene The scene to use the layer in
  130033. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  130034. */
  130035. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  130036. /**
  130037. * Get the effect name of the layer.
  130038. * @return The effect name
  130039. */
  130040. getEffectName(): string;
  130041. /**
  130042. * Create the merge effect. This is the shader use to blit the information back
  130043. * to the main canvas at the end of the scene rendering.
  130044. */
  130045. protected _createMergeEffect(): Effect;
  130046. /**
  130047. * Creates the render target textures and post processes used in the glow layer.
  130048. */
  130049. protected _createTextureAndPostProcesses(): void;
  130050. /**
  130051. * Checks for the readiness of the element composing the layer.
  130052. * @param subMesh the mesh to check for
  130053. * @param useInstances specify wether or not to use instances to render the mesh
  130054. * @param emissiveTexture the associated emissive texture used to generate the glow
  130055. * @return true if ready otherwise, false
  130056. */
  130057. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130058. /**
  130059. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  130060. */
  130061. needStencil(): boolean;
  130062. /**
  130063. * Returns true if the mesh can be rendered, otherwise false.
  130064. * @param mesh The mesh to render
  130065. * @param material The material used on the mesh
  130066. * @returns true if it can be rendered otherwise false
  130067. */
  130068. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  130069. /**
  130070. * Implementation specific of rendering the generating effect on the main canvas.
  130071. * @param effect The effect used to render through
  130072. */
  130073. protected _internalRender(effect: Effect): void;
  130074. /**
  130075. * Sets the required values for both the emissive texture and and the main color.
  130076. */
  130077. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130078. /**
  130079. * Returns true if the mesh should render, otherwise false.
  130080. * @param mesh The mesh to render
  130081. * @returns true if it should render otherwise false
  130082. */
  130083. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130084. /**
  130085. * Adds specific effects defines.
  130086. * @param defines The defines to add specifics to.
  130087. */
  130088. protected _addCustomEffectDefines(defines: string[]): void;
  130089. /**
  130090. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  130091. * @param mesh The mesh to exclude from the glow layer
  130092. */
  130093. addExcludedMesh(mesh: Mesh): void;
  130094. /**
  130095. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  130096. * @param mesh The mesh to remove
  130097. */
  130098. removeExcludedMesh(mesh: Mesh): void;
  130099. /**
  130100. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  130101. * @param mesh The mesh to include in the glow layer
  130102. */
  130103. addIncludedOnlyMesh(mesh: Mesh): void;
  130104. /**
  130105. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  130106. * @param mesh The mesh to remove
  130107. */
  130108. removeIncludedOnlyMesh(mesh: Mesh): void;
  130109. /**
  130110. * Determine if a given mesh will be used in the glow layer
  130111. * @param mesh The mesh to test
  130112. * @returns true if the mesh will be highlighted by the current glow layer
  130113. */
  130114. hasMesh(mesh: AbstractMesh): boolean;
  130115. /**
  130116. * Defines whether the current material of the mesh should be use to render the effect.
  130117. * @param mesh defines the current mesh to render
  130118. */
  130119. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  130120. /**
  130121. * Add a mesh to be rendered through its own material and not with emissive only.
  130122. * @param mesh The mesh for which we need to use its material
  130123. */
  130124. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  130125. /**
  130126. * Remove a mesh from being rendered through its own material and not with emissive only.
  130127. * @param mesh The mesh for which we need to not use its material
  130128. */
  130129. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  130130. /**
  130131. * Free any resources and references associated to a mesh.
  130132. * Internal use
  130133. * @param mesh The mesh to free.
  130134. * @hidden
  130135. */
  130136. _disposeMesh(mesh: Mesh): void;
  130137. /**
  130138. * Gets the class name of the effect layer
  130139. * @returns the string with the class name of the effect layer
  130140. */
  130141. getClassName(): string;
  130142. /**
  130143. * Serializes this glow layer
  130144. * @returns a serialized glow layer object
  130145. */
  130146. serialize(): any;
  130147. /**
  130148. * Creates a Glow Layer from parsed glow layer data
  130149. * @param parsedGlowLayer defines glow layer data
  130150. * @param scene defines the current scene
  130151. * @param rootUrl defines the root URL containing the glow layer information
  130152. * @returns a parsed Glow Layer
  130153. */
  130154. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  130155. }
  130156. }
  130157. declare module BABYLON {
  130158. /** @hidden */
  130159. export var glowBlurPostProcessPixelShader: {
  130160. name: string;
  130161. shader: string;
  130162. };
  130163. }
  130164. declare module BABYLON {
  130165. interface AbstractScene {
  130166. /**
  130167. * Return a the first highlight layer of the scene with a given name.
  130168. * @param name The name of the highlight layer to look for.
  130169. * @return The highlight layer if found otherwise null.
  130170. */
  130171. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  130172. }
  130173. /**
  130174. * Highlight layer options. This helps customizing the behaviour
  130175. * of the highlight layer.
  130176. */
  130177. export interface IHighlightLayerOptions {
  130178. /**
  130179. * Multiplication factor apply to the canvas size to compute the render target size
  130180. * used to generated the glowing objects (the smaller the faster).
  130181. */
  130182. mainTextureRatio: number;
  130183. /**
  130184. * Enforces a fixed size texture to ensure resize independant blur.
  130185. */
  130186. mainTextureFixedSize?: number;
  130187. /**
  130188. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  130189. * of the picture to blur (the smaller the faster).
  130190. */
  130191. blurTextureSizeRatio: number;
  130192. /**
  130193. * How big in texel of the blur texture is the vertical blur.
  130194. */
  130195. blurVerticalSize: number;
  130196. /**
  130197. * How big in texel of the blur texture is the horizontal blur.
  130198. */
  130199. blurHorizontalSize: number;
  130200. /**
  130201. * Alpha blending mode used to apply the blur. Default is combine.
  130202. */
  130203. alphaBlendingMode: number;
  130204. /**
  130205. * The camera attached to the layer.
  130206. */
  130207. camera: Nullable<Camera>;
  130208. /**
  130209. * Should we display highlight as a solid stroke?
  130210. */
  130211. isStroke?: boolean;
  130212. /**
  130213. * The rendering group to draw the layer in.
  130214. */
  130215. renderingGroupId: number;
  130216. }
  130217. /**
  130218. * The highlight layer Helps adding a glow effect around a mesh.
  130219. *
  130220. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  130221. * glowy meshes to your scene.
  130222. *
  130223. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  130224. */
  130225. export class HighlightLayer extends EffectLayer {
  130226. name: string;
  130227. /**
  130228. * Effect Name of the highlight layer.
  130229. */
  130230. static readonly EffectName: string;
  130231. /**
  130232. * The neutral color used during the preparation of the glow effect.
  130233. * This is black by default as the blend operation is a blend operation.
  130234. */
  130235. static NeutralColor: Color4;
  130236. /**
  130237. * Stencil value used for glowing meshes.
  130238. */
  130239. static GlowingMeshStencilReference: number;
  130240. /**
  130241. * Stencil value used for the other meshes in the scene.
  130242. */
  130243. static NormalMeshStencilReference: number;
  130244. /**
  130245. * Specifies whether or not the inner glow is ACTIVE in the layer.
  130246. */
  130247. innerGlow: boolean;
  130248. /**
  130249. * Specifies whether or not the outer glow is ACTIVE in the layer.
  130250. */
  130251. outerGlow: boolean;
  130252. /**
  130253. * Specifies the horizontal size of the blur.
  130254. */
  130255. set blurHorizontalSize(value: number);
  130256. /**
  130257. * Specifies the vertical size of the blur.
  130258. */
  130259. set blurVerticalSize(value: number);
  130260. /**
  130261. * Gets the horizontal size of the blur.
  130262. */
  130263. get blurHorizontalSize(): number;
  130264. /**
  130265. * Gets the vertical size of the blur.
  130266. */
  130267. get blurVerticalSize(): number;
  130268. /**
  130269. * An event triggered when the highlight layer is being blurred.
  130270. */
  130271. onBeforeBlurObservable: Observable<HighlightLayer>;
  130272. /**
  130273. * An event triggered when the highlight layer has been blurred.
  130274. */
  130275. onAfterBlurObservable: Observable<HighlightLayer>;
  130276. private _instanceGlowingMeshStencilReference;
  130277. private _options;
  130278. private _downSamplePostprocess;
  130279. private _horizontalBlurPostprocess;
  130280. private _verticalBlurPostprocess;
  130281. private _blurTexture;
  130282. private _meshes;
  130283. private _excludedMeshes;
  130284. /**
  130285. * Instantiates a new highlight Layer and references it to the scene..
  130286. * @param name The name of the layer
  130287. * @param scene The scene to use the layer in
  130288. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  130289. */
  130290. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  130291. /**
  130292. * Get the effect name of the layer.
  130293. * @return The effect name
  130294. */
  130295. getEffectName(): string;
  130296. /**
  130297. * Create the merge effect. This is the shader use to blit the information back
  130298. * to the main canvas at the end of the scene rendering.
  130299. */
  130300. protected _createMergeEffect(): Effect;
  130301. /**
  130302. * Creates the render target textures and post processes used in the highlight layer.
  130303. */
  130304. protected _createTextureAndPostProcesses(): void;
  130305. /**
  130306. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  130307. */
  130308. needStencil(): boolean;
  130309. /**
  130310. * Checks for the readiness of the element composing the layer.
  130311. * @param subMesh the mesh to check for
  130312. * @param useInstances specify wether or not to use instances to render the mesh
  130313. * @param emissiveTexture the associated emissive texture used to generate the glow
  130314. * @return true if ready otherwise, false
  130315. */
  130316. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130317. /**
  130318. * Implementation specific of rendering the generating effect on the main canvas.
  130319. * @param effect The effect used to render through
  130320. */
  130321. protected _internalRender(effect: Effect): void;
  130322. /**
  130323. * Returns true if the layer contains information to display, otherwise false.
  130324. */
  130325. shouldRender(): boolean;
  130326. /**
  130327. * Returns true if the mesh should render, otherwise false.
  130328. * @param mesh The mesh to render
  130329. * @returns true if it should render otherwise false
  130330. */
  130331. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130332. /**
  130333. * Adds specific effects defines.
  130334. * @param defines The defines to add specifics to.
  130335. */
  130336. protected _addCustomEffectDefines(defines: string[]): void;
  130337. /**
  130338. * Sets the required values for both the emissive texture and and the main color.
  130339. */
  130340. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130341. /**
  130342. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  130343. * @param mesh The mesh to exclude from the highlight layer
  130344. */
  130345. addExcludedMesh(mesh: Mesh): void;
  130346. /**
  130347. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  130348. * @param mesh The mesh to highlight
  130349. */
  130350. removeExcludedMesh(mesh: Mesh): void;
  130351. /**
  130352. * Determine if a given mesh will be highlighted by the current HighlightLayer
  130353. * @param mesh mesh to test
  130354. * @returns true if the mesh will be highlighted by the current HighlightLayer
  130355. */
  130356. hasMesh(mesh: AbstractMesh): boolean;
  130357. /**
  130358. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  130359. * @param mesh The mesh to highlight
  130360. * @param color The color of the highlight
  130361. * @param glowEmissiveOnly Extract the glow from the emissive texture
  130362. */
  130363. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  130364. /**
  130365. * Remove a mesh from the highlight layer in order to make it stop glowing.
  130366. * @param mesh The mesh to highlight
  130367. */
  130368. removeMesh(mesh: Mesh): void;
  130369. /**
  130370. * Remove all the meshes currently referenced in the highlight layer
  130371. */
  130372. removeAllMeshes(): void;
  130373. /**
  130374. * Force the stencil to the normal expected value for none glowing parts
  130375. */
  130376. private _defaultStencilReference;
  130377. /**
  130378. * Free any resources and references associated to a mesh.
  130379. * Internal use
  130380. * @param mesh The mesh to free.
  130381. * @hidden
  130382. */
  130383. _disposeMesh(mesh: Mesh): void;
  130384. /**
  130385. * Dispose the highlight layer and free resources.
  130386. */
  130387. dispose(): void;
  130388. /**
  130389. * Gets the class name of the effect layer
  130390. * @returns the string with the class name of the effect layer
  130391. */
  130392. getClassName(): string;
  130393. /**
  130394. * Serializes this Highlight layer
  130395. * @returns a serialized Highlight layer object
  130396. */
  130397. serialize(): any;
  130398. /**
  130399. * Creates a Highlight layer from parsed Highlight layer data
  130400. * @param parsedHightlightLayer defines the Highlight layer data
  130401. * @param scene defines the current scene
  130402. * @param rootUrl defines the root URL containing the Highlight layer information
  130403. * @returns a parsed Highlight layer
  130404. */
  130405. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  130406. }
  130407. }
  130408. declare module BABYLON {
  130409. interface AbstractScene {
  130410. /**
  130411. * The list of layers (background and foreground) of the scene
  130412. */
  130413. layers: Array<Layer>;
  130414. }
  130415. /**
  130416. * Defines the layer scene component responsible to manage any layers
  130417. * in a given scene.
  130418. */
  130419. export class LayerSceneComponent implements ISceneComponent {
  130420. /**
  130421. * The component name helpfull to identify the component in the list of scene components.
  130422. */
  130423. readonly name: string;
  130424. /**
  130425. * The scene the component belongs to.
  130426. */
  130427. scene: Scene;
  130428. private _engine;
  130429. /**
  130430. * Creates a new instance of the component for the given scene
  130431. * @param scene Defines the scene to register the component in
  130432. */
  130433. constructor(scene: Scene);
  130434. /**
  130435. * Registers the component in a given scene
  130436. */
  130437. register(): void;
  130438. /**
  130439. * Rebuilds the elements related to this component in case of
  130440. * context lost for instance.
  130441. */
  130442. rebuild(): void;
  130443. /**
  130444. * Disposes the component and the associated ressources.
  130445. */
  130446. dispose(): void;
  130447. private _draw;
  130448. private _drawCameraPredicate;
  130449. private _drawCameraBackground;
  130450. private _drawCameraForeground;
  130451. private _drawRenderTargetPredicate;
  130452. private _drawRenderTargetBackground;
  130453. private _drawRenderTargetForeground;
  130454. /**
  130455. * Adds all the elements from the container to the scene
  130456. * @param container the container holding the elements
  130457. */
  130458. addFromContainer(container: AbstractScene): void;
  130459. /**
  130460. * Removes all the elements in the container from the scene
  130461. * @param container contains the elements to remove
  130462. * @param dispose if the removed element should be disposed (default: false)
  130463. */
  130464. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130465. }
  130466. }
  130467. declare module BABYLON {
  130468. /** @hidden */
  130469. export var layerPixelShader: {
  130470. name: string;
  130471. shader: string;
  130472. };
  130473. }
  130474. declare module BABYLON {
  130475. /** @hidden */
  130476. export var layerVertexShader: {
  130477. name: string;
  130478. shader: string;
  130479. };
  130480. }
  130481. declare module BABYLON {
  130482. /**
  130483. * This represents a full screen 2d layer.
  130484. * This can be useful to display a picture in the background of your scene for instance.
  130485. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130486. */
  130487. export class Layer {
  130488. /**
  130489. * Define the name of the layer.
  130490. */
  130491. name: string;
  130492. /**
  130493. * Define the texture the layer should display.
  130494. */
  130495. texture: Nullable<Texture>;
  130496. /**
  130497. * Is the layer in background or foreground.
  130498. */
  130499. isBackground: boolean;
  130500. /**
  130501. * Define the color of the layer (instead of texture).
  130502. */
  130503. color: Color4;
  130504. /**
  130505. * Define the scale of the layer in order to zoom in out of the texture.
  130506. */
  130507. scale: Vector2;
  130508. /**
  130509. * Define an offset for the layer in order to shift the texture.
  130510. */
  130511. offset: Vector2;
  130512. /**
  130513. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  130514. */
  130515. alphaBlendingMode: number;
  130516. /**
  130517. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  130518. * Alpha test will not mix with the background color in case of transparency.
  130519. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  130520. */
  130521. alphaTest: boolean;
  130522. /**
  130523. * Define a mask to restrict the layer to only some of the scene cameras.
  130524. */
  130525. layerMask: number;
  130526. /**
  130527. * Define the list of render target the layer is visible into.
  130528. */
  130529. renderTargetTextures: RenderTargetTexture[];
  130530. /**
  130531. * Define if the layer is only used in renderTarget or if it also
  130532. * renders in the main frame buffer of the canvas.
  130533. */
  130534. renderOnlyInRenderTargetTextures: boolean;
  130535. private _scene;
  130536. private _vertexBuffers;
  130537. private _indexBuffer;
  130538. private _effect;
  130539. private _previousDefines;
  130540. /**
  130541. * An event triggered when the layer is disposed.
  130542. */
  130543. onDisposeObservable: Observable<Layer>;
  130544. private _onDisposeObserver;
  130545. /**
  130546. * Back compatibility with callback before the onDisposeObservable existed.
  130547. * The set callback will be triggered when the layer has been disposed.
  130548. */
  130549. set onDispose(callback: () => void);
  130550. /**
  130551. * An event triggered before rendering the scene
  130552. */
  130553. onBeforeRenderObservable: Observable<Layer>;
  130554. private _onBeforeRenderObserver;
  130555. /**
  130556. * Back compatibility with callback before the onBeforeRenderObservable existed.
  130557. * The set callback will be triggered just before rendering the layer.
  130558. */
  130559. set onBeforeRender(callback: () => void);
  130560. /**
  130561. * An event triggered after rendering the scene
  130562. */
  130563. onAfterRenderObservable: Observable<Layer>;
  130564. private _onAfterRenderObserver;
  130565. /**
  130566. * Back compatibility with callback before the onAfterRenderObservable existed.
  130567. * The set callback will be triggered just after rendering the layer.
  130568. */
  130569. set onAfterRender(callback: () => void);
  130570. /**
  130571. * Instantiates a new layer.
  130572. * This represents a full screen 2d layer.
  130573. * This can be useful to display a picture in the background of your scene for instance.
  130574. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130575. * @param name Define the name of the layer in the scene
  130576. * @param imgUrl Define the url of the texture to display in the layer
  130577. * @param scene Define the scene the layer belongs to
  130578. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  130579. * @param color Defines a color for the layer
  130580. */
  130581. constructor(
  130582. /**
  130583. * Define the name of the layer.
  130584. */
  130585. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  130586. private _createIndexBuffer;
  130587. /** @hidden */
  130588. _rebuild(): void;
  130589. /**
  130590. * Renders the layer in the scene.
  130591. */
  130592. render(): void;
  130593. /**
  130594. * Disposes and releases the associated ressources.
  130595. */
  130596. dispose(): void;
  130597. }
  130598. }
  130599. declare module BABYLON {
  130600. /** @hidden */
  130601. export var lensFlarePixelShader: {
  130602. name: string;
  130603. shader: string;
  130604. };
  130605. }
  130606. declare module BABYLON {
  130607. /** @hidden */
  130608. export var lensFlareVertexShader: {
  130609. name: string;
  130610. shader: string;
  130611. };
  130612. }
  130613. declare module BABYLON {
  130614. /**
  130615. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130616. * It is usually composed of several `lensFlare`.
  130617. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130618. */
  130619. export class LensFlareSystem {
  130620. /**
  130621. * Define the name of the lens flare system
  130622. */
  130623. name: string;
  130624. /**
  130625. * List of lens flares used in this system.
  130626. */
  130627. lensFlares: LensFlare[];
  130628. /**
  130629. * Define a limit from the border the lens flare can be visible.
  130630. */
  130631. borderLimit: number;
  130632. /**
  130633. * Define a viewport border we do not want to see the lens flare in.
  130634. */
  130635. viewportBorder: number;
  130636. /**
  130637. * Define a predicate which could limit the list of meshes able to occlude the effect.
  130638. */
  130639. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130640. /**
  130641. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  130642. */
  130643. layerMask: number;
  130644. /**
  130645. * Define the id of the lens flare system in the scene.
  130646. * (equal to name by default)
  130647. */
  130648. id: string;
  130649. private _scene;
  130650. private _emitter;
  130651. private _vertexBuffers;
  130652. private _indexBuffer;
  130653. private _effect;
  130654. private _positionX;
  130655. private _positionY;
  130656. private _isEnabled;
  130657. /** @hidden */
  130658. static _SceneComponentInitialization: (scene: Scene) => void;
  130659. /**
  130660. * Instantiates a lens flare system.
  130661. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130662. * It is usually composed of several `lensFlare`.
  130663. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130664. * @param name Define the name of the lens flare system in the scene
  130665. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  130666. * @param scene Define the scene the lens flare system belongs to
  130667. */
  130668. constructor(
  130669. /**
  130670. * Define the name of the lens flare system
  130671. */
  130672. name: string, emitter: any, scene: Scene);
  130673. /**
  130674. * Define if the lens flare system is enabled.
  130675. */
  130676. get isEnabled(): boolean;
  130677. set isEnabled(value: boolean);
  130678. /**
  130679. * Get the scene the effects belongs to.
  130680. * @returns the scene holding the lens flare system
  130681. */
  130682. getScene(): Scene;
  130683. /**
  130684. * Get the emitter of the lens flare system.
  130685. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130686. * @returns the emitter of the lens flare system
  130687. */
  130688. getEmitter(): any;
  130689. /**
  130690. * Set the emitter of the lens flare system.
  130691. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130692. * @param newEmitter Define the new emitter of the system
  130693. */
  130694. setEmitter(newEmitter: any): void;
  130695. /**
  130696. * Get the lens flare system emitter position.
  130697. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  130698. * @returns the position
  130699. */
  130700. getEmitterPosition(): Vector3;
  130701. /**
  130702. * @hidden
  130703. */
  130704. computeEffectivePosition(globalViewport: Viewport): boolean;
  130705. /** @hidden */
  130706. _isVisible(): boolean;
  130707. /**
  130708. * @hidden
  130709. */
  130710. render(): boolean;
  130711. /**
  130712. * Dispose and release the lens flare with its associated resources.
  130713. */
  130714. dispose(): void;
  130715. /**
  130716. * Parse a lens flare system from a JSON repressentation
  130717. * @param parsedLensFlareSystem Define the JSON to parse
  130718. * @param scene Define the scene the parsed system should be instantiated in
  130719. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  130720. * @returns the parsed system
  130721. */
  130722. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  130723. /**
  130724. * Serialize the current Lens Flare System into a JSON representation.
  130725. * @returns the serialized JSON
  130726. */
  130727. serialize(): any;
  130728. }
  130729. }
  130730. declare module BABYLON {
  130731. /**
  130732. * This represents one of the lens effect in a `lensFlareSystem`.
  130733. * It controls one of the indiviual texture used in the effect.
  130734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130735. */
  130736. export class LensFlare {
  130737. /**
  130738. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130739. */
  130740. size: number;
  130741. /**
  130742. * 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.
  130743. */
  130744. position: number;
  130745. /**
  130746. * Define the lens color.
  130747. */
  130748. color: Color3;
  130749. /**
  130750. * Define the lens texture.
  130751. */
  130752. texture: Nullable<Texture>;
  130753. /**
  130754. * Define the alpha mode to render this particular lens.
  130755. */
  130756. alphaMode: number;
  130757. private _system;
  130758. /**
  130759. * Creates a new Lens Flare.
  130760. * This represents one of the lens effect in a `lensFlareSystem`.
  130761. * It controls one of the indiviual texture used in the effect.
  130762. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130763. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  130764. * @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.
  130765. * @param color Define the lens color
  130766. * @param imgUrl Define the lens texture url
  130767. * @param system Define the `lensFlareSystem` this flare is part of
  130768. * @returns The newly created Lens Flare
  130769. */
  130770. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  130771. /**
  130772. * Instantiates a new Lens Flare.
  130773. * This represents one of the lens effect in a `lensFlareSystem`.
  130774. * It controls one of the indiviual texture used in the effect.
  130775. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130776. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  130777. * @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.
  130778. * @param color Define the lens color
  130779. * @param imgUrl Define the lens texture url
  130780. * @param system Define the `lensFlareSystem` this flare is part of
  130781. */
  130782. constructor(
  130783. /**
  130784. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130785. */
  130786. size: number,
  130787. /**
  130788. * 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.
  130789. */
  130790. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  130791. /**
  130792. * Dispose and release the lens flare with its associated resources.
  130793. */
  130794. dispose(): void;
  130795. }
  130796. }
  130797. declare module BABYLON {
  130798. interface AbstractScene {
  130799. /**
  130800. * The list of lens flare system added to the scene
  130801. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130802. */
  130803. lensFlareSystems: Array<LensFlareSystem>;
  130804. /**
  130805. * Removes the given lens flare system from this scene.
  130806. * @param toRemove The lens flare system to remove
  130807. * @returns The index of the removed lens flare system
  130808. */
  130809. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  130810. /**
  130811. * Adds the given lens flare system to this scene
  130812. * @param newLensFlareSystem The lens flare system to add
  130813. */
  130814. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  130815. /**
  130816. * Gets a lens flare system using its name
  130817. * @param name defines the name to look for
  130818. * @returns the lens flare system or null if not found
  130819. */
  130820. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  130821. /**
  130822. * Gets a lens flare system using its id
  130823. * @param id defines the id to look for
  130824. * @returns the lens flare system or null if not found
  130825. */
  130826. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  130827. }
  130828. /**
  130829. * Defines the lens flare scene component responsible to manage any lens flares
  130830. * in a given scene.
  130831. */
  130832. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  130833. /**
  130834. * The component name helpfull to identify the component in the list of scene components.
  130835. */
  130836. readonly name: string;
  130837. /**
  130838. * The scene the component belongs to.
  130839. */
  130840. scene: Scene;
  130841. /**
  130842. * Creates a new instance of the component for the given scene
  130843. * @param scene Defines the scene to register the component in
  130844. */
  130845. constructor(scene: Scene);
  130846. /**
  130847. * Registers the component in a given scene
  130848. */
  130849. register(): void;
  130850. /**
  130851. * Rebuilds the elements related to this component in case of
  130852. * context lost for instance.
  130853. */
  130854. rebuild(): void;
  130855. /**
  130856. * Adds all the elements from the container to the scene
  130857. * @param container the container holding the elements
  130858. */
  130859. addFromContainer(container: AbstractScene): void;
  130860. /**
  130861. * Removes all the elements in the container from the scene
  130862. * @param container contains the elements to remove
  130863. * @param dispose if the removed element should be disposed (default: false)
  130864. */
  130865. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130866. /**
  130867. * Serializes the component data to the specified json object
  130868. * @param serializationObject The object to serialize to
  130869. */
  130870. serialize(serializationObject: any): void;
  130871. /**
  130872. * Disposes the component and the associated ressources.
  130873. */
  130874. dispose(): void;
  130875. private _draw;
  130876. }
  130877. }
  130878. declare module BABYLON {
  130879. /** @hidden */
  130880. export var depthPixelShader: {
  130881. name: string;
  130882. shader: string;
  130883. };
  130884. }
  130885. declare module BABYLON {
  130886. /** @hidden */
  130887. export var depthVertexShader: {
  130888. name: string;
  130889. shader: string;
  130890. };
  130891. }
  130892. declare module BABYLON {
  130893. /**
  130894. * This represents a depth renderer in Babylon.
  130895. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130896. */
  130897. export class DepthRenderer {
  130898. private _scene;
  130899. private _depthMap;
  130900. private _effect;
  130901. private readonly _storeNonLinearDepth;
  130902. private readonly _clearColor;
  130903. /** Get if the depth renderer is using packed depth or not */
  130904. readonly isPacked: boolean;
  130905. private _cachedDefines;
  130906. private _camera;
  130907. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  130908. enabled: boolean;
  130909. /**
  130910. * Specifiess that the depth renderer will only be used within
  130911. * the camera it is created for.
  130912. * This can help forcing its rendering during the camera processing.
  130913. */
  130914. useOnlyInActiveCamera: boolean;
  130915. /** @hidden */
  130916. static _SceneComponentInitialization: (scene: Scene) => void;
  130917. /**
  130918. * Instantiates a depth renderer
  130919. * @param scene The scene the renderer belongs to
  130920. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130921. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130922. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130923. */
  130924. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130925. /**
  130926. * Creates the depth rendering effect and checks if the effect is ready.
  130927. * @param subMesh The submesh to be used to render the depth map of
  130928. * @param useInstances If multiple world instances should be used
  130929. * @returns if the depth renderer is ready to render the depth map
  130930. */
  130931. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130932. /**
  130933. * Gets the texture which the depth map will be written to.
  130934. * @returns The depth map texture
  130935. */
  130936. getDepthMap(): RenderTargetTexture;
  130937. /**
  130938. * Disposes of the depth renderer.
  130939. */
  130940. dispose(): void;
  130941. }
  130942. }
  130943. declare module BABYLON {
  130944. /** @hidden */
  130945. export var minmaxReduxPixelShader: {
  130946. name: string;
  130947. shader: string;
  130948. };
  130949. }
  130950. declare module BABYLON {
  130951. /**
  130952. * This class computes a min/max reduction from a texture: it means it computes the minimum
  130953. * and maximum values from all values of the texture.
  130954. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  130955. * The source values are read from the red channel of the texture.
  130956. */
  130957. export class MinMaxReducer {
  130958. /**
  130959. * Observable triggered when the computation has been performed
  130960. */
  130961. onAfterReductionPerformed: Observable<{
  130962. min: number;
  130963. max: number;
  130964. }>;
  130965. protected _camera: Camera;
  130966. protected _sourceTexture: Nullable<RenderTargetTexture>;
  130967. protected _reductionSteps: Nullable<Array<PostProcess>>;
  130968. protected _postProcessManager: PostProcessManager;
  130969. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  130970. protected _forceFullscreenViewport: boolean;
  130971. /**
  130972. * Creates a min/max reducer
  130973. * @param camera The camera to use for the post processes
  130974. */
  130975. constructor(camera: Camera);
  130976. /**
  130977. * Gets the texture used to read the values from.
  130978. */
  130979. get sourceTexture(): Nullable<RenderTargetTexture>;
  130980. /**
  130981. * Sets the source texture to read the values from.
  130982. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  130983. * because in such textures '1' value must not be taken into account to compute the maximum
  130984. * as this value is used to clear the texture.
  130985. * Note that the computation is not activated by calling this function, you must call activate() for that!
  130986. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  130987. * @param depthRedux Indicates if the texture is a depth texture or not
  130988. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  130989. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130990. */
  130991. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130992. /**
  130993. * Defines the refresh rate of the computation.
  130994. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130995. */
  130996. get refreshRate(): number;
  130997. set refreshRate(value: number);
  130998. protected _activated: boolean;
  130999. /**
  131000. * Gets the activation status of the reducer
  131001. */
  131002. get activated(): boolean;
  131003. /**
  131004. * Activates the reduction computation.
  131005. * When activated, the observers registered in onAfterReductionPerformed are
  131006. * called after the compuation is performed
  131007. */
  131008. activate(): void;
  131009. /**
  131010. * Deactivates the reduction computation.
  131011. */
  131012. deactivate(): void;
  131013. /**
  131014. * Disposes the min/max reducer
  131015. * @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.
  131016. */
  131017. dispose(disposeAll?: boolean): void;
  131018. }
  131019. }
  131020. declare module BABYLON {
  131021. /**
  131022. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  131023. */
  131024. export class DepthReducer extends MinMaxReducer {
  131025. private _depthRenderer;
  131026. private _depthRendererId;
  131027. /**
  131028. * Gets the depth renderer used for the computation.
  131029. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  131030. */
  131031. get depthRenderer(): Nullable<DepthRenderer>;
  131032. /**
  131033. * Creates a depth reducer
  131034. * @param camera The camera used to render the depth texture
  131035. */
  131036. constructor(camera: Camera);
  131037. /**
  131038. * Sets the depth renderer to use to generate the depth map
  131039. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  131040. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  131041. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  131042. */
  131043. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  131044. /** @hidden */
  131045. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  131046. /**
  131047. * Activates the reduction computation.
  131048. * When activated, the observers registered in onAfterReductionPerformed are
  131049. * called after the compuation is performed
  131050. */
  131051. activate(): void;
  131052. /**
  131053. * Deactivates the reduction computation.
  131054. */
  131055. deactivate(): void;
  131056. /**
  131057. * Disposes the depth reducer
  131058. * @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.
  131059. */
  131060. dispose(disposeAll?: boolean): void;
  131061. }
  131062. }
  131063. declare module BABYLON {
  131064. /**
  131065. * A CSM implementation allowing casting shadows on large scenes.
  131066. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131067. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  131068. */
  131069. export class CascadedShadowGenerator extends ShadowGenerator {
  131070. private static readonly frustumCornersNDCSpace;
  131071. /**
  131072. * Name of the CSM class
  131073. */
  131074. static CLASSNAME: string;
  131075. /**
  131076. * Defines the default number of cascades used by the CSM.
  131077. */
  131078. static readonly DEFAULT_CASCADES_COUNT: number;
  131079. /**
  131080. * Defines the minimum number of cascades used by the CSM.
  131081. */
  131082. static readonly MIN_CASCADES_COUNT: number;
  131083. /**
  131084. * Defines the maximum number of cascades used by the CSM.
  131085. */
  131086. static readonly MAX_CASCADES_COUNT: number;
  131087. protected _validateFilter(filter: number): number;
  131088. /**
  131089. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  131090. */
  131091. penumbraDarkness: number;
  131092. private _numCascades;
  131093. /**
  131094. * Gets or set the number of cascades used by the CSM.
  131095. */
  131096. get numCascades(): number;
  131097. set numCascades(value: number);
  131098. /**
  131099. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  131100. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  131101. */
  131102. stabilizeCascades: boolean;
  131103. private _freezeShadowCastersBoundingInfo;
  131104. private _freezeShadowCastersBoundingInfoObservable;
  131105. /**
  131106. * Enables or disables the shadow casters bounding info computation.
  131107. * If your shadow casters don't move, you can disable this feature.
  131108. * If it is enabled, the bounding box computation is done every frame.
  131109. */
  131110. get freezeShadowCastersBoundingInfo(): boolean;
  131111. set freezeShadowCastersBoundingInfo(freeze: boolean);
  131112. private _scbiMin;
  131113. private _scbiMax;
  131114. protected _computeShadowCastersBoundingInfo(): void;
  131115. protected _shadowCastersBoundingInfo: BoundingInfo;
  131116. /**
  131117. * Gets or sets the shadow casters bounding info.
  131118. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  131119. * so that the system won't overwrite the bounds you provide
  131120. */
  131121. get shadowCastersBoundingInfo(): BoundingInfo;
  131122. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  131123. protected _breaksAreDirty: boolean;
  131124. protected _minDistance: number;
  131125. protected _maxDistance: number;
  131126. /**
  131127. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  131128. *
  131129. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  131130. * If you don't know these values, simply leave them to their defaults and don't call this function.
  131131. * @param min minimal distance for the breaks (default to 0.)
  131132. * @param max maximal distance for the breaks (default to 1.)
  131133. */
  131134. setMinMaxDistance(min: number, max: number): void;
  131135. /** Gets the minimal distance used in the cascade break computation */
  131136. get minDistance(): number;
  131137. /** Gets the maximal distance used in the cascade break computation */
  131138. get maxDistance(): number;
  131139. /**
  131140. * Gets the class name of that object
  131141. * @returns "CascadedShadowGenerator"
  131142. */
  131143. getClassName(): string;
  131144. private _cascadeMinExtents;
  131145. private _cascadeMaxExtents;
  131146. /**
  131147. * Gets a cascade minimum extents
  131148. * @param cascadeIndex index of the cascade
  131149. * @returns the minimum cascade extents
  131150. */
  131151. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  131152. /**
  131153. * Gets a cascade maximum extents
  131154. * @param cascadeIndex index of the cascade
  131155. * @returns the maximum cascade extents
  131156. */
  131157. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  131158. private _cascades;
  131159. private _currentLayer;
  131160. private _viewSpaceFrustumsZ;
  131161. private _viewMatrices;
  131162. private _projectionMatrices;
  131163. private _transformMatrices;
  131164. private _transformMatricesAsArray;
  131165. private _frustumLengths;
  131166. private _lightSizeUVCorrection;
  131167. private _depthCorrection;
  131168. private _frustumCornersWorldSpace;
  131169. private _frustumCenter;
  131170. private _shadowCameraPos;
  131171. private _shadowMaxZ;
  131172. /**
  131173. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  131174. * It defaults to camera.maxZ
  131175. */
  131176. get shadowMaxZ(): number;
  131177. /**
  131178. * Sets the shadow max z distance.
  131179. */
  131180. set shadowMaxZ(value: number);
  131181. protected _debug: boolean;
  131182. /**
  131183. * Gets or sets the debug flag.
  131184. * When enabled, the cascades are materialized by different colors on the screen.
  131185. */
  131186. get debug(): boolean;
  131187. set debug(dbg: boolean);
  131188. private _depthClamp;
  131189. /**
  131190. * Gets or sets the depth clamping value.
  131191. *
  131192. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  131193. * to account for the shadow casters far away.
  131194. *
  131195. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  131196. */
  131197. get depthClamp(): boolean;
  131198. set depthClamp(value: boolean);
  131199. private _cascadeBlendPercentage;
  131200. /**
  131201. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  131202. * It defaults to 0.1 (10% blending).
  131203. */
  131204. get cascadeBlendPercentage(): number;
  131205. set cascadeBlendPercentage(value: number);
  131206. private _lambda;
  131207. /**
  131208. * Gets or set the lambda parameter.
  131209. * This parameter is used to split the camera frustum and create the cascades.
  131210. * 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.
  131211. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  131212. */
  131213. get lambda(): number;
  131214. set lambda(value: number);
  131215. /**
  131216. * Gets the view matrix corresponding to a given cascade
  131217. * @param cascadeNum cascade to retrieve the view matrix from
  131218. * @returns the cascade view matrix
  131219. */
  131220. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  131221. /**
  131222. * Gets the projection matrix corresponding to a given cascade
  131223. * @param cascadeNum cascade to retrieve the projection matrix from
  131224. * @returns the cascade projection matrix
  131225. */
  131226. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  131227. /**
  131228. * Gets the transformation matrix corresponding to a given cascade
  131229. * @param cascadeNum cascade to retrieve the transformation matrix from
  131230. * @returns the cascade transformation matrix
  131231. */
  131232. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  131233. private _depthRenderer;
  131234. /**
  131235. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  131236. *
  131237. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  131238. *
  131239. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  131240. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  131241. * @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
  131242. */
  131243. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  131244. private _depthReducer;
  131245. private _autoCalcDepthBounds;
  131246. /**
  131247. * Gets or sets the autoCalcDepthBounds property.
  131248. *
  131249. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  131250. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  131251. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  131252. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  131253. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  131254. */
  131255. get autoCalcDepthBounds(): boolean;
  131256. set autoCalcDepthBounds(value: boolean);
  131257. /**
  131258. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  131259. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  131260. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  131261. * for setting the refresh rate on the renderer yourself!
  131262. */
  131263. get autoCalcDepthBoundsRefreshRate(): number;
  131264. set autoCalcDepthBoundsRefreshRate(value: number);
  131265. /**
  131266. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  131267. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  131268. * you change the camera near/far planes!
  131269. */
  131270. splitFrustum(): void;
  131271. private _splitFrustum;
  131272. private _computeMatrices;
  131273. private _computeFrustumInWorldSpace;
  131274. private _computeCascadeFrustum;
  131275. /**
  131276. * Support test.
  131277. */
  131278. static get IsSupported(): boolean;
  131279. /** @hidden */
  131280. static _SceneComponentInitialization: (scene: Scene) => void;
  131281. /**
  131282. * Creates a Cascaded Shadow Generator object.
  131283. * A ShadowGenerator is the required tool to use the shadows.
  131284. * Each directional light casting shadows needs to use its own ShadowGenerator.
  131285. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131286. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  131287. * @param light The directional light object generating the shadows.
  131288. * @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.
  131289. */
  131290. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  131291. protected _initializeGenerator(): void;
  131292. protected _createTargetRenderTexture(): void;
  131293. protected _initializeShadowMap(): void;
  131294. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  131295. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  131296. /**
  131297. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  131298. * @param defines Defines of the material we want to update
  131299. * @param lightIndex Index of the light in the enabled light list of the material
  131300. */
  131301. prepareDefines(defines: any, lightIndex: number): void;
  131302. /**
  131303. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  131304. * defined in the generator but impacting the effect).
  131305. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  131306. * @param effect The effect we are binfing the information for
  131307. */
  131308. bindShadowLight(lightIndex: string, effect: Effect): void;
  131309. /**
  131310. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  131311. * (eq to view projection * shadow projection matrices)
  131312. * @returns The transform matrix used to create the shadow map
  131313. */
  131314. getTransformMatrix(): Matrix;
  131315. /**
  131316. * Disposes the ShadowGenerator.
  131317. * Returns nothing.
  131318. */
  131319. dispose(): void;
  131320. /**
  131321. * Serializes the shadow generator setup to a json object.
  131322. * @returns The serialized JSON object
  131323. */
  131324. serialize(): any;
  131325. /**
  131326. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  131327. * @param parsedShadowGenerator The JSON object to parse
  131328. * @param scene The scene to create the shadow map for
  131329. * @returns The parsed shadow generator
  131330. */
  131331. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  131332. }
  131333. }
  131334. declare module BABYLON {
  131335. /**
  131336. * Defines the shadow generator component responsible to manage any shadow generators
  131337. * in a given scene.
  131338. */
  131339. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  131340. /**
  131341. * The component name helpfull to identify the component in the list of scene components.
  131342. */
  131343. readonly name: string;
  131344. /**
  131345. * The scene the component belongs to.
  131346. */
  131347. scene: Scene;
  131348. /**
  131349. * Creates a new instance of the component for the given scene
  131350. * @param scene Defines the scene to register the component in
  131351. */
  131352. constructor(scene: Scene);
  131353. /**
  131354. * Registers the component in a given scene
  131355. */
  131356. register(): void;
  131357. /**
  131358. * Rebuilds the elements related to this component in case of
  131359. * context lost for instance.
  131360. */
  131361. rebuild(): void;
  131362. /**
  131363. * Serializes the component data to the specified json object
  131364. * @param serializationObject The object to serialize to
  131365. */
  131366. serialize(serializationObject: any): void;
  131367. /**
  131368. * Adds all the elements from the container to the scene
  131369. * @param container the container holding the elements
  131370. */
  131371. addFromContainer(container: AbstractScene): void;
  131372. /**
  131373. * Removes all the elements in the container from the scene
  131374. * @param container contains the elements to remove
  131375. * @param dispose if the removed element should be disposed (default: false)
  131376. */
  131377. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  131378. /**
  131379. * Rebuilds the elements related to this component in case of
  131380. * context lost for instance.
  131381. */
  131382. dispose(): void;
  131383. private _gatherRenderTargets;
  131384. }
  131385. }
  131386. declare module BABYLON {
  131387. /**
  131388. * A point light is a light defined by an unique point in world space.
  131389. * The light is emitted in every direction from this point.
  131390. * A good example of a point light is a standard light bulb.
  131391. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131392. */
  131393. export class PointLight extends ShadowLight {
  131394. private _shadowAngle;
  131395. /**
  131396. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131397. * This specifies what angle the shadow will use to be created.
  131398. *
  131399. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131400. */
  131401. get shadowAngle(): number;
  131402. /**
  131403. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131404. * This specifies what angle the shadow will use to be created.
  131405. *
  131406. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131407. */
  131408. set shadowAngle(value: number);
  131409. /**
  131410. * Gets the direction if it has been set.
  131411. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131412. */
  131413. get direction(): Vector3;
  131414. /**
  131415. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131416. */
  131417. set direction(value: Vector3);
  131418. /**
  131419. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  131420. * A PointLight emits the light in every direction.
  131421. * It can cast shadows.
  131422. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  131423. * ```javascript
  131424. * var pointLight = new PointLight("pl", camera.position, scene);
  131425. * ```
  131426. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131427. * @param name The light friendly name
  131428. * @param position The position of the point light in the scene
  131429. * @param scene The scene the lights belongs to
  131430. */
  131431. constructor(name: string, position: Vector3, scene: Scene);
  131432. /**
  131433. * Returns the string "PointLight"
  131434. * @returns the class name
  131435. */
  131436. getClassName(): string;
  131437. /**
  131438. * Returns the integer 0.
  131439. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131440. */
  131441. getTypeID(): number;
  131442. /**
  131443. * Specifies wether or not the shadowmap should be a cube texture.
  131444. * @returns true if the shadowmap needs to be a cube texture.
  131445. */
  131446. needCube(): boolean;
  131447. /**
  131448. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  131449. * @param faceIndex The index of the face we are computed the direction to generate shadow
  131450. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  131451. */
  131452. getShadowDirection(faceIndex?: number): Vector3;
  131453. /**
  131454. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  131455. * - fov = PI / 2
  131456. * - aspect ratio : 1.0
  131457. * - z-near and far equal to the active camera minZ and maxZ.
  131458. * Returns the PointLight.
  131459. */
  131460. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131461. protected _buildUniformLayout(): void;
  131462. /**
  131463. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  131464. * @param effect The effect to update
  131465. * @param lightIndex The index of the light in the effect to update
  131466. * @returns The point light
  131467. */
  131468. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  131469. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131470. /**
  131471. * Prepares the list of defines specific to the light type.
  131472. * @param defines the list of defines
  131473. * @param lightIndex defines the index of the light for the effect
  131474. */
  131475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131476. }
  131477. }
  131478. declare module BABYLON {
  131479. /**
  131480. * Header information of HDR texture files.
  131481. */
  131482. export interface HDRInfo {
  131483. /**
  131484. * The height of the texture in pixels.
  131485. */
  131486. height: number;
  131487. /**
  131488. * The width of the texture in pixels.
  131489. */
  131490. width: number;
  131491. /**
  131492. * The index of the beginning of the data in the binary file.
  131493. */
  131494. dataPosition: number;
  131495. }
  131496. /**
  131497. * This groups tools to convert HDR texture to native colors array.
  131498. */
  131499. export class HDRTools {
  131500. private static Ldexp;
  131501. private static Rgbe2float;
  131502. private static readStringLine;
  131503. /**
  131504. * Reads header information from an RGBE texture stored in a native array.
  131505. * More information on this format are available here:
  131506. * https://en.wikipedia.org/wiki/RGBE_image_format
  131507. *
  131508. * @param uint8array The binary file stored in native array.
  131509. * @return The header information.
  131510. */
  131511. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  131512. /**
  131513. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  131514. * This RGBE texture needs to store the information as a panorama.
  131515. *
  131516. * More information on this format are available here:
  131517. * https://en.wikipedia.org/wiki/RGBE_image_format
  131518. *
  131519. * @param buffer The binary file stored in an array buffer.
  131520. * @param size The expected size of the extracted cubemap.
  131521. * @return The Cube Map information.
  131522. */
  131523. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  131524. /**
  131525. * Returns the pixels data extracted from an RGBE texture.
  131526. * This pixels will be stored left to right up to down in the R G B order in one array.
  131527. *
  131528. * More information on this format are available here:
  131529. * https://en.wikipedia.org/wiki/RGBE_image_format
  131530. *
  131531. * @param uint8array The binary file stored in an array buffer.
  131532. * @param hdrInfo The header information of the file.
  131533. * @return The pixels data in RGB right to left up to down order.
  131534. */
  131535. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  131536. private static RGBE_ReadPixels_RLE;
  131537. }
  131538. }
  131539. declare module BABYLON {
  131540. /**
  131541. * This represents a texture coming from an HDR input.
  131542. *
  131543. * The only supported format is currently panorama picture stored in RGBE format.
  131544. * Example of such files can be found on HDRLib: http://hdrlib.com/
  131545. */
  131546. export class HDRCubeTexture extends BaseTexture {
  131547. private static _facesMapping;
  131548. private _generateHarmonics;
  131549. private _noMipmap;
  131550. private _textureMatrix;
  131551. private _size;
  131552. private _onLoad;
  131553. private _onError;
  131554. /**
  131555. * The texture URL.
  131556. */
  131557. url: string;
  131558. /**
  131559. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  131560. */
  131561. coordinatesMode: number;
  131562. protected _isBlocking: boolean;
  131563. /**
  131564. * Sets wether or not the texture is blocking during loading.
  131565. */
  131566. set isBlocking(value: boolean);
  131567. /**
  131568. * Gets wether or not the texture is blocking during loading.
  131569. */
  131570. get isBlocking(): boolean;
  131571. protected _rotationY: number;
  131572. /**
  131573. * Sets texture matrix rotation angle around Y axis in radians.
  131574. */
  131575. set rotationY(value: number);
  131576. /**
  131577. * Gets texture matrix rotation angle around Y axis radians.
  131578. */
  131579. get rotationY(): number;
  131580. /**
  131581. * Gets or sets the center of the bounding box associated with the cube texture
  131582. * It must define where the camera used to render the texture was set
  131583. */
  131584. boundingBoxPosition: Vector3;
  131585. private _boundingBoxSize;
  131586. /**
  131587. * Gets or sets the size of the bounding box associated with the cube texture
  131588. * When defined, the cubemap will switch to local mode
  131589. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  131590. * @example https://www.babylonjs-playground.com/#RNASML
  131591. */
  131592. set boundingBoxSize(value: Vector3);
  131593. get boundingBoxSize(): Vector3;
  131594. /**
  131595. * Instantiates an HDRTexture from the following parameters.
  131596. *
  131597. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  131598. * @param sceneOrEngine The scene or engine the texture will be used in
  131599. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  131600. * @param noMipmap Forces to not generate the mipmap if true
  131601. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  131602. * @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)
  131603. * @param reserved Reserved flag for internal use.
  131604. */
  131605. 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>);
  131606. /**
  131607. * Get the current class name of the texture useful for serialization or dynamic coding.
  131608. * @returns "HDRCubeTexture"
  131609. */
  131610. getClassName(): string;
  131611. /**
  131612. * Occurs when the file is raw .hdr file.
  131613. */
  131614. private loadTexture;
  131615. clone(): HDRCubeTexture;
  131616. delayLoad(): void;
  131617. /**
  131618. * Get the texture reflection matrix used to rotate/transform the reflection.
  131619. * @returns the reflection matrix
  131620. */
  131621. getReflectionTextureMatrix(): Matrix;
  131622. /**
  131623. * Set the texture reflection matrix used to rotate/transform the reflection.
  131624. * @param value Define the reflection matrix to set
  131625. */
  131626. setReflectionTextureMatrix(value: Matrix): void;
  131627. /**
  131628. * Parses a JSON representation of an HDR Texture in order to create the texture
  131629. * @param parsedTexture Define the JSON representation
  131630. * @param scene Define the scene the texture should be created in
  131631. * @param rootUrl Define the root url in case we need to load relative dependencies
  131632. * @returns the newly created texture after parsing
  131633. */
  131634. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  131635. serialize(): any;
  131636. }
  131637. }
  131638. declare module BABYLON {
  131639. /**
  131640. * Class used to control physics engine
  131641. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  131642. */
  131643. export class PhysicsEngine implements IPhysicsEngine {
  131644. private _physicsPlugin;
  131645. /**
  131646. * Global value used to control the smallest number supported by the simulation
  131647. */
  131648. static Epsilon: number;
  131649. private _impostors;
  131650. private _joints;
  131651. private _subTimeStep;
  131652. /**
  131653. * Gets the gravity vector used by the simulation
  131654. */
  131655. gravity: Vector3;
  131656. /**
  131657. * Factory used to create the default physics plugin.
  131658. * @returns The default physics plugin
  131659. */
  131660. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  131661. /**
  131662. * Creates a new Physics Engine
  131663. * @param gravity defines the gravity vector used by the simulation
  131664. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  131665. */
  131666. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  131667. /**
  131668. * Sets the gravity vector used by the simulation
  131669. * @param gravity defines the gravity vector to use
  131670. */
  131671. setGravity(gravity: Vector3): void;
  131672. /**
  131673. * Set the time step of the physics engine.
  131674. * Default is 1/60.
  131675. * To slow it down, enter 1/600 for example.
  131676. * To speed it up, 1/30
  131677. * @param newTimeStep defines the new timestep to apply to this world.
  131678. */
  131679. setTimeStep(newTimeStep?: number): void;
  131680. /**
  131681. * Get the time step of the physics engine.
  131682. * @returns the current time step
  131683. */
  131684. getTimeStep(): number;
  131685. /**
  131686. * Set the sub time step of the physics engine.
  131687. * Default is 0 meaning there is no sub steps
  131688. * To increase physics resolution precision, set a small value (like 1 ms)
  131689. * @param subTimeStep defines the new sub timestep used for physics resolution.
  131690. */
  131691. setSubTimeStep(subTimeStep?: number): void;
  131692. /**
  131693. * Get the sub time step of the physics engine.
  131694. * @returns the current sub time step
  131695. */
  131696. getSubTimeStep(): number;
  131697. /**
  131698. * Release all resources
  131699. */
  131700. dispose(): void;
  131701. /**
  131702. * Gets the name of the current physics plugin
  131703. * @returns the name of the plugin
  131704. */
  131705. getPhysicsPluginName(): string;
  131706. /**
  131707. * Adding a new impostor for the impostor tracking.
  131708. * This will be done by the impostor itself.
  131709. * @param impostor the impostor to add
  131710. */
  131711. addImpostor(impostor: PhysicsImpostor): void;
  131712. /**
  131713. * Remove an impostor from the engine.
  131714. * This impostor and its mesh will not longer be updated by the physics engine.
  131715. * @param impostor the impostor to remove
  131716. */
  131717. removeImpostor(impostor: PhysicsImpostor): void;
  131718. /**
  131719. * Add a joint to the physics engine
  131720. * @param mainImpostor defines the main impostor to which the joint is added.
  131721. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  131722. * @param joint defines the joint that will connect both impostors.
  131723. */
  131724. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131725. /**
  131726. * Removes a joint from the simulation
  131727. * @param mainImpostor defines the impostor used with the joint
  131728. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  131729. * @param joint defines the joint to remove
  131730. */
  131731. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131732. /**
  131733. * Called by the scene. No need to call it.
  131734. * @param delta defines the timespam between frames
  131735. */
  131736. _step(delta: number): void;
  131737. /**
  131738. * Gets the current plugin used to run the simulation
  131739. * @returns current plugin
  131740. */
  131741. getPhysicsPlugin(): IPhysicsEnginePlugin;
  131742. /**
  131743. * Gets the list of physic impostors
  131744. * @returns an array of PhysicsImpostor
  131745. */
  131746. getImpostors(): Array<PhysicsImpostor>;
  131747. /**
  131748. * Gets the impostor for a physics enabled object
  131749. * @param object defines the object impersonated by the impostor
  131750. * @returns the PhysicsImpostor or null if not found
  131751. */
  131752. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  131753. /**
  131754. * Gets the impostor for a physics body object
  131755. * @param body defines physics body used by the impostor
  131756. * @returns the PhysicsImpostor or null if not found
  131757. */
  131758. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  131759. /**
  131760. * Does a raycast in the physics world
  131761. * @param from when should the ray start?
  131762. * @param to when should the ray end?
  131763. * @returns PhysicsRaycastResult
  131764. */
  131765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131766. }
  131767. }
  131768. declare module BABYLON {
  131769. /** @hidden */
  131770. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  131771. private _useDeltaForWorldStep;
  131772. world: any;
  131773. name: string;
  131774. private _physicsMaterials;
  131775. private _fixedTimeStep;
  131776. private _cannonRaycastResult;
  131777. private _raycastResult;
  131778. private _physicsBodysToRemoveAfterStep;
  131779. BJSCANNON: any;
  131780. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  131781. setGravity(gravity: Vector3): void;
  131782. setTimeStep(timeStep: number): void;
  131783. getTimeStep(): number;
  131784. executeStep(delta: number): void;
  131785. private _removeMarkedPhysicsBodiesFromWorld;
  131786. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131787. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131788. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131789. private _processChildMeshes;
  131790. removePhysicsBody(impostor: PhysicsImpostor): void;
  131791. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131792. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131793. private _addMaterial;
  131794. private _checkWithEpsilon;
  131795. private _createShape;
  131796. private _createHeightmap;
  131797. private _minus90X;
  131798. private _plus90X;
  131799. private _tmpPosition;
  131800. private _tmpDeltaPosition;
  131801. private _tmpUnityRotation;
  131802. private _updatePhysicsBodyTransformation;
  131803. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131804. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131805. isSupported(): boolean;
  131806. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131807. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131808. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131809. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131810. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131811. getBodyMass(impostor: PhysicsImpostor): number;
  131812. getBodyFriction(impostor: PhysicsImpostor): number;
  131813. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131814. getBodyRestitution(impostor: PhysicsImpostor): number;
  131815. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131816. sleepBody(impostor: PhysicsImpostor): void;
  131817. wakeUpBody(impostor: PhysicsImpostor): void;
  131818. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  131819. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  131820. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  131821. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131822. getRadius(impostor: PhysicsImpostor): number;
  131823. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131824. dispose(): void;
  131825. private _extendNamespace;
  131826. /**
  131827. * Does a raycast in the physics world
  131828. * @param from when should the ray start?
  131829. * @param to when should the ray end?
  131830. * @returns PhysicsRaycastResult
  131831. */
  131832. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131833. }
  131834. }
  131835. declare module BABYLON {
  131836. /** @hidden */
  131837. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  131838. private _useDeltaForWorldStep;
  131839. world: any;
  131840. name: string;
  131841. BJSOIMO: any;
  131842. private _raycastResult;
  131843. private _fixedTimeStep;
  131844. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  131845. setGravity(gravity: Vector3): void;
  131846. setTimeStep(timeStep: number): void;
  131847. getTimeStep(): number;
  131848. private _tmpImpostorsArray;
  131849. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131850. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131851. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131852. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131853. private _tmpPositionVector;
  131854. removePhysicsBody(impostor: PhysicsImpostor): void;
  131855. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131856. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131857. isSupported(): boolean;
  131858. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131859. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131860. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131861. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131862. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131863. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131864. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131865. getBodyMass(impostor: PhysicsImpostor): number;
  131866. getBodyFriction(impostor: PhysicsImpostor): number;
  131867. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131868. getBodyRestitution(impostor: PhysicsImpostor): number;
  131869. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131870. sleepBody(impostor: PhysicsImpostor): void;
  131871. wakeUpBody(impostor: PhysicsImpostor): void;
  131872. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  131873. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  131874. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  131875. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131876. getRadius(impostor: PhysicsImpostor): number;
  131877. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131878. dispose(): void;
  131879. /**
  131880. * Does a raycast in the physics world
  131881. * @param from when should the ray start?
  131882. * @param to when should the ray end?
  131883. * @returns PhysicsRaycastResult
  131884. */
  131885. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131886. }
  131887. }
  131888. declare module BABYLON {
  131889. /**
  131890. * Class containing static functions to help procedurally build meshes
  131891. */
  131892. export class RibbonBuilder {
  131893. /**
  131894. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131895. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131896. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131897. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131898. * * 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
  131899. * * 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
  131900. * * 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
  131901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131902. * * 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
  131903. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131904. * * 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
  131905. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131906. * * 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
  131907. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131909. * @param name defines the name of the mesh
  131910. * @param options defines the options used to create the mesh
  131911. * @param scene defines the hosting scene
  131912. * @returns the ribbon mesh
  131913. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131914. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131915. */
  131916. static CreateRibbon(name: string, options: {
  131917. pathArray: Vector3[][];
  131918. closeArray?: boolean;
  131919. closePath?: boolean;
  131920. offset?: number;
  131921. updatable?: boolean;
  131922. sideOrientation?: number;
  131923. frontUVs?: Vector4;
  131924. backUVs?: Vector4;
  131925. instance?: Mesh;
  131926. invertUV?: boolean;
  131927. uvs?: Vector2[];
  131928. colors?: Color4[];
  131929. }, scene?: Nullable<Scene>): Mesh;
  131930. }
  131931. }
  131932. declare module BABYLON {
  131933. /**
  131934. * Class containing static functions to help procedurally build meshes
  131935. */
  131936. export class ShapeBuilder {
  131937. /**
  131938. * 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.
  131939. * * 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.
  131940. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131941. * * 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.
  131942. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131943. * * 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
  131944. * * 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
  131945. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131947. * * 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
  131948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131950. * @param name defines the name of the mesh
  131951. * @param options defines the options used to create the mesh
  131952. * @param scene defines the hosting scene
  131953. * @returns the extruded shape mesh
  131954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131956. */
  131957. static ExtrudeShape(name: string, options: {
  131958. shape: Vector3[];
  131959. path: Vector3[];
  131960. scale?: number;
  131961. rotation?: number;
  131962. cap?: number;
  131963. updatable?: boolean;
  131964. sideOrientation?: number;
  131965. frontUVs?: Vector4;
  131966. backUVs?: Vector4;
  131967. instance?: Mesh;
  131968. invertUV?: boolean;
  131969. }, scene?: Nullable<Scene>): Mesh;
  131970. /**
  131971. * Creates an custom extruded shape mesh.
  131972. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131973. * * 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.
  131974. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131975. * * 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
  131976. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131977. * * 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
  131978. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131979. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131980. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131981. * * 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
  131982. * * 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
  131983. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131985. * * 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
  131986. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131988. * @param name defines the name of the mesh
  131989. * @param options defines the options used to create the mesh
  131990. * @param scene defines the hosting scene
  131991. * @returns the custom extruded shape mesh
  131992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131995. */
  131996. static ExtrudeShapeCustom(name: string, options: {
  131997. shape: Vector3[];
  131998. path: Vector3[];
  131999. scaleFunction?: any;
  132000. rotationFunction?: any;
  132001. ribbonCloseArray?: boolean;
  132002. ribbonClosePath?: boolean;
  132003. cap?: number;
  132004. updatable?: boolean;
  132005. sideOrientation?: number;
  132006. frontUVs?: Vector4;
  132007. backUVs?: Vector4;
  132008. instance?: Mesh;
  132009. invertUV?: boolean;
  132010. }, scene?: Nullable<Scene>): Mesh;
  132011. private static _ExtrudeShapeGeneric;
  132012. }
  132013. }
  132014. declare module BABYLON {
  132015. /**
  132016. * AmmoJS Physics plugin
  132017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  132018. * @see https://github.com/kripken/ammo.js/
  132019. */
  132020. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  132021. private _useDeltaForWorldStep;
  132022. /**
  132023. * Reference to the Ammo library
  132024. */
  132025. bjsAMMO: any;
  132026. /**
  132027. * Created ammoJS world which physics bodies are added to
  132028. */
  132029. world: any;
  132030. /**
  132031. * Name of the plugin
  132032. */
  132033. name: string;
  132034. private _timeStep;
  132035. private _fixedTimeStep;
  132036. private _maxSteps;
  132037. private _tmpQuaternion;
  132038. private _tmpAmmoTransform;
  132039. private _tmpAmmoQuaternion;
  132040. private _tmpAmmoConcreteContactResultCallback;
  132041. private _collisionConfiguration;
  132042. private _dispatcher;
  132043. private _overlappingPairCache;
  132044. private _solver;
  132045. private _softBodySolver;
  132046. private _tmpAmmoVectorA;
  132047. private _tmpAmmoVectorB;
  132048. private _tmpAmmoVectorC;
  132049. private _tmpAmmoVectorD;
  132050. private _tmpContactCallbackResult;
  132051. private _tmpAmmoVectorRCA;
  132052. private _tmpAmmoVectorRCB;
  132053. private _raycastResult;
  132054. private static readonly DISABLE_COLLISION_FLAG;
  132055. private static readonly KINEMATIC_FLAG;
  132056. private static readonly DISABLE_DEACTIVATION_FLAG;
  132057. /**
  132058. * Initializes the ammoJS plugin
  132059. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  132060. * @param ammoInjection can be used to inject your own ammo reference
  132061. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  132062. */
  132063. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  132064. /**
  132065. * Sets the gravity of the physics world (m/(s^2))
  132066. * @param gravity Gravity to set
  132067. */
  132068. setGravity(gravity: Vector3): void;
  132069. /**
  132070. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  132071. * @param timeStep timestep to use in seconds
  132072. */
  132073. setTimeStep(timeStep: number): void;
  132074. /**
  132075. * 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)
  132076. * @param fixedTimeStep fixedTimeStep to use in seconds
  132077. */
  132078. setFixedTimeStep(fixedTimeStep: number): void;
  132079. /**
  132080. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  132081. * @param maxSteps the maximum number of steps by the physics engine per frame
  132082. */
  132083. setMaxSteps(maxSteps: number): void;
  132084. /**
  132085. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  132086. * @returns the current timestep in seconds
  132087. */
  132088. getTimeStep(): number;
  132089. /**
  132090. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  132091. */
  132092. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  132093. private _isImpostorInContact;
  132094. private _isImpostorPairInContact;
  132095. private _stepSimulation;
  132096. /**
  132097. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  132098. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  132099. * After the step the babylon meshes are set to the position of the physics imposters
  132100. * @param delta amount of time to step forward
  132101. * @param impostors array of imposters to update before/after the step
  132102. */
  132103. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  132104. /**
  132105. * Update babylon mesh to match physics world object
  132106. * @param impostor imposter to match
  132107. */
  132108. private _afterSoftStep;
  132109. /**
  132110. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  132111. * @param impostor imposter to match
  132112. */
  132113. private _ropeStep;
  132114. /**
  132115. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  132116. * @param impostor imposter to match
  132117. */
  132118. private _softbodyOrClothStep;
  132119. private _tmpMatrix;
  132120. /**
  132121. * Applies an impulse on the imposter
  132122. * @param impostor imposter to apply impulse to
  132123. * @param force amount of force to be applied to the imposter
  132124. * @param contactPoint the location to apply the impulse on the imposter
  132125. */
  132126. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  132127. /**
  132128. * Applies a force on the imposter
  132129. * @param impostor imposter to apply force
  132130. * @param force amount of force to be applied to the imposter
  132131. * @param contactPoint the location to apply the force on the imposter
  132132. */
  132133. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  132134. /**
  132135. * Creates a physics body using the plugin
  132136. * @param impostor the imposter to create the physics body on
  132137. */
  132138. generatePhysicsBody(impostor: PhysicsImpostor): void;
  132139. /**
  132140. * Removes the physics body from the imposter and disposes of the body's memory
  132141. * @param impostor imposter to remove the physics body from
  132142. */
  132143. removePhysicsBody(impostor: PhysicsImpostor): void;
  132144. /**
  132145. * Generates a joint
  132146. * @param impostorJoint the imposter joint to create the joint with
  132147. */
  132148. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  132149. /**
  132150. * Removes a joint
  132151. * @param impostorJoint the imposter joint to remove the joint from
  132152. */
  132153. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  132154. private _addMeshVerts;
  132155. /**
  132156. * Initialise the soft body vertices to match its object's (mesh) vertices
  132157. * Softbody vertices (nodes) are in world space and to match this
  132158. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  132159. * @param impostor to create the softbody for
  132160. */
  132161. private _softVertexData;
  132162. /**
  132163. * Create an impostor's soft body
  132164. * @param impostor to create the softbody for
  132165. */
  132166. private _createSoftbody;
  132167. /**
  132168. * Create cloth for an impostor
  132169. * @param impostor to create the softbody for
  132170. */
  132171. private _createCloth;
  132172. /**
  132173. * Create rope for an impostor
  132174. * @param impostor to create the softbody for
  132175. */
  132176. private _createRope;
  132177. /**
  132178. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  132179. * @param impostor to create the custom physics shape for
  132180. */
  132181. private _createCustom;
  132182. private _addHullVerts;
  132183. private _createShape;
  132184. /**
  132185. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  132186. * @param impostor imposter containing the physics body and babylon object
  132187. */
  132188. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  132189. /**
  132190. * Sets the babylon object's position/rotation from the physics body's position/rotation
  132191. * @param impostor imposter containing the physics body and babylon object
  132192. * @param newPosition new position
  132193. * @param newRotation new rotation
  132194. */
  132195. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  132196. /**
  132197. * If this plugin is supported
  132198. * @returns true if its supported
  132199. */
  132200. isSupported(): boolean;
  132201. /**
  132202. * Sets the linear velocity of the physics body
  132203. * @param impostor imposter to set the velocity on
  132204. * @param velocity velocity to set
  132205. */
  132206. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  132207. /**
  132208. * Sets the angular velocity of the physics body
  132209. * @param impostor imposter to set the velocity on
  132210. * @param velocity velocity to set
  132211. */
  132212. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  132213. /**
  132214. * gets the linear velocity
  132215. * @param impostor imposter to get linear velocity from
  132216. * @returns linear velocity
  132217. */
  132218. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  132219. /**
  132220. * gets the angular velocity
  132221. * @param impostor imposter to get angular velocity from
  132222. * @returns angular velocity
  132223. */
  132224. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  132225. /**
  132226. * Sets the mass of physics body
  132227. * @param impostor imposter to set the mass on
  132228. * @param mass mass to set
  132229. */
  132230. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  132231. /**
  132232. * Gets the mass of the physics body
  132233. * @param impostor imposter to get the mass from
  132234. * @returns mass
  132235. */
  132236. getBodyMass(impostor: PhysicsImpostor): number;
  132237. /**
  132238. * Gets friction of the impostor
  132239. * @param impostor impostor to get friction from
  132240. * @returns friction value
  132241. */
  132242. getBodyFriction(impostor: PhysicsImpostor): number;
  132243. /**
  132244. * Sets friction of the impostor
  132245. * @param impostor impostor to set friction on
  132246. * @param friction friction value
  132247. */
  132248. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  132249. /**
  132250. * Gets restitution of the impostor
  132251. * @param impostor impostor to get restitution from
  132252. * @returns restitution value
  132253. */
  132254. getBodyRestitution(impostor: PhysicsImpostor): number;
  132255. /**
  132256. * Sets resitution of the impostor
  132257. * @param impostor impostor to set resitution on
  132258. * @param restitution resitution value
  132259. */
  132260. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  132261. /**
  132262. * Gets pressure inside the impostor
  132263. * @param impostor impostor to get pressure from
  132264. * @returns pressure value
  132265. */
  132266. getBodyPressure(impostor: PhysicsImpostor): number;
  132267. /**
  132268. * Sets pressure inside a soft body impostor
  132269. * Cloth and rope must remain 0 pressure
  132270. * @param impostor impostor to set pressure on
  132271. * @param pressure pressure value
  132272. */
  132273. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  132274. /**
  132275. * Gets stiffness of the impostor
  132276. * @param impostor impostor to get stiffness from
  132277. * @returns pressure value
  132278. */
  132279. getBodyStiffness(impostor: PhysicsImpostor): number;
  132280. /**
  132281. * Sets stiffness of the impostor
  132282. * @param impostor impostor to set stiffness on
  132283. * @param stiffness stiffness value from 0 to 1
  132284. */
  132285. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  132286. /**
  132287. * Gets velocityIterations of the impostor
  132288. * @param impostor impostor to get velocity iterations from
  132289. * @returns velocityIterations value
  132290. */
  132291. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  132292. /**
  132293. * Sets velocityIterations of the impostor
  132294. * @param impostor impostor to set velocity iterations on
  132295. * @param velocityIterations velocityIterations value
  132296. */
  132297. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  132298. /**
  132299. * Gets positionIterations of the impostor
  132300. * @param impostor impostor to get position iterations from
  132301. * @returns positionIterations value
  132302. */
  132303. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  132304. /**
  132305. * Sets positionIterations of the impostor
  132306. * @param impostor impostor to set position on
  132307. * @param positionIterations positionIterations value
  132308. */
  132309. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  132310. /**
  132311. * Append an anchor to a cloth object
  132312. * @param impostor is the cloth impostor to add anchor to
  132313. * @param otherImpostor is the rigid impostor to anchor to
  132314. * @param width ratio across width from 0 to 1
  132315. * @param height ratio up height from 0 to 1
  132316. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  132317. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132318. */
  132319. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132320. /**
  132321. * Append an hook to a rope object
  132322. * @param impostor is the rope impostor to add hook to
  132323. * @param otherImpostor is the rigid impostor to hook to
  132324. * @param length ratio along the rope from 0 to 1
  132325. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  132326. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132327. */
  132328. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132329. /**
  132330. * Sleeps the physics body and stops it from being active
  132331. * @param impostor impostor to sleep
  132332. */
  132333. sleepBody(impostor: PhysicsImpostor): void;
  132334. /**
  132335. * Activates the physics body
  132336. * @param impostor impostor to activate
  132337. */
  132338. wakeUpBody(impostor: PhysicsImpostor): void;
  132339. /**
  132340. * Updates the distance parameters of the joint
  132341. * @param joint joint to update
  132342. * @param maxDistance maximum distance of the joint
  132343. * @param minDistance minimum distance of the joint
  132344. */
  132345. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  132346. /**
  132347. * Sets a motor on the joint
  132348. * @param joint joint to set motor on
  132349. * @param speed speed of the motor
  132350. * @param maxForce maximum force of the motor
  132351. * @param motorIndex index of the motor
  132352. */
  132353. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  132354. /**
  132355. * Sets the motors limit
  132356. * @param joint joint to set limit on
  132357. * @param upperLimit upper limit
  132358. * @param lowerLimit lower limit
  132359. */
  132360. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  132361. /**
  132362. * Syncs the position and rotation of a mesh with the impostor
  132363. * @param mesh mesh to sync
  132364. * @param impostor impostor to update the mesh with
  132365. */
  132366. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  132367. /**
  132368. * Gets the radius of the impostor
  132369. * @param impostor impostor to get radius from
  132370. * @returns the radius
  132371. */
  132372. getRadius(impostor: PhysicsImpostor): number;
  132373. /**
  132374. * Gets the box size of the impostor
  132375. * @param impostor impostor to get box size from
  132376. * @param result the resulting box size
  132377. */
  132378. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  132379. /**
  132380. * Disposes of the impostor
  132381. */
  132382. dispose(): void;
  132383. /**
  132384. * Does a raycast in the physics world
  132385. * @param from when should the ray start?
  132386. * @param to when should the ray end?
  132387. * @returns PhysicsRaycastResult
  132388. */
  132389. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  132390. }
  132391. }
  132392. declare module BABYLON {
  132393. interface AbstractScene {
  132394. /**
  132395. * The list of reflection probes added to the scene
  132396. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132397. */
  132398. reflectionProbes: Array<ReflectionProbe>;
  132399. /**
  132400. * Removes the given reflection probe from this scene.
  132401. * @param toRemove The reflection probe to remove
  132402. * @returns The index of the removed reflection probe
  132403. */
  132404. removeReflectionProbe(toRemove: ReflectionProbe): number;
  132405. /**
  132406. * Adds the given reflection probe to this scene.
  132407. * @param newReflectionProbe The reflection probe to add
  132408. */
  132409. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  132410. }
  132411. /**
  132412. * Class used to generate realtime reflection / refraction cube textures
  132413. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132414. */
  132415. export class ReflectionProbe {
  132416. /** defines the name of the probe */
  132417. name: string;
  132418. private _scene;
  132419. private _renderTargetTexture;
  132420. private _projectionMatrix;
  132421. private _viewMatrix;
  132422. private _target;
  132423. private _add;
  132424. private _attachedMesh;
  132425. private _invertYAxis;
  132426. /** Gets or sets probe position (center of the cube map) */
  132427. position: Vector3;
  132428. /**
  132429. * Creates a new reflection probe
  132430. * @param name defines the name of the probe
  132431. * @param size defines the texture resolution (for each face)
  132432. * @param scene defines the hosting scene
  132433. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  132434. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  132435. */
  132436. constructor(
  132437. /** defines the name of the probe */
  132438. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  132439. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  132440. get samples(): number;
  132441. set samples(value: number);
  132442. /** Gets or sets the refresh rate to use (on every frame by default) */
  132443. get refreshRate(): number;
  132444. set refreshRate(value: number);
  132445. /**
  132446. * Gets the hosting scene
  132447. * @returns a Scene
  132448. */
  132449. getScene(): Scene;
  132450. /** Gets the internal CubeTexture used to render to */
  132451. get cubeTexture(): RenderTargetTexture;
  132452. /** Gets the list of meshes to render */
  132453. get renderList(): Nullable<AbstractMesh[]>;
  132454. /**
  132455. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  132456. * @param mesh defines the mesh to attach to
  132457. */
  132458. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132459. /**
  132460. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  132461. * @param renderingGroupId The rendering group id corresponding to its index
  132462. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132463. */
  132464. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  132465. /**
  132466. * Clean all associated resources
  132467. */
  132468. dispose(): void;
  132469. /**
  132470. * Converts the reflection probe information to a readable string for debug purpose.
  132471. * @param fullDetails Supports for multiple levels of logging within scene loading
  132472. * @returns the human readable reflection probe info
  132473. */
  132474. toString(fullDetails?: boolean): string;
  132475. /**
  132476. * Get the class name of the relfection probe.
  132477. * @returns "ReflectionProbe"
  132478. */
  132479. getClassName(): string;
  132480. /**
  132481. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  132482. * @returns The JSON representation of the texture
  132483. */
  132484. serialize(): any;
  132485. /**
  132486. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  132487. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  132488. * @param scene Define the scene the parsed reflection probe should be instantiated in
  132489. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  132490. * @returns The parsed reflection probe if successful
  132491. */
  132492. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  132493. }
  132494. }
  132495. declare module BABYLON {
  132496. /** @hidden */
  132497. export var _BabylonLoaderRegistered: boolean;
  132498. /**
  132499. * Helps setting up some configuration for the babylon file loader.
  132500. */
  132501. export class BabylonFileLoaderConfiguration {
  132502. /**
  132503. * The loader does not allow injecting custom physix engine into the plugins.
  132504. * Unfortunately in ES6, we need to manually inject them into the plugin.
  132505. * So you could set this variable to your engine import to make it work.
  132506. */
  132507. static LoaderInjectedPhysicsEngine: any;
  132508. }
  132509. }
  132510. declare module BABYLON {
  132511. /**
  132512. * The Physically based simple base material of BJS.
  132513. *
  132514. * This enables better naming and convention enforcements on top of the pbrMaterial.
  132515. * It is used as the base class for both the specGloss and metalRough conventions.
  132516. */
  132517. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  132518. /**
  132519. * Number of Simultaneous lights allowed on the material.
  132520. */
  132521. maxSimultaneousLights: number;
  132522. /**
  132523. * If sets to true, disables all the lights affecting the material.
  132524. */
  132525. disableLighting: boolean;
  132526. /**
  132527. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  132528. */
  132529. environmentTexture: BaseTexture;
  132530. /**
  132531. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132532. */
  132533. invertNormalMapX: boolean;
  132534. /**
  132535. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132536. */
  132537. invertNormalMapY: boolean;
  132538. /**
  132539. * Normal map used in the model.
  132540. */
  132541. normalTexture: BaseTexture;
  132542. /**
  132543. * Emissivie color used to self-illuminate the model.
  132544. */
  132545. emissiveColor: Color3;
  132546. /**
  132547. * Emissivie texture used to self-illuminate the model.
  132548. */
  132549. emissiveTexture: BaseTexture;
  132550. /**
  132551. * Occlusion Channel Strenght.
  132552. */
  132553. occlusionStrength: number;
  132554. /**
  132555. * Occlusion Texture of the material (adding extra occlusion effects).
  132556. */
  132557. occlusionTexture: BaseTexture;
  132558. /**
  132559. * Defines the alpha limits in alpha test mode.
  132560. */
  132561. alphaCutOff: number;
  132562. /**
  132563. * Gets the current double sided mode.
  132564. */
  132565. get doubleSided(): boolean;
  132566. /**
  132567. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132568. */
  132569. set doubleSided(value: boolean);
  132570. /**
  132571. * Stores the pre-calculated light information of a mesh in a texture.
  132572. */
  132573. lightmapTexture: BaseTexture;
  132574. /**
  132575. * If true, the light map contains occlusion information instead of lighting info.
  132576. */
  132577. useLightmapAsShadowmap: boolean;
  132578. /**
  132579. * Instantiates a new PBRMaterial instance.
  132580. *
  132581. * @param name The material name
  132582. * @param scene The scene the material will be use in.
  132583. */
  132584. constructor(name: string, scene: Scene);
  132585. getClassName(): string;
  132586. }
  132587. }
  132588. declare module BABYLON {
  132589. /**
  132590. * The PBR material of BJS following the metal roughness convention.
  132591. *
  132592. * This fits to the PBR convention in the GLTF definition:
  132593. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  132594. */
  132595. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  132596. /**
  132597. * The base color has two different interpretations depending on the value of metalness.
  132598. * When the material is a metal, the base color is the specific measured reflectance value
  132599. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  132600. * of the material.
  132601. */
  132602. baseColor: Color3;
  132603. /**
  132604. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  132605. * well as opacity information in the alpha channel.
  132606. */
  132607. baseTexture: BaseTexture;
  132608. /**
  132609. * Specifies the metallic scalar value of the material.
  132610. * Can also be used to scale the metalness values of the metallic texture.
  132611. */
  132612. metallic: number;
  132613. /**
  132614. * Specifies the roughness scalar value of the material.
  132615. * Can also be used to scale the roughness values of the metallic texture.
  132616. */
  132617. roughness: number;
  132618. /**
  132619. * Texture containing both the metallic value in the B channel and the
  132620. * roughness value in the G channel to keep better precision.
  132621. */
  132622. metallicRoughnessTexture: BaseTexture;
  132623. /**
  132624. * Instantiates a new PBRMetalRoughnessMaterial instance.
  132625. *
  132626. * @param name The material name
  132627. * @param scene The scene the material will be use in.
  132628. */
  132629. constructor(name: string, scene: Scene);
  132630. /**
  132631. * Return the currrent class name of the material.
  132632. */
  132633. getClassName(): string;
  132634. /**
  132635. * Makes a duplicate of the current material.
  132636. * @param name - name to use for the new material.
  132637. */
  132638. clone(name: string): PBRMetallicRoughnessMaterial;
  132639. /**
  132640. * Serialize the material to a parsable JSON object.
  132641. */
  132642. serialize(): any;
  132643. /**
  132644. * Parses a JSON object correponding to the serialize function.
  132645. */
  132646. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  132647. }
  132648. }
  132649. declare module BABYLON {
  132650. /**
  132651. * The PBR material of BJS following the specular glossiness convention.
  132652. *
  132653. * This fits to the PBR convention in the GLTF definition:
  132654. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  132655. */
  132656. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  132657. /**
  132658. * Specifies the diffuse color of the material.
  132659. */
  132660. diffuseColor: Color3;
  132661. /**
  132662. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  132663. * channel.
  132664. */
  132665. diffuseTexture: BaseTexture;
  132666. /**
  132667. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  132668. */
  132669. specularColor: Color3;
  132670. /**
  132671. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  132672. */
  132673. glossiness: number;
  132674. /**
  132675. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  132676. */
  132677. specularGlossinessTexture: BaseTexture;
  132678. /**
  132679. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  132680. *
  132681. * @param name The material name
  132682. * @param scene The scene the material will be use in.
  132683. */
  132684. constructor(name: string, scene: Scene);
  132685. /**
  132686. * Return the currrent class name of the material.
  132687. */
  132688. getClassName(): string;
  132689. /**
  132690. * Makes a duplicate of the current material.
  132691. * @param name - name to use for the new material.
  132692. */
  132693. clone(name: string): PBRSpecularGlossinessMaterial;
  132694. /**
  132695. * Serialize the material to a parsable JSON object.
  132696. */
  132697. serialize(): any;
  132698. /**
  132699. * Parses a JSON object correponding to the serialize function.
  132700. */
  132701. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  132702. }
  132703. }
  132704. declare module BABYLON {
  132705. /**
  132706. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  132707. * It can help converting any input color in a desired output one. This can then be used to create effects
  132708. * from sepia, black and white to sixties or futuristic rendering...
  132709. *
  132710. * The only supported format is currently 3dl.
  132711. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  132712. */
  132713. export class ColorGradingTexture extends BaseTexture {
  132714. /**
  132715. * The texture URL.
  132716. */
  132717. url: string;
  132718. /**
  132719. * Empty line regex stored for GC.
  132720. */
  132721. private static _noneEmptyLineRegex;
  132722. private _textureMatrix;
  132723. private _onLoad;
  132724. /**
  132725. * Instantiates a ColorGradingTexture from the following parameters.
  132726. *
  132727. * @param url The location of the color gradind data (currently only supporting 3dl)
  132728. * @param sceneOrEngine The scene or engine the texture will be used in
  132729. * @param onLoad defines a callback triggered when the texture has been loaded
  132730. */
  132731. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  132732. /**
  132733. * Fires the onload event from the constructor if requested.
  132734. */
  132735. private _triggerOnLoad;
  132736. /**
  132737. * Returns the texture matrix used in most of the material.
  132738. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  132739. */
  132740. getTextureMatrix(): Matrix;
  132741. /**
  132742. * Occurs when the file being loaded is a .3dl LUT file.
  132743. */
  132744. private load3dlTexture;
  132745. /**
  132746. * Starts the loading process of the texture.
  132747. */
  132748. private loadTexture;
  132749. /**
  132750. * Clones the color gradind texture.
  132751. */
  132752. clone(): ColorGradingTexture;
  132753. /**
  132754. * Called during delayed load for textures.
  132755. */
  132756. delayLoad(): void;
  132757. /**
  132758. * Parses a color grading texture serialized by Babylon.
  132759. * @param parsedTexture The texture information being parsedTexture
  132760. * @param scene The scene to load the texture in
  132761. * @param rootUrl The root url of the data assets to load
  132762. * @return A color gradind texture
  132763. */
  132764. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  132765. /**
  132766. * Serializes the LUT texture to json format.
  132767. */
  132768. serialize(): any;
  132769. }
  132770. }
  132771. declare module BABYLON {
  132772. /**
  132773. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  132774. */
  132775. export class EquiRectangularCubeTexture extends BaseTexture {
  132776. /** The six faces of the cube. */
  132777. private static _FacesMapping;
  132778. private _noMipmap;
  132779. private _onLoad;
  132780. private _onError;
  132781. /** The size of the cubemap. */
  132782. private _size;
  132783. /** The buffer of the image. */
  132784. private _buffer;
  132785. /** The width of the input image. */
  132786. private _width;
  132787. /** The height of the input image. */
  132788. private _height;
  132789. /** The URL to the image. */
  132790. url: string;
  132791. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  132792. coordinatesMode: number;
  132793. /**
  132794. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  132795. * @param url The location of the image
  132796. * @param scene The scene the texture will be used in
  132797. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  132798. * @param noMipmap Forces to not generate the mipmap if true
  132799. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132800. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132801. * @param onLoad — defines a callback called when texture is loaded
  132802. * @param onError — defines a callback called if there is an error
  132803. */
  132804. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  132805. /**
  132806. * Load the image data, by putting the image on a canvas and extracting its buffer.
  132807. */
  132808. private loadImage;
  132809. /**
  132810. * Convert the image buffer into a cubemap and create a CubeTexture.
  132811. */
  132812. private loadTexture;
  132813. /**
  132814. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  132815. * @param buffer The ArrayBuffer that should be converted.
  132816. * @returns The buffer as Float32Array.
  132817. */
  132818. private getFloat32ArrayFromArrayBuffer;
  132819. /**
  132820. * Get the current class name of the texture useful for serialization or dynamic coding.
  132821. * @returns "EquiRectangularCubeTexture"
  132822. */
  132823. getClassName(): string;
  132824. /**
  132825. * Create a clone of the current EquiRectangularCubeTexture and return it.
  132826. * @returns A clone of the current EquiRectangularCubeTexture.
  132827. */
  132828. clone(): EquiRectangularCubeTexture;
  132829. }
  132830. }
  132831. declare module BABYLON {
  132832. /**
  132833. * Based on jsTGALoader - Javascript loader for TGA file
  132834. * By Vincent Thibault
  132835. * @see http://blog.robrowser.com/javascript-tga-loader.html
  132836. */
  132837. export class TGATools {
  132838. private static _TYPE_INDEXED;
  132839. private static _TYPE_RGB;
  132840. private static _TYPE_GREY;
  132841. private static _TYPE_RLE_INDEXED;
  132842. private static _TYPE_RLE_RGB;
  132843. private static _TYPE_RLE_GREY;
  132844. private static _ORIGIN_MASK;
  132845. private static _ORIGIN_SHIFT;
  132846. private static _ORIGIN_BL;
  132847. private static _ORIGIN_BR;
  132848. private static _ORIGIN_UL;
  132849. private static _ORIGIN_UR;
  132850. /**
  132851. * Gets the header of a TGA file
  132852. * @param data defines the TGA data
  132853. * @returns the header
  132854. */
  132855. static GetTGAHeader(data: Uint8Array): any;
  132856. /**
  132857. * Uploads TGA content to a Babylon Texture
  132858. * @hidden
  132859. */
  132860. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  132861. /** @hidden */
  132862. 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;
  132863. /** @hidden */
  132864. 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;
  132865. /** @hidden */
  132866. 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;
  132867. /** @hidden */
  132868. 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;
  132869. /** @hidden */
  132870. 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;
  132871. /** @hidden */
  132872. 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;
  132873. }
  132874. }
  132875. declare module BABYLON {
  132876. /**
  132877. * Implementation of the TGA Texture Loader.
  132878. * @hidden
  132879. */
  132880. export class _TGATextureLoader implements IInternalTextureLoader {
  132881. /**
  132882. * Defines wether the loader supports cascade loading the different faces.
  132883. */
  132884. readonly supportCascades: boolean;
  132885. /**
  132886. * This returns if the loader support the current file information.
  132887. * @param extension defines the file extension of the file being loaded
  132888. * @returns true if the loader can load the specified file
  132889. */
  132890. canLoad(extension: string): boolean;
  132891. /**
  132892. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132893. * @param data contains the texture data
  132894. * @param texture defines the BabylonJS internal texture
  132895. * @param createPolynomials will be true if polynomials have been requested
  132896. * @param onLoad defines the callback to trigger once the texture is ready
  132897. * @param onError defines the callback to trigger in case of error
  132898. */
  132899. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132900. /**
  132901. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132902. * @param data contains the texture data
  132903. * @param texture defines the BabylonJS internal texture
  132904. * @param callback defines the method to call once ready to upload
  132905. */
  132906. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132907. }
  132908. }
  132909. declare module BABYLON {
  132910. /**
  132911. * Info about the .basis files
  132912. */
  132913. class BasisFileInfo {
  132914. /**
  132915. * If the file has alpha
  132916. */
  132917. hasAlpha: boolean;
  132918. /**
  132919. * Info about each image of the basis file
  132920. */
  132921. images: Array<{
  132922. levels: Array<{
  132923. width: number;
  132924. height: number;
  132925. transcodedPixels: ArrayBufferView;
  132926. }>;
  132927. }>;
  132928. }
  132929. /**
  132930. * Result of transcoding a basis file
  132931. */
  132932. class TranscodeResult {
  132933. /**
  132934. * Info about the .basis file
  132935. */
  132936. fileInfo: BasisFileInfo;
  132937. /**
  132938. * Format to use when loading the file
  132939. */
  132940. format: number;
  132941. }
  132942. /**
  132943. * Configuration options for the Basis transcoder
  132944. */
  132945. export class BasisTranscodeConfiguration {
  132946. /**
  132947. * Supported compression formats used to determine the supported output format of the transcoder
  132948. */
  132949. supportedCompressionFormats?: {
  132950. /**
  132951. * etc1 compression format
  132952. */
  132953. etc1?: boolean;
  132954. /**
  132955. * s3tc compression format
  132956. */
  132957. s3tc?: boolean;
  132958. /**
  132959. * pvrtc compression format
  132960. */
  132961. pvrtc?: boolean;
  132962. /**
  132963. * etc2 compression format
  132964. */
  132965. etc2?: boolean;
  132966. };
  132967. /**
  132968. * If mipmap levels should be loaded for transcoded images (Default: true)
  132969. */
  132970. loadMipmapLevels?: boolean;
  132971. /**
  132972. * Index of a single image to load (Default: all images)
  132973. */
  132974. loadSingleImage?: number;
  132975. }
  132976. /**
  132977. * Used to load .Basis files
  132978. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  132979. */
  132980. export class BasisTools {
  132981. private static _IgnoreSupportedFormats;
  132982. /**
  132983. * URL to use when loading the basis transcoder
  132984. */
  132985. static JSModuleURL: string;
  132986. /**
  132987. * URL to use when loading the wasm module for the transcoder
  132988. */
  132989. static WasmModuleURL: string;
  132990. /**
  132991. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  132992. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  132993. * @returns internal format corresponding to the Basis format
  132994. */
  132995. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  132996. private static _WorkerPromise;
  132997. private static _Worker;
  132998. private static _actionId;
  132999. private static _CreateWorkerAsync;
  133000. /**
  133001. * Transcodes a loaded image file to compressed pixel data
  133002. * @param data image data to transcode
  133003. * @param config configuration options for the transcoding
  133004. * @returns a promise resulting in the transcoded image
  133005. */
  133006. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  133007. /**
  133008. * Loads a texture from the transcode result
  133009. * @param texture texture load to
  133010. * @param transcodeResult the result of transcoding the basis file to load from
  133011. */
  133012. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  133013. }
  133014. }
  133015. declare module BABYLON {
  133016. /**
  133017. * Loader for .basis file format
  133018. */
  133019. export class _BasisTextureLoader implements IInternalTextureLoader {
  133020. /**
  133021. * Defines whether the loader supports cascade loading the different faces.
  133022. */
  133023. readonly supportCascades: boolean;
  133024. /**
  133025. * This returns if the loader support the current file information.
  133026. * @param extension defines the file extension of the file being loaded
  133027. * @returns true if the loader can load the specified file
  133028. */
  133029. canLoad(extension: string): boolean;
  133030. /**
  133031. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133032. * @param data contains the texture data
  133033. * @param texture defines the BabylonJS internal texture
  133034. * @param createPolynomials will be true if polynomials have been requested
  133035. * @param onLoad defines the callback to trigger once the texture is ready
  133036. * @param onError defines the callback to trigger in case of error
  133037. */
  133038. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133039. /**
  133040. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133041. * @param data contains the texture data
  133042. * @param texture defines the BabylonJS internal texture
  133043. * @param callback defines the method to call once ready to upload
  133044. */
  133045. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133046. }
  133047. }
  133048. declare module BABYLON {
  133049. /**
  133050. * 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.
  133051. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  133052. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  133053. */
  133054. export class CustomProceduralTexture extends ProceduralTexture {
  133055. private _animate;
  133056. private _time;
  133057. private _config;
  133058. private _texturePath;
  133059. /**
  133060. * Instantiates a new Custom Procedural Texture.
  133061. * 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.
  133062. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  133063. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  133064. * @param name Define the name of the texture
  133065. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  133066. * @param size Define the size of the texture to create
  133067. * @param scene Define the scene the texture belongs to
  133068. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  133069. * @param generateMipMaps Define if the texture should creates mip maps or not
  133070. */
  133071. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  133072. private _loadJson;
  133073. /**
  133074. * Is the texture ready to be used ? (rendered at least once)
  133075. * @returns true if ready, otherwise, false.
  133076. */
  133077. isReady(): boolean;
  133078. /**
  133079. * Render the texture to its associated render target.
  133080. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  133081. */
  133082. render(useCameraPostProcess?: boolean): void;
  133083. /**
  133084. * Update the list of dependant textures samplers in the shader.
  133085. */
  133086. updateTextures(): void;
  133087. /**
  133088. * Update the uniform values of the procedural texture in the shader.
  133089. */
  133090. updateShaderUniforms(): void;
  133091. /**
  133092. * Define if the texture animates or not.
  133093. */
  133094. get animate(): boolean;
  133095. set animate(value: boolean);
  133096. }
  133097. }
  133098. declare module BABYLON {
  133099. /** @hidden */
  133100. export var noisePixelShader: {
  133101. name: string;
  133102. shader: string;
  133103. };
  133104. }
  133105. declare module BABYLON {
  133106. /**
  133107. * Class used to generate noise procedural textures
  133108. */
  133109. export class NoiseProceduralTexture extends ProceduralTexture {
  133110. private _time;
  133111. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  133112. brightness: number;
  133113. /** Defines the number of octaves to process */
  133114. octaves: number;
  133115. /** Defines the level of persistence (0.8 by default) */
  133116. persistence: number;
  133117. /** Gets or sets animation speed factor (default is 1) */
  133118. animationSpeedFactor: number;
  133119. /**
  133120. * Creates a new NoiseProceduralTexture
  133121. * @param name defines the name fo the texture
  133122. * @param size defines the size of the texture (default is 256)
  133123. * @param scene defines the hosting scene
  133124. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  133125. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  133126. */
  133127. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  133128. private _updateShaderUniforms;
  133129. protected _getDefines(): string;
  133130. /** Generate the current state of the procedural texture */
  133131. render(useCameraPostProcess?: boolean): void;
  133132. /**
  133133. * Serializes this noise procedural texture
  133134. * @returns a serialized noise procedural texture object
  133135. */
  133136. serialize(): any;
  133137. /**
  133138. * Clone the texture.
  133139. * @returns the cloned texture
  133140. */
  133141. clone(): NoiseProceduralTexture;
  133142. /**
  133143. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  133144. * @param parsedTexture defines parsed texture data
  133145. * @param scene defines the current scene
  133146. * @param rootUrl defines the root URL containing noise procedural texture information
  133147. * @returns a parsed NoiseProceduralTexture
  133148. */
  133149. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  133150. }
  133151. }
  133152. declare module BABYLON {
  133153. /**
  133154. * Raw cube texture where the raw buffers are passed in
  133155. */
  133156. export class RawCubeTexture extends CubeTexture {
  133157. /**
  133158. * Creates a cube texture where the raw buffers are passed in.
  133159. * @param scene defines the scene the texture is attached to
  133160. * @param data defines the array of data to use to create each face
  133161. * @param size defines the size of the textures
  133162. * @param format defines the format of the data
  133163. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  133164. * @param generateMipMaps defines if the engine should generate the mip levels
  133165. * @param invertY defines if data must be stored with Y axis inverted
  133166. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  133167. * @param compression defines the compression used (null by default)
  133168. */
  133169. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  133170. /**
  133171. * Updates the raw cube texture.
  133172. * @param data defines the data to store
  133173. * @param format defines the data format
  133174. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  133175. * @param invertY defines if data must be stored with Y axis inverted
  133176. * @param compression defines the compression used (null by default)
  133177. * @param level defines which level of the texture to update
  133178. */
  133179. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  133180. /**
  133181. * Updates a raw cube texture with RGBD encoded data.
  133182. * @param data defines the array of data [mipmap][face] to use to create each face
  133183. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  133184. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133185. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133186. * @returns a promsie that resolves when the operation is complete
  133187. */
  133188. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  133189. /**
  133190. * Clones the raw cube texture.
  133191. * @return a new cube texture
  133192. */
  133193. clone(): CubeTexture;
  133194. /** @hidden */
  133195. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133196. }
  133197. }
  133198. declare module BABYLON {
  133199. /**
  133200. * Class used to store 3D textures containing user data
  133201. */
  133202. export class RawTexture3D extends Texture {
  133203. /** Gets or sets the texture format to use */
  133204. format: number;
  133205. /**
  133206. * Create a new RawTexture3D
  133207. * @param data defines the data of the texture
  133208. * @param width defines the width of the texture
  133209. * @param height defines the height of the texture
  133210. * @param depth defines the depth of the texture
  133211. * @param format defines the texture format to use
  133212. * @param scene defines the hosting scene
  133213. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  133214. * @param invertY defines if texture must be stored with Y axis inverted
  133215. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133216. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  133217. */
  133218. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  133219. /** Gets or sets the texture format to use */
  133220. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  133221. /**
  133222. * Update the texture with new data
  133223. * @param data defines the data to store in the texture
  133224. */
  133225. update(data: ArrayBufferView): void;
  133226. }
  133227. }
  133228. declare module BABYLON {
  133229. /**
  133230. * Class used to store 2D array textures containing user data
  133231. */
  133232. export class RawTexture2DArray extends Texture {
  133233. /** Gets or sets the texture format to use */
  133234. format: number;
  133235. /**
  133236. * Create a new RawTexture2DArray
  133237. * @param data defines the data of the texture
  133238. * @param width defines the width of the texture
  133239. * @param height defines the height of the texture
  133240. * @param depth defines the number of layers of the texture
  133241. * @param format defines the texture format to use
  133242. * @param scene defines the hosting scene
  133243. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  133244. * @param invertY defines if texture must be stored with Y axis inverted
  133245. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133246. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  133247. */
  133248. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  133249. /** Gets or sets the texture format to use */
  133250. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  133251. /**
  133252. * Update the texture with new data
  133253. * @param data defines the data to store in the texture
  133254. */
  133255. update(data: ArrayBufferView): void;
  133256. }
  133257. }
  133258. declare module BABYLON {
  133259. /**
  133260. * Creates a refraction texture used by refraction channel of the standard material.
  133261. * It is like a mirror but to see through a material.
  133262. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133263. */
  133264. export class RefractionTexture extends RenderTargetTexture {
  133265. /**
  133266. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  133267. * 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.
  133268. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133269. */
  133270. refractionPlane: Plane;
  133271. /**
  133272. * Define how deep under the surface we should see.
  133273. */
  133274. depth: number;
  133275. /**
  133276. * Creates a refraction texture used by refraction channel of the standard material.
  133277. * It is like a mirror but to see through a material.
  133278. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133279. * @param name Define the texture name
  133280. * @param size Define the size of the underlying texture
  133281. * @param scene Define the scene the refraction belongs to
  133282. * @param generateMipMaps Define if we need to generate mips level for the refraction
  133283. */
  133284. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  133285. /**
  133286. * Clone the refraction texture.
  133287. * @returns the cloned texture
  133288. */
  133289. clone(): RefractionTexture;
  133290. /**
  133291. * Serialize the texture to a JSON representation you could use in Parse later on
  133292. * @returns the serialized JSON representation
  133293. */
  133294. serialize(): any;
  133295. }
  133296. }
  133297. declare module BABYLON {
  133298. /**
  133299. * Defines the options related to the creation of an HtmlElementTexture
  133300. */
  133301. export interface IHtmlElementTextureOptions {
  133302. /**
  133303. * Defines wether mip maps should be created or not.
  133304. */
  133305. generateMipMaps?: boolean;
  133306. /**
  133307. * Defines the sampling mode of the texture.
  133308. */
  133309. samplingMode?: number;
  133310. /**
  133311. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  133312. */
  133313. engine: Nullable<ThinEngine>;
  133314. /**
  133315. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  133316. */
  133317. scene: Nullable<Scene>;
  133318. }
  133319. /**
  133320. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  133321. * To be as efficient as possible depending on your constraints nothing aside the first upload
  133322. * is automatically managed.
  133323. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  133324. * in your application.
  133325. *
  133326. * As the update is not automatic, you need to call them manually.
  133327. */
  133328. export class HtmlElementTexture extends BaseTexture {
  133329. /**
  133330. * The texture URL.
  133331. */
  133332. element: HTMLVideoElement | HTMLCanvasElement;
  133333. private static readonly DefaultOptions;
  133334. private _textureMatrix;
  133335. private _isVideo;
  133336. private _generateMipMaps;
  133337. private _samplingMode;
  133338. /**
  133339. * Instantiates a HtmlElementTexture from the following parameters.
  133340. *
  133341. * @param name Defines the name of the texture
  133342. * @param element Defines the video or canvas the texture is filled with
  133343. * @param options Defines the other none mandatory texture creation options
  133344. */
  133345. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  133346. private _createInternalTexture;
  133347. /**
  133348. * Returns the texture matrix used in most of the material.
  133349. */
  133350. getTextureMatrix(): Matrix;
  133351. /**
  133352. * Updates the content of the texture.
  133353. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  133354. */
  133355. update(invertY?: Nullable<boolean>): void;
  133356. }
  133357. }
  133358. declare module BABYLON {
  133359. /**
  133360. * Defines the basic options interface of a TexturePacker Frame
  133361. */
  133362. export interface ITexturePackerFrame {
  133363. /**
  133364. * The frame ID
  133365. */
  133366. id: number;
  133367. /**
  133368. * The frames Scale
  133369. */
  133370. scale: Vector2;
  133371. /**
  133372. * The Frames offset
  133373. */
  133374. offset: Vector2;
  133375. }
  133376. /**
  133377. * This is a support class for frame Data on texture packer sets.
  133378. */
  133379. export class TexturePackerFrame implements ITexturePackerFrame {
  133380. /**
  133381. * The frame ID
  133382. */
  133383. id: number;
  133384. /**
  133385. * The frames Scale
  133386. */
  133387. scale: Vector2;
  133388. /**
  133389. * The Frames offset
  133390. */
  133391. offset: Vector2;
  133392. /**
  133393. * Initializes a texture package frame.
  133394. * @param id The numerical frame identifier
  133395. * @param scale Scalar Vector2 for UV frame
  133396. * @param offset Vector2 for the frame position in UV units.
  133397. * @returns TexturePackerFrame
  133398. */
  133399. constructor(id: number, scale: Vector2, offset: Vector2);
  133400. }
  133401. }
  133402. declare module BABYLON {
  133403. /**
  133404. * Defines the basic options interface of a TexturePacker
  133405. */
  133406. export interface ITexturePackerOptions {
  133407. /**
  133408. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  133409. */
  133410. map?: string[];
  133411. /**
  133412. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133413. */
  133414. uvsIn?: string;
  133415. /**
  133416. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133417. */
  133418. uvsOut?: string;
  133419. /**
  133420. * number representing the layout style. Defaults to LAYOUT_STRIP
  133421. */
  133422. layout?: number;
  133423. /**
  133424. * number of columns if using custom column count layout(2). This defaults to 4.
  133425. */
  133426. colnum?: number;
  133427. /**
  133428. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  133429. */
  133430. updateInputMeshes?: boolean;
  133431. /**
  133432. * boolean flag to dispose all the source textures. Defaults to true.
  133433. */
  133434. disposeSources?: boolean;
  133435. /**
  133436. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  133437. */
  133438. fillBlanks?: boolean;
  133439. /**
  133440. * string value representing the context fill style color. Defaults to 'black'.
  133441. */
  133442. customFillColor?: string;
  133443. /**
  133444. * Width and Height Value of each Frame in the TexturePacker Sets
  133445. */
  133446. frameSize?: number;
  133447. /**
  133448. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  133449. */
  133450. paddingRatio?: number;
  133451. /**
  133452. * Number that declares the fill method for the padding gutter.
  133453. */
  133454. paddingMode?: number;
  133455. /**
  133456. * If in SUBUV_COLOR padding mode what color to use.
  133457. */
  133458. paddingColor?: Color3 | Color4;
  133459. }
  133460. /**
  133461. * Defines the basic interface of a TexturePacker JSON File
  133462. */
  133463. export interface ITexturePackerJSON {
  133464. /**
  133465. * The frame ID
  133466. */
  133467. name: string;
  133468. /**
  133469. * The base64 channel data
  133470. */
  133471. sets: any;
  133472. /**
  133473. * The options of the Packer
  133474. */
  133475. options: ITexturePackerOptions;
  133476. /**
  133477. * The frame data of the Packer
  133478. */
  133479. frames: Array<number>;
  133480. }
  133481. /**
  133482. * This is a support class that generates a series of packed texture sets.
  133483. * @see https://doc.babylonjs.com/babylon101/materials
  133484. */
  133485. export class TexturePacker {
  133486. /** Packer Layout Constant 0 */
  133487. static readonly LAYOUT_STRIP: number;
  133488. /** Packer Layout Constant 1 */
  133489. static readonly LAYOUT_POWER2: number;
  133490. /** Packer Layout Constant 2 */
  133491. static readonly LAYOUT_COLNUM: number;
  133492. /** Packer Layout Constant 0 */
  133493. static readonly SUBUV_WRAP: number;
  133494. /** Packer Layout Constant 1 */
  133495. static readonly SUBUV_EXTEND: number;
  133496. /** Packer Layout Constant 2 */
  133497. static readonly SUBUV_COLOR: number;
  133498. /** The Name of the Texture Package */
  133499. name: string;
  133500. /** The scene scope of the TexturePacker */
  133501. scene: Scene;
  133502. /** The Meshes to target */
  133503. meshes: AbstractMesh[];
  133504. /** Arguments passed with the Constructor */
  133505. options: ITexturePackerOptions;
  133506. /** The promise that is started upon initialization */
  133507. promise: Nullable<Promise<TexturePacker | string>>;
  133508. /** The Container object for the channel sets that are generated */
  133509. sets: object;
  133510. /** The Container array for the frames that are generated */
  133511. frames: TexturePackerFrame[];
  133512. /** The expected number of textures the system is parsing. */
  133513. private _expecting;
  133514. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  133515. private _paddingValue;
  133516. /**
  133517. * Initializes a texture package series from an array of meshes or a single mesh.
  133518. * @param name The name of the package
  133519. * @param meshes The target meshes to compose the package from
  133520. * @param options The arguments that texture packer should follow while building.
  133521. * @param scene The scene which the textures are scoped to.
  133522. * @returns TexturePacker
  133523. */
  133524. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  133525. /**
  133526. * Starts the package process
  133527. * @param resolve The promises resolution function
  133528. * @returns TexturePacker
  133529. */
  133530. private _createFrames;
  133531. /**
  133532. * Calculates the Size of the Channel Sets
  133533. * @returns Vector2
  133534. */
  133535. private _calculateSize;
  133536. /**
  133537. * Calculates the UV data for the frames.
  133538. * @param baseSize the base frameSize
  133539. * @param padding the base frame padding
  133540. * @param dtSize size of the Dynamic Texture for that channel
  133541. * @param dtUnits is 1/dtSize
  133542. * @param update flag to update the input meshes
  133543. */
  133544. private _calculateMeshUVFrames;
  133545. /**
  133546. * Calculates the frames Offset.
  133547. * @param index of the frame
  133548. * @returns Vector2
  133549. */
  133550. private _getFrameOffset;
  133551. /**
  133552. * Updates a Mesh to the frame data
  133553. * @param mesh that is the target
  133554. * @param frameID or the frame index
  133555. */
  133556. private _updateMeshUV;
  133557. /**
  133558. * Updates a Meshes materials to use the texture packer channels
  133559. * @param m is the mesh to target
  133560. * @param force all channels on the packer to be set.
  133561. */
  133562. private _updateTextureReferences;
  133563. /**
  133564. * Public method to set a Mesh to a frame
  133565. * @param m that is the target
  133566. * @param frameID or the frame index
  133567. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  133568. */
  133569. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  133570. /**
  133571. * Starts the async promise to compile the texture packer.
  133572. * @returns Promise<void>
  133573. */
  133574. processAsync(): Promise<void>;
  133575. /**
  133576. * Disposes all textures associated with this packer
  133577. */
  133578. dispose(): void;
  133579. /**
  133580. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  133581. * @param imageType is the image type to use.
  133582. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  133583. */
  133584. download(imageType?: string, quality?: number): void;
  133585. /**
  133586. * Public method to load a texturePacker JSON file.
  133587. * @param data of the JSON file in string format.
  133588. */
  133589. updateFromJSON(data: string): void;
  133590. }
  133591. }
  133592. declare module BABYLON {
  133593. /**
  133594. * Enum used to define the target of a block
  133595. */
  133596. export enum NodeMaterialBlockTargets {
  133597. /** Vertex shader */
  133598. Vertex = 1,
  133599. /** Fragment shader */
  133600. Fragment = 2,
  133601. /** Neutral */
  133602. Neutral = 4,
  133603. /** Vertex and Fragment */
  133604. VertexAndFragment = 3
  133605. }
  133606. }
  133607. declare module BABYLON {
  133608. /**
  133609. * Defines the kind of connection point for node based material
  133610. */
  133611. export enum NodeMaterialBlockConnectionPointTypes {
  133612. /** Float */
  133613. Float = 1,
  133614. /** Int */
  133615. Int = 2,
  133616. /** Vector2 */
  133617. Vector2 = 4,
  133618. /** Vector3 */
  133619. Vector3 = 8,
  133620. /** Vector4 */
  133621. Vector4 = 16,
  133622. /** Color3 */
  133623. Color3 = 32,
  133624. /** Color4 */
  133625. Color4 = 64,
  133626. /** Matrix */
  133627. Matrix = 128,
  133628. /** Custom object */
  133629. Object = 256,
  133630. /** Detect type based on connection */
  133631. AutoDetect = 1024,
  133632. /** Output type that will be defined by input type */
  133633. BasedOnInput = 2048
  133634. }
  133635. }
  133636. declare module BABYLON {
  133637. /**
  133638. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  133639. */
  133640. export enum NodeMaterialBlockConnectionPointMode {
  133641. /** Value is an uniform */
  133642. Uniform = 0,
  133643. /** Value is a mesh attribute */
  133644. Attribute = 1,
  133645. /** Value is a varying between vertex and fragment shaders */
  133646. Varying = 2,
  133647. /** Mode is undefined */
  133648. Undefined = 3
  133649. }
  133650. }
  133651. declare module BABYLON {
  133652. /**
  133653. * Enum used to define system values e.g. values automatically provided by the system
  133654. */
  133655. export enum NodeMaterialSystemValues {
  133656. /** World */
  133657. World = 1,
  133658. /** View */
  133659. View = 2,
  133660. /** Projection */
  133661. Projection = 3,
  133662. /** ViewProjection */
  133663. ViewProjection = 4,
  133664. /** WorldView */
  133665. WorldView = 5,
  133666. /** WorldViewProjection */
  133667. WorldViewProjection = 6,
  133668. /** CameraPosition */
  133669. CameraPosition = 7,
  133670. /** Fog Color */
  133671. FogColor = 8,
  133672. /** Delta time */
  133673. DeltaTime = 9
  133674. }
  133675. }
  133676. declare module BABYLON {
  133677. /**
  133678. * Enum used to define the material modes
  133679. */
  133680. export enum NodeMaterialModes {
  133681. /** Regular material */
  133682. Material = 0,
  133683. /** For post process */
  133684. PostProcess = 1
  133685. }
  133686. }
  133687. declare module BABYLON {
  133688. /**
  133689. * Root class for all node material optimizers
  133690. */
  133691. export class NodeMaterialOptimizer {
  133692. /**
  133693. * Function used to optimize a NodeMaterial graph
  133694. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  133695. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  133696. */
  133697. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  133698. }
  133699. }
  133700. declare module BABYLON {
  133701. /**
  133702. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  133703. */
  133704. export class TransformBlock extends NodeMaterialBlock {
  133705. /**
  133706. * Defines the value to use to complement W value to transform it to a Vector4
  133707. */
  133708. complementW: number;
  133709. /**
  133710. * Defines the value to use to complement z value to transform it to a Vector4
  133711. */
  133712. complementZ: number;
  133713. /**
  133714. * Creates a new TransformBlock
  133715. * @param name defines the block name
  133716. */
  133717. constructor(name: string);
  133718. /**
  133719. * Gets the current class name
  133720. * @returns the class name
  133721. */
  133722. getClassName(): string;
  133723. /**
  133724. * Gets the vector input
  133725. */
  133726. get vector(): NodeMaterialConnectionPoint;
  133727. /**
  133728. * Gets the output component
  133729. */
  133730. get output(): NodeMaterialConnectionPoint;
  133731. /**
  133732. * Gets the xyz output component
  133733. */
  133734. get xyz(): NodeMaterialConnectionPoint;
  133735. /**
  133736. * Gets the matrix transform input
  133737. */
  133738. get transform(): NodeMaterialConnectionPoint;
  133739. protected _buildBlock(state: NodeMaterialBuildState): this;
  133740. serialize(): any;
  133741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133742. protected _dumpPropertiesCode(): string;
  133743. }
  133744. }
  133745. declare module BABYLON {
  133746. /**
  133747. * Block used to output the vertex position
  133748. */
  133749. export class VertexOutputBlock extends NodeMaterialBlock {
  133750. /**
  133751. * Creates a new VertexOutputBlock
  133752. * @param name defines the block name
  133753. */
  133754. constructor(name: string);
  133755. /**
  133756. * Gets the current class name
  133757. * @returns the class name
  133758. */
  133759. getClassName(): string;
  133760. /**
  133761. * Gets the vector input component
  133762. */
  133763. get vector(): NodeMaterialConnectionPoint;
  133764. protected _buildBlock(state: NodeMaterialBuildState): this;
  133765. }
  133766. }
  133767. declare module BABYLON {
  133768. /**
  133769. * Block used to output the final color
  133770. */
  133771. export class FragmentOutputBlock extends NodeMaterialBlock {
  133772. /**
  133773. * Create a new FragmentOutputBlock
  133774. * @param name defines the block name
  133775. */
  133776. constructor(name: string);
  133777. /**
  133778. * Gets the current class name
  133779. * @returns the class name
  133780. */
  133781. getClassName(): string;
  133782. /**
  133783. * Gets the rgba input component
  133784. */
  133785. get rgba(): NodeMaterialConnectionPoint;
  133786. /**
  133787. * Gets the rgb input component
  133788. */
  133789. get rgb(): NodeMaterialConnectionPoint;
  133790. /**
  133791. * Gets the a input component
  133792. */
  133793. get a(): NodeMaterialConnectionPoint;
  133794. protected _buildBlock(state: NodeMaterialBuildState): this;
  133795. }
  133796. }
  133797. declare module BABYLON {
  133798. /**
  133799. * Base block used to read a reflection texture from a sampler
  133800. */
  133801. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  133802. /** @hidden */
  133803. _define3DName: string;
  133804. /** @hidden */
  133805. _defineCubicName: string;
  133806. /** @hidden */
  133807. _defineExplicitName: string;
  133808. /** @hidden */
  133809. _defineProjectionName: string;
  133810. /** @hidden */
  133811. _defineLocalCubicName: string;
  133812. /** @hidden */
  133813. _defineSphericalName: string;
  133814. /** @hidden */
  133815. _definePlanarName: string;
  133816. /** @hidden */
  133817. _defineEquirectangularName: string;
  133818. /** @hidden */
  133819. _defineMirroredEquirectangularFixedName: string;
  133820. /** @hidden */
  133821. _defineEquirectangularFixedName: string;
  133822. /** @hidden */
  133823. _defineSkyboxName: string;
  133824. /** @hidden */
  133825. _defineOppositeZ: string;
  133826. /** @hidden */
  133827. _cubeSamplerName: string;
  133828. /** @hidden */
  133829. _2DSamplerName: string;
  133830. protected _positionUVWName: string;
  133831. protected _directionWName: string;
  133832. protected _reflectionVectorName: string;
  133833. /** @hidden */
  133834. _reflectionCoordsName: string;
  133835. /** @hidden */
  133836. _reflectionMatrixName: string;
  133837. protected _reflectionColorName: string;
  133838. /**
  133839. * Gets or sets the texture associated with the node
  133840. */
  133841. texture: Nullable<BaseTexture>;
  133842. /**
  133843. * Create a new ReflectionTextureBaseBlock
  133844. * @param name defines the block name
  133845. */
  133846. constructor(name: string);
  133847. /**
  133848. * Gets the current class name
  133849. * @returns the class name
  133850. */
  133851. getClassName(): string;
  133852. /**
  133853. * Gets the world position input component
  133854. */
  133855. abstract get position(): NodeMaterialConnectionPoint;
  133856. /**
  133857. * Gets the world position input component
  133858. */
  133859. abstract get worldPosition(): NodeMaterialConnectionPoint;
  133860. /**
  133861. * Gets the world normal input component
  133862. */
  133863. abstract get worldNormal(): NodeMaterialConnectionPoint;
  133864. /**
  133865. * Gets the world input component
  133866. */
  133867. abstract get world(): NodeMaterialConnectionPoint;
  133868. /**
  133869. * Gets the camera (or eye) position component
  133870. */
  133871. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  133872. /**
  133873. * Gets the view input component
  133874. */
  133875. abstract get view(): NodeMaterialConnectionPoint;
  133876. protected _getTexture(): Nullable<BaseTexture>;
  133877. autoConfigure(material: NodeMaterial): void;
  133878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133879. isReady(): boolean;
  133880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133881. /**
  133882. * Gets the code to inject in the vertex shader
  133883. * @param state current state of the node material building
  133884. * @returns the shader code
  133885. */
  133886. handleVertexSide(state: NodeMaterialBuildState): string;
  133887. /**
  133888. * Handles the inits for the fragment code path
  133889. * @param state node material build state
  133890. */
  133891. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  133892. /**
  133893. * Generates the reflection coords code for the fragment code path
  133894. * @param worldNormalVarName name of the world normal variable
  133895. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  133896. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  133897. * @returns the shader code
  133898. */
  133899. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  133900. /**
  133901. * Generates the reflection color code for the fragment code path
  133902. * @param lodVarName name of the lod variable
  133903. * @param swizzleLookupTexture swizzle to use for the final color variable
  133904. * @returns the shader code
  133905. */
  133906. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  133907. /**
  133908. * Generates the code corresponding to the connected output points
  133909. * @param state node material build state
  133910. * @param varName name of the variable to output
  133911. * @returns the shader code
  133912. */
  133913. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  133914. protected _buildBlock(state: NodeMaterialBuildState): this;
  133915. protected _dumpPropertiesCode(): string;
  133916. serialize(): any;
  133917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133918. }
  133919. }
  133920. declare module BABYLON {
  133921. /**
  133922. * Defines a connection point to be used for points with a custom object type
  133923. */
  133924. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  133925. private _blockType;
  133926. private _blockName;
  133927. private _nameForCheking?;
  133928. /**
  133929. * Creates a new connection point
  133930. * @param name defines the connection point name
  133931. * @param ownerBlock defines the block hosting this connection point
  133932. * @param direction defines the direction of the connection point
  133933. */
  133934. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  133935. /**
  133936. * Gets a number indicating if the current point can be connected to another point
  133937. * @param connectionPoint defines the other connection point
  133938. * @returns a number defining the compatibility state
  133939. */
  133940. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  133941. /**
  133942. * Creates a block suitable to be used as an input for this input point.
  133943. * If null is returned, a block based on the point type will be created.
  133944. * @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
  133945. */
  133946. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  133947. }
  133948. }
  133949. declare module BABYLON {
  133950. /**
  133951. * Enum defining the type of properties that can be edited in the property pages in the NME
  133952. */
  133953. export enum PropertyTypeForEdition {
  133954. /** property is a boolean */
  133955. Boolean = 0,
  133956. /** property is a float */
  133957. Float = 1,
  133958. /** property is a Vector2 */
  133959. Vector2 = 2,
  133960. /** property is a list of values */
  133961. List = 3
  133962. }
  133963. /**
  133964. * Interface that defines an option in a variable of type list
  133965. */
  133966. export interface IEditablePropertyListOption {
  133967. /** label of the option */
  133968. "label": string;
  133969. /** value of the option */
  133970. "value": number;
  133971. }
  133972. /**
  133973. * Interface that defines the options available for an editable property
  133974. */
  133975. export interface IEditablePropertyOption {
  133976. /** min value */
  133977. "min"?: number;
  133978. /** max value */
  133979. "max"?: number;
  133980. /** notifiers: indicates which actions to take when the property is changed */
  133981. "notifiers"?: {
  133982. /** the material should be rebuilt */
  133983. "rebuild"?: boolean;
  133984. /** the preview should be updated */
  133985. "update"?: boolean;
  133986. };
  133987. /** list of the options for a variable of type list */
  133988. "options"?: IEditablePropertyListOption[];
  133989. }
  133990. /**
  133991. * Interface that describes an editable property
  133992. */
  133993. export interface IPropertyDescriptionForEdition {
  133994. /** name of the property */
  133995. "propertyName": string;
  133996. /** display name of the property */
  133997. "displayName": string;
  133998. /** type of the property */
  133999. "type": PropertyTypeForEdition;
  134000. /** group of the property - all properties with the same group value will be displayed in a specific section */
  134001. "groupName": string;
  134002. /** options for the property */
  134003. "options": IEditablePropertyOption;
  134004. }
  134005. /**
  134006. * Decorator that flags a property in a node material block as being editable
  134007. */
  134008. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  134009. }
  134010. declare module BABYLON {
  134011. /**
  134012. * Block used to implement the refraction part of the sub surface module of the PBR material
  134013. */
  134014. export class RefractionBlock extends NodeMaterialBlock {
  134015. /** @hidden */
  134016. _define3DName: string;
  134017. /** @hidden */
  134018. _refractionMatrixName: string;
  134019. /** @hidden */
  134020. _defineLODRefractionAlpha: string;
  134021. /** @hidden */
  134022. _defineLinearSpecularRefraction: string;
  134023. /** @hidden */
  134024. _defineOppositeZ: string;
  134025. /** @hidden */
  134026. _cubeSamplerName: string;
  134027. /** @hidden */
  134028. _2DSamplerName: string;
  134029. /** @hidden */
  134030. _vRefractionMicrosurfaceInfosName: string;
  134031. /** @hidden */
  134032. _vRefractionInfosName: string;
  134033. private _scene;
  134034. /**
  134035. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134036. * Materials half opaque for instance using refraction could benefit from this control.
  134037. */
  134038. linkRefractionWithTransparency: boolean;
  134039. /**
  134040. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134041. */
  134042. invertRefractionY: boolean;
  134043. /**
  134044. * Gets or sets the texture associated with the node
  134045. */
  134046. texture: Nullable<BaseTexture>;
  134047. /**
  134048. * Create a new RefractionBlock
  134049. * @param name defines the block name
  134050. */
  134051. constructor(name: string);
  134052. /**
  134053. * Gets the current class name
  134054. * @returns the class name
  134055. */
  134056. getClassName(): string;
  134057. /**
  134058. * Gets the intensity input component
  134059. */
  134060. get intensity(): NodeMaterialConnectionPoint;
  134061. /**
  134062. * Gets the index of refraction input component
  134063. */
  134064. get indexOfRefraction(): NodeMaterialConnectionPoint;
  134065. /**
  134066. * Gets the tint at distance input component
  134067. */
  134068. get tintAtDistance(): NodeMaterialConnectionPoint;
  134069. /**
  134070. * Gets the view input component
  134071. */
  134072. get view(): NodeMaterialConnectionPoint;
  134073. /**
  134074. * Gets the refraction object output component
  134075. */
  134076. get refraction(): NodeMaterialConnectionPoint;
  134077. /**
  134078. * Returns true if the block has a texture
  134079. */
  134080. get hasTexture(): boolean;
  134081. protected _getTexture(): Nullable<BaseTexture>;
  134082. autoConfigure(material: NodeMaterial): void;
  134083. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134084. isReady(): boolean;
  134085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  134086. /**
  134087. * Gets the main code of the block (fragment side)
  134088. * @param state current state of the node material building
  134089. * @returns the shader code
  134090. */
  134091. getCode(state: NodeMaterialBuildState): string;
  134092. protected _buildBlock(state: NodeMaterialBuildState): this;
  134093. protected _dumpPropertiesCode(): string;
  134094. serialize(): any;
  134095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134096. }
  134097. }
  134098. declare module BABYLON {
  134099. /**
  134100. * Base block used as input for post process
  134101. */
  134102. export class CurrentScreenBlock extends NodeMaterialBlock {
  134103. private _samplerName;
  134104. private _linearDefineName;
  134105. private _gammaDefineName;
  134106. private _mainUVName;
  134107. private _tempTextureRead;
  134108. /**
  134109. * Gets or sets the texture associated with the node
  134110. */
  134111. texture: Nullable<BaseTexture>;
  134112. /**
  134113. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134114. */
  134115. convertToGammaSpace: boolean;
  134116. /**
  134117. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134118. */
  134119. convertToLinearSpace: boolean;
  134120. /**
  134121. * Create a new CurrentScreenBlock
  134122. * @param name defines the block name
  134123. */
  134124. constructor(name: string);
  134125. /**
  134126. * Gets the current class name
  134127. * @returns the class name
  134128. */
  134129. getClassName(): string;
  134130. /**
  134131. * Gets the uv input component
  134132. */
  134133. get uv(): NodeMaterialConnectionPoint;
  134134. /**
  134135. * Gets the rgba output component
  134136. */
  134137. get rgba(): NodeMaterialConnectionPoint;
  134138. /**
  134139. * Gets the rgb output component
  134140. */
  134141. get rgb(): NodeMaterialConnectionPoint;
  134142. /**
  134143. * Gets the r output component
  134144. */
  134145. get r(): NodeMaterialConnectionPoint;
  134146. /**
  134147. * Gets the g output component
  134148. */
  134149. get g(): NodeMaterialConnectionPoint;
  134150. /**
  134151. * Gets the b output component
  134152. */
  134153. get b(): NodeMaterialConnectionPoint;
  134154. /**
  134155. * Gets the a output component
  134156. */
  134157. get a(): NodeMaterialConnectionPoint;
  134158. /**
  134159. * Initialize the block and prepare the context for build
  134160. * @param state defines the state that will be used for the build
  134161. */
  134162. initialize(state: NodeMaterialBuildState): void;
  134163. get target(): NodeMaterialBlockTargets;
  134164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134165. isReady(): boolean;
  134166. private _injectVertexCode;
  134167. private _writeTextureRead;
  134168. private _writeOutput;
  134169. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134170. serialize(): any;
  134171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134172. }
  134173. }
  134174. declare module BABYLON {
  134175. /**
  134176. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  134177. */
  134178. export class VectorMergerBlock extends NodeMaterialBlock {
  134179. /**
  134180. * Create a new VectorMergerBlock
  134181. * @param name defines the block name
  134182. */
  134183. constructor(name: string);
  134184. /**
  134185. * Gets the current class name
  134186. * @returns the class name
  134187. */
  134188. getClassName(): string;
  134189. /**
  134190. * Gets the xyz component (input)
  134191. */
  134192. get xyzIn(): NodeMaterialConnectionPoint;
  134193. /**
  134194. * Gets the xy component (input)
  134195. */
  134196. get xyIn(): NodeMaterialConnectionPoint;
  134197. /**
  134198. * Gets the x component (input)
  134199. */
  134200. get x(): NodeMaterialConnectionPoint;
  134201. /**
  134202. * Gets the y component (input)
  134203. */
  134204. get y(): NodeMaterialConnectionPoint;
  134205. /**
  134206. * Gets the z component (input)
  134207. */
  134208. get z(): NodeMaterialConnectionPoint;
  134209. /**
  134210. * Gets the w component (input)
  134211. */
  134212. get w(): NodeMaterialConnectionPoint;
  134213. /**
  134214. * Gets the xyzw component (output)
  134215. */
  134216. get xyzw(): NodeMaterialConnectionPoint;
  134217. /**
  134218. * Gets the xyz component (output)
  134219. */
  134220. get xyzOut(): NodeMaterialConnectionPoint;
  134221. /**
  134222. * Gets the xy component (output)
  134223. */
  134224. get xyOut(): NodeMaterialConnectionPoint;
  134225. /**
  134226. * Gets the xy component (output)
  134227. * @deprecated Please use xyOut instead.
  134228. */
  134229. get xy(): NodeMaterialConnectionPoint;
  134230. /**
  134231. * Gets the xyz component (output)
  134232. * @deprecated Please use xyzOut instead.
  134233. */
  134234. get xyz(): NodeMaterialConnectionPoint;
  134235. protected _buildBlock(state: NodeMaterialBuildState): this;
  134236. }
  134237. }
  134238. declare module BABYLON {
  134239. /**
  134240. * Block used to remap a float from a range to a new one
  134241. */
  134242. export class RemapBlock extends NodeMaterialBlock {
  134243. /**
  134244. * Gets or sets the source range
  134245. */
  134246. sourceRange: Vector2;
  134247. /**
  134248. * Gets or sets the target range
  134249. */
  134250. targetRange: Vector2;
  134251. /**
  134252. * Creates a new RemapBlock
  134253. * @param name defines the block name
  134254. */
  134255. constructor(name: string);
  134256. /**
  134257. * Gets the current class name
  134258. * @returns the class name
  134259. */
  134260. getClassName(): string;
  134261. /**
  134262. * Gets the input component
  134263. */
  134264. get input(): NodeMaterialConnectionPoint;
  134265. /**
  134266. * Gets the source min input component
  134267. */
  134268. get sourceMin(): NodeMaterialConnectionPoint;
  134269. /**
  134270. * Gets the source max input component
  134271. */
  134272. get sourceMax(): NodeMaterialConnectionPoint;
  134273. /**
  134274. * Gets the target min input component
  134275. */
  134276. get targetMin(): NodeMaterialConnectionPoint;
  134277. /**
  134278. * Gets the target max input component
  134279. */
  134280. get targetMax(): NodeMaterialConnectionPoint;
  134281. /**
  134282. * Gets the output component
  134283. */
  134284. get output(): NodeMaterialConnectionPoint;
  134285. protected _buildBlock(state: NodeMaterialBuildState): this;
  134286. protected _dumpPropertiesCode(): string;
  134287. serialize(): any;
  134288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134289. }
  134290. }
  134291. declare module BABYLON {
  134292. /**
  134293. * Block used to multiply 2 values
  134294. */
  134295. export class MultiplyBlock extends NodeMaterialBlock {
  134296. /**
  134297. * Creates a new MultiplyBlock
  134298. * @param name defines the block name
  134299. */
  134300. constructor(name: string);
  134301. /**
  134302. * Gets the current class name
  134303. * @returns the class name
  134304. */
  134305. getClassName(): string;
  134306. /**
  134307. * Gets the left operand input component
  134308. */
  134309. get left(): NodeMaterialConnectionPoint;
  134310. /**
  134311. * Gets the right operand input component
  134312. */
  134313. get right(): NodeMaterialConnectionPoint;
  134314. /**
  134315. * Gets the output component
  134316. */
  134317. get output(): NodeMaterialConnectionPoint;
  134318. protected _buildBlock(state: NodeMaterialBuildState): this;
  134319. }
  134320. }
  134321. declare module BABYLON {
  134322. /**
  134323. * Interface used to configure the node material editor
  134324. */
  134325. export interface INodeMaterialEditorOptions {
  134326. /** Define the URl to load node editor script */
  134327. editorURL?: string;
  134328. }
  134329. /** @hidden */
  134330. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  134331. NORMAL: boolean;
  134332. TANGENT: boolean;
  134333. UV1: boolean;
  134334. /** BONES */
  134335. NUM_BONE_INFLUENCERS: number;
  134336. BonesPerMesh: number;
  134337. BONETEXTURE: boolean;
  134338. /** MORPH TARGETS */
  134339. MORPHTARGETS: boolean;
  134340. MORPHTARGETS_NORMAL: boolean;
  134341. MORPHTARGETS_TANGENT: boolean;
  134342. MORPHTARGETS_UV: boolean;
  134343. NUM_MORPH_INFLUENCERS: number;
  134344. /** IMAGE PROCESSING */
  134345. IMAGEPROCESSING: boolean;
  134346. VIGNETTE: boolean;
  134347. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134348. VIGNETTEBLENDMODEOPAQUE: boolean;
  134349. TONEMAPPING: boolean;
  134350. TONEMAPPING_ACES: boolean;
  134351. CONTRAST: boolean;
  134352. EXPOSURE: boolean;
  134353. COLORCURVES: boolean;
  134354. COLORGRADING: boolean;
  134355. COLORGRADING3D: boolean;
  134356. SAMPLER3DGREENDEPTH: boolean;
  134357. SAMPLER3DBGRMAP: boolean;
  134358. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134359. /** MISC. */
  134360. BUMPDIRECTUV: number;
  134361. constructor();
  134362. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  134363. }
  134364. /**
  134365. * Class used to configure NodeMaterial
  134366. */
  134367. export interface INodeMaterialOptions {
  134368. /**
  134369. * Defines if blocks should emit comments
  134370. */
  134371. emitComments: boolean;
  134372. }
  134373. /**
  134374. * Class used to create a node based material built by assembling shader blocks
  134375. */
  134376. export class NodeMaterial extends PushMaterial {
  134377. private static _BuildIdGenerator;
  134378. private _options;
  134379. private _vertexCompilationState;
  134380. private _fragmentCompilationState;
  134381. private _sharedData;
  134382. private _buildId;
  134383. private _buildWasSuccessful;
  134384. private _cachedWorldViewMatrix;
  134385. private _cachedWorldViewProjectionMatrix;
  134386. private _optimizers;
  134387. private _animationFrame;
  134388. /** Define the Url to load node editor script */
  134389. static EditorURL: string;
  134390. /** Define the Url to load snippets */
  134391. static SnippetUrl: string;
  134392. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  134393. static IgnoreTexturesAtLoadTime: boolean;
  134394. private BJSNODEMATERIALEDITOR;
  134395. /** Get the inspector from bundle or global */
  134396. private _getGlobalNodeMaterialEditor;
  134397. /**
  134398. * Snippet ID if the material was created from the snippet server
  134399. */
  134400. snippetId: string;
  134401. /**
  134402. * Gets or sets data used by visual editor
  134403. * @see https://nme.babylonjs.com
  134404. */
  134405. editorData: any;
  134406. /**
  134407. * 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)
  134408. */
  134409. ignoreAlpha: boolean;
  134410. /**
  134411. * Defines the maximum number of lights that can be used in the material
  134412. */
  134413. maxSimultaneousLights: number;
  134414. /**
  134415. * Observable raised when the material is built
  134416. */
  134417. onBuildObservable: Observable<NodeMaterial>;
  134418. /**
  134419. * Gets or sets the root nodes of the material vertex shader
  134420. */
  134421. _vertexOutputNodes: NodeMaterialBlock[];
  134422. /**
  134423. * Gets or sets the root nodes of the material fragment (pixel) shader
  134424. */
  134425. _fragmentOutputNodes: NodeMaterialBlock[];
  134426. /** Gets or sets options to control the node material overall behavior */
  134427. get options(): INodeMaterialOptions;
  134428. set options(options: INodeMaterialOptions);
  134429. /**
  134430. * Default configuration related to image processing available in the standard Material.
  134431. */
  134432. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134433. /**
  134434. * Gets the image processing configuration used either in this material.
  134435. */
  134436. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134437. /**
  134438. * Sets the Default image processing configuration used either in the this material.
  134439. *
  134440. * If sets to null, the scene one is in use.
  134441. */
  134442. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134443. /**
  134444. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  134445. */
  134446. attachedBlocks: NodeMaterialBlock[];
  134447. /**
  134448. * Specifies the mode of the node material
  134449. * @hidden
  134450. */
  134451. _mode: NodeMaterialModes;
  134452. /**
  134453. * Gets the mode property
  134454. */
  134455. get mode(): NodeMaterialModes;
  134456. /**
  134457. * Create a new node based material
  134458. * @param name defines the material name
  134459. * @param scene defines the hosting scene
  134460. * @param options defines creation option
  134461. */
  134462. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  134463. /**
  134464. * Gets the current class name of the material e.g. "NodeMaterial"
  134465. * @returns the class name
  134466. */
  134467. getClassName(): string;
  134468. /**
  134469. * Keep track of the image processing observer to allow dispose and replace.
  134470. */
  134471. private _imageProcessingObserver;
  134472. /**
  134473. * Attaches a new image processing configuration to the Standard Material.
  134474. * @param configuration
  134475. */
  134476. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134477. /**
  134478. * Get a block by its name
  134479. * @param name defines the name of the block to retrieve
  134480. * @returns the required block or null if not found
  134481. */
  134482. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  134483. /**
  134484. * Get a block by its name
  134485. * @param predicate defines the predicate used to find the good candidate
  134486. * @returns the required block or null if not found
  134487. */
  134488. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  134489. /**
  134490. * Get an input block by its name
  134491. * @param predicate defines the predicate used to find the good candidate
  134492. * @returns the required input block or null if not found
  134493. */
  134494. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  134495. /**
  134496. * Gets the list of input blocks attached to this material
  134497. * @returns an array of InputBlocks
  134498. */
  134499. getInputBlocks(): InputBlock[];
  134500. /**
  134501. * Adds a new optimizer to the list of optimizers
  134502. * @param optimizer defines the optimizers to add
  134503. * @returns the current material
  134504. */
  134505. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  134506. /**
  134507. * Remove an optimizer from the list of optimizers
  134508. * @param optimizer defines the optimizers to remove
  134509. * @returns the current material
  134510. */
  134511. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  134512. /**
  134513. * Add a new block to the list of output nodes
  134514. * @param node defines the node to add
  134515. * @returns the current material
  134516. */
  134517. addOutputNode(node: NodeMaterialBlock): this;
  134518. /**
  134519. * Remove a block from the list of root nodes
  134520. * @param node defines the node to remove
  134521. * @returns the current material
  134522. */
  134523. removeOutputNode(node: NodeMaterialBlock): this;
  134524. private _addVertexOutputNode;
  134525. private _removeVertexOutputNode;
  134526. private _addFragmentOutputNode;
  134527. private _removeFragmentOutputNode;
  134528. /**
  134529. * Specifies if the material will require alpha blending
  134530. * @returns a boolean specifying if alpha blending is needed
  134531. */
  134532. needAlphaBlending(): boolean;
  134533. /**
  134534. * Specifies if this material should be rendered in alpha test mode
  134535. * @returns a boolean specifying if an alpha test is needed.
  134536. */
  134537. needAlphaTesting(): boolean;
  134538. private _initializeBlock;
  134539. private _resetDualBlocks;
  134540. /**
  134541. * Remove a block from the current node material
  134542. * @param block defines the block to remove
  134543. */
  134544. removeBlock(block: NodeMaterialBlock): void;
  134545. /**
  134546. * Build the material and generates the inner effect
  134547. * @param verbose defines if the build should log activity
  134548. */
  134549. build(verbose?: boolean): void;
  134550. /**
  134551. * Runs an otpimization phase to try to improve the shader code
  134552. */
  134553. optimize(): void;
  134554. private _prepareDefinesForAttributes;
  134555. /**
  134556. * Create a post process from the material
  134557. * @param camera The camera to apply the render pass to.
  134558. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  134559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134560. * @param engine The engine which the post process will be applied. (default: current engine)
  134561. * @param reusable If the post process can be reused on the same frame. (default: false)
  134562. * @param textureType Type of textures used when performing the post process. (default: 0)
  134563. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  134564. * @returns the post process created
  134565. */
  134566. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  134567. private _processDefines;
  134568. /**
  134569. * Get if the submesh is ready to be used and all its information available.
  134570. * Child classes can use it to update shaders
  134571. * @param mesh defines the mesh to check
  134572. * @param subMesh defines which submesh to check
  134573. * @param useInstances specifies that instances should be used
  134574. * @returns a boolean indicating that the submesh is ready or not
  134575. */
  134576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134577. /**
  134578. * Get a string representing the shaders built by the current node graph
  134579. */
  134580. get compiledShaders(): string;
  134581. /**
  134582. * Binds the world matrix to the material
  134583. * @param world defines the world transformation matrix
  134584. */
  134585. bindOnlyWorldMatrix(world: Matrix): void;
  134586. /**
  134587. * Binds the submesh to this material by preparing the effect and shader to draw
  134588. * @param world defines the world transformation matrix
  134589. * @param mesh defines the mesh containing the submesh
  134590. * @param subMesh defines the submesh to bind the material to
  134591. */
  134592. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134593. /**
  134594. * Gets the active textures from the material
  134595. * @returns an array of textures
  134596. */
  134597. getActiveTextures(): BaseTexture[];
  134598. /**
  134599. * Gets the list of texture blocks
  134600. * @returns an array of texture blocks
  134601. */
  134602. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  134603. /**
  134604. * Specifies if the material uses a texture
  134605. * @param texture defines the texture to check against the material
  134606. * @returns a boolean specifying if the material uses the texture
  134607. */
  134608. hasTexture(texture: BaseTexture): boolean;
  134609. /**
  134610. * Disposes the material
  134611. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  134612. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  134613. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  134614. */
  134615. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  134616. /** Creates the node editor window. */
  134617. private _createNodeEditor;
  134618. /**
  134619. * Launch the node material editor
  134620. * @param config Define the configuration of the editor
  134621. * @return a promise fulfilled when the node editor is visible
  134622. */
  134623. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  134624. /**
  134625. * Clear the current material
  134626. */
  134627. clear(): void;
  134628. /**
  134629. * Clear the current material and set it to a default state
  134630. */
  134631. setToDefault(): void;
  134632. /**
  134633. * Clear the current material and set it to a default state for post process
  134634. */
  134635. setToDefaultPostProcess(): void;
  134636. /**
  134637. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  134638. * @param url defines the url to load from
  134639. * @returns a promise that will fullfil when the material is fully loaded
  134640. */
  134641. loadAsync(url: string): Promise<void>;
  134642. private _gatherBlocks;
  134643. /**
  134644. * Generate a string containing the code declaration required to create an equivalent of this material
  134645. * @returns a string
  134646. */
  134647. generateCode(): string;
  134648. /**
  134649. * Serializes this material in a JSON representation
  134650. * @returns the serialized material object
  134651. */
  134652. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  134653. private _restoreConnections;
  134654. /**
  134655. * Clear the current graph and load a new one from a serialization object
  134656. * @param source defines the JSON representation of the material
  134657. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134658. */
  134659. loadFromSerialization(source: any, rootUrl?: string): void;
  134660. /**
  134661. * Makes a duplicate of the current material.
  134662. * @param name - name to use for the new material.
  134663. */
  134664. clone(name: string): NodeMaterial;
  134665. /**
  134666. * Creates a node material from parsed material data
  134667. * @param source defines the JSON representation of the material
  134668. * @param scene defines the hosting scene
  134669. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134670. * @returns a new node material
  134671. */
  134672. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  134673. /**
  134674. * Creates a node material from a snippet saved in a remote file
  134675. * @param name defines the name of the material to create
  134676. * @param url defines the url to load from
  134677. * @param scene defines the hosting scene
  134678. * @returns a promise that will resolve to the new node material
  134679. */
  134680. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  134681. /**
  134682. * Creates a node material from a snippet saved by the node material editor
  134683. * @param snippetId defines the snippet to load
  134684. * @param scene defines the hosting scene
  134685. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134686. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  134687. * @returns a promise that will resolve to the new node material
  134688. */
  134689. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  134690. /**
  134691. * Creates a new node material set to default basic configuration
  134692. * @param name defines the name of the material
  134693. * @param scene defines the hosting scene
  134694. * @returns a new NodeMaterial
  134695. */
  134696. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  134697. }
  134698. }
  134699. declare module BABYLON {
  134700. /**
  134701. * Block used to read a texture from a sampler
  134702. */
  134703. export class TextureBlock extends NodeMaterialBlock {
  134704. private _defineName;
  134705. private _linearDefineName;
  134706. private _gammaDefineName;
  134707. private _tempTextureRead;
  134708. private _samplerName;
  134709. private _transformedUVName;
  134710. private _textureTransformName;
  134711. private _textureInfoName;
  134712. private _mainUVName;
  134713. private _mainUVDefineName;
  134714. /**
  134715. * Gets or sets the texture associated with the node
  134716. */
  134717. texture: Nullable<Texture>;
  134718. /**
  134719. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134720. */
  134721. convertToGammaSpace: boolean;
  134722. /**
  134723. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134724. */
  134725. convertToLinearSpace: boolean;
  134726. /**
  134727. * Create a new TextureBlock
  134728. * @param name defines the block name
  134729. */
  134730. constructor(name: string);
  134731. /**
  134732. * Gets the current class name
  134733. * @returns the class name
  134734. */
  134735. getClassName(): string;
  134736. /**
  134737. * Gets the uv input component
  134738. */
  134739. get uv(): NodeMaterialConnectionPoint;
  134740. /**
  134741. * Gets the rgba output component
  134742. */
  134743. get rgba(): NodeMaterialConnectionPoint;
  134744. /**
  134745. * Gets the rgb output component
  134746. */
  134747. get rgb(): NodeMaterialConnectionPoint;
  134748. /**
  134749. * Gets the r output component
  134750. */
  134751. get r(): NodeMaterialConnectionPoint;
  134752. /**
  134753. * Gets the g output component
  134754. */
  134755. get g(): NodeMaterialConnectionPoint;
  134756. /**
  134757. * Gets the b output component
  134758. */
  134759. get b(): NodeMaterialConnectionPoint;
  134760. /**
  134761. * Gets the a output component
  134762. */
  134763. get a(): NodeMaterialConnectionPoint;
  134764. get target(): NodeMaterialBlockTargets;
  134765. autoConfigure(material: NodeMaterial): void;
  134766. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134768. isReady(): boolean;
  134769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134770. private get _isMixed();
  134771. private _injectVertexCode;
  134772. private _writeTextureRead;
  134773. private _writeOutput;
  134774. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134775. protected _dumpPropertiesCode(): string;
  134776. serialize(): any;
  134777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134778. }
  134779. }
  134780. declare module BABYLON {
  134781. /**
  134782. * Class used to store shared data between 2 NodeMaterialBuildState
  134783. */
  134784. export class NodeMaterialBuildStateSharedData {
  134785. /**
  134786. * Gets the list of emitted varyings
  134787. */
  134788. temps: string[];
  134789. /**
  134790. * Gets the list of emitted varyings
  134791. */
  134792. varyings: string[];
  134793. /**
  134794. * Gets the varying declaration string
  134795. */
  134796. varyingDeclaration: string;
  134797. /**
  134798. * Input blocks
  134799. */
  134800. inputBlocks: InputBlock[];
  134801. /**
  134802. * Input blocks
  134803. */
  134804. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  134805. /**
  134806. * Bindable blocks (Blocks that need to set data to the effect)
  134807. */
  134808. bindableBlocks: NodeMaterialBlock[];
  134809. /**
  134810. * List of blocks that can provide a compilation fallback
  134811. */
  134812. blocksWithFallbacks: NodeMaterialBlock[];
  134813. /**
  134814. * List of blocks that can provide a define update
  134815. */
  134816. blocksWithDefines: NodeMaterialBlock[];
  134817. /**
  134818. * List of blocks that can provide a repeatable content
  134819. */
  134820. repeatableContentBlocks: NodeMaterialBlock[];
  134821. /**
  134822. * List of blocks that can provide a dynamic list of uniforms
  134823. */
  134824. dynamicUniformBlocks: NodeMaterialBlock[];
  134825. /**
  134826. * List of blocks that can block the isReady function for the material
  134827. */
  134828. blockingBlocks: NodeMaterialBlock[];
  134829. /**
  134830. * Gets the list of animated inputs
  134831. */
  134832. animatedInputs: InputBlock[];
  134833. /**
  134834. * Build Id used to avoid multiple recompilations
  134835. */
  134836. buildId: number;
  134837. /** List of emitted variables */
  134838. variableNames: {
  134839. [key: string]: number;
  134840. };
  134841. /** List of emitted defines */
  134842. defineNames: {
  134843. [key: string]: number;
  134844. };
  134845. /** Should emit comments? */
  134846. emitComments: boolean;
  134847. /** Emit build activity */
  134848. verbose: boolean;
  134849. /** Gets or sets the hosting scene */
  134850. scene: Scene;
  134851. /**
  134852. * Gets the compilation hints emitted at compilation time
  134853. */
  134854. hints: {
  134855. needWorldViewMatrix: boolean;
  134856. needWorldViewProjectionMatrix: boolean;
  134857. needAlphaBlending: boolean;
  134858. needAlphaTesting: boolean;
  134859. };
  134860. /**
  134861. * List of compilation checks
  134862. */
  134863. checks: {
  134864. emitVertex: boolean;
  134865. emitFragment: boolean;
  134866. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  134867. };
  134868. /** Creates a new shared data */
  134869. constructor();
  134870. /**
  134871. * Emits console errors and exceptions if there is a failing check
  134872. */
  134873. emitErrors(): void;
  134874. }
  134875. }
  134876. declare module BABYLON {
  134877. /**
  134878. * Class used to store node based material build state
  134879. */
  134880. export class NodeMaterialBuildState {
  134881. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  134882. supportUniformBuffers: boolean;
  134883. /**
  134884. * Gets the list of emitted attributes
  134885. */
  134886. attributes: string[];
  134887. /**
  134888. * Gets the list of emitted uniforms
  134889. */
  134890. uniforms: string[];
  134891. /**
  134892. * Gets the list of emitted constants
  134893. */
  134894. constants: string[];
  134895. /**
  134896. * Gets the list of emitted samplers
  134897. */
  134898. samplers: string[];
  134899. /**
  134900. * Gets the list of emitted functions
  134901. */
  134902. functions: {
  134903. [key: string]: string;
  134904. };
  134905. /**
  134906. * Gets the list of emitted extensions
  134907. */
  134908. extensions: {
  134909. [key: string]: string;
  134910. };
  134911. /**
  134912. * Gets the target of the compilation state
  134913. */
  134914. target: NodeMaterialBlockTargets;
  134915. /**
  134916. * Gets the list of emitted counters
  134917. */
  134918. counters: {
  134919. [key: string]: number;
  134920. };
  134921. /**
  134922. * Shared data between multiple NodeMaterialBuildState instances
  134923. */
  134924. sharedData: NodeMaterialBuildStateSharedData;
  134925. /** @hidden */
  134926. _vertexState: NodeMaterialBuildState;
  134927. /** @hidden */
  134928. _attributeDeclaration: string;
  134929. /** @hidden */
  134930. _uniformDeclaration: string;
  134931. /** @hidden */
  134932. _constantDeclaration: string;
  134933. /** @hidden */
  134934. _samplerDeclaration: string;
  134935. /** @hidden */
  134936. _varyingTransfer: string;
  134937. /** @hidden */
  134938. _injectAtEnd: string;
  134939. private _repeatableContentAnchorIndex;
  134940. /** @hidden */
  134941. _builtCompilationString: string;
  134942. /**
  134943. * Gets the emitted compilation strings
  134944. */
  134945. compilationString: string;
  134946. /**
  134947. * Finalize the compilation strings
  134948. * @param state defines the current compilation state
  134949. */
  134950. finalize(state: NodeMaterialBuildState): void;
  134951. /** @hidden */
  134952. get _repeatableContentAnchor(): string;
  134953. /** @hidden */
  134954. _getFreeVariableName(prefix: string): string;
  134955. /** @hidden */
  134956. _getFreeDefineName(prefix: string): string;
  134957. /** @hidden */
  134958. _excludeVariableName(name: string): void;
  134959. /** @hidden */
  134960. _emit2DSampler(name: string): void;
  134961. /** @hidden */
  134962. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  134963. /** @hidden */
  134964. _emitExtension(name: string, extension: string, define?: string): void;
  134965. /** @hidden */
  134966. _emitFunction(name: string, code: string, comments: string): void;
  134967. /** @hidden */
  134968. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  134969. replaceStrings?: {
  134970. search: RegExp;
  134971. replace: string;
  134972. }[];
  134973. repeatKey?: string;
  134974. }): string;
  134975. /** @hidden */
  134976. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  134977. repeatKey?: string;
  134978. removeAttributes?: boolean;
  134979. removeUniforms?: boolean;
  134980. removeVaryings?: boolean;
  134981. removeIfDef?: boolean;
  134982. replaceStrings?: {
  134983. search: RegExp;
  134984. replace: string;
  134985. }[];
  134986. }, storeKey?: string): void;
  134987. /** @hidden */
  134988. _registerTempVariable(name: string): boolean;
  134989. /** @hidden */
  134990. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  134991. /** @hidden */
  134992. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  134993. /** @hidden */
  134994. _emitFloat(value: number): string;
  134995. }
  134996. }
  134997. declare module BABYLON {
  134998. /**
  134999. * Defines a block that can be used inside a node based material
  135000. */
  135001. export class NodeMaterialBlock {
  135002. private _buildId;
  135003. private _buildTarget;
  135004. private _target;
  135005. private _isFinalMerger;
  135006. private _isInput;
  135007. protected _isUnique: boolean;
  135008. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  135009. inputsAreExclusive: boolean;
  135010. /** @hidden */
  135011. _codeVariableName: string;
  135012. /** @hidden */
  135013. _inputs: NodeMaterialConnectionPoint[];
  135014. /** @hidden */
  135015. _outputs: NodeMaterialConnectionPoint[];
  135016. /** @hidden */
  135017. _preparationId: number;
  135018. /**
  135019. * Gets or sets the name of the block
  135020. */
  135021. name: string;
  135022. /**
  135023. * Gets or sets the unique id of the node
  135024. */
  135025. uniqueId: number;
  135026. /**
  135027. * Gets or sets the comments associated with this block
  135028. */
  135029. comments: string;
  135030. /**
  135031. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  135032. */
  135033. get isUnique(): boolean;
  135034. /**
  135035. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  135036. */
  135037. get isFinalMerger(): boolean;
  135038. /**
  135039. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  135040. */
  135041. get isInput(): boolean;
  135042. /**
  135043. * Gets or sets the build Id
  135044. */
  135045. get buildId(): number;
  135046. set buildId(value: number);
  135047. /**
  135048. * Gets or sets the target of the block
  135049. */
  135050. get target(): NodeMaterialBlockTargets;
  135051. set target(value: NodeMaterialBlockTargets);
  135052. /**
  135053. * Gets the list of input points
  135054. */
  135055. get inputs(): NodeMaterialConnectionPoint[];
  135056. /** Gets the list of output points */
  135057. get outputs(): NodeMaterialConnectionPoint[];
  135058. /**
  135059. * Find an input by its name
  135060. * @param name defines the name of the input to look for
  135061. * @returns the input or null if not found
  135062. */
  135063. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  135064. /**
  135065. * Find an output by its name
  135066. * @param name defines the name of the outputto look for
  135067. * @returns the output or null if not found
  135068. */
  135069. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  135070. /**
  135071. * Creates a new NodeMaterialBlock
  135072. * @param name defines the block name
  135073. * @param target defines the target of that block (Vertex by default)
  135074. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  135075. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  135076. */
  135077. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  135078. /**
  135079. * Initialize the block and prepare the context for build
  135080. * @param state defines the state that will be used for the build
  135081. */
  135082. initialize(state: NodeMaterialBuildState): void;
  135083. /**
  135084. * Bind data to effect. Will only be called for blocks with isBindable === true
  135085. * @param effect defines the effect to bind data to
  135086. * @param nodeMaterial defines the hosting NodeMaterial
  135087. * @param mesh defines the mesh that will be rendered
  135088. * @param subMesh defines the submesh that will be rendered
  135089. */
  135090. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  135091. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  135092. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  135093. protected _writeFloat(value: number): string;
  135094. /**
  135095. * Gets the current class name e.g. "NodeMaterialBlock"
  135096. * @returns the class name
  135097. */
  135098. getClassName(): string;
  135099. /**
  135100. * Register a new input. Must be called inside a block constructor
  135101. * @param name defines the connection point name
  135102. * @param type defines the connection point type
  135103. * @param isOptional defines a boolean indicating that this input can be omitted
  135104. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  135105. * @param point an already created connection point. If not provided, create a new one
  135106. * @returns the current block
  135107. */
  135108. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  135109. /**
  135110. * Register a new output. Must be called inside a block constructor
  135111. * @param name defines the connection point name
  135112. * @param type defines the connection point type
  135113. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  135114. * @param point an already created connection point. If not provided, create a new one
  135115. * @returns the current block
  135116. */
  135117. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  135118. /**
  135119. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  135120. * @param forOutput defines an optional connection point to check compatibility with
  135121. * @returns the first available input or null
  135122. */
  135123. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  135124. /**
  135125. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  135126. * @param forBlock defines an optional block to check compatibility with
  135127. * @returns the first available input or null
  135128. */
  135129. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  135130. /**
  135131. * Gets the sibling of the given output
  135132. * @param current defines the current output
  135133. * @returns the next output in the list or null
  135134. */
  135135. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  135136. /**
  135137. * Connect current block with another block
  135138. * @param other defines the block to connect with
  135139. * @param options define the various options to help pick the right connections
  135140. * @returns the current block
  135141. */
  135142. connectTo(other: NodeMaterialBlock, options?: {
  135143. input?: string;
  135144. output?: string;
  135145. outputSwizzle?: string;
  135146. }): this | undefined;
  135147. protected _buildBlock(state: NodeMaterialBuildState): void;
  135148. /**
  135149. * Add uniforms, samplers and uniform buffers at compilation time
  135150. * @param state defines the state to update
  135151. * @param nodeMaterial defines the node material requesting the update
  135152. * @param defines defines the material defines to update
  135153. * @param uniformBuffers defines the list of uniform buffer names
  135154. */
  135155. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  135156. /**
  135157. * Add potential fallbacks if shader compilation fails
  135158. * @param mesh defines the mesh to be rendered
  135159. * @param fallbacks defines the current prioritized list of fallbacks
  135160. */
  135161. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135162. /**
  135163. * Initialize defines for shader compilation
  135164. * @param mesh defines the mesh to be rendered
  135165. * @param nodeMaterial defines the node material requesting the update
  135166. * @param defines defines the material defines to update
  135167. * @param useInstances specifies that instances should be used
  135168. */
  135169. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135170. /**
  135171. * Update defines for shader compilation
  135172. * @param mesh defines the mesh to be rendered
  135173. * @param nodeMaterial defines the node material requesting the update
  135174. * @param defines defines the material defines to update
  135175. * @param useInstances specifies that instances should be used
  135176. */
  135177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135178. /**
  135179. * Lets the block try to connect some inputs automatically
  135180. * @param material defines the hosting NodeMaterial
  135181. */
  135182. autoConfigure(material: NodeMaterial): void;
  135183. /**
  135184. * Function called when a block is declared as repeatable content generator
  135185. * @param vertexShaderState defines the current compilation state for the vertex shader
  135186. * @param fragmentShaderState defines the current compilation state for the fragment shader
  135187. * @param mesh defines the mesh to be rendered
  135188. * @param defines defines the material defines to update
  135189. */
  135190. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135191. /**
  135192. * Checks if the block is ready
  135193. * @param mesh defines the mesh to be rendered
  135194. * @param nodeMaterial defines the node material requesting the update
  135195. * @param defines defines the material defines to update
  135196. * @param useInstances specifies that instances should be used
  135197. * @returns true if the block is ready
  135198. */
  135199. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  135200. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  135201. private _processBuild;
  135202. /**
  135203. * Compile the current node and generate the shader code
  135204. * @param state defines the current compilation state (uniforms, samplers, current string)
  135205. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  135206. * @returns true if already built
  135207. */
  135208. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  135209. protected _inputRename(name: string): string;
  135210. protected _outputRename(name: string): string;
  135211. protected _dumpPropertiesCode(): string;
  135212. /** @hidden */
  135213. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  135214. /** @hidden */
  135215. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  135216. /**
  135217. * Clone the current block to a new identical block
  135218. * @param scene defines the hosting scene
  135219. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  135220. * @returns a copy of the current block
  135221. */
  135222. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  135223. /**
  135224. * Serializes this block in a JSON representation
  135225. * @returns the serialized block object
  135226. */
  135227. serialize(): any;
  135228. /** @hidden */
  135229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135230. private _deserializePortDisplayNames;
  135231. /**
  135232. * Release resources
  135233. */
  135234. dispose(): void;
  135235. }
  135236. }
  135237. declare module BABYLON {
  135238. /**
  135239. * Enum defining the type of animations supported by InputBlock
  135240. */
  135241. export enum AnimatedInputBlockTypes {
  135242. /** No animation */
  135243. None = 0,
  135244. /** Time based animation. Will only work for floats */
  135245. Time = 1
  135246. }
  135247. }
  135248. declare module BABYLON {
  135249. /**
  135250. * Block used to expose an input value
  135251. */
  135252. export class InputBlock extends NodeMaterialBlock {
  135253. private _mode;
  135254. private _associatedVariableName;
  135255. private _storedValue;
  135256. private _valueCallback;
  135257. private _type;
  135258. private _animationType;
  135259. /** Gets or set a value used to limit the range of float values */
  135260. min: number;
  135261. /** Gets or set a value used to limit the range of float values */
  135262. max: number;
  135263. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  135264. isBoolean: boolean;
  135265. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  135266. matrixMode: number;
  135267. /** @hidden */
  135268. _systemValue: Nullable<NodeMaterialSystemValues>;
  135269. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  135270. visibleInInspector: boolean;
  135271. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  135272. isConstant: boolean;
  135273. /** Gets or sets the group to use to display this block in the Inspector */
  135274. groupInInspector: string;
  135275. /** Gets an observable raised when the value is changed */
  135276. onValueChangedObservable: Observable<InputBlock>;
  135277. /**
  135278. * Gets or sets the connection point type (default is float)
  135279. */
  135280. get type(): NodeMaterialBlockConnectionPointTypes;
  135281. /**
  135282. * Creates a new InputBlock
  135283. * @param name defines the block name
  135284. * @param target defines the target of that block (Vertex by default)
  135285. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  135286. */
  135287. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  135288. /**
  135289. * Gets the output component
  135290. */
  135291. get output(): NodeMaterialConnectionPoint;
  135292. /**
  135293. * Set the source of this connection point to a vertex attribute
  135294. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  135295. * @returns the current connection point
  135296. */
  135297. setAsAttribute(attributeName?: string): InputBlock;
  135298. /**
  135299. * Set the source of this connection point to a system value
  135300. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  135301. * @returns the current connection point
  135302. */
  135303. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  135304. /**
  135305. * Gets or sets the value of that point.
  135306. * Please note that this value will be ignored if valueCallback is defined
  135307. */
  135308. get value(): any;
  135309. set value(value: any);
  135310. /**
  135311. * Gets or sets a callback used to get the value of that point.
  135312. * Please note that setting this value will force the connection point to ignore the value property
  135313. */
  135314. get valueCallback(): () => any;
  135315. set valueCallback(value: () => any);
  135316. /**
  135317. * Gets or sets the associated variable name in the shader
  135318. */
  135319. get associatedVariableName(): string;
  135320. set associatedVariableName(value: string);
  135321. /** Gets or sets the type of animation applied to the input */
  135322. get animationType(): AnimatedInputBlockTypes;
  135323. set animationType(value: AnimatedInputBlockTypes);
  135324. /**
  135325. * Gets a boolean indicating that this connection point not defined yet
  135326. */
  135327. get isUndefined(): boolean;
  135328. /**
  135329. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  135330. * In this case the connection point name must be the name of the uniform to use.
  135331. * Can only be set on inputs
  135332. */
  135333. get isUniform(): boolean;
  135334. set isUniform(value: boolean);
  135335. /**
  135336. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  135337. * In this case the connection point name must be the name of the attribute to use
  135338. * Can only be set on inputs
  135339. */
  135340. get isAttribute(): boolean;
  135341. set isAttribute(value: boolean);
  135342. /**
  135343. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  135344. * Can only be set on exit points
  135345. */
  135346. get isVarying(): boolean;
  135347. set isVarying(value: boolean);
  135348. /**
  135349. * Gets a boolean indicating that the current connection point is a system value
  135350. */
  135351. get isSystemValue(): boolean;
  135352. /**
  135353. * Gets or sets the current well known value or null if not defined as a system value
  135354. */
  135355. get systemValue(): Nullable<NodeMaterialSystemValues>;
  135356. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  135357. /**
  135358. * Gets the current class name
  135359. * @returns the class name
  135360. */
  135361. getClassName(): string;
  135362. /**
  135363. * Animate the input if animationType !== None
  135364. * @param scene defines the rendering scene
  135365. */
  135366. animate(scene: Scene): void;
  135367. private _emitDefine;
  135368. initialize(state: NodeMaterialBuildState): void;
  135369. /**
  135370. * Set the input block to its default value (based on its type)
  135371. */
  135372. setDefaultValue(): void;
  135373. private _emitConstant;
  135374. private _emit;
  135375. /** @hidden */
  135376. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  135377. /** @hidden */
  135378. _transmit(effect: Effect, scene: Scene): void;
  135379. protected _buildBlock(state: NodeMaterialBuildState): void;
  135380. protected _dumpPropertiesCode(): string;
  135381. dispose(): void;
  135382. serialize(): any;
  135383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135384. }
  135385. }
  135386. declare module BABYLON {
  135387. /**
  135388. * Enum used to define the compatibility state between two connection points
  135389. */
  135390. export enum NodeMaterialConnectionPointCompatibilityStates {
  135391. /** Points are compatibles */
  135392. Compatible = 0,
  135393. /** Points are incompatible because of their types */
  135394. TypeIncompatible = 1,
  135395. /** Points are incompatible because of their targets (vertex vs fragment) */
  135396. TargetIncompatible = 2
  135397. }
  135398. /**
  135399. * Defines the direction of a connection point
  135400. */
  135401. export enum NodeMaterialConnectionPointDirection {
  135402. /** Input */
  135403. Input = 0,
  135404. /** Output */
  135405. Output = 1
  135406. }
  135407. /**
  135408. * Defines a connection point for a block
  135409. */
  135410. export class NodeMaterialConnectionPoint {
  135411. /** @hidden */
  135412. _ownerBlock: NodeMaterialBlock;
  135413. /** @hidden */
  135414. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  135415. private _endpoints;
  135416. private _associatedVariableName;
  135417. private _direction;
  135418. /** @hidden */
  135419. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  135420. /** @hidden */
  135421. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  135422. private _type;
  135423. /** @hidden */
  135424. _enforceAssociatedVariableName: boolean;
  135425. /** Gets the direction of the point */
  135426. get direction(): NodeMaterialConnectionPointDirection;
  135427. /** Indicates that this connection point needs dual validation before being connected to another point */
  135428. needDualDirectionValidation: boolean;
  135429. /**
  135430. * Gets or sets the additional types supported by this connection point
  135431. */
  135432. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  135433. /**
  135434. * Gets or sets the additional types excluded by this connection point
  135435. */
  135436. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  135437. /**
  135438. * Observable triggered when this point is connected
  135439. */
  135440. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  135441. /**
  135442. * Gets or sets the associated variable name in the shader
  135443. */
  135444. get associatedVariableName(): string;
  135445. set associatedVariableName(value: string);
  135446. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  135447. get innerType(): NodeMaterialBlockConnectionPointTypes;
  135448. /**
  135449. * Gets or sets the connection point type (default is float)
  135450. */
  135451. get type(): NodeMaterialBlockConnectionPointTypes;
  135452. set type(value: NodeMaterialBlockConnectionPointTypes);
  135453. /**
  135454. * Gets or sets the connection point name
  135455. */
  135456. name: string;
  135457. /**
  135458. * Gets or sets the connection point name
  135459. */
  135460. displayName: string;
  135461. /**
  135462. * Gets or sets a boolean indicating that this connection point can be omitted
  135463. */
  135464. isOptional: boolean;
  135465. /**
  135466. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  135467. */
  135468. define: string;
  135469. /** @hidden */
  135470. _prioritizeVertex: boolean;
  135471. private _target;
  135472. /** Gets or sets the target of that connection point */
  135473. get target(): NodeMaterialBlockTargets;
  135474. set target(value: NodeMaterialBlockTargets);
  135475. /**
  135476. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  135477. */
  135478. get isConnected(): boolean;
  135479. /**
  135480. * Gets a boolean indicating that the current point is connected to an input block
  135481. */
  135482. get isConnectedToInputBlock(): boolean;
  135483. /**
  135484. * Gets a the connected input block (if any)
  135485. */
  135486. get connectInputBlock(): Nullable<InputBlock>;
  135487. /** Get the other side of the connection (if any) */
  135488. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  135489. /** Get the block that owns this connection point */
  135490. get ownerBlock(): NodeMaterialBlock;
  135491. /** Get the block connected on the other side of this connection (if any) */
  135492. get sourceBlock(): Nullable<NodeMaterialBlock>;
  135493. /** Get the block connected on the endpoints of this connection (if any) */
  135494. get connectedBlocks(): Array<NodeMaterialBlock>;
  135495. /** Gets the list of connected endpoints */
  135496. get endpoints(): NodeMaterialConnectionPoint[];
  135497. /** Gets a boolean indicating if that output point is connected to at least one input */
  135498. get hasEndpoints(): boolean;
  135499. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  135500. get isConnectedInVertexShader(): boolean;
  135501. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  135502. get isConnectedInFragmentShader(): boolean;
  135503. /**
  135504. * Creates a block suitable to be used as an input for this input point.
  135505. * If null is returned, a block based on the point type will be created.
  135506. * @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
  135507. */
  135508. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  135509. /**
  135510. * Creates a new connection point
  135511. * @param name defines the connection point name
  135512. * @param ownerBlock defines the block hosting this connection point
  135513. * @param direction defines the direction of the connection point
  135514. */
  135515. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  135516. /**
  135517. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  135518. * @returns the class name
  135519. */
  135520. getClassName(): string;
  135521. /**
  135522. * Gets a boolean indicating if the current point can be connected to another point
  135523. * @param connectionPoint defines the other connection point
  135524. * @returns a boolean
  135525. */
  135526. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  135527. /**
  135528. * Gets a number indicating if the current point can be connected to another point
  135529. * @param connectionPoint defines the other connection point
  135530. * @returns a number defining the compatibility state
  135531. */
  135532. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  135533. /**
  135534. * Connect this point to another connection point
  135535. * @param connectionPoint defines the other connection point
  135536. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  135537. * @returns the current connection point
  135538. */
  135539. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  135540. /**
  135541. * Disconnect this point from one of his endpoint
  135542. * @param endpoint defines the other connection point
  135543. * @returns the current connection point
  135544. */
  135545. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  135546. /**
  135547. * Serializes this point in a JSON representation
  135548. * @param isInput defines if the connection point is an input (default is true)
  135549. * @returns the serialized point object
  135550. */
  135551. serialize(isInput?: boolean): any;
  135552. /**
  135553. * Release resources
  135554. */
  135555. dispose(): void;
  135556. }
  135557. }
  135558. declare module BABYLON {
  135559. /**
  135560. * Block used to add support for vertex skinning (bones)
  135561. */
  135562. export class BonesBlock extends NodeMaterialBlock {
  135563. /**
  135564. * Creates a new BonesBlock
  135565. * @param name defines the block name
  135566. */
  135567. constructor(name: string);
  135568. /**
  135569. * Initialize the block and prepare the context for build
  135570. * @param state defines the state that will be used for the build
  135571. */
  135572. initialize(state: NodeMaterialBuildState): void;
  135573. /**
  135574. * Gets the current class name
  135575. * @returns the class name
  135576. */
  135577. getClassName(): string;
  135578. /**
  135579. * Gets the matrix indices input component
  135580. */
  135581. get matricesIndices(): NodeMaterialConnectionPoint;
  135582. /**
  135583. * Gets the matrix weights input component
  135584. */
  135585. get matricesWeights(): NodeMaterialConnectionPoint;
  135586. /**
  135587. * Gets the extra matrix indices input component
  135588. */
  135589. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  135590. /**
  135591. * Gets the extra matrix weights input component
  135592. */
  135593. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  135594. /**
  135595. * Gets the world input component
  135596. */
  135597. get world(): NodeMaterialConnectionPoint;
  135598. /**
  135599. * Gets the output component
  135600. */
  135601. get output(): NodeMaterialConnectionPoint;
  135602. autoConfigure(material: NodeMaterial): void;
  135603. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135604. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135606. protected _buildBlock(state: NodeMaterialBuildState): this;
  135607. }
  135608. }
  135609. declare module BABYLON {
  135610. /**
  135611. * Block used to add support for instances
  135612. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  135613. */
  135614. export class InstancesBlock extends NodeMaterialBlock {
  135615. /**
  135616. * Creates a new InstancesBlock
  135617. * @param name defines the block name
  135618. */
  135619. constructor(name: string);
  135620. /**
  135621. * Gets the current class name
  135622. * @returns the class name
  135623. */
  135624. getClassName(): string;
  135625. /**
  135626. * Gets the first world row input component
  135627. */
  135628. get world0(): NodeMaterialConnectionPoint;
  135629. /**
  135630. * Gets the second world row input component
  135631. */
  135632. get world1(): NodeMaterialConnectionPoint;
  135633. /**
  135634. * Gets the third world row input component
  135635. */
  135636. get world2(): NodeMaterialConnectionPoint;
  135637. /**
  135638. * Gets the forth world row input component
  135639. */
  135640. get world3(): NodeMaterialConnectionPoint;
  135641. /**
  135642. * Gets the world input component
  135643. */
  135644. get world(): NodeMaterialConnectionPoint;
  135645. /**
  135646. * Gets the output component
  135647. */
  135648. get output(): NodeMaterialConnectionPoint;
  135649. /**
  135650. * Gets the isntanceID component
  135651. */
  135652. get instanceID(): NodeMaterialConnectionPoint;
  135653. autoConfigure(material: NodeMaterial): void;
  135654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135655. protected _buildBlock(state: NodeMaterialBuildState): this;
  135656. }
  135657. }
  135658. declare module BABYLON {
  135659. /**
  135660. * Block used to add morph targets support to vertex shader
  135661. */
  135662. export class MorphTargetsBlock extends NodeMaterialBlock {
  135663. private _repeatableContentAnchor;
  135664. /**
  135665. * Create a new MorphTargetsBlock
  135666. * @param name defines the block name
  135667. */
  135668. constructor(name: string);
  135669. /**
  135670. * Gets the current class name
  135671. * @returns the class name
  135672. */
  135673. getClassName(): string;
  135674. /**
  135675. * Gets the position input component
  135676. */
  135677. get position(): NodeMaterialConnectionPoint;
  135678. /**
  135679. * Gets the normal input component
  135680. */
  135681. get normal(): NodeMaterialConnectionPoint;
  135682. /**
  135683. * Gets the tangent input component
  135684. */
  135685. get tangent(): NodeMaterialConnectionPoint;
  135686. /**
  135687. * Gets the tangent input component
  135688. */
  135689. get uv(): NodeMaterialConnectionPoint;
  135690. /**
  135691. * Gets the position output component
  135692. */
  135693. get positionOutput(): NodeMaterialConnectionPoint;
  135694. /**
  135695. * Gets the normal output component
  135696. */
  135697. get normalOutput(): NodeMaterialConnectionPoint;
  135698. /**
  135699. * Gets the tangent output component
  135700. */
  135701. get tangentOutput(): NodeMaterialConnectionPoint;
  135702. /**
  135703. * Gets the tangent output component
  135704. */
  135705. get uvOutput(): NodeMaterialConnectionPoint;
  135706. initialize(state: NodeMaterialBuildState): void;
  135707. autoConfigure(material: NodeMaterial): void;
  135708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135710. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135711. protected _buildBlock(state: NodeMaterialBuildState): this;
  135712. }
  135713. }
  135714. declare module BABYLON {
  135715. /**
  135716. * Block used to get data information from a light
  135717. */
  135718. export class LightInformationBlock extends NodeMaterialBlock {
  135719. private _lightDataUniformName;
  135720. private _lightColorUniformName;
  135721. private _lightTypeDefineName;
  135722. /**
  135723. * Gets or sets the light associated with this block
  135724. */
  135725. light: Nullable<Light>;
  135726. /**
  135727. * Creates a new LightInformationBlock
  135728. * @param name defines the block name
  135729. */
  135730. constructor(name: string);
  135731. /**
  135732. * Gets the current class name
  135733. * @returns the class name
  135734. */
  135735. getClassName(): string;
  135736. /**
  135737. * Gets the world position input component
  135738. */
  135739. get worldPosition(): NodeMaterialConnectionPoint;
  135740. /**
  135741. * Gets the direction output component
  135742. */
  135743. get direction(): NodeMaterialConnectionPoint;
  135744. /**
  135745. * Gets the direction output component
  135746. */
  135747. get color(): NodeMaterialConnectionPoint;
  135748. /**
  135749. * Gets the direction output component
  135750. */
  135751. get intensity(): NodeMaterialConnectionPoint;
  135752. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135754. protected _buildBlock(state: NodeMaterialBuildState): this;
  135755. serialize(): any;
  135756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135757. }
  135758. }
  135759. declare module BABYLON {
  135760. /**
  135761. * Block used to add image processing support to fragment shader
  135762. */
  135763. export class ImageProcessingBlock extends NodeMaterialBlock {
  135764. /**
  135765. * Create a new ImageProcessingBlock
  135766. * @param name defines the block name
  135767. */
  135768. constructor(name: string);
  135769. /**
  135770. * Gets the current class name
  135771. * @returns the class name
  135772. */
  135773. getClassName(): string;
  135774. /**
  135775. * Gets the color input component
  135776. */
  135777. get color(): NodeMaterialConnectionPoint;
  135778. /**
  135779. * Gets the output component
  135780. */
  135781. get output(): NodeMaterialConnectionPoint;
  135782. /**
  135783. * Initialize the block and prepare the context for build
  135784. * @param state defines the state that will be used for the build
  135785. */
  135786. initialize(state: NodeMaterialBuildState): void;
  135787. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  135788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135790. protected _buildBlock(state: NodeMaterialBuildState): this;
  135791. }
  135792. }
  135793. declare module BABYLON {
  135794. /**
  135795. * Block used to pertub normals based on a normal map
  135796. */
  135797. export class PerturbNormalBlock extends NodeMaterialBlock {
  135798. private _tangentSpaceParameterName;
  135799. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  135800. invertX: boolean;
  135801. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  135802. invertY: boolean;
  135803. /**
  135804. * Create a new PerturbNormalBlock
  135805. * @param name defines the block name
  135806. */
  135807. constructor(name: string);
  135808. /**
  135809. * Gets the current class name
  135810. * @returns the class name
  135811. */
  135812. getClassName(): string;
  135813. /**
  135814. * Gets the world position input component
  135815. */
  135816. get worldPosition(): NodeMaterialConnectionPoint;
  135817. /**
  135818. * Gets the world normal input component
  135819. */
  135820. get worldNormal(): NodeMaterialConnectionPoint;
  135821. /**
  135822. * Gets the world tangent input component
  135823. */
  135824. get worldTangent(): NodeMaterialConnectionPoint;
  135825. /**
  135826. * Gets the uv input component
  135827. */
  135828. get uv(): NodeMaterialConnectionPoint;
  135829. /**
  135830. * Gets the normal map color input component
  135831. */
  135832. get normalMapColor(): NodeMaterialConnectionPoint;
  135833. /**
  135834. * Gets the strength input component
  135835. */
  135836. get strength(): NodeMaterialConnectionPoint;
  135837. /**
  135838. * Gets the output component
  135839. */
  135840. get output(): NodeMaterialConnectionPoint;
  135841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135843. autoConfigure(material: NodeMaterial): void;
  135844. protected _buildBlock(state: NodeMaterialBuildState): this;
  135845. protected _dumpPropertiesCode(): string;
  135846. serialize(): any;
  135847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135848. }
  135849. }
  135850. declare module BABYLON {
  135851. /**
  135852. * Block used to discard a pixel if a value is smaller than a cutoff
  135853. */
  135854. export class DiscardBlock extends NodeMaterialBlock {
  135855. /**
  135856. * Create a new DiscardBlock
  135857. * @param name defines the block name
  135858. */
  135859. constructor(name: string);
  135860. /**
  135861. * Gets the current class name
  135862. * @returns the class name
  135863. */
  135864. getClassName(): string;
  135865. /**
  135866. * Gets the color input component
  135867. */
  135868. get value(): NodeMaterialConnectionPoint;
  135869. /**
  135870. * Gets the cutoff input component
  135871. */
  135872. get cutoff(): NodeMaterialConnectionPoint;
  135873. protected _buildBlock(state: NodeMaterialBuildState): this;
  135874. }
  135875. }
  135876. declare module BABYLON {
  135877. /**
  135878. * Block used to test if the fragment shader is front facing
  135879. */
  135880. export class FrontFacingBlock extends NodeMaterialBlock {
  135881. /**
  135882. * Creates a new FrontFacingBlock
  135883. * @param name defines the block name
  135884. */
  135885. constructor(name: string);
  135886. /**
  135887. * Gets the current class name
  135888. * @returns the class name
  135889. */
  135890. getClassName(): string;
  135891. /**
  135892. * Gets the output component
  135893. */
  135894. get output(): NodeMaterialConnectionPoint;
  135895. protected _buildBlock(state: NodeMaterialBuildState): this;
  135896. }
  135897. }
  135898. declare module BABYLON {
  135899. /**
  135900. * Block used to get the derivative value on x and y of a given input
  135901. */
  135902. export class DerivativeBlock extends NodeMaterialBlock {
  135903. /**
  135904. * Create a new DerivativeBlock
  135905. * @param name defines the block name
  135906. */
  135907. constructor(name: string);
  135908. /**
  135909. * Gets the current class name
  135910. * @returns the class name
  135911. */
  135912. getClassName(): string;
  135913. /**
  135914. * Gets the input component
  135915. */
  135916. get input(): NodeMaterialConnectionPoint;
  135917. /**
  135918. * Gets the derivative output on x
  135919. */
  135920. get dx(): NodeMaterialConnectionPoint;
  135921. /**
  135922. * Gets the derivative output on y
  135923. */
  135924. get dy(): NodeMaterialConnectionPoint;
  135925. protected _buildBlock(state: NodeMaterialBuildState): this;
  135926. }
  135927. }
  135928. declare module BABYLON {
  135929. /**
  135930. * Block used to add support for scene fog
  135931. */
  135932. export class FogBlock extends NodeMaterialBlock {
  135933. private _fogDistanceName;
  135934. private _fogParameters;
  135935. /**
  135936. * Create a new FogBlock
  135937. * @param name defines the block name
  135938. */
  135939. constructor(name: string);
  135940. /**
  135941. * Gets the current class name
  135942. * @returns the class name
  135943. */
  135944. getClassName(): string;
  135945. /**
  135946. * Gets the world position input component
  135947. */
  135948. get worldPosition(): NodeMaterialConnectionPoint;
  135949. /**
  135950. * Gets the view input component
  135951. */
  135952. get view(): NodeMaterialConnectionPoint;
  135953. /**
  135954. * Gets the color input component
  135955. */
  135956. get input(): NodeMaterialConnectionPoint;
  135957. /**
  135958. * Gets the fog color input component
  135959. */
  135960. get fogColor(): NodeMaterialConnectionPoint;
  135961. /**
  135962. * Gets the output component
  135963. */
  135964. get output(): NodeMaterialConnectionPoint;
  135965. autoConfigure(material: NodeMaterial): void;
  135966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135967. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135968. protected _buildBlock(state: NodeMaterialBuildState): this;
  135969. }
  135970. }
  135971. declare module BABYLON {
  135972. /**
  135973. * Block used to add light in the fragment shader
  135974. */
  135975. export class LightBlock extends NodeMaterialBlock {
  135976. private _lightId;
  135977. /**
  135978. * Gets or sets the light associated with this block
  135979. */
  135980. light: Nullable<Light>;
  135981. /**
  135982. * Create a new LightBlock
  135983. * @param name defines the block name
  135984. */
  135985. constructor(name: string);
  135986. /**
  135987. * Gets the current class name
  135988. * @returns the class name
  135989. */
  135990. getClassName(): string;
  135991. /**
  135992. * Gets the world position input component
  135993. */
  135994. get worldPosition(): NodeMaterialConnectionPoint;
  135995. /**
  135996. * Gets the world normal input component
  135997. */
  135998. get worldNormal(): NodeMaterialConnectionPoint;
  135999. /**
  136000. * Gets the camera (or eye) position component
  136001. */
  136002. get cameraPosition(): NodeMaterialConnectionPoint;
  136003. /**
  136004. * Gets the glossiness component
  136005. */
  136006. get glossiness(): NodeMaterialConnectionPoint;
  136007. /**
  136008. * Gets the glossinness power component
  136009. */
  136010. get glossPower(): NodeMaterialConnectionPoint;
  136011. /**
  136012. * Gets the diffuse color component
  136013. */
  136014. get diffuseColor(): NodeMaterialConnectionPoint;
  136015. /**
  136016. * Gets the specular color component
  136017. */
  136018. get specularColor(): NodeMaterialConnectionPoint;
  136019. /**
  136020. * Gets the diffuse output component
  136021. */
  136022. get diffuseOutput(): NodeMaterialConnectionPoint;
  136023. /**
  136024. * Gets the specular output component
  136025. */
  136026. get specularOutput(): NodeMaterialConnectionPoint;
  136027. /**
  136028. * Gets the shadow output component
  136029. */
  136030. get shadow(): NodeMaterialConnectionPoint;
  136031. autoConfigure(material: NodeMaterial): void;
  136032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  136033. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  136034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  136035. private _injectVertexCode;
  136036. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136037. serialize(): any;
  136038. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136039. }
  136040. }
  136041. declare module BABYLON {
  136042. /**
  136043. * Block used to read a reflection texture from a sampler
  136044. */
  136045. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  136046. /**
  136047. * Create a new ReflectionTextureBlock
  136048. * @param name defines the block name
  136049. */
  136050. constructor(name: string);
  136051. /**
  136052. * Gets the current class name
  136053. * @returns the class name
  136054. */
  136055. getClassName(): string;
  136056. /**
  136057. * Gets the world position input component
  136058. */
  136059. get position(): NodeMaterialConnectionPoint;
  136060. /**
  136061. * Gets the world position input component
  136062. */
  136063. get worldPosition(): NodeMaterialConnectionPoint;
  136064. /**
  136065. * Gets the world normal input component
  136066. */
  136067. get worldNormal(): NodeMaterialConnectionPoint;
  136068. /**
  136069. * Gets the world input component
  136070. */
  136071. get world(): NodeMaterialConnectionPoint;
  136072. /**
  136073. * Gets the camera (or eye) position component
  136074. */
  136075. get cameraPosition(): NodeMaterialConnectionPoint;
  136076. /**
  136077. * Gets the view input component
  136078. */
  136079. get view(): NodeMaterialConnectionPoint;
  136080. /**
  136081. * Gets the rgb output component
  136082. */
  136083. get rgb(): NodeMaterialConnectionPoint;
  136084. /**
  136085. * Gets the r output component
  136086. */
  136087. get r(): NodeMaterialConnectionPoint;
  136088. /**
  136089. * Gets the g output component
  136090. */
  136091. get g(): NodeMaterialConnectionPoint;
  136092. /**
  136093. * Gets the b output component
  136094. */
  136095. get b(): NodeMaterialConnectionPoint;
  136096. autoConfigure(material: NodeMaterial): void;
  136097. protected _buildBlock(state: NodeMaterialBuildState): this;
  136098. }
  136099. }
  136100. declare module BABYLON {
  136101. /**
  136102. * Block used to add 2 vectors
  136103. */
  136104. export class AddBlock extends NodeMaterialBlock {
  136105. /**
  136106. * Creates a new AddBlock
  136107. * @param name defines the block name
  136108. */
  136109. constructor(name: string);
  136110. /**
  136111. * Gets the current class name
  136112. * @returns the class name
  136113. */
  136114. getClassName(): string;
  136115. /**
  136116. * Gets the left operand input component
  136117. */
  136118. get left(): NodeMaterialConnectionPoint;
  136119. /**
  136120. * Gets the right operand input component
  136121. */
  136122. get right(): NodeMaterialConnectionPoint;
  136123. /**
  136124. * Gets the output component
  136125. */
  136126. get output(): NodeMaterialConnectionPoint;
  136127. protected _buildBlock(state: NodeMaterialBuildState): this;
  136128. }
  136129. }
  136130. declare module BABYLON {
  136131. /**
  136132. * Block used to scale a vector by a float
  136133. */
  136134. export class ScaleBlock extends NodeMaterialBlock {
  136135. /**
  136136. * Creates a new ScaleBlock
  136137. * @param name defines the block name
  136138. */
  136139. constructor(name: string);
  136140. /**
  136141. * Gets the current class name
  136142. * @returns the class name
  136143. */
  136144. getClassName(): string;
  136145. /**
  136146. * Gets the input component
  136147. */
  136148. get input(): NodeMaterialConnectionPoint;
  136149. /**
  136150. * Gets the factor input component
  136151. */
  136152. get factor(): NodeMaterialConnectionPoint;
  136153. /**
  136154. * Gets the output component
  136155. */
  136156. get output(): NodeMaterialConnectionPoint;
  136157. protected _buildBlock(state: NodeMaterialBuildState): this;
  136158. }
  136159. }
  136160. declare module BABYLON {
  136161. /**
  136162. * Block used to clamp a float
  136163. */
  136164. export class ClampBlock extends NodeMaterialBlock {
  136165. /** Gets or sets the minimum range */
  136166. minimum: number;
  136167. /** Gets or sets the maximum range */
  136168. maximum: number;
  136169. /**
  136170. * Creates a new ClampBlock
  136171. * @param name defines the block name
  136172. */
  136173. constructor(name: string);
  136174. /**
  136175. * Gets the current class name
  136176. * @returns the class name
  136177. */
  136178. getClassName(): string;
  136179. /**
  136180. * Gets the value input component
  136181. */
  136182. get value(): NodeMaterialConnectionPoint;
  136183. /**
  136184. * Gets the output component
  136185. */
  136186. get output(): NodeMaterialConnectionPoint;
  136187. protected _buildBlock(state: NodeMaterialBuildState): this;
  136188. protected _dumpPropertiesCode(): string;
  136189. serialize(): any;
  136190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136191. }
  136192. }
  136193. declare module BABYLON {
  136194. /**
  136195. * Block used to apply a cross product between 2 vectors
  136196. */
  136197. export class CrossBlock extends NodeMaterialBlock {
  136198. /**
  136199. * Creates a new CrossBlock
  136200. * @param name defines the block name
  136201. */
  136202. constructor(name: string);
  136203. /**
  136204. * Gets the current class name
  136205. * @returns the class name
  136206. */
  136207. getClassName(): string;
  136208. /**
  136209. * Gets the left operand input component
  136210. */
  136211. get left(): NodeMaterialConnectionPoint;
  136212. /**
  136213. * Gets the right operand input component
  136214. */
  136215. get right(): NodeMaterialConnectionPoint;
  136216. /**
  136217. * Gets the output component
  136218. */
  136219. get output(): NodeMaterialConnectionPoint;
  136220. protected _buildBlock(state: NodeMaterialBuildState): this;
  136221. }
  136222. }
  136223. declare module BABYLON {
  136224. /**
  136225. * Block used to apply a dot product between 2 vectors
  136226. */
  136227. export class DotBlock extends NodeMaterialBlock {
  136228. /**
  136229. * Creates a new DotBlock
  136230. * @param name defines the block name
  136231. */
  136232. constructor(name: string);
  136233. /**
  136234. * Gets the current class name
  136235. * @returns the class name
  136236. */
  136237. getClassName(): string;
  136238. /**
  136239. * Gets the left operand input component
  136240. */
  136241. get left(): NodeMaterialConnectionPoint;
  136242. /**
  136243. * Gets the right operand input component
  136244. */
  136245. get right(): NodeMaterialConnectionPoint;
  136246. /**
  136247. * Gets the output component
  136248. */
  136249. get output(): NodeMaterialConnectionPoint;
  136250. protected _buildBlock(state: NodeMaterialBuildState): this;
  136251. }
  136252. }
  136253. declare module BABYLON {
  136254. /**
  136255. * Block used to normalize a vector
  136256. */
  136257. export class NormalizeBlock extends NodeMaterialBlock {
  136258. /**
  136259. * Creates a new NormalizeBlock
  136260. * @param name defines the block name
  136261. */
  136262. constructor(name: string);
  136263. /**
  136264. * Gets the current class name
  136265. * @returns the class name
  136266. */
  136267. getClassName(): string;
  136268. /**
  136269. * Gets the input component
  136270. */
  136271. get input(): NodeMaterialConnectionPoint;
  136272. /**
  136273. * Gets the output component
  136274. */
  136275. get output(): NodeMaterialConnectionPoint;
  136276. protected _buildBlock(state: NodeMaterialBuildState): this;
  136277. }
  136278. }
  136279. declare module BABYLON {
  136280. /**
  136281. * Operations supported by the Trigonometry block
  136282. */
  136283. export enum TrigonometryBlockOperations {
  136284. /** Cos */
  136285. Cos = 0,
  136286. /** Sin */
  136287. Sin = 1,
  136288. /** Abs */
  136289. Abs = 2,
  136290. /** Exp */
  136291. Exp = 3,
  136292. /** Exp2 */
  136293. Exp2 = 4,
  136294. /** Round */
  136295. Round = 5,
  136296. /** Floor */
  136297. Floor = 6,
  136298. /** Ceiling */
  136299. Ceiling = 7,
  136300. /** Square root */
  136301. Sqrt = 8,
  136302. /** Log */
  136303. Log = 9,
  136304. /** Tangent */
  136305. Tan = 10,
  136306. /** Arc tangent */
  136307. ArcTan = 11,
  136308. /** Arc cosinus */
  136309. ArcCos = 12,
  136310. /** Arc sinus */
  136311. ArcSin = 13,
  136312. /** Fraction */
  136313. Fract = 14,
  136314. /** Sign */
  136315. Sign = 15,
  136316. /** To radians (from degrees) */
  136317. Radians = 16,
  136318. /** To degrees (from radians) */
  136319. Degrees = 17
  136320. }
  136321. /**
  136322. * Block used to apply trigonometry operation to floats
  136323. */
  136324. export class TrigonometryBlock extends NodeMaterialBlock {
  136325. /**
  136326. * Gets or sets the operation applied by the block
  136327. */
  136328. operation: TrigonometryBlockOperations;
  136329. /**
  136330. * Creates a new TrigonometryBlock
  136331. * @param name defines the block name
  136332. */
  136333. constructor(name: string);
  136334. /**
  136335. * Gets the current class name
  136336. * @returns the class name
  136337. */
  136338. getClassName(): string;
  136339. /**
  136340. * Gets the input component
  136341. */
  136342. get input(): NodeMaterialConnectionPoint;
  136343. /**
  136344. * Gets the output component
  136345. */
  136346. get output(): NodeMaterialConnectionPoint;
  136347. protected _buildBlock(state: NodeMaterialBuildState): this;
  136348. serialize(): any;
  136349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136350. protected _dumpPropertiesCode(): string;
  136351. }
  136352. }
  136353. declare module BABYLON {
  136354. /**
  136355. * Block used to create a Color3/4 out of individual inputs (one for each component)
  136356. */
  136357. export class ColorMergerBlock extends NodeMaterialBlock {
  136358. /**
  136359. * Create a new ColorMergerBlock
  136360. * @param name defines the block name
  136361. */
  136362. constructor(name: string);
  136363. /**
  136364. * Gets the current class name
  136365. * @returns the class name
  136366. */
  136367. getClassName(): string;
  136368. /**
  136369. * Gets the rgb component (input)
  136370. */
  136371. get rgbIn(): NodeMaterialConnectionPoint;
  136372. /**
  136373. * Gets the r component (input)
  136374. */
  136375. get r(): NodeMaterialConnectionPoint;
  136376. /**
  136377. * Gets the g component (input)
  136378. */
  136379. get g(): NodeMaterialConnectionPoint;
  136380. /**
  136381. * Gets the b component (input)
  136382. */
  136383. get b(): NodeMaterialConnectionPoint;
  136384. /**
  136385. * Gets the a component (input)
  136386. */
  136387. get a(): NodeMaterialConnectionPoint;
  136388. /**
  136389. * Gets the rgba component (output)
  136390. */
  136391. get rgba(): NodeMaterialConnectionPoint;
  136392. /**
  136393. * Gets the rgb component (output)
  136394. */
  136395. get rgbOut(): NodeMaterialConnectionPoint;
  136396. /**
  136397. * Gets the rgb component (output)
  136398. * @deprecated Please use rgbOut instead.
  136399. */
  136400. get rgb(): NodeMaterialConnectionPoint;
  136401. protected _buildBlock(state: NodeMaterialBuildState): this;
  136402. }
  136403. }
  136404. declare module BABYLON {
  136405. /**
  136406. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  136407. */
  136408. export class ColorSplitterBlock extends NodeMaterialBlock {
  136409. /**
  136410. * Create a new ColorSplitterBlock
  136411. * @param name defines the block name
  136412. */
  136413. constructor(name: string);
  136414. /**
  136415. * Gets the current class name
  136416. * @returns the class name
  136417. */
  136418. getClassName(): string;
  136419. /**
  136420. * Gets the rgba component (input)
  136421. */
  136422. get rgba(): NodeMaterialConnectionPoint;
  136423. /**
  136424. * Gets the rgb component (input)
  136425. */
  136426. get rgbIn(): NodeMaterialConnectionPoint;
  136427. /**
  136428. * Gets the rgb component (output)
  136429. */
  136430. get rgbOut(): NodeMaterialConnectionPoint;
  136431. /**
  136432. * Gets the r component (output)
  136433. */
  136434. get r(): NodeMaterialConnectionPoint;
  136435. /**
  136436. * Gets the g component (output)
  136437. */
  136438. get g(): NodeMaterialConnectionPoint;
  136439. /**
  136440. * Gets the b component (output)
  136441. */
  136442. get b(): NodeMaterialConnectionPoint;
  136443. /**
  136444. * Gets the a component (output)
  136445. */
  136446. get a(): NodeMaterialConnectionPoint;
  136447. protected _inputRename(name: string): string;
  136448. protected _outputRename(name: string): string;
  136449. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136450. }
  136451. }
  136452. declare module BABYLON {
  136453. /**
  136454. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  136455. */
  136456. export class VectorSplitterBlock extends NodeMaterialBlock {
  136457. /**
  136458. * Create a new VectorSplitterBlock
  136459. * @param name defines the block name
  136460. */
  136461. constructor(name: string);
  136462. /**
  136463. * Gets the current class name
  136464. * @returns the class name
  136465. */
  136466. getClassName(): string;
  136467. /**
  136468. * Gets the xyzw component (input)
  136469. */
  136470. get xyzw(): NodeMaterialConnectionPoint;
  136471. /**
  136472. * Gets the xyz component (input)
  136473. */
  136474. get xyzIn(): NodeMaterialConnectionPoint;
  136475. /**
  136476. * Gets the xy component (input)
  136477. */
  136478. get xyIn(): NodeMaterialConnectionPoint;
  136479. /**
  136480. * Gets the xyz component (output)
  136481. */
  136482. get xyzOut(): NodeMaterialConnectionPoint;
  136483. /**
  136484. * Gets the xy component (output)
  136485. */
  136486. get xyOut(): NodeMaterialConnectionPoint;
  136487. /**
  136488. * Gets the x component (output)
  136489. */
  136490. get x(): NodeMaterialConnectionPoint;
  136491. /**
  136492. * Gets the y component (output)
  136493. */
  136494. get y(): NodeMaterialConnectionPoint;
  136495. /**
  136496. * Gets the z component (output)
  136497. */
  136498. get z(): NodeMaterialConnectionPoint;
  136499. /**
  136500. * Gets the w component (output)
  136501. */
  136502. get w(): NodeMaterialConnectionPoint;
  136503. protected _inputRename(name: string): string;
  136504. protected _outputRename(name: string): string;
  136505. protected _buildBlock(state: NodeMaterialBuildState): this;
  136506. }
  136507. }
  136508. declare module BABYLON {
  136509. /**
  136510. * Block used to lerp between 2 values
  136511. */
  136512. export class LerpBlock extends NodeMaterialBlock {
  136513. /**
  136514. * Creates a new LerpBlock
  136515. * @param name defines the block name
  136516. */
  136517. constructor(name: string);
  136518. /**
  136519. * Gets the current class name
  136520. * @returns the class name
  136521. */
  136522. getClassName(): string;
  136523. /**
  136524. * Gets the left operand input component
  136525. */
  136526. get left(): NodeMaterialConnectionPoint;
  136527. /**
  136528. * Gets the right operand input component
  136529. */
  136530. get right(): NodeMaterialConnectionPoint;
  136531. /**
  136532. * Gets the gradient operand input component
  136533. */
  136534. get gradient(): NodeMaterialConnectionPoint;
  136535. /**
  136536. * Gets the output component
  136537. */
  136538. get output(): NodeMaterialConnectionPoint;
  136539. protected _buildBlock(state: NodeMaterialBuildState): this;
  136540. }
  136541. }
  136542. declare module BABYLON {
  136543. /**
  136544. * Block used to divide 2 vectors
  136545. */
  136546. export class DivideBlock extends NodeMaterialBlock {
  136547. /**
  136548. * Creates a new DivideBlock
  136549. * @param name defines the block name
  136550. */
  136551. constructor(name: string);
  136552. /**
  136553. * Gets the current class name
  136554. * @returns the class name
  136555. */
  136556. getClassName(): string;
  136557. /**
  136558. * Gets the left operand input component
  136559. */
  136560. get left(): NodeMaterialConnectionPoint;
  136561. /**
  136562. * Gets the right operand input component
  136563. */
  136564. get right(): NodeMaterialConnectionPoint;
  136565. /**
  136566. * Gets the output component
  136567. */
  136568. get output(): NodeMaterialConnectionPoint;
  136569. protected _buildBlock(state: NodeMaterialBuildState): this;
  136570. }
  136571. }
  136572. declare module BABYLON {
  136573. /**
  136574. * Block used to subtract 2 vectors
  136575. */
  136576. export class SubtractBlock extends NodeMaterialBlock {
  136577. /**
  136578. * Creates a new SubtractBlock
  136579. * @param name defines the block name
  136580. */
  136581. constructor(name: string);
  136582. /**
  136583. * Gets the current class name
  136584. * @returns the class name
  136585. */
  136586. getClassName(): string;
  136587. /**
  136588. * Gets the left operand input component
  136589. */
  136590. get left(): NodeMaterialConnectionPoint;
  136591. /**
  136592. * Gets the right operand input component
  136593. */
  136594. get right(): NodeMaterialConnectionPoint;
  136595. /**
  136596. * Gets the output component
  136597. */
  136598. get output(): NodeMaterialConnectionPoint;
  136599. protected _buildBlock(state: NodeMaterialBuildState): this;
  136600. }
  136601. }
  136602. declare module BABYLON {
  136603. /**
  136604. * Block used to step a value
  136605. */
  136606. export class StepBlock extends NodeMaterialBlock {
  136607. /**
  136608. * Creates a new StepBlock
  136609. * @param name defines the block name
  136610. */
  136611. constructor(name: string);
  136612. /**
  136613. * Gets the current class name
  136614. * @returns the class name
  136615. */
  136616. getClassName(): string;
  136617. /**
  136618. * Gets the value operand input component
  136619. */
  136620. get value(): NodeMaterialConnectionPoint;
  136621. /**
  136622. * Gets the edge operand input component
  136623. */
  136624. get edge(): NodeMaterialConnectionPoint;
  136625. /**
  136626. * Gets the output component
  136627. */
  136628. get output(): NodeMaterialConnectionPoint;
  136629. protected _buildBlock(state: NodeMaterialBuildState): this;
  136630. }
  136631. }
  136632. declare module BABYLON {
  136633. /**
  136634. * Block used to get the opposite (1 - x) of a value
  136635. */
  136636. export class OneMinusBlock extends NodeMaterialBlock {
  136637. /**
  136638. * Creates a new OneMinusBlock
  136639. * @param name defines the block name
  136640. */
  136641. constructor(name: string);
  136642. /**
  136643. * Gets the current class name
  136644. * @returns the class name
  136645. */
  136646. getClassName(): string;
  136647. /**
  136648. * Gets the input component
  136649. */
  136650. get input(): NodeMaterialConnectionPoint;
  136651. /**
  136652. * Gets the output component
  136653. */
  136654. get output(): NodeMaterialConnectionPoint;
  136655. protected _buildBlock(state: NodeMaterialBuildState): this;
  136656. }
  136657. }
  136658. declare module BABYLON {
  136659. /**
  136660. * Block used to get the view direction
  136661. */
  136662. export class ViewDirectionBlock extends NodeMaterialBlock {
  136663. /**
  136664. * Creates a new ViewDirectionBlock
  136665. * @param name defines the block name
  136666. */
  136667. constructor(name: string);
  136668. /**
  136669. * Gets the current class name
  136670. * @returns the class name
  136671. */
  136672. getClassName(): string;
  136673. /**
  136674. * Gets the world position component
  136675. */
  136676. get worldPosition(): NodeMaterialConnectionPoint;
  136677. /**
  136678. * Gets the camera position component
  136679. */
  136680. get cameraPosition(): NodeMaterialConnectionPoint;
  136681. /**
  136682. * Gets the output component
  136683. */
  136684. get output(): NodeMaterialConnectionPoint;
  136685. autoConfigure(material: NodeMaterial): void;
  136686. protected _buildBlock(state: NodeMaterialBuildState): this;
  136687. }
  136688. }
  136689. declare module BABYLON {
  136690. /**
  136691. * Block used to compute fresnel value
  136692. */
  136693. export class FresnelBlock extends NodeMaterialBlock {
  136694. /**
  136695. * Create a new FresnelBlock
  136696. * @param name defines the block name
  136697. */
  136698. constructor(name: string);
  136699. /**
  136700. * Gets the current class name
  136701. * @returns the class name
  136702. */
  136703. getClassName(): string;
  136704. /**
  136705. * Gets the world normal input component
  136706. */
  136707. get worldNormal(): NodeMaterialConnectionPoint;
  136708. /**
  136709. * Gets the view direction input component
  136710. */
  136711. get viewDirection(): NodeMaterialConnectionPoint;
  136712. /**
  136713. * Gets the bias input component
  136714. */
  136715. get bias(): NodeMaterialConnectionPoint;
  136716. /**
  136717. * Gets the camera (or eye) position component
  136718. */
  136719. get power(): NodeMaterialConnectionPoint;
  136720. /**
  136721. * Gets the fresnel output component
  136722. */
  136723. get fresnel(): NodeMaterialConnectionPoint;
  136724. autoConfigure(material: NodeMaterial): void;
  136725. protected _buildBlock(state: NodeMaterialBuildState): this;
  136726. }
  136727. }
  136728. declare module BABYLON {
  136729. /**
  136730. * Block used to get the max of 2 values
  136731. */
  136732. export class MaxBlock extends NodeMaterialBlock {
  136733. /**
  136734. * Creates a new MaxBlock
  136735. * @param name defines the block name
  136736. */
  136737. constructor(name: string);
  136738. /**
  136739. * Gets the current class name
  136740. * @returns the class name
  136741. */
  136742. getClassName(): string;
  136743. /**
  136744. * Gets the left operand input component
  136745. */
  136746. get left(): NodeMaterialConnectionPoint;
  136747. /**
  136748. * Gets the right operand input component
  136749. */
  136750. get right(): NodeMaterialConnectionPoint;
  136751. /**
  136752. * Gets the output component
  136753. */
  136754. get output(): NodeMaterialConnectionPoint;
  136755. protected _buildBlock(state: NodeMaterialBuildState): this;
  136756. }
  136757. }
  136758. declare module BABYLON {
  136759. /**
  136760. * Block used to get the min of 2 values
  136761. */
  136762. export class MinBlock extends NodeMaterialBlock {
  136763. /**
  136764. * Creates a new MinBlock
  136765. * @param name defines the block name
  136766. */
  136767. constructor(name: string);
  136768. /**
  136769. * Gets the current class name
  136770. * @returns the class name
  136771. */
  136772. getClassName(): string;
  136773. /**
  136774. * Gets the left operand input component
  136775. */
  136776. get left(): NodeMaterialConnectionPoint;
  136777. /**
  136778. * Gets the right operand input component
  136779. */
  136780. get right(): NodeMaterialConnectionPoint;
  136781. /**
  136782. * Gets the output component
  136783. */
  136784. get output(): NodeMaterialConnectionPoint;
  136785. protected _buildBlock(state: NodeMaterialBuildState): this;
  136786. }
  136787. }
  136788. declare module BABYLON {
  136789. /**
  136790. * Block used to get the distance between 2 values
  136791. */
  136792. export class DistanceBlock extends NodeMaterialBlock {
  136793. /**
  136794. * Creates a new DistanceBlock
  136795. * @param name defines the block name
  136796. */
  136797. constructor(name: string);
  136798. /**
  136799. * Gets the current class name
  136800. * @returns the class name
  136801. */
  136802. getClassName(): string;
  136803. /**
  136804. * Gets the left operand input component
  136805. */
  136806. get left(): NodeMaterialConnectionPoint;
  136807. /**
  136808. * Gets the right operand input component
  136809. */
  136810. get right(): NodeMaterialConnectionPoint;
  136811. /**
  136812. * Gets the output component
  136813. */
  136814. get output(): NodeMaterialConnectionPoint;
  136815. protected _buildBlock(state: NodeMaterialBuildState): this;
  136816. }
  136817. }
  136818. declare module BABYLON {
  136819. /**
  136820. * Block used to get the length of a vector
  136821. */
  136822. export class LengthBlock extends NodeMaterialBlock {
  136823. /**
  136824. * Creates a new LengthBlock
  136825. * @param name defines the block name
  136826. */
  136827. constructor(name: string);
  136828. /**
  136829. * Gets the current class name
  136830. * @returns the class name
  136831. */
  136832. getClassName(): string;
  136833. /**
  136834. * Gets the value input component
  136835. */
  136836. get value(): NodeMaterialConnectionPoint;
  136837. /**
  136838. * Gets the output component
  136839. */
  136840. get output(): NodeMaterialConnectionPoint;
  136841. protected _buildBlock(state: NodeMaterialBuildState): this;
  136842. }
  136843. }
  136844. declare module BABYLON {
  136845. /**
  136846. * Block used to get negative version of a value (i.e. x * -1)
  136847. */
  136848. export class NegateBlock extends NodeMaterialBlock {
  136849. /**
  136850. * Creates a new NegateBlock
  136851. * @param name defines the block name
  136852. */
  136853. constructor(name: string);
  136854. /**
  136855. * Gets the current class name
  136856. * @returns the class name
  136857. */
  136858. getClassName(): string;
  136859. /**
  136860. * Gets the value input component
  136861. */
  136862. get value(): NodeMaterialConnectionPoint;
  136863. /**
  136864. * Gets the output component
  136865. */
  136866. get output(): NodeMaterialConnectionPoint;
  136867. protected _buildBlock(state: NodeMaterialBuildState): this;
  136868. }
  136869. }
  136870. declare module BABYLON {
  136871. /**
  136872. * Block used to get the value of the first parameter raised to the power of the second
  136873. */
  136874. export class PowBlock extends NodeMaterialBlock {
  136875. /**
  136876. * Creates a new PowBlock
  136877. * @param name defines the block name
  136878. */
  136879. constructor(name: string);
  136880. /**
  136881. * Gets the current class name
  136882. * @returns the class name
  136883. */
  136884. getClassName(): string;
  136885. /**
  136886. * Gets the value operand input component
  136887. */
  136888. get value(): NodeMaterialConnectionPoint;
  136889. /**
  136890. * Gets the power operand input component
  136891. */
  136892. get power(): NodeMaterialConnectionPoint;
  136893. /**
  136894. * Gets the output component
  136895. */
  136896. get output(): NodeMaterialConnectionPoint;
  136897. protected _buildBlock(state: NodeMaterialBuildState): this;
  136898. }
  136899. }
  136900. declare module BABYLON {
  136901. /**
  136902. * Block used to get a random number
  136903. */
  136904. export class RandomNumberBlock extends NodeMaterialBlock {
  136905. /**
  136906. * Creates a new RandomNumberBlock
  136907. * @param name defines the block name
  136908. */
  136909. constructor(name: string);
  136910. /**
  136911. * Gets the current class name
  136912. * @returns the class name
  136913. */
  136914. getClassName(): string;
  136915. /**
  136916. * Gets the seed input component
  136917. */
  136918. get seed(): NodeMaterialConnectionPoint;
  136919. /**
  136920. * Gets the output component
  136921. */
  136922. get output(): NodeMaterialConnectionPoint;
  136923. protected _buildBlock(state: NodeMaterialBuildState): this;
  136924. }
  136925. }
  136926. declare module BABYLON {
  136927. /**
  136928. * Block used to compute arc tangent of 2 values
  136929. */
  136930. export class ArcTan2Block extends NodeMaterialBlock {
  136931. /**
  136932. * Creates a new ArcTan2Block
  136933. * @param name defines the block name
  136934. */
  136935. constructor(name: string);
  136936. /**
  136937. * Gets the current class name
  136938. * @returns the class name
  136939. */
  136940. getClassName(): string;
  136941. /**
  136942. * Gets the x operand input component
  136943. */
  136944. get x(): NodeMaterialConnectionPoint;
  136945. /**
  136946. * Gets the y operand input component
  136947. */
  136948. get y(): NodeMaterialConnectionPoint;
  136949. /**
  136950. * Gets the output component
  136951. */
  136952. get output(): NodeMaterialConnectionPoint;
  136953. protected _buildBlock(state: NodeMaterialBuildState): this;
  136954. }
  136955. }
  136956. declare module BABYLON {
  136957. /**
  136958. * Block used to smooth step a value
  136959. */
  136960. export class SmoothStepBlock extends NodeMaterialBlock {
  136961. /**
  136962. * Creates a new SmoothStepBlock
  136963. * @param name defines the block name
  136964. */
  136965. constructor(name: string);
  136966. /**
  136967. * Gets the current class name
  136968. * @returns the class name
  136969. */
  136970. getClassName(): string;
  136971. /**
  136972. * Gets the value operand input component
  136973. */
  136974. get value(): NodeMaterialConnectionPoint;
  136975. /**
  136976. * Gets the first edge operand input component
  136977. */
  136978. get edge0(): NodeMaterialConnectionPoint;
  136979. /**
  136980. * Gets the second edge operand input component
  136981. */
  136982. get edge1(): NodeMaterialConnectionPoint;
  136983. /**
  136984. * Gets the output component
  136985. */
  136986. get output(): NodeMaterialConnectionPoint;
  136987. protected _buildBlock(state: NodeMaterialBuildState): this;
  136988. }
  136989. }
  136990. declare module BABYLON {
  136991. /**
  136992. * Block used to get the reciprocal (1 / x) of a value
  136993. */
  136994. export class ReciprocalBlock extends NodeMaterialBlock {
  136995. /**
  136996. * Creates a new ReciprocalBlock
  136997. * @param name defines the block name
  136998. */
  136999. constructor(name: string);
  137000. /**
  137001. * Gets the current class name
  137002. * @returns the class name
  137003. */
  137004. getClassName(): string;
  137005. /**
  137006. * Gets the input component
  137007. */
  137008. get input(): NodeMaterialConnectionPoint;
  137009. /**
  137010. * Gets the output component
  137011. */
  137012. get output(): NodeMaterialConnectionPoint;
  137013. protected _buildBlock(state: NodeMaterialBuildState): this;
  137014. }
  137015. }
  137016. declare module BABYLON {
  137017. /**
  137018. * Block used to replace a color by another one
  137019. */
  137020. export class ReplaceColorBlock extends NodeMaterialBlock {
  137021. /**
  137022. * Creates a new ReplaceColorBlock
  137023. * @param name defines the block name
  137024. */
  137025. constructor(name: string);
  137026. /**
  137027. * Gets the current class name
  137028. * @returns the class name
  137029. */
  137030. getClassName(): string;
  137031. /**
  137032. * Gets the value input component
  137033. */
  137034. get value(): NodeMaterialConnectionPoint;
  137035. /**
  137036. * Gets the reference input component
  137037. */
  137038. get reference(): NodeMaterialConnectionPoint;
  137039. /**
  137040. * Gets the distance input component
  137041. */
  137042. get distance(): NodeMaterialConnectionPoint;
  137043. /**
  137044. * Gets the replacement input component
  137045. */
  137046. get replacement(): NodeMaterialConnectionPoint;
  137047. /**
  137048. * Gets the output component
  137049. */
  137050. get output(): NodeMaterialConnectionPoint;
  137051. protected _buildBlock(state: NodeMaterialBuildState): this;
  137052. }
  137053. }
  137054. declare module BABYLON {
  137055. /**
  137056. * Block used to posterize a value
  137057. * @see https://en.wikipedia.org/wiki/Posterization
  137058. */
  137059. export class PosterizeBlock extends NodeMaterialBlock {
  137060. /**
  137061. * Creates a new PosterizeBlock
  137062. * @param name defines the block name
  137063. */
  137064. constructor(name: string);
  137065. /**
  137066. * Gets the current class name
  137067. * @returns the class name
  137068. */
  137069. getClassName(): string;
  137070. /**
  137071. * Gets the value input component
  137072. */
  137073. get value(): NodeMaterialConnectionPoint;
  137074. /**
  137075. * Gets the steps input component
  137076. */
  137077. get steps(): NodeMaterialConnectionPoint;
  137078. /**
  137079. * Gets the output component
  137080. */
  137081. get output(): NodeMaterialConnectionPoint;
  137082. protected _buildBlock(state: NodeMaterialBuildState): this;
  137083. }
  137084. }
  137085. declare module BABYLON {
  137086. /**
  137087. * Operations supported by the Wave block
  137088. */
  137089. export enum WaveBlockKind {
  137090. /** SawTooth */
  137091. SawTooth = 0,
  137092. /** Square */
  137093. Square = 1,
  137094. /** Triangle */
  137095. Triangle = 2
  137096. }
  137097. /**
  137098. * Block used to apply wave operation to floats
  137099. */
  137100. export class WaveBlock extends NodeMaterialBlock {
  137101. /**
  137102. * Gets or sets the kibnd of wave to be applied by the block
  137103. */
  137104. kind: WaveBlockKind;
  137105. /**
  137106. * Creates a new WaveBlock
  137107. * @param name defines the block name
  137108. */
  137109. constructor(name: string);
  137110. /**
  137111. * Gets the current class name
  137112. * @returns the class name
  137113. */
  137114. getClassName(): string;
  137115. /**
  137116. * Gets the input component
  137117. */
  137118. get input(): NodeMaterialConnectionPoint;
  137119. /**
  137120. * Gets the output component
  137121. */
  137122. get output(): NodeMaterialConnectionPoint;
  137123. protected _buildBlock(state: NodeMaterialBuildState): this;
  137124. serialize(): any;
  137125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137126. }
  137127. }
  137128. declare module BABYLON {
  137129. /**
  137130. * Class used to store a color step for the GradientBlock
  137131. */
  137132. export class GradientBlockColorStep {
  137133. /**
  137134. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  137135. */
  137136. step: number;
  137137. /**
  137138. * Gets or sets the color associated with this step
  137139. */
  137140. color: Color3;
  137141. /**
  137142. * Creates a new GradientBlockColorStep
  137143. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  137144. * @param color defines the color associated with this step
  137145. */
  137146. constructor(
  137147. /**
  137148. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  137149. */
  137150. step: number,
  137151. /**
  137152. * Gets or sets the color associated with this step
  137153. */
  137154. color: Color3);
  137155. }
  137156. /**
  137157. * Block used to return a color from a gradient based on an input value between 0 and 1
  137158. */
  137159. export class GradientBlock extends NodeMaterialBlock {
  137160. /**
  137161. * Gets or sets the list of color steps
  137162. */
  137163. colorSteps: GradientBlockColorStep[];
  137164. /**
  137165. * Creates a new GradientBlock
  137166. * @param name defines the block name
  137167. */
  137168. constructor(name: string);
  137169. /**
  137170. * Gets the current class name
  137171. * @returns the class name
  137172. */
  137173. getClassName(): string;
  137174. /**
  137175. * Gets the gradient input component
  137176. */
  137177. get gradient(): NodeMaterialConnectionPoint;
  137178. /**
  137179. * Gets the output component
  137180. */
  137181. get output(): NodeMaterialConnectionPoint;
  137182. private _writeColorConstant;
  137183. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137184. serialize(): any;
  137185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137186. protected _dumpPropertiesCode(): string;
  137187. }
  137188. }
  137189. declare module BABYLON {
  137190. /**
  137191. * Block used to normalize lerp between 2 values
  137192. */
  137193. export class NLerpBlock extends NodeMaterialBlock {
  137194. /**
  137195. * Creates a new NLerpBlock
  137196. * @param name defines the block name
  137197. */
  137198. constructor(name: string);
  137199. /**
  137200. * Gets the current class name
  137201. * @returns the class name
  137202. */
  137203. getClassName(): string;
  137204. /**
  137205. * Gets the left operand input component
  137206. */
  137207. get left(): NodeMaterialConnectionPoint;
  137208. /**
  137209. * Gets the right operand input component
  137210. */
  137211. get right(): NodeMaterialConnectionPoint;
  137212. /**
  137213. * Gets the gradient operand input component
  137214. */
  137215. get gradient(): NodeMaterialConnectionPoint;
  137216. /**
  137217. * Gets the output component
  137218. */
  137219. get output(): NodeMaterialConnectionPoint;
  137220. protected _buildBlock(state: NodeMaterialBuildState): this;
  137221. }
  137222. }
  137223. declare module BABYLON {
  137224. /**
  137225. * block used to Generate a Worley Noise 3D Noise Pattern
  137226. */
  137227. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  137228. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  137229. manhattanDistance: boolean;
  137230. /**
  137231. * Creates a new WorleyNoise3DBlock
  137232. * @param name defines the block name
  137233. */
  137234. constructor(name: string);
  137235. /**
  137236. * Gets the current class name
  137237. * @returns the class name
  137238. */
  137239. getClassName(): string;
  137240. /**
  137241. * Gets the seed input component
  137242. */
  137243. get seed(): NodeMaterialConnectionPoint;
  137244. /**
  137245. * Gets the jitter input component
  137246. */
  137247. get jitter(): NodeMaterialConnectionPoint;
  137248. /**
  137249. * Gets the output component
  137250. */
  137251. get output(): NodeMaterialConnectionPoint;
  137252. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137253. /**
  137254. * Exposes the properties to the UI?
  137255. */
  137256. protected _dumpPropertiesCode(): string;
  137257. /**
  137258. * Exposes the properties to the Seralize?
  137259. */
  137260. serialize(): any;
  137261. /**
  137262. * Exposes the properties to the deseralize?
  137263. */
  137264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137265. }
  137266. }
  137267. declare module BABYLON {
  137268. /**
  137269. * block used to Generate a Simplex Perlin 3d Noise Pattern
  137270. */
  137271. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  137272. /**
  137273. * Creates a new SimplexPerlin3DBlock
  137274. * @param name defines the block name
  137275. */
  137276. constructor(name: string);
  137277. /**
  137278. * Gets the current class name
  137279. * @returns the class name
  137280. */
  137281. getClassName(): string;
  137282. /**
  137283. * Gets the seed operand input component
  137284. */
  137285. get seed(): NodeMaterialConnectionPoint;
  137286. /**
  137287. * Gets the output component
  137288. */
  137289. get output(): NodeMaterialConnectionPoint;
  137290. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137291. }
  137292. }
  137293. declare module BABYLON {
  137294. /**
  137295. * Block used to blend normals
  137296. */
  137297. export class NormalBlendBlock extends NodeMaterialBlock {
  137298. /**
  137299. * Creates a new NormalBlendBlock
  137300. * @param name defines the block name
  137301. */
  137302. constructor(name: string);
  137303. /**
  137304. * Gets the current class name
  137305. * @returns the class name
  137306. */
  137307. getClassName(): string;
  137308. /**
  137309. * Gets the first input component
  137310. */
  137311. get normalMap0(): NodeMaterialConnectionPoint;
  137312. /**
  137313. * Gets the second input component
  137314. */
  137315. get normalMap1(): NodeMaterialConnectionPoint;
  137316. /**
  137317. * Gets the output component
  137318. */
  137319. get output(): NodeMaterialConnectionPoint;
  137320. protected _buildBlock(state: NodeMaterialBuildState): this;
  137321. }
  137322. }
  137323. declare module BABYLON {
  137324. /**
  137325. * Block used to rotate a 2d vector by a given angle
  137326. */
  137327. export class Rotate2dBlock extends NodeMaterialBlock {
  137328. /**
  137329. * Creates a new Rotate2dBlock
  137330. * @param name defines the block name
  137331. */
  137332. constructor(name: string);
  137333. /**
  137334. * Gets the current class name
  137335. * @returns the class name
  137336. */
  137337. getClassName(): string;
  137338. /**
  137339. * Gets the input vector
  137340. */
  137341. get input(): NodeMaterialConnectionPoint;
  137342. /**
  137343. * Gets the input angle
  137344. */
  137345. get angle(): NodeMaterialConnectionPoint;
  137346. /**
  137347. * Gets the output component
  137348. */
  137349. get output(): NodeMaterialConnectionPoint;
  137350. autoConfigure(material: NodeMaterial): void;
  137351. protected _buildBlock(state: NodeMaterialBuildState): this;
  137352. }
  137353. }
  137354. declare module BABYLON {
  137355. /**
  137356. * Block used to get the reflected vector from a direction and a normal
  137357. */
  137358. export class ReflectBlock extends NodeMaterialBlock {
  137359. /**
  137360. * Creates a new ReflectBlock
  137361. * @param name defines the block name
  137362. */
  137363. constructor(name: string);
  137364. /**
  137365. * Gets the current class name
  137366. * @returns the class name
  137367. */
  137368. getClassName(): string;
  137369. /**
  137370. * Gets the incident component
  137371. */
  137372. get incident(): NodeMaterialConnectionPoint;
  137373. /**
  137374. * Gets the normal component
  137375. */
  137376. get normal(): NodeMaterialConnectionPoint;
  137377. /**
  137378. * Gets the output component
  137379. */
  137380. get output(): NodeMaterialConnectionPoint;
  137381. protected _buildBlock(state: NodeMaterialBuildState): this;
  137382. }
  137383. }
  137384. declare module BABYLON {
  137385. /**
  137386. * Block used to get the refracted vector from a direction and a normal
  137387. */
  137388. export class RefractBlock extends NodeMaterialBlock {
  137389. /**
  137390. * Creates a new RefractBlock
  137391. * @param name defines the block name
  137392. */
  137393. constructor(name: string);
  137394. /**
  137395. * Gets the current class name
  137396. * @returns the class name
  137397. */
  137398. getClassName(): string;
  137399. /**
  137400. * Gets the incident component
  137401. */
  137402. get incident(): NodeMaterialConnectionPoint;
  137403. /**
  137404. * Gets the normal component
  137405. */
  137406. get normal(): NodeMaterialConnectionPoint;
  137407. /**
  137408. * Gets the index of refraction component
  137409. */
  137410. get ior(): NodeMaterialConnectionPoint;
  137411. /**
  137412. * Gets the output component
  137413. */
  137414. get output(): NodeMaterialConnectionPoint;
  137415. protected _buildBlock(state: NodeMaterialBuildState): this;
  137416. }
  137417. }
  137418. declare module BABYLON {
  137419. /**
  137420. * Block used to desaturate a color
  137421. */
  137422. export class DesaturateBlock extends NodeMaterialBlock {
  137423. /**
  137424. * Creates a new DesaturateBlock
  137425. * @param name defines the block name
  137426. */
  137427. constructor(name: string);
  137428. /**
  137429. * Gets the current class name
  137430. * @returns the class name
  137431. */
  137432. getClassName(): string;
  137433. /**
  137434. * Gets the color operand input component
  137435. */
  137436. get color(): NodeMaterialConnectionPoint;
  137437. /**
  137438. * Gets the level operand input component
  137439. */
  137440. get level(): NodeMaterialConnectionPoint;
  137441. /**
  137442. * Gets the output component
  137443. */
  137444. get output(): NodeMaterialConnectionPoint;
  137445. protected _buildBlock(state: NodeMaterialBuildState): this;
  137446. }
  137447. }
  137448. declare module BABYLON {
  137449. /**
  137450. * Block used to implement the ambient occlusion module of the PBR material
  137451. */
  137452. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  137453. /**
  137454. * Create a new AmbientOcclusionBlock
  137455. * @param name defines the block name
  137456. */
  137457. constructor(name: string);
  137458. /**
  137459. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137460. */
  137461. useAmbientInGrayScale: boolean;
  137462. /**
  137463. * Initialize the block and prepare the context for build
  137464. * @param state defines the state that will be used for the build
  137465. */
  137466. initialize(state: NodeMaterialBuildState): void;
  137467. /**
  137468. * Gets the current class name
  137469. * @returns the class name
  137470. */
  137471. getClassName(): string;
  137472. /**
  137473. * Gets the texture input component
  137474. */
  137475. get texture(): NodeMaterialConnectionPoint;
  137476. /**
  137477. * Gets the texture intensity component
  137478. */
  137479. get intensity(): NodeMaterialConnectionPoint;
  137480. /**
  137481. * Gets the direct light intensity input component
  137482. */
  137483. get directLightIntensity(): NodeMaterialConnectionPoint;
  137484. /**
  137485. * Gets the ambient occlusion object output component
  137486. */
  137487. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137488. /**
  137489. * Gets the main code of the block (fragment side)
  137490. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  137491. * @returns the shader code
  137492. */
  137493. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  137494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137495. protected _buildBlock(state: NodeMaterialBuildState): this;
  137496. protected _dumpPropertiesCode(): string;
  137497. serialize(): any;
  137498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137499. }
  137500. }
  137501. declare module BABYLON {
  137502. /**
  137503. * Block used to implement the reflection module of the PBR material
  137504. */
  137505. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  137506. /** @hidden */
  137507. _defineLODReflectionAlpha: string;
  137508. /** @hidden */
  137509. _defineLinearSpecularReflection: string;
  137510. private _vEnvironmentIrradianceName;
  137511. /** @hidden */
  137512. _vReflectionMicrosurfaceInfosName: string;
  137513. /** @hidden */
  137514. _vReflectionInfosName: string;
  137515. private _scene;
  137516. /**
  137517. * The three properties below are set by the main PBR block prior to calling methods of this class.
  137518. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137519. * It's less burden on the user side in the editor part.
  137520. */
  137521. /** @hidden */
  137522. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137523. /** @hidden */
  137524. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137525. /** @hidden */
  137526. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  137527. /**
  137528. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  137529. * diffuse part of the IBL.
  137530. */
  137531. useSphericalHarmonics: boolean;
  137532. /**
  137533. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137534. */
  137535. forceIrradianceInFragment: boolean;
  137536. /**
  137537. * Create a new ReflectionBlock
  137538. * @param name defines the block name
  137539. */
  137540. constructor(name: string);
  137541. /**
  137542. * Gets the current class name
  137543. * @returns the class name
  137544. */
  137545. getClassName(): string;
  137546. /**
  137547. * Gets the position input component
  137548. */
  137549. get position(): NodeMaterialConnectionPoint;
  137550. /**
  137551. * Gets the world position input component
  137552. */
  137553. get worldPosition(): NodeMaterialConnectionPoint;
  137554. /**
  137555. * Gets the world normal input component
  137556. */
  137557. get worldNormal(): NodeMaterialConnectionPoint;
  137558. /**
  137559. * Gets the world input component
  137560. */
  137561. get world(): NodeMaterialConnectionPoint;
  137562. /**
  137563. * Gets the camera (or eye) position component
  137564. */
  137565. get cameraPosition(): NodeMaterialConnectionPoint;
  137566. /**
  137567. * Gets the view input component
  137568. */
  137569. get view(): NodeMaterialConnectionPoint;
  137570. /**
  137571. * Gets the color input component
  137572. */
  137573. get color(): NodeMaterialConnectionPoint;
  137574. /**
  137575. * Gets the reflection object output component
  137576. */
  137577. get reflection(): NodeMaterialConnectionPoint;
  137578. /**
  137579. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  137580. */
  137581. get hasTexture(): boolean;
  137582. /**
  137583. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  137584. */
  137585. get reflectionColor(): string;
  137586. protected _getTexture(): Nullable<BaseTexture>;
  137587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137588. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137589. /**
  137590. * Gets the code to inject in the vertex shader
  137591. * @param state current state of the node material building
  137592. * @returns the shader code
  137593. */
  137594. handleVertexSide(state: NodeMaterialBuildState): string;
  137595. /**
  137596. * Gets the main code of the block (fragment side)
  137597. * @param state current state of the node material building
  137598. * @param normalVarName name of the existing variable corresponding to the normal
  137599. * @returns the shader code
  137600. */
  137601. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  137602. protected _buildBlock(state: NodeMaterialBuildState): this;
  137603. protected _dumpPropertiesCode(): string;
  137604. serialize(): any;
  137605. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137606. }
  137607. }
  137608. declare module BABYLON {
  137609. /**
  137610. * Block used to implement the sheen module of the PBR material
  137611. */
  137612. export class SheenBlock extends NodeMaterialBlock {
  137613. /**
  137614. * Create a new SheenBlock
  137615. * @param name defines the block name
  137616. */
  137617. constructor(name: string);
  137618. /**
  137619. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  137620. * It allows the strength of the sheen effect to not depend on the base color of the material,
  137621. * making it easier to setup and tweak the effect
  137622. */
  137623. albedoScaling: boolean;
  137624. /**
  137625. * Defines if the sheen is linked to the sheen color.
  137626. */
  137627. linkSheenWithAlbedo: boolean;
  137628. /**
  137629. * Initialize the block and prepare the context for build
  137630. * @param state defines the state that will be used for the build
  137631. */
  137632. initialize(state: NodeMaterialBuildState): void;
  137633. /**
  137634. * Gets the current class name
  137635. * @returns the class name
  137636. */
  137637. getClassName(): string;
  137638. /**
  137639. * Gets the intensity input component
  137640. */
  137641. get intensity(): NodeMaterialConnectionPoint;
  137642. /**
  137643. * Gets the color input component
  137644. */
  137645. get color(): NodeMaterialConnectionPoint;
  137646. /**
  137647. * Gets the roughness input component
  137648. */
  137649. get roughness(): NodeMaterialConnectionPoint;
  137650. /**
  137651. * Gets the texture input component
  137652. */
  137653. get texture(): NodeMaterialConnectionPoint;
  137654. /**
  137655. * Gets the sheen object output component
  137656. */
  137657. get sheen(): NodeMaterialConnectionPoint;
  137658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137659. /**
  137660. * Gets the main code of the block (fragment side)
  137661. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137662. * @returns the shader code
  137663. */
  137664. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  137665. protected _buildBlock(state: NodeMaterialBuildState): this;
  137666. protected _dumpPropertiesCode(): string;
  137667. serialize(): any;
  137668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137669. }
  137670. }
  137671. declare module BABYLON {
  137672. /**
  137673. * Block used to implement the reflectivity module of the PBR material
  137674. */
  137675. export class ReflectivityBlock extends NodeMaterialBlock {
  137676. /**
  137677. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137678. */
  137679. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137680. /**
  137681. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137682. */
  137683. useMetallnessFromMetallicTextureBlue: boolean;
  137684. /**
  137685. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137686. */
  137687. useRoughnessFromMetallicTextureAlpha: boolean;
  137688. /**
  137689. * Specifies if the metallic texture contains the roughness information in its green channel.
  137690. */
  137691. useRoughnessFromMetallicTextureGreen: boolean;
  137692. /**
  137693. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  137694. */
  137695. useMetallicF0FactorFromMetallicTexture: boolean;
  137696. /**
  137697. * Create a new ReflectivityBlock
  137698. * @param name defines the block name
  137699. */
  137700. constructor(name: string);
  137701. /**
  137702. * Initialize the block and prepare the context for build
  137703. * @param state defines the state that will be used for the build
  137704. */
  137705. initialize(state: NodeMaterialBuildState): void;
  137706. /**
  137707. * Gets the current class name
  137708. * @returns the class name
  137709. */
  137710. getClassName(): string;
  137711. /**
  137712. * Gets the metallic input component
  137713. */
  137714. get metallic(): NodeMaterialConnectionPoint;
  137715. /**
  137716. * Gets the roughness input component
  137717. */
  137718. get roughness(): NodeMaterialConnectionPoint;
  137719. /**
  137720. * Gets the texture input component
  137721. */
  137722. get texture(): NodeMaterialConnectionPoint;
  137723. /**
  137724. * Gets the reflectivity object output component
  137725. */
  137726. get reflectivity(): NodeMaterialConnectionPoint;
  137727. /**
  137728. * Gets the main code of the block (fragment side)
  137729. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  137730. * @returns the shader code
  137731. */
  137732. getCode(aoIntensityVarName: string): string;
  137733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137734. protected _buildBlock(state: NodeMaterialBuildState): this;
  137735. protected _dumpPropertiesCode(): string;
  137736. serialize(): any;
  137737. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137738. }
  137739. }
  137740. declare module BABYLON {
  137741. /**
  137742. * Block used to implement the anisotropy module of the PBR material
  137743. */
  137744. export class AnisotropyBlock extends NodeMaterialBlock {
  137745. /**
  137746. * The two properties below are set by the main PBR block prior to calling methods of this class.
  137747. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137748. * It's less burden on the user side in the editor part.
  137749. */
  137750. /** @hidden */
  137751. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137752. /** @hidden */
  137753. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137754. /**
  137755. * Create a new AnisotropyBlock
  137756. * @param name defines the block name
  137757. */
  137758. constructor(name: string);
  137759. /**
  137760. * Initialize the block and prepare the context for build
  137761. * @param state defines the state that will be used for the build
  137762. */
  137763. initialize(state: NodeMaterialBuildState): void;
  137764. /**
  137765. * Gets the current class name
  137766. * @returns the class name
  137767. */
  137768. getClassName(): string;
  137769. /**
  137770. * Gets the intensity input component
  137771. */
  137772. get intensity(): NodeMaterialConnectionPoint;
  137773. /**
  137774. * Gets the direction input component
  137775. */
  137776. get direction(): NodeMaterialConnectionPoint;
  137777. /**
  137778. * Gets the texture input component
  137779. */
  137780. get texture(): NodeMaterialConnectionPoint;
  137781. /**
  137782. * Gets the uv input component
  137783. */
  137784. get uv(): NodeMaterialConnectionPoint;
  137785. /**
  137786. * Gets the worldTangent input component
  137787. */
  137788. get worldTangent(): NodeMaterialConnectionPoint;
  137789. /**
  137790. * Gets the anisotropy object output component
  137791. */
  137792. get anisotropy(): NodeMaterialConnectionPoint;
  137793. private _generateTBNSpace;
  137794. /**
  137795. * Gets the main code of the block (fragment side)
  137796. * @param state current state of the node material building
  137797. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137798. * @returns the shader code
  137799. */
  137800. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  137801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137802. protected _buildBlock(state: NodeMaterialBuildState): this;
  137803. }
  137804. }
  137805. declare module BABYLON {
  137806. /**
  137807. * Block used to implement the clear coat module of the PBR material
  137808. */
  137809. export class ClearCoatBlock extends NodeMaterialBlock {
  137810. private _scene;
  137811. /**
  137812. * Create a new ClearCoatBlock
  137813. * @param name defines the block name
  137814. */
  137815. constructor(name: string);
  137816. /**
  137817. * Initialize the block and prepare the context for build
  137818. * @param state defines the state that will be used for the build
  137819. */
  137820. initialize(state: NodeMaterialBuildState): void;
  137821. /**
  137822. * Gets the current class name
  137823. * @returns the class name
  137824. */
  137825. getClassName(): string;
  137826. /**
  137827. * Gets the intensity input component
  137828. */
  137829. get intensity(): NodeMaterialConnectionPoint;
  137830. /**
  137831. * Gets the roughness input component
  137832. */
  137833. get roughness(): NodeMaterialConnectionPoint;
  137834. /**
  137835. * Gets the ior input component
  137836. */
  137837. get ior(): NodeMaterialConnectionPoint;
  137838. /**
  137839. * Gets the texture input component
  137840. */
  137841. get texture(): NodeMaterialConnectionPoint;
  137842. /**
  137843. * Gets the bump texture input component
  137844. */
  137845. get bumpTexture(): NodeMaterialConnectionPoint;
  137846. /**
  137847. * Gets the uv input component
  137848. */
  137849. get uv(): NodeMaterialConnectionPoint;
  137850. /**
  137851. * Gets the tint color input component
  137852. */
  137853. get tintColor(): NodeMaterialConnectionPoint;
  137854. /**
  137855. * Gets the tint "at distance" input component
  137856. */
  137857. get tintAtDistance(): NodeMaterialConnectionPoint;
  137858. /**
  137859. * Gets the tint thickness input component
  137860. */
  137861. get tintThickness(): NodeMaterialConnectionPoint;
  137862. /**
  137863. * Gets the tint texture input component
  137864. */
  137865. get tintTexture(): NodeMaterialConnectionPoint;
  137866. /**
  137867. * Gets the world tangent input component
  137868. */
  137869. get worldTangent(): NodeMaterialConnectionPoint;
  137870. /**
  137871. * Gets the clear coat object output component
  137872. */
  137873. get clearcoat(): NodeMaterialConnectionPoint;
  137874. autoConfigure(material: NodeMaterial): void;
  137875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137876. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137877. private _generateTBNSpace;
  137878. /**
  137879. * Gets the main code of the block (fragment side)
  137880. * @param state current state of the node material building
  137881. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  137882. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137883. * @param worldPosVarName name of the variable holding the world position
  137884. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137885. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  137886. * @param worldNormalVarName name of the variable holding the world normal
  137887. * @returns the shader code
  137888. */
  137889. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  137890. protected _buildBlock(state: NodeMaterialBuildState): this;
  137891. }
  137892. }
  137893. declare module BABYLON {
  137894. /**
  137895. * Block used to implement the sub surface module of the PBR material
  137896. */
  137897. export class SubSurfaceBlock extends NodeMaterialBlock {
  137898. /**
  137899. * Create a new SubSurfaceBlock
  137900. * @param name defines the block name
  137901. */
  137902. constructor(name: string);
  137903. /**
  137904. * Stores the intensity of the different subsurface effects in the thickness texture.
  137905. * * the green channel is the translucency intensity.
  137906. * * the blue channel is the scattering intensity.
  137907. * * the alpha channel is the refraction intensity.
  137908. */
  137909. useMaskFromThicknessTexture: boolean;
  137910. /**
  137911. * Initialize the block and prepare the context for build
  137912. * @param state defines the state that will be used for the build
  137913. */
  137914. initialize(state: NodeMaterialBuildState): void;
  137915. /**
  137916. * Gets the current class name
  137917. * @returns the class name
  137918. */
  137919. getClassName(): string;
  137920. /**
  137921. * Gets the min thickness input component
  137922. */
  137923. get minThickness(): NodeMaterialConnectionPoint;
  137924. /**
  137925. * Gets the max thickness input component
  137926. */
  137927. get maxThickness(): NodeMaterialConnectionPoint;
  137928. /**
  137929. * Gets the thickness texture component
  137930. */
  137931. get thicknessTexture(): NodeMaterialConnectionPoint;
  137932. /**
  137933. * Gets the tint color input component
  137934. */
  137935. get tintColor(): NodeMaterialConnectionPoint;
  137936. /**
  137937. * Gets the translucency intensity input component
  137938. */
  137939. get translucencyIntensity(): NodeMaterialConnectionPoint;
  137940. /**
  137941. * Gets the translucency diffusion distance input component
  137942. */
  137943. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  137944. /**
  137945. * Gets the refraction object parameters
  137946. */
  137947. get refraction(): NodeMaterialConnectionPoint;
  137948. /**
  137949. * Gets the sub surface object output component
  137950. */
  137951. get subsurface(): NodeMaterialConnectionPoint;
  137952. autoConfigure(material: NodeMaterial): void;
  137953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137954. /**
  137955. * Gets the main code of the block (fragment side)
  137956. * @param state current state of the node material building
  137957. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  137958. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137959. * @param worldPosVarName name of the variable holding the world position
  137960. * @returns the shader code
  137961. */
  137962. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  137963. protected _buildBlock(state: NodeMaterialBuildState): this;
  137964. }
  137965. }
  137966. declare module BABYLON {
  137967. /**
  137968. * Block used to implement the PBR metallic/roughness model
  137969. */
  137970. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  137971. /**
  137972. * Gets or sets the light associated with this block
  137973. */
  137974. light: Nullable<Light>;
  137975. private _lightId;
  137976. private _scene;
  137977. private _environmentBRDFTexture;
  137978. private _environmentBrdfSamplerName;
  137979. private _vNormalWName;
  137980. private _invertNormalName;
  137981. /**
  137982. * Create a new ReflectionBlock
  137983. * @param name defines the block name
  137984. */
  137985. constructor(name: string);
  137986. /**
  137987. * Intensity of the direct lights e.g. the four lights available in your scene.
  137988. * This impacts both the direct diffuse and specular highlights.
  137989. */
  137990. directIntensity: number;
  137991. /**
  137992. * Intensity of the environment e.g. how much the environment will light the object
  137993. * either through harmonics for rough material or through the refelction for shiny ones.
  137994. */
  137995. environmentIntensity: number;
  137996. /**
  137997. * This is a special control allowing the reduction of the specular highlights coming from the
  137998. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137999. */
  138000. specularIntensity: number;
  138001. /**
  138002. * Defines the falloff type used in this material.
  138003. * It by default is Physical.
  138004. */
  138005. lightFalloff: number;
  138006. /**
  138007. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  138008. */
  138009. useAlphaFromAlbedoTexture: boolean;
  138010. /**
  138011. * Specifies that alpha test should be used
  138012. */
  138013. useAlphaTest: boolean;
  138014. /**
  138015. * Defines the alpha limits in alpha test mode.
  138016. */
  138017. alphaTestCutoff: number;
  138018. /**
  138019. * Specifies that alpha blending should be used
  138020. */
  138021. useAlphaBlending: boolean;
  138022. /**
  138023. * Defines if the alpha value should be determined via the rgb values.
  138024. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  138025. */
  138026. opacityRGB: boolean;
  138027. /**
  138028. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  138029. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  138030. */
  138031. useRadianceOverAlpha: boolean;
  138032. /**
  138033. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  138034. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  138035. */
  138036. useSpecularOverAlpha: boolean;
  138037. /**
  138038. * Enables specular anti aliasing in the PBR shader.
  138039. * It will both interacts on the Geometry for analytical and IBL lighting.
  138040. * It also prefilter the roughness map based on the bump values.
  138041. */
  138042. enableSpecularAntiAliasing: boolean;
  138043. /**
  138044. * Defines if the material uses energy conservation.
  138045. */
  138046. useEnergyConservation: boolean;
  138047. /**
  138048. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  138049. * too much the area relying on ambient texture to define their ambient occlusion.
  138050. */
  138051. useRadianceOcclusion: boolean;
  138052. /**
  138053. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  138054. * makes the reflect vector face the model (under horizon).
  138055. */
  138056. useHorizonOcclusion: boolean;
  138057. /**
  138058. * If set to true, no lighting calculations will be applied.
  138059. */
  138060. unlit: boolean;
  138061. /**
  138062. * Force normal to face away from face.
  138063. */
  138064. forceNormalForward: boolean;
  138065. /**
  138066. * Defines the material debug mode.
  138067. * It helps seeing only some components of the material while troubleshooting.
  138068. */
  138069. debugMode: number;
  138070. /**
  138071. * Specify from where on screen the debug mode should start.
  138072. * The value goes from -1 (full screen) to 1 (not visible)
  138073. * It helps with side by side comparison against the final render
  138074. * This defaults to 0
  138075. */
  138076. debugLimit: number;
  138077. /**
  138078. * As the default viewing range might not be enough (if the ambient is really small for instance)
  138079. * You can use the factor to better multiply the final value.
  138080. */
  138081. debugFactor: number;
  138082. /**
  138083. * Initialize the block and prepare the context for build
  138084. * @param state defines the state that will be used for the build
  138085. */
  138086. initialize(state: NodeMaterialBuildState): void;
  138087. /**
  138088. * Gets the current class name
  138089. * @returns the class name
  138090. */
  138091. getClassName(): string;
  138092. /**
  138093. * Gets the world position input component
  138094. */
  138095. get worldPosition(): NodeMaterialConnectionPoint;
  138096. /**
  138097. * Gets the world normal input component
  138098. */
  138099. get worldNormal(): NodeMaterialConnectionPoint;
  138100. /**
  138101. * Gets the perturbed normal input component
  138102. */
  138103. get perturbedNormal(): NodeMaterialConnectionPoint;
  138104. /**
  138105. * Gets the camera position input component
  138106. */
  138107. get cameraPosition(): NodeMaterialConnectionPoint;
  138108. /**
  138109. * Gets the base color input component
  138110. */
  138111. get baseColor(): NodeMaterialConnectionPoint;
  138112. /**
  138113. * Gets the base texture input component
  138114. */
  138115. get baseTexture(): NodeMaterialConnectionPoint;
  138116. /**
  138117. * Gets the opacity texture input component
  138118. */
  138119. get opacityTexture(): NodeMaterialConnectionPoint;
  138120. /**
  138121. * Gets the ambient color input component
  138122. */
  138123. get ambientColor(): NodeMaterialConnectionPoint;
  138124. /**
  138125. * Gets the reflectivity object parameters
  138126. */
  138127. get reflectivity(): NodeMaterialConnectionPoint;
  138128. /**
  138129. * Gets the ambient occlusion object parameters
  138130. */
  138131. get ambientOcclusion(): NodeMaterialConnectionPoint;
  138132. /**
  138133. * Gets the reflection object parameters
  138134. */
  138135. get reflection(): NodeMaterialConnectionPoint;
  138136. /**
  138137. * Gets the sheen object parameters
  138138. */
  138139. get sheen(): NodeMaterialConnectionPoint;
  138140. /**
  138141. * Gets the clear coat object parameters
  138142. */
  138143. get clearcoat(): NodeMaterialConnectionPoint;
  138144. /**
  138145. * Gets the sub surface object parameters
  138146. */
  138147. get subsurface(): NodeMaterialConnectionPoint;
  138148. /**
  138149. * Gets the anisotropy object parameters
  138150. */
  138151. get anisotropy(): NodeMaterialConnectionPoint;
  138152. /**
  138153. * Gets the ambient output component
  138154. */
  138155. get ambient(): NodeMaterialConnectionPoint;
  138156. /**
  138157. * Gets the diffuse output component
  138158. */
  138159. get diffuse(): NodeMaterialConnectionPoint;
  138160. /**
  138161. * Gets the specular output component
  138162. */
  138163. get specular(): NodeMaterialConnectionPoint;
  138164. /**
  138165. * Gets the sheen output component
  138166. */
  138167. get sheenDir(): NodeMaterialConnectionPoint;
  138168. /**
  138169. * Gets the clear coat output component
  138170. */
  138171. get clearcoatDir(): NodeMaterialConnectionPoint;
  138172. /**
  138173. * Gets the indirect diffuse output component
  138174. */
  138175. get diffuseIndirect(): NodeMaterialConnectionPoint;
  138176. /**
  138177. * Gets the indirect specular output component
  138178. */
  138179. get specularIndirect(): NodeMaterialConnectionPoint;
  138180. /**
  138181. * Gets the indirect sheen output component
  138182. */
  138183. get sheenIndirect(): NodeMaterialConnectionPoint;
  138184. /**
  138185. * Gets the indirect clear coat output component
  138186. */
  138187. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  138188. /**
  138189. * Gets the refraction output component
  138190. */
  138191. get refraction(): NodeMaterialConnectionPoint;
  138192. /**
  138193. * Gets the global lighting output component
  138194. */
  138195. get lighting(): NodeMaterialConnectionPoint;
  138196. /**
  138197. * Gets the shadow output component
  138198. */
  138199. get shadow(): NodeMaterialConnectionPoint;
  138200. /**
  138201. * Gets the alpha output component
  138202. */
  138203. get alpha(): NodeMaterialConnectionPoint;
  138204. autoConfigure(material: NodeMaterial): void;
  138205. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138206. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138207. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138208. private _injectVertexCode;
  138209. /**
  138210. * Gets the code corresponding to the albedo/opacity module
  138211. * @returns the shader code
  138212. */
  138213. getAlbedoOpacityCode(): string;
  138214. protected _buildBlock(state: NodeMaterialBuildState): this;
  138215. protected _dumpPropertiesCode(): string;
  138216. serialize(): any;
  138217. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138218. }
  138219. }
  138220. declare module BABYLON {
  138221. /**
  138222. * Effect Render Options
  138223. */
  138224. export interface IEffectRendererOptions {
  138225. /**
  138226. * Defines the vertices positions.
  138227. */
  138228. positions?: number[];
  138229. /**
  138230. * Defines the indices.
  138231. */
  138232. indices?: number[];
  138233. }
  138234. /**
  138235. * Helper class to render one or more effects.
  138236. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138237. */
  138238. export class EffectRenderer {
  138239. private engine;
  138240. private static _DefaultOptions;
  138241. private _vertexBuffers;
  138242. private _indexBuffer;
  138243. private _fullscreenViewport;
  138244. /**
  138245. * Creates an effect renderer
  138246. * @param engine the engine to use for rendering
  138247. * @param options defines the options of the effect renderer
  138248. */
  138249. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138250. /**
  138251. * Sets the current viewport in normalized coordinates 0-1
  138252. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138253. */
  138254. setViewport(viewport?: Viewport): void;
  138255. /**
  138256. * Binds the embedded attributes buffer to the effect.
  138257. * @param effect Defines the effect to bind the attributes for
  138258. */
  138259. bindBuffers(effect: Effect): void;
  138260. /**
  138261. * Sets the current effect wrapper to use during draw.
  138262. * The effect needs to be ready before calling this api.
  138263. * This also sets the default full screen position attribute.
  138264. * @param effectWrapper Defines the effect to draw with
  138265. */
  138266. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138267. /**
  138268. * Draws a full screen quad.
  138269. */
  138270. draw(): void;
  138271. private isRenderTargetTexture;
  138272. /**
  138273. * renders one or more effects to a specified texture
  138274. * @param effectWrapper the effect to renderer
  138275. * @param outputTexture texture to draw to, if null it will render to the screen.
  138276. */
  138277. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138278. /**
  138279. * Disposes of the effect renderer
  138280. */
  138281. dispose(): void;
  138282. }
  138283. /**
  138284. * Options to create an EffectWrapper
  138285. */
  138286. interface EffectWrapperCreationOptions {
  138287. /**
  138288. * Engine to use to create the effect
  138289. */
  138290. engine: ThinEngine;
  138291. /**
  138292. * Fragment shader for the effect
  138293. */
  138294. fragmentShader: string;
  138295. /**
  138296. * Vertex shader for the effect
  138297. */
  138298. vertexShader?: string;
  138299. /**
  138300. * Attributes to use in the shader
  138301. */
  138302. attributeNames?: Array<string>;
  138303. /**
  138304. * Uniforms to use in the shader
  138305. */
  138306. uniformNames?: Array<string>;
  138307. /**
  138308. * Texture sampler names to use in the shader
  138309. */
  138310. samplerNames?: Array<string>;
  138311. /**
  138312. * The friendly name of the effect displayed in Spector.
  138313. */
  138314. name?: string;
  138315. }
  138316. /**
  138317. * Wraps an effect to be used for rendering
  138318. */
  138319. export class EffectWrapper {
  138320. /**
  138321. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138322. */
  138323. onApplyObservable: Observable<{}>;
  138324. /**
  138325. * The underlying effect
  138326. */
  138327. effect: Effect;
  138328. /**
  138329. * Creates an effect to be renderer
  138330. * @param creationOptions options to create the effect
  138331. */
  138332. constructor(creationOptions: EffectWrapperCreationOptions);
  138333. /**
  138334. * Disposes of the effect wrapper
  138335. */
  138336. dispose(): void;
  138337. }
  138338. }
  138339. declare module BABYLON {
  138340. /**
  138341. * Helper class to push actions to a pool of workers.
  138342. */
  138343. export class WorkerPool implements IDisposable {
  138344. private _workerInfos;
  138345. private _pendingActions;
  138346. /**
  138347. * Constructor
  138348. * @param workers Array of workers to use for actions
  138349. */
  138350. constructor(workers: Array<Worker>);
  138351. /**
  138352. * Terminates all workers and clears any pending actions.
  138353. */
  138354. dispose(): void;
  138355. /**
  138356. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138357. * pended until a worker has completed its action.
  138358. * @param action The action to perform. Call onComplete when the action is complete.
  138359. */
  138360. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138361. private _execute;
  138362. }
  138363. }
  138364. declare module BABYLON {
  138365. /**
  138366. * Configuration for Draco compression
  138367. */
  138368. export interface IDracoCompressionConfiguration {
  138369. /**
  138370. * Configuration for the decoder.
  138371. */
  138372. decoder: {
  138373. /**
  138374. * The url to the WebAssembly module.
  138375. */
  138376. wasmUrl?: string;
  138377. /**
  138378. * The url to the WebAssembly binary.
  138379. */
  138380. wasmBinaryUrl?: string;
  138381. /**
  138382. * The url to the fallback JavaScript module.
  138383. */
  138384. fallbackUrl?: string;
  138385. };
  138386. }
  138387. /**
  138388. * Draco compression (https://google.github.io/draco/)
  138389. *
  138390. * This class wraps the Draco module.
  138391. *
  138392. * **Encoder**
  138393. *
  138394. * The encoder is not currently implemented.
  138395. *
  138396. * **Decoder**
  138397. *
  138398. * 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.
  138399. *
  138400. * To update the configuration, use the following code:
  138401. * ```javascript
  138402. * DracoCompression.Configuration = {
  138403. * decoder: {
  138404. * wasmUrl: "<url to the WebAssembly library>",
  138405. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  138406. * fallbackUrl: "<url to the fallback JavaScript library>",
  138407. * }
  138408. * };
  138409. * ```
  138410. *
  138411. * 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.
  138412. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  138413. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  138414. *
  138415. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  138416. * ```javascript
  138417. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  138418. * ```
  138419. *
  138420. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  138421. */
  138422. export class DracoCompression implements IDisposable {
  138423. private _workerPoolPromise?;
  138424. private _decoderModulePromise?;
  138425. /**
  138426. * The configuration. Defaults to the following urls:
  138427. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  138428. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  138429. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  138430. */
  138431. static Configuration: IDracoCompressionConfiguration;
  138432. /**
  138433. * Returns true if the decoder configuration is available.
  138434. */
  138435. static get DecoderAvailable(): boolean;
  138436. /**
  138437. * Default number of workers to create when creating the draco compression object.
  138438. */
  138439. static DefaultNumWorkers: number;
  138440. private static GetDefaultNumWorkers;
  138441. private static _Default;
  138442. /**
  138443. * Default instance for the draco compression object.
  138444. */
  138445. static get Default(): DracoCompression;
  138446. /**
  138447. * Constructor
  138448. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138449. */
  138450. constructor(numWorkers?: number);
  138451. /**
  138452. * Stop all async operations and release resources.
  138453. */
  138454. dispose(): void;
  138455. /**
  138456. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  138457. * @returns a promise that resolves when ready
  138458. */
  138459. whenReadyAsync(): Promise<void>;
  138460. /**
  138461. * Decode Draco compressed mesh data to vertex data.
  138462. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  138463. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  138464. * @returns A promise that resolves with the decoded vertex data
  138465. */
  138466. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  138467. [kind: string]: number;
  138468. }): Promise<VertexData>;
  138469. }
  138470. }
  138471. declare module BABYLON {
  138472. /**
  138473. * Class for building Constructive Solid Geometry
  138474. */
  138475. export class CSG {
  138476. private polygons;
  138477. /**
  138478. * The world matrix
  138479. */
  138480. matrix: Matrix;
  138481. /**
  138482. * Stores the position
  138483. */
  138484. position: Vector3;
  138485. /**
  138486. * Stores the rotation
  138487. */
  138488. rotation: Vector3;
  138489. /**
  138490. * Stores the rotation quaternion
  138491. */
  138492. rotationQuaternion: Nullable<Quaternion>;
  138493. /**
  138494. * Stores the scaling vector
  138495. */
  138496. scaling: Vector3;
  138497. /**
  138498. * Convert the Mesh to CSG
  138499. * @param mesh The Mesh to convert to CSG
  138500. * @returns A new CSG from the Mesh
  138501. */
  138502. static FromMesh(mesh: Mesh): CSG;
  138503. /**
  138504. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  138505. * @param polygons Polygons used to construct a CSG solid
  138506. */
  138507. private static FromPolygons;
  138508. /**
  138509. * Clones, or makes a deep copy, of the CSG
  138510. * @returns A new CSG
  138511. */
  138512. clone(): CSG;
  138513. /**
  138514. * Unions this CSG with another CSG
  138515. * @param csg The CSG to union against this CSG
  138516. * @returns The unioned CSG
  138517. */
  138518. union(csg: CSG): CSG;
  138519. /**
  138520. * Unions this CSG with another CSG in place
  138521. * @param csg The CSG to union against this CSG
  138522. */
  138523. unionInPlace(csg: CSG): void;
  138524. /**
  138525. * Subtracts this CSG with another CSG
  138526. * @param csg The CSG to subtract against this CSG
  138527. * @returns A new CSG
  138528. */
  138529. subtract(csg: CSG): CSG;
  138530. /**
  138531. * Subtracts this CSG with another CSG in place
  138532. * @param csg The CSG to subtact against this CSG
  138533. */
  138534. subtractInPlace(csg: CSG): void;
  138535. /**
  138536. * Intersect this CSG with another CSG
  138537. * @param csg The CSG to intersect against this CSG
  138538. * @returns A new CSG
  138539. */
  138540. intersect(csg: CSG): CSG;
  138541. /**
  138542. * Intersects this CSG with another CSG in place
  138543. * @param csg The CSG to intersect against this CSG
  138544. */
  138545. intersectInPlace(csg: CSG): void;
  138546. /**
  138547. * Return a new CSG solid with solid and empty space switched. This solid is
  138548. * not modified.
  138549. * @returns A new CSG solid with solid and empty space switched
  138550. */
  138551. inverse(): CSG;
  138552. /**
  138553. * Inverses the CSG in place
  138554. */
  138555. inverseInPlace(): void;
  138556. /**
  138557. * This is used to keep meshes transformations so they can be restored
  138558. * when we build back a Babylon Mesh
  138559. * NB : All CSG operations are performed in world coordinates
  138560. * @param csg The CSG to copy the transform attributes from
  138561. * @returns This CSG
  138562. */
  138563. copyTransformAttributes(csg: CSG): CSG;
  138564. /**
  138565. * Build Raw mesh from CSG
  138566. * Coordinates here are in world space
  138567. * @param name The name of the mesh geometry
  138568. * @param scene The Scene
  138569. * @param keepSubMeshes Specifies if the submeshes should be kept
  138570. * @returns A new Mesh
  138571. */
  138572. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138573. /**
  138574. * Build Mesh from CSG taking material and transforms into account
  138575. * @param name The name of the Mesh
  138576. * @param material The material of the Mesh
  138577. * @param scene The Scene
  138578. * @param keepSubMeshes Specifies if submeshes should be kept
  138579. * @returns The new Mesh
  138580. */
  138581. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138582. }
  138583. }
  138584. declare module BABYLON {
  138585. /**
  138586. * Class used to create a trail following a mesh
  138587. */
  138588. export class TrailMesh extends Mesh {
  138589. private _generator;
  138590. private _autoStart;
  138591. private _running;
  138592. private _diameter;
  138593. private _length;
  138594. private _sectionPolygonPointsCount;
  138595. private _sectionVectors;
  138596. private _sectionNormalVectors;
  138597. private _beforeRenderObserver;
  138598. /**
  138599. * @constructor
  138600. * @param name The value used by scene.getMeshByName() to do a lookup.
  138601. * @param generator The mesh or transform node to generate a trail.
  138602. * @param scene The scene to add this mesh to.
  138603. * @param diameter Diameter of trailing mesh. Default is 1.
  138604. * @param length Length of trailing mesh. Default is 60.
  138605. * @param autoStart Automatically start trailing mesh. Default true.
  138606. */
  138607. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  138608. /**
  138609. * "TrailMesh"
  138610. * @returns "TrailMesh"
  138611. */
  138612. getClassName(): string;
  138613. private _createMesh;
  138614. /**
  138615. * Start trailing mesh.
  138616. */
  138617. start(): void;
  138618. /**
  138619. * Stop trailing mesh.
  138620. */
  138621. stop(): void;
  138622. /**
  138623. * Update trailing mesh geometry.
  138624. */
  138625. update(): void;
  138626. /**
  138627. * Returns a new TrailMesh object.
  138628. * @param name is a string, the name given to the new mesh
  138629. * @param newGenerator use new generator object for cloned trail mesh
  138630. * @returns a new mesh
  138631. */
  138632. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  138633. /**
  138634. * Serializes this trail mesh
  138635. * @param serializationObject object to write serialization to
  138636. */
  138637. serialize(serializationObject: any): void;
  138638. /**
  138639. * Parses a serialized trail mesh
  138640. * @param parsedMesh the serialized mesh
  138641. * @param scene the scene to create the trail mesh in
  138642. * @returns the created trail mesh
  138643. */
  138644. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  138645. }
  138646. }
  138647. declare module BABYLON {
  138648. /**
  138649. * Class containing static functions to help procedurally build meshes
  138650. */
  138651. export class TiledBoxBuilder {
  138652. /**
  138653. * Creates a box mesh
  138654. * 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)
  138655. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138657. * * 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
  138658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138659. * @param name defines the name of the mesh
  138660. * @param options defines the options used to create the mesh
  138661. * @param scene defines the hosting scene
  138662. * @returns the box mesh
  138663. */
  138664. static CreateTiledBox(name: string, options: {
  138665. pattern?: number;
  138666. width?: number;
  138667. height?: number;
  138668. depth?: number;
  138669. tileSize?: number;
  138670. tileWidth?: number;
  138671. tileHeight?: number;
  138672. alignHorizontal?: number;
  138673. alignVertical?: number;
  138674. faceUV?: Vector4[];
  138675. faceColors?: Color4[];
  138676. sideOrientation?: number;
  138677. updatable?: boolean;
  138678. }, scene?: Nullable<Scene>): Mesh;
  138679. }
  138680. }
  138681. declare module BABYLON {
  138682. /**
  138683. * Class containing static functions to help procedurally build meshes
  138684. */
  138685. export class TorusKnotBuilder {
  138686. /**
  138687. * Creates a torus knot mesh
  138688. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138689. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138690. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138691. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138693. * * 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
  138694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138695. * @param name defines the name of the mesh
  138696. * @param options defines the options used to create the mesh
  138697. * @param scene defines the hosting scene
  138698. * @returns the torus knot mesh
  138699. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138700. */
  138701. static CreateTorusKnot(name: string, options: {
  138702. radius?: number;
  138703. tube?: number;
  138704. radialSegments?: number;
  138705. tubularSegments?: number;
  138706. p?: number;
  138707. q?: number;
  138708. updatable?: boolean;
  138709. sideOrientation?: number;
  138710. frontUVs?: Vector4;
  138711. backUVs?: Vector4;
  138712. }, scene: any): Mesh;
  138713. }
  138714. }
  138715. declare module BABYLON {
  138716. /**
  138717. * Polygon
  138718. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  138719. */
  138720. export class Polygon {
  138721. /**
  138722. * Creates a rectangle
  138723. * @param xmin bottom X coord
  138724. * @param ymin bottom Y coord
  138725. * @param xmax top X coord
  138726. * @param ymax top Y coord
  138727. * @returns points that make the resulting rectation
  138728. */
  138729. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  138730. /**
  138731. * Creates a circle
  138732. * @param radius radius of circle
  138733. * @param cx scale in x
  138734. * @param cy scale in y
  138735. * @param numberOfSides number of sides that make up the circle
  138736. * @returns points that make the resulting circle
  138737. */
  138738. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  138739. /**
  138740. * Creates a polygon from input string
  138741. * @param input Input polygon data
  138742. * @returns the parsed points
  138743. */
  138744. static Parse(input: string): Vector2[];
  138745. /**
  138746. * Starts building a polygon from x and y coordinates
  138747. * @param x x coordinate
  138748. * @param y y coordinate
  138749. * @returns the started path2
  138750. */
  138751. static StartingAt(x: number, y: number): Path2;
  138752. }
  138753. /**
  138754. * Builds a polygon
  138755. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  138756. */
  138757. export class PolygonMeshBuilder {
  138758. private _points;
  138759. private _outlinepoints;
  138760. private _holes;
  138761. private _name;
  138762. private _scene;
  138763. private _epoints;
  138764. private _eholes;
  138765. private _addToepoint;
  138766. /**
  138767. * Babylon reference to the earcut plugin.
  138768. */
  138769. bjsEarcut: any;
  138770. /**
  138771. * Creates a PolygonMeshBuilder
  138772. * @param name name of the builder
  138773. * @param contours Path of the polygon
  138774. * @param scene scene to add to when creating the mesh
  138775. * @param earcutInjection can be used to inject your own earcut reference
  138776. */
  138777. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  138778. /**
  138779. * Adds a whole within the polygon
  138780. * @param hole Array of points defining the hole
  138781. * @returns this
  138782. */
  138783. addHole(hole: Vector2[]): PolygonMeshBuilder;
  138784. /**
  138785. * Creates the polygon
  138786. * @param updatable If the mesh should be updatable
  138787. * @param depth The depth of the mesh created
  138788. * @returns the created mesh
  138789. */
  138790. build(updatable?: boolean, depth?: number): Mesh;
  138791. /**
  138792. * Creates the polygon
  138793. * @param depth The depth of the mesh created
  138794. * @returns the created VertexData
  138795. */
  138796. buildVertexData(depth?: number): VertexData;
  138797. /**
  138798. * Adds a side to the polygon
  138799. * @param positions points that make the polygon
  138800. * @param normals normals of the polygon
  138801. * @param uvs uvs of the polygon
  138802. * @param indices indices of the polygon
  138803. * @param bounds bounds of the polygon
  138804. * @param points points of the polygon
  138805. * @param depth depth of the polygon
  138806. * @param flip flip of the polygon
  138807. */
  138808. private addSide;
  138809. }
  138810. }
  138811. declare module BABYLON {
  138812. /**
  138813. * Class containing static functions to help procedurally build meshes
  138814. */
  138815. export class PolygonBuilder {
  138816. /**
  138817. * Creates a polygon mesh
  138818. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  138819. * * 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
  138820. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138822. * * 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)
  138823. * * Remember you can only change the shape positions, not their number when updating a polygon
  138824. * @param name defines the name of the mesh
  138825. * @param options defines the options used to create the mesh
  138826. * @param scene defines the hosting scene
  138827. * @param earcutInjection can be used to inject your own earcut reference
  138828. * @returns the polygon mesh
  138829. */
  138830. static CreatePolygon(name: string, options: {
  138831. shape: Vector3[];
  138832. holes?: Vector3[][];
  138833. depth?: number;
  138834. faceUV?: Vector4[];
  138835. faceColors?: Color4[];
  138836. updatable?: boolean;
  138837. sideOrientation?: number;
  138838. frontUVs?: Vector4;
  138839. backUVs?: Vector4;
  138840. wrap?: boolean;
  138841. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138842. /**
  138843. * Creates an extruded polygon mesh, with depth in the Y direction.
  138844. * * 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)
  138845. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138846. * @param name defines the name of the mesh
  138847. * @param options defines the options used to create the mesh
  138848. * @param scene defines the hosting scene
  138849. * @param earcutInjection can be used to inject your own earcut reference
  138850. * @returns the polygon mesh
  138851. */
  138852. static ExtrudePolygon(name: string, options: {
  138853. shape: Vector3[];
  138854. holes?: Vector3[][];
  138855. depth?: number;
  138856. faceUV?: Vector4[];
  138857. faceColors?: Color4[];
  138858. updatable?: boolean;
  138859. sideOrientation?: number;
  138860. frontUVs?: Vector4;
  138861. backUVs?: Vector4;
  138862. wrap?: boolean;
  138863. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138864. }
  138865. }
  138866. declare module BABYLON {
  138867. /**
  138868. * Class containing static functions to help procedurally build meshes
  138869. */
  138870. export class LatheBuilder {
  138871. /**
  138872. * Creates lathe mesh.
  138873. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  138874. * * 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
  138875. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  138876. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  138877. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  138878. * * 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
  138879. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  138880. * * 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
  138881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138882. * * 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
  138883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138885. * @param name defines the name of the mesh
  138886. * @param options defines the options used to create the mesh
  138887. * @param scene defines the hosting scene
  138888. * @returns the lathe mesh
  138889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  138890. */
  138891. static CreateLathe(name: string, options: {
  138892. shape: Vector3[];
  138893. radius?: number;
  138894. tessellation?: number;
  138895. clip?: number;
  138896. arc?: number;
  138897. closed?: boolean;
  138898. updatable?: boolean;
  138899. sideOrientation?: number;
  138900. frontUVs?: Vector4;
  138901. backUVs?: Vector4;
  138902. cap?: number;
  138903. invertUV?: boolean;
  138904. }, scene?: Nullable<Scene>): Mesh;
  138905. }
  138906. }
  138907. declare module BABYLON {
  138908. /**
  138909. * Class containing static functions to help procedurally build meshes
  138910. */
  138911. export class TiledPlaneBuilder {
  138912. /**
  138913. * Creates a tiled plane mesh
  138914. * * The parameter `pattern` will, depending on value, do nothing or
  138915. * * * flip (reflect about central vertical) alternate tiles across and up
  138916. * * * flip every tile on alternate rows
  138917. * * * rotate (180 degs) alternate tiles across and up
  138918. * * * rotate every tile on alternate rows
  138919. * * * flip and rotate alternate tiles across and up
  138920. * * * flip and rotate every tile on alternate rows
  138921. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  138922. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  138923. * * 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
  138924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138925. * * 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)
  138926. * * 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)
  138927. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  138928. * @param name defines the name of the mesh
  138929. * @param options defines the options used to create the mesh
  138930. * @param scene defines the hosting scene
  138931. * @returns the box mesh
  138932. */
  138933. static CreateTiledPlane(name: string, options: {
  138934. pattern?: number;
  138935. tileSize?: number;
  138936. tileWidth?: number;
  138937. tileHeight?: number;
  138938. size?: number;
  138939. width?: number;
  138940. height?: number;
  138941. alignHorizontal?: number;
  138942. alignVertical?: number;
  138943. sideOrientation?: number;
  138944. frontUVs?: Vector4;
  138945. backUVs?: Vector4;
  138946. updatable?: boolean;
  138947. }, scene?: Nullable<Scene>): Mesh;
  138948. }
  138949. }
  138950. declare module BABYLON {
  138951. /**
  138952. * Class containing static functions to help procedurally build meshes
  138953. */
  138954. export class TubeBuilder {
  138955. /**
  138956. * Creates a tube mesh.
  138957. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138958. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  138959. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  138960. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  138961. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  138962. * * 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)
  138963. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  138964. * * 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
  138965. * * 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
  138966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138967. * * 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
  138968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138970. * @param name defines the name of the mesh
  138971. * @param options defines the options used to create the mesh
  138972. * @param scene defines the hosting scene
  138973. * @returns the tube mesh
  138974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138975. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  138976. */
  138977. static CreateTube(name: string, options: {
  138978. path: Vector3[];
  138979. radius?: number;
  138980. tessellation?: number;
  138981. radiusFunction?: {
  138982. (i: number, distance: number): number;
  138983. };
  138984. cap?: number;
  138985. arc?: number;
  138986. updatable?: boolean;
  138987. sideOrientation?: number;
  138988. frontUVs?: Vector4;
  138989. backUVs?: Vector4;
  138990. instance?: Mesh;
  138991. invertUV?: boolean;
  138992. }, scene?: Nullable<Scene>): Mesh;
  138993. }
  138994. }
  138995. declare module BABYLON {
  138996. /**
  138997. * Class containing static functions to help procedurally build meshes
  138998. */
  138999. export class IcoSphereBuilder {
  139000. /**
  139001. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  139002. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  139003. * * 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`)
  139004. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  139005. * * 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
  139006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139007. * * 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
  139008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139009. * @param name defines the name of the mesh
  139010. * @param options defines the options used to create the mesh
  139011. * @param scene defines the hosting scene
  139012. * @returns the icosahedron mesh
  139013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  139014. */
  139015. static CreateIcoSphere(name: string, options: {
  139016. radius?: number;
  139017. radiusX?: number;
  139018. radiusY?: number;
  139019. radiusZ?: number;
  139020. flat?: boolean;
  139021. subdivisions?: number;
  139022. sideOrientation?: number;
  139023. frontUVs?: Vector4;
  139024. backUVs?: Vector4;
  139025. updatable?: boolean;
  139026. }, scene?: Nullable<Scene>): Mesh;
  139027. }
  139028. }
  139029. declare module BABYLON {
  139030. /**
  139031. * Class containing static functions to help procedurally build meshes
  139032. */
  139033. export class DecalBuilder {
  139034. /**
  139035. * Creates a decal mesh.
  139036. * 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
  139037. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  139038. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  139039. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  139040. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  139041. * @param name defines the name of the mesh
  139042. * @param sourceMesh defines the mesh where the decal must be applied
  139043. * @param options defines the options used to create the mesh
  139044. * @param scene defines the hosting scene
  139045. * @returns the decal mesh
  139046. * @see https://doc.babylonjs.com/how_to/decals
  139047. */
  139048. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  139049. position?: Vector3;
  139050. normal?: Vector3;
  139051. size?: Vector3;
  139052. angle?: number;
  139053. }): Mesh;
  139054. }
  139055. }
  139056. declare module BABYLON {
  139057. /**
  139058. * Class containing static functions to help procedurally build meshes
  139059. */
  139060. export class MeshBuilder {
  139061. /**
  139062. * Creates a box mesh
  139063. * * The parameter `size` sets the size (float) of each box side (default 1)
  139064. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  139065. * * 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)
  139066. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139068. * * 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
  139069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139070. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  139071. * @param name defines the name of the mesh
  139072. * @param options defines the options used to create the mesh
  139073. * @param scene defines the hosting scene
  139074. * @returns the box mesh
  139075. */
  139076. static CreateBox(name: string, options: {
  139077. size?: number;
  139078. width?: number;
  139079. height?: number;
  139080. depth?: number;
  139081. faceUV?: Vector4[];
  139082. faceColors?: Color4[];
  139083. sideOrientation?: number;
  139084. frontUVs?: Vector4;
  139085. backUVs?: Vector4;
  139086. wrap?: boolean;
  139087. topBaseAt?: number;
  139088. bottomBaseAt?: number;
  139089. updatable?: boolean;
  139090. }, scene?: Nullable<Scene>): Mesh;
  139091. /**
  139092. * Creates a tiled box mesh
  139093. * * faceTiles sets the pattern, tile size and number of tiles for a face
  139094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139095. * @param name defines the name of the mesh
  139096. * @param options defines the options used to create the mesh
  139097. * @param scene defines the hosting scene
  139098. * @returns the tiled box mesh
  139099. */
  139100. static CreateTiledBox(name: string, options: {
  139101. pattern?: number;
  139102. size?: number;
  139103. width?: number;
  139104. height?: number;
  139105. depth: number;
  139106. tileSize?: number;
  139107. tileWidth?: number;
  139108. tileHeight?: number;
  139109. faceUV?: Vector4[];
  139110. faceColors?: Color4[];
  139111. alignHorizontal?: number;
  139112. alignVertical?: number;
  139113. sideOrientation?: number;
  139114. updatable?: boolean;
  139115. }, scene?: Nullable<Scene>): Mesh;
  139116. /**
  139117. * Creates a sphere mesh
  139118. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  139119. * * 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`)
  139120. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  139121. * * 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
  139122. * * 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)
  139123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139124. * * 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
  139125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139126. * @param name defines the name of the mesh
  139127. * @param options defines the options used to create the mesh
  139128. * @param scene defines the hosting scene
  139129. * @returns the sphere mesh
  139130. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  139131. */
  139132. static CreateSphere(name: string, options: {
  139133. segments?: number;
  139134. diameter?: number;
  139135. diameterX?: number;
  139136. diameterY?: number;
  139137. diameterZ?: number;
  139138. arc?: number;
  139139. slice?: number;
  139140. sideOrientation?: number;
  139141. frontUVs?: Vector4;
  139142. backUVs?: Vector4;
  139143. updatable?: boolean;
  139144. }, scene?: Nullable<Scene>): Mesh;
  139145. /**
  139146. * Creates a plane polygonal mesh. By default, this is a disc
  139147. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  139148. * * 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
  139149. * * 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
  139150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139151. * * 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
  139152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139153. * @param name defines the name of the mesh
  139154. * @param options defines the options used to create the mesh
  139155. * @param scene defines the hosting scene
  139156. * @returns the plane polygonal mesh
  139157. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  139158. */
  139159. static CreateDisc(name: string, options: {
  139160. radius?: number;
  139161. tessellation?: number;
  139162. arc?: number;
  139163. updatable?: boolean;
  139164. sideOrientation?: number;
  139165. frontUVs?: Vector4;
  139166. backUVs?: Vector4;
  139167. }, scene?: Nullable<Scene>): Mesh;
  139168. /**
  139169. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  139170. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  139171. * * 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`)
  139172. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  139173. * * 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
  139174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139175. * * 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
  139176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139177. * @param name defines the name of the mesh
  139178. * @param options defines the options used to create the mesh
  139179. * @param scene defines the hosting scene
  139180. * @returns the icosahedron mesh
  139181. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  139182. */
  139183. static CreateIcoSphere(name: string, options: {
  139184. radius?: number;
  139185. radiusX?: number;
  139186. radiusY?: number;
  139187. radiusZ?: number;
  139188. flat?: boolean;
  139189. subdivisions?: number;
  139190. sideOrientation?: number;
  139191. frontUVs?: Vector4;
  139192. backUVs?: Vector4;
  139193. updatable?: boolean;
  139194. }, scene?: Nullable<Scene>): Mesh;
  139195. /**
  139196. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139197. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  139198. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  139199. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  139200. * * 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
  139201. * * 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
  139202. * * 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
  139203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139204. * * 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
  139205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139206. * * 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
  139207. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  139208. * * 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
  139209. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  139210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139211. * @param name defines the name of the mesh
  139212. * @param options defines the options used to create the mesh
  139213. * @param scene defines the hosting scene
  139214. * @returns the ribbon mesh
  139215. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  139216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139217. */
  139218. static CreateRibbon(name: string, options: {
  139219. pathArray: Vector3[][];
  139220. closeArray?: boolean;
  139221. closePath?: boolean;
  139222. offset?: number;
  139223. updatable?: boolean;
  139224. sideOrientation?: number;
  139225. frontUVs?: Vector4;
  139226. backUVs?: Vector4;
  139227. instance?: Mesh;
  139228. invertUV?: boolean;
  139229. uvs?: Vector2[];
  139230. colors?: Color4[];
  139231. }, scene?: Nullable<Scene>): Mesh;
  139232. /**
  139233. * Creates a cylinder or a cone mesh
  139234. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  139235. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  139236. * * 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.
  139237. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  139238. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  139239. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  139240. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  139241. * * 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).
  139242. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  139243. * * 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).
  139244. * * 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
  139245. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  139246. * * 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
  139247. * * 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.
  139248. * * If `enclose` is false, a ring surface is one element.
  139249. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  139250. * * 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
  139251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139252. * * 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
  139253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139254. * @param name defines the name of the mesh
  139255. * @param options defines the options used to create the mesh
  139256. * @param scene defines the hosting scene
  139257. * @returns the cylinder mesh
  139258. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  139259. */
  139260. static CreateCylinder(name: string, options: {
  139261. height?: number;
  139262. diameterTop?: number;
  139263. diameterBottom?: number;
  139264. diameter?: number;
  139265. tessellation?: number;
  139266. subdivisions?: number;
  139267. arc?: number;
  139268. faceColors?: Color4[];
  139269. faceUV?: Vector4[];
  139270. updatable?: boolean;
  139271. hasRings?: boolean;
  139272. enclose?: boolean;
  139273. cap?: number;
  139274. sideOrientation?: number;
  139275. frontUVs?: Vector4;
  139276. backUVs?: Vector4;
  139277. }, scene?: Nullable<Scene>): Mesh;
  139278. /**
  139279. * Creates a torus mesh
  139280. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  139281. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  139282. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  139283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139284. * * 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
  139285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139286. * @param name defines the name of the mesh
  139287. * @param options defines the options used to create the mesh
  139288. * @param scene defines the hosting scene
  139289. * @returns the torus mesh
  139290. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  139291. */
  139292. static CreateTorus(name: string, options: {
  139293. diameter?: number;
  139294. thickness?: number;
  139295. tessellation?: number;
  139296. updatable?: boolean;
  139297. sideOrientation?: number;
  139298. frontUVs?: Vector4;
  139299. backUVs?: Vector4;
  139300. }, scene?: Nullable<Scene>): Mesh;
  139301. /**
  139302. * Creates a torus knot mesh
  139303. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  139304. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  139305. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  139306. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  139307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139308. * * 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
  139309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139310. * @param name defines the name of the mesh
  139311. * @param options defines the options used to create the mesh
  139312. * @param scene defines the hosting scene
  139313. * @returns the torus knot mesh
  139314. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  139315. */
  139316. static CreateTorusKnot(name: string, options: {
  139317. radius?: number;
  139318. tube?: number;
  139319. radialSegments?: number;
  139320. tubularSegments?: number;
  139321. p?: number;
  139322. q?: number;
  139323. updatable?: boolean;
  139324. sideOrientation?: number;
  139325. frontUVs?: Vector4;
  139326. backUVs?: Vector4;
  139327. }, scene?: Nullable<Scene>): Mesh;
  139328. /**
  139329. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  139330. * * 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
  139331. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  139332. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  139333. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  139334. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  139335. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  139336. * * 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
  139337. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  139338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  139340. * @param name defines the name of the new line system
  139341. * @param options defines the options used to create the line system
  139342. * @param scene defines the hosting scene
  139343. * @returns a new line system mesh
  139344. */
  139345. static CreateLineSystem(name: string, options: {
  139346. lines: Vector3[][];
  139347. updatable?: boolean;
  139348. instance?: Nullable<LinesMesh>;
  139349. colors?: Nullable<Color4[][]>;
  139350. useVertexAlpha?: boolean;
  139351. }, scene: Nullable<Scene>): LinesMesh;
  139352. /**
  139353. * Creates a line mesh
  139354. * 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
  139355. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  139356. * * The parameter `points` is an array successive Vector3
  139357. * * 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
  139358. * * The optional parameter `colors` is an array of successive Color4, one per line point
  139359. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  139360. * * When updating an instance, remember that only point positions can change, not the number of points
  139361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  139363. * @param name defines the name of the new line system
  139364. * @param options defines the options used to create the line system
  139365. * @param scene defines the hosting scene
  139366. * @returns a new line mesh
  139367. */
  139368. static CreateLines(name: string, options: {
  139369. points: Vector3[];
  139370. updatable?: boolean;
  139371. instance?: Nullable<LinesMesh>;
  139372. colors?: Color4[];
  139373. useVertexAlpha?: boolean;
  139374. }, scene?: Nullable<Scene>): LinesMesh;
  139375. /**
  139376. * Creates a dashed line mesh
  139377. * * 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
  139378. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  139379. * * The parameter `points` is an array successive Vector3
  139380. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  139381. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  139382. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  139383. * * 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
  139384. * * When updating an instance, remember that only point positions can change, not the number of points
  139385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139386. * @param name defines the name of the mesh
  139387. * @param options defines the options used to create the mesh
  139388. * @param scene defines the hosting scene
  139389. * @returns the dashed line mesh
  139390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  139391. */
  139392. static CreateDashedLines(name: string, options: {
  139393. points: Vector3[];
  139394. dashSize?: number;
  139395. gapSize?: number;
  139396. dashNb?: number;
  139397. updatable?: boolean;
  139398. instance?: LinesMesh;
  139399. }, scene?: Nullable<Scene>): LinesMesh;
  139400. /**
  139401. * 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.
  139402. * * 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.
  139403. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139404. * * 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.
  139405. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  139406. * * 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
  139407. * * 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
  139408. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  139409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139410. * * 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
  139411. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  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. * @param name defines the name of the mesh
  139414. * @param options defines the options used to create the mesh
  139415. * @param scene defines the hosting scene
  139416. * @returns the extruded shape mesh
  139417. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139419. */
  139420. static ExtrudeShape(name: string, options: {
  139421. shape: Vector3[];
  139422. path: Vector3[];
  139423. scale?: number;
  139424. rotation?: number;
  139425. cap?: number;
  139426. updatable?: boolean;
  139427. sideOrientation?: number;
  139428. frontUVs?: Vector4;
  139429. backUVs?: Vector4;
  139430. instance?: Mesh;
  139431. invertUV?: boolean;
  139432. }, scene?: Nullable<Scene>): Mesh;
  139433. /**
  139434. * Creates an custom extruded shape mesh.
  139435. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  139436. * * 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.
  139437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139438. * * 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
  139439. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  139440. * * 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
  139441. * * It must returns a float value that will be the scale value applied to the shape on each path point
  139442. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  139443. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  139444. * * 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
  139445. * * 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
  139446. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  139447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139448. * * 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
  139449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139451. * @param name defines the name of the mesh
  139452. * @param options defines the options used to create the mesh
  139453. * @param scene defines the hosting scene
  139454. * @returns the custom extruded shape mesh
  139455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  139456. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139458. */
  139459. static ExtrudeShapeCustom(name: string, options: {
  139460. shape: Vector3[];
  139461. path: Vector3[];
  139462. scaleFunction?: any;
  139463. rotationFunction?: any;
  139464. ribbonCloseArray?: boolean;
  139465. ribbonClosePath?: boolean;
  139466. cap?: number;
  139467. updatable?: boolean;
  139468. sideOrientation?: number;
  139469. frontUVs?: Vector4;
  139470. backUVs?: Vector4;
  139471. instance?: Mesh;
  139472. invertUV?: boolean;
  139473. }, scene?: Nullable<Scene>): Mesh;
  139474. /**
  139475. * Creates lathe mesh.
  139476. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  139477. * * 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
  139478. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  139479. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  139480. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  139481. * * 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
  139482. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  139483. * * 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
  139484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139485. * * 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
  139486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139488. * @param name defines the name of the mesh
  139489. * @param options defines the options used to create the mesh
  139490. * @param scene defines the hosting scene
  139491. * @returns the lathe mesh
  139492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  139493. */
  139494. static CreateLathe(name: string, options: {
  139495. shape: Vector3[];
  139496. radius?: number;
  139497. tessellation?: number;
  139498. clip?: number;
  139499. arc?: number;
  139500. closed?: boolean;
  139501. updatable?: boolean;
  139502. sideOrientation?: number;
  139503. frontUVs?: Vector4;
  139504. backUVs?: Vector4;
  139505. cap?: number;
  139506. invertUV?: boolean;
  139507. }, scene?: Nullable<Scene>): Mesh;
  139508. /**
  139509. * Creates a tiled plane mesh
  139510. * * You can set a limited pattern arrangement with the tiles
  139511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139512. * * 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
  139513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139514. * @param name defines the name of the mesh
  139515. * @param options defines the options used to create the mesh
  139516. * @param scene defines the hosting scene
  139517. * @returns the plane mesh
  139518. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139519. */
  139520. static CreateTiledPlane(name: string, options: {
  139521. pattern?: number;
  139522. tileSize?: number;
  139523. tileWidth?: number;
  139524. tileHeight?: number;
  139525. size?: number;
  139526. width?: number;
  139527. height?: number;
  139528. alignHorizontal?: number;
  139529. alignVertical?: number;
  139530. sideOrientation?: number;
  139531. frontUVs?: Vector4;
  139532. backUVs?: Vector4;
  139533. updatable?: boolean;
  139534. }, scene?: Nullable<Scene>): Mesh;
  139535. /**
  139536. * Creates a plane mesh
  139537. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  139538. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  139539. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  139540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139541. * * 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
  139542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139543. * @param name defines the name of the mesh
  139544. * @param options defines the options used to create the mesh
  139545. * @param scene defines the hosting scene
  139546. * @returns the plane mesh
  139547. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139548. */
  139549. static CreatePlane(name: string, options: {
  139550. size?: number;
  139551. width?: number;
  139552. height?: number;
  139553. sideOrientation?: number;
  139554. frontUVs?: Vector4;
  139555. backUVs?: Vector4;
  139556. updatable?: boolean;
  139557. sourcePlane?: Plane;
  139558. }, scene?: Nullable<Scene>): Mesh;
  139559. /**
  139560. * Creates a ground mesh
  139561. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  139562. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  139563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139564. * @param name defines the name of the mesh
  139565. * @param options defines the options used to create the mesh
  139566. * @param scene defines the hosting scene
  139567. * @returns the ground mesh
  139568. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  139569. */
  139570. static CreateGround(name: string, options: {
  139571. width?: number;
  139572. height?: number;
  139573. subdivisions?: number;
  139574. subdivisionsX?: number;
  139575. subdivisionsY?: number;
  139576. updatable?: boolean;
  139577. }, scene?: Nullable<Scene>): Mesh;
  139578. /**
  139579. * Creates a tiled ground mesh
  139580. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  139581. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  139582. * * 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
  139583. * * 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
  139584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139585. * @param name defines the name of the mesh
  139586. * @param options defines the options used to create the mesh
  139587. * @param scene defines the hosting scene
  139588. * @returns the tiled ground mesh
  139589. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  139590. */
  139591. static CreateTiledGround(name: string, options: {
  139592. xmin: number;
  139593. zmin: number;
  139594. xmax: number;
  139595. zmax: number;
  139596. subdivisions?: {
  139597. w: number;
  139598. h: number;
  139599. };
  139600. precision?: {
  139601. w: number;
  139602. h: number;
  139603. };
  139604. updatable?: boolean;
  139605. }, scene?: Nullable<Scene>): Mesh;
  139606. /**
  139607. * Creates a ground mesh from a height map
  139608. * * The parameter `url` sets the URL of the height map image resource.
  139609. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  139610. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  139611. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  139612. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  139613. * * 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.
  139614. * * 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).
  139615. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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 url defines the url to the height map
  139619. * @param options defines the options used to create the mesh
  139620. * @param scene defines the hosting scene
  139621. * @returns the ground mesh
  139622. * @see https://doc.babylonjs.com/babylon101/height_map
  139623. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  139624. */
  139625. static CreateGroundFromHeightMap(name: string, url: string, options: {
  139626. width?: number;
  139627. height?: number;
  139628. subdivisions?: number;
  139629. minHeight?: number;
  139630. maxHeight?: number;
  139631. colorFilter?: Color3;
  139632. alphaFilter?: number;
  139633. updatable?: boolean;
  139634. onReady?: (mesh: GroundMesh) => void;
  139635. }, scene?: Nullable<Scene>): GroundMesh;
  139636. /**
  139637. * Creates a polygon mesh
  139638. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  139639. * * 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
  139640. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  139641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139642. * * 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)
  139643. * * Remember you can only change the shape positions, not their number when updating a polygon
  139644. * @param name defines the name of the mesh
  139645. * @param options defines the options used to create the mesh
  139646. * @param scene defines the hosting scene
  139647. * @param earcutInjection can be used to inject your own earcut reference
  139648. * @returns the polygon mesh
  139649. */
  139650. static CreatePolygon(name: string, options: {
  139651. shape: Vector3[];
  139652. holes?: Vector3[][];
  139653. depth?: number;
  139654. faceUV?: Vector4[];
  139655. faceColors?: Color4[];
  139656. updatable?: boolean;
  139657. sideOrientation?: number;
  139658. frontUVs?: Vector4;
  139659. backUVs?: Vector4;
  139660. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139661. /**
  139662. * Creates an extruded polygon mesh, with depth in the Y direction.
  139663. * * 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)
  139664. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139665. * @param name defines the name of the mesh
  139666. * @param options defines the options used to create the mesh
  139667. * @param scene defines the hosting scene
  139668. * @param earcutInjection can be used to inject your own earcut reference
  139669. * @returns the polygon mesh
  139670. */
  139671. static ExtrudePolygon(name: string, options: {
  139672. shape: Vector3[];
  139673. holes?: Vector3[][];
  139674. depth?: number;
  139675. faceUV?: Vector4[];
  139676. faceColors?: Color4[];
  139677. updatable?: boolean;
  139678. sideOrientation?: number;
  139679. frontUVs?: Vector4;
  139680. backUVs?: Vector4;
  139681. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139682. /**
  139683. * Creates a tube mesh.
  139684. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139685. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  139686. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  139687. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  139688. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  139689. * * 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)
  139690. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  139691. * * 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
  139692. * * 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
  139693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139694. * * 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
  139695. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139697. * @param name defines the name of the mesh
  139698. * @param options defines the options used to create the mesh
  139699. * @param scene defines the hosting scene
  139700. * @returns the tube mesh
  139701. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139702. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  139703. */
  139704. static CreateTube(name: string, options: {
  139705. path: Vector3[];
  139706. radius?: number;
  139707. tessellation?: number;
  139708. radiusFunction?: {
  139709. (i: number, distance: number): number;
  139710. };
  139711. cap?: number;
  139712. arc?: number;
  139713. updatable?: boolean;
  139714. sideOrientation?: number;
  139715. frontUVs?: Vector4;
  139716. backUVs?: Vector4;
  139717. instance?: Mesh;
  139718. invertUV?: boolean;
  139719. }, scene?: Nullable<Scene>): Mesh;
  139720. /**
  139721. * Creates a polyhedron mesh
  139722. * * 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
  139723. * * The parameter `size` (positive float, default 1) sets the polygon size
  139724. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  139725. * * 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`
  139726. * * 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
  139727. * * 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)`)
  139728. * * 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
  139729. * * 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
  139730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139731. * * 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
  139732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139733. * @param name defines the name of the mesh
  139734. * @param options defines the options used to create the mesh
  139735. * @param scene defines the hosting scene
  139736. * @returns the polyhedron mesh
  139737. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  139738. */
  139739. static CreatePolyhedron(name: string, options: {
  139740. type?: number;
  139741. size?: number;
  139742. sizeX?: number;
  139743. sizeY?: number;
  139744. sizeZ?: number;
  139745. custom?: any;
  139746. faceUV?: Vector4[];
  139747. faceColors?: Color4[];
  139748. flat?: boolean;
  139749. updatable?: boolean;
  139750. sideOrientation?: number;
  139751. frontUVs?: Vector4;
  139752. backUVs?: Vector4;
  139753. }, scene?: Nullable<Scene>): Mesh;
  139754. /**
  139755. * Creates a decal mesh.
  139756. * 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
  139757. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  139758. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  139759. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  139760. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  139761. * @param name defines the name of the mesh
  139762. * @param sourceMesh defines the mesh where the decal must be applied
  139763. * @param options defines the options used to create the mesh
  139764. * @param scene defines the hosting scene
  139765. * @returns the decal mesh
  139766. * @see https://doc.babylonjs.com/how_to/decals
  139767. */
  139768. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  139769. position?: Vector3;
  139770. normal?: Vector3;
  139771. size?: Vector3;
  139772. angle?: number;
  139773. }): Mesh;
  139774. }
  139775. }
  139776. declare module BABYLON {
  139777. /**
  139778. * A simplifier interface for future simplification implementations
  139779. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139780. */
  139781. export interface ISimplifier {
  139782. /**
  139783. * Simplification of a given mesh according to the given settings.
  139784. * Since this requires computation, it is assumed that the function runs async.
  139785. * @param settings The settings of the simplification, including quality and distance
  139786. * @param successCallback A callback that will be called after the mesh was simplified.
  139787. * @param errorCallback in case of an error, this callback will be called. optional.
  139788. */
  139789. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  139790. }
  139791. /**
  139792. * Expected simplification settings.
  139793. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  139794. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139795. */
  139796. export interface ISimplificationSettings {
  139797. /**
  139798. * Gets or sets the expected quality
  139799. */
  139800. quality: number;
  139801. /**
  139802. * Gets or sets the distance when this optimized version should be used
  139803. */
  139804. distance: number;
  139805. /**
  139806. * Gets an already optimized mesh
  139807. */
  139808. optimizeMesh?: boolean;
  139809. }
  139810. /**
  139811. * Class used to specify simplification options
  139812. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139813. */
  139814. export class SimplificationSettings implements ISimplificationSettings {
  139815. /** expected quality */
  139816. quality: number;
  139817. /** distance when this optimized version should be used */
  139818. distance: number;
  139819. /** already optimized mesh */
  139820. optimizeMesh?: boolean | undefined;
  139821. /**
  139822. * Creates a SimplificationSettings
  139823. * @param quality expected quality
  139824. * @param distance distance when this optimized version should be used
  139825. * @param optimizeMesh already optimized mesh
  139826. */
  139827. constructor(
  139828. /** expected quality */
  139829. quality: number,
  139830. /** distance when this optimized version should be used */
  139831. distance: number,
  139832. /** already optimized mesh */
  139833. optimizeMesh?: boolean | undefined);
  139834. }
  139835. /**
  139836. * Interface used to define a simplification task
  139837. */
  139838. export interface ISimplificationTask {
  139839. /**
  139840. * Array of settings
  139841. */
  139842. settings: Array<ISimplificationSettings>;
  139843. /**
  139844. * Simplification type
  139845. */
  139846. simplificationType: SimplificationType;
  139847. /**
  139848. * Mesh to simplify
  139849. */
  139850. mesh: Mesh;
  139851. /**
  139852. * Callback called on success
  139853. */
  139854. successCallback?: () => void;
  139855. /**
  139856. * Defines if parallel processing can be used
  139857. */
  139858. parallelProcessing: boolean;
  139859. }
  139860. /**
  139861. * Queue used to order the simplification tasks
  139862. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139863. */
  139864. export class SimplificationQueue {
  139865. private _simplificationArray;
  139866. /**
  139867. * Gets a boolean indicating that the process is still running
  139868. */
  139869. running: boolean;
  139870. /**
  139871. * Creates a new queue
  139872. */
  139873. constructor();
  139874. /**
  139875. * Adds a new simplification task
  139876. * @param task defines a task to add
  139877. */
  139878. addTask(task: ISimplificationTask): void;
  139879. /**
  139880. * Execute next task
  139881. */
  139882. executeNext(): void;
  139883. /**
  139884. * Execute a simplification task
  139885. * @param task defines the task to run
  139886. */
  139887. runSimplification(task: ISimplificationTask): void;
  139888. private getSimplifier;
  139889. }
  139890. /**
  139891. * The implemented types of simplification
  139892. * At the moment only Quadratic Error Decimation is implemented
  139893. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139894. */
  139895. export enum SimplificationType {
  139896. /** Quadratic error decimation */
  139897. QUADRATIC = 0
  139898. }
  139899. /**
  139900. * An implementation of the Quadratic Error simplification algorithm.
  139901. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  139902. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  139903. * @author RaananW
  139904. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139905. */
  139906. export class QuadraticErrorSimplification implements ISimplifier {
  139907. private _mesh;
  139908. private triangles;
  139909. private vertices;
  139910. private references;
  139911. private _reconstructedMesh;
  139912. /** Gets or sets the number pf sync interations */
  139913. syncIterations: number;
  139914. /** Gets or sets the aggressiveness of the simplifier */
  139915. aggressiveness: number;
  139916. /** Gets or sets the number of allowed iterations for decimation */
  139917. decimationIterations: number;
  139918. /** Gets or sets the espilon to use for bounding box computation */
  139919. boundingBoxEpsilon: number;
  139920. /**
  139921. * Creates a new QuadraticErrorSimplification
  139922. * @param _mesh defines the target mesh
  139923. */
  139924. constructor(_mesh: Mesh);
  139925. /**
  139926. * Simplification of a given mesh according to the given settings.
  139927. * Since this requires computation, it is assumed that the function runs async.
  139928. * @param settings The settings of the simplification, including quality and distance
  139929. * @param successCallback A callback that will be called after the mesh was simplified.
  139930. */
  139931. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  139932. private runDecimation;
  139933. private initWithMesh;
  139934. private init;
  139935. private reconstructMesh;
  139936. private initDecimatedMesh;
  139937. private isFlipped;
  139938. private updateTriangles;
  139939. private identifyBorder;
  139940. private updateMesh;
  139941. private vertexError;
  139942. private calculateError;
  139943. }
  139944. }
  139945. declare module BABYLON {
  139946. interface Scene {
  139947. /** @hidden (Backing field) */
  139948. _simplificationQueue: SimplificationQueue;
  139949. /**
  139950. * Gets or sets the simplification queue attached to the scene
  139951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139952. */
  139953. simplificationQueue: SimplificationQueue;
  139954. }
  139955. interface Mesh {
  139956. /**
  139957. * Simplify the mesh according to the given array of settings.
  139958. * Function will return immediately and will simplify async
  139959. * @param settings a collection of simplification settings
  139960. * @param parallelProcessing should all levels calculate parallel or one after the other
  139961. * @param simplificationType the type of simplification to run
  139962. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  139963. * @returns the current mesh
  139964. */
  139965. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  139966. }
  139967. /**
  139968. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  139969. * created in a scene
  139970. */
  139971. export class SimplicationQueueSceneComponent implements ISceneComponent {
  139972. /**
  139973. * The component name helpfull to identify the component in the list of scene components.
  139974. */
  139975. readonly name: string;
  139976. /**
  139977. * The scene the component belongs to.
  139978. */
  139979. scene: Scene;
  139980. /**
  139981. * Creates a new instance of the component for the given scene
  139982. * @param scene Defines the scene to register the component in
  139983. */
  139984. constructor(scene: Scene);
  139985. /**
  139986. * Registers the component in a given scene
  139987. */
  139988. register(): void;
  139989. /**
  139990. * Rebuilds the elements related to this component in case of
  139991. * context lost for instance.
  139992. */
  139993. rebuild(): void;
  139994. /**
  139995. * Disposes the component and the associated ressources
  139996. */
  139997. dispose(): void;
  139998. private _beforeCameraUpdate;
  139999. }
  140000. }
  140001. declare module BABYLON {
  140002. /**
  140003. * Navigation plugin interface to add navigation constrained by a navigation mesh
  140004. */
  140005. export interface INavigationEnginePlugin {
  140006. /**
  140007. * plugin name
  140008. */
  140009. name: string;
  140010. /**
  140011. * Creates a navigation mesh
  140012. * @param meshes array of all the geometry used to compute the navigatio mesh
  140013. * @param parameters bunch of parameters used to filter geometry
  140014. */
  140015. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  140016. /**
  140017. * Create a navigation mesh debug mesh
  140018. * @param scene is where the mesh will be added
  140019. * @returns debug display mesh
  140020. */
  140021. createDebugNavMesh(scene: Scene): Mesh;
  140022. /**
  140023. * Get a navigation mesh constrained position, closest to the parameter position
  140024. * @param position world position
  140025. * @returns the closest point to position constrained by the navigation mesh
  140026. */
  140027. getClosestPoint(position: Vector3): Vector3;
  140028. /**
  140029. * Get a navigation mesh constrained position, closest to the parameter position
  140030. * @param position world position
  140031. * @param result output the closest point to position constrained by the navigation mesh
  140032. */
  140033. getClosestPointToRef(position: Vector3, result: Vector3): void;
  140034. /**
  140035. * Get a navigation mesh constrained position, within a particular radius
  140036. * @param position world position
  140037. * @param maxRadius the maximum distance to the constrained world position
  140038. * @returns the closest point to position constrained by the navigation mesh
  140039. */
  140040. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  140041. /**
  140042. * Get a navigation mesh constrained position, within a particular radius
  140043. * @param position world position
  140044. * @param maxRadius the maximum distance to the constrained world position
  140045. * @param result output the closest point to position constrained by the navigation mesh
  140046. */
  140047. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  140048. /**
  140049. * Compute the final position from a segment made of destination-position
  140050. * @param position world position
  140051. * @param destination world position
  140052. * @returns the resulting point along the navmesh
  140053. */
  140054. moveAlong(position: Vector3, destination: Vector3): Vector3;
  140055. /**
  140056. * Compute the final position from a segment made of destination-position
  140057. * @param position world position
  140058. * @param destination world position
  140059. * @param result output the resulting point along the navmesh
  140060. */
  140061. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  140062. /**
  140063. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  140064. * @param start world position
  140065. * @param end world position
  140066. * @returns array containing world position composing the path
  140067. */
  140068. computePath(start: Vector3, end: Vector3): Vector3[];
  140069. /**
  140070. * If this plugin is supported
  140071. * @returns true if plugin is supported
  140072. */
  140073. isSupported(): boolean;
  140074. /**
  140075. * Create a new Crowd so you can add agents
  140076. * @param maxAgents the maximum agent count in the crowd
  140077. * @param maxAgentRadius the maximum radius an agent can have
  140078. * @param scene to attach the crowd to
  140079. * @returns the crowd you can add agents to
  140080. */
  140081. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140082. /**
  140083. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140084. * The queries will try to find a solution within those bounds
  140085. * default is (1,1,1)
  140086. * @param extent x,y,z value that define the extent around the queries point of reference
  140087. */
  140088. setDefaultQueryExtent(extent: Vector3): void;
  140089. /**
  140090. * Get the Bounding box extent specified by setDefaultQueryExtent
  140091. * @returns the box extent values
  140092. */
  140093. getDefaultQueryExtent(): Vector3;
  140094. /**
  140095. * build the navmesh from a previously saved state using getNavmeshData
  140096. * @param data the Uint8Array returned by getNavmeshData
  140097. */
  140098. buildFromNavmeshData(data: Uint8Array): void;
  140099. /**
  140100. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140101. * @returns data the Uint8Array that can be saved and reused
  140102. */
  140103. getNavmeshData(): Uint8Array;
  140104. /**
  140105. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140106. * @param result output the box extent values
  140107. */
  140108. getDefaultQueryExtentToRef(result: Vector3): void;
  140109. /**
  140110. * Release all resources
  140111. */
  140112. dispose(): void;
  140113. }
  140114. /**
  140115. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  140116. */
  140117. export interface ICrowd {
  140118. /**
  140119. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140120. * You can attach anything to that node. The node position is updated in the scene update tick.
  140121. * @param pos world position that will be constrained by the navigation mesh
  140122. * @param parameters agent parameters
  140123. * @param transform hooked to the agent that will be update by the scene
  140124. * @returns agent index
  140125. */
  140126. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140127. /**
  140128. * Returns the agent position in world space
  140129. * @param index agent index returned by addAgent
  140130. * @returns world space position
  140131. */
  140132. getAgentPosition(index: number): Vector3;
  140133. /**
  140134. * Gets the agent position result in world space
  140135. * @param index agent index returned by addAgent
  140136. * @param result output world space position
  140137. */
  140138. getAgentPositionToRef(index: number, result: Vector3): void;
  140139. /**
  140140. * Gets the agent velocity in world space
  140141. * @param index agent index returned by addAgent
  140142. * @returns world space velocity
  140143. */
  140144. getAgentVelocity(index: number): Vector3;
  140145. /**
  140146. * Gets the agent velocity result in world space
  140147. * @param index agent index returned by addAgent
  140148. * @param result output world space velocity
  140149. */
  140150. getAgentVelocityToRef(index: number, result: Vector3): void;
  140151. /**
  140152. * remove a particular agent previously created
  140153. * @param index agent index returned by addAgent
  140154. */
  140155. removeAgent(index: number): void;
  140156. /**
  140157. * get the list of all agents attached to this crowd
  140158. * @returns list of agent indices
  140159. */
  140160. getAgents(): number[];
  140161. /**
  140162. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140163. * @param deltaTime in seconds
  140164. */
  140165. update(deltaTime: number): void;
  140166. /**
  140167. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140168. * @param index agent index returned by addAgent
  140169. * @param destination targeted world position
  140170. */
  140171. agentGoto(index: number, destination: Vector3): void;
  140172. /**
  140173. * Teleport the agent to a new position
  140174. * @param index agent index returned by addAgent
  140175. * @param destination targeted world position
  140176. */
  140177. agentTeleport(index: number, destination: Vector3): void;
  140178. /**
  140179. * Update agent parameters
  140180. * @param index agent index returned by addAgent
  140181. * @param parameters agent parameters
  140182. */
  140183. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140184. /**
  140185. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140186. * The queries will try to find a solution within those bounds
  140187. * default is (1,1,1)
  140188. * @param extent x,y,z value that define the extent around the queries point of reference
  140189. */
  140190. setDefaultQueryExtent(extent: Vector3): void;
  140191. /**
  140192. * Get the Bounding box extent specified by setDefaultQueryExtent
  140193. * @returns the box extent values
  140194. */
  140195. getDefaultQueryExtent(): Vector3;
  140196. /**
  140197. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140198. * @param result output the box extent values
  140199. */
  140200. getDefaultQueryExtentToRef(result: Vector3): void;
  140201. /**
  140202. * Release all resources
  140203. */
  140204. dispose(): void;
  140205. }
  140206. /**
  140207. * Configures an agent
  140208. */
  140209. export interface IAgentParameters {
  140210. /**
  140211. * Agent radius. [Limit: >= 0]
  140212. */
  140213. radius: number;
  140214. /**
  140215. * Agent height. [Limit: > 0]
  140216. */
  140217. height: number;
  140218. /**
  140219. * Maximum allowed acceleration. [Limit: >= 0]
  140220. */
  140221. maxAcceleration: number;
  140222. /**
  140223. * Maximum allowed speed. [Limit: >= 0]
  140224. */
  140225. maxSpeed: number;
  140226. /**
  140227. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  140228. */
  140229. collisionQueryRange: number;
  140230. /**
  140231. * The path visibility optimization range. [Limit: > 0]
  140232. */
  140233. pathOptimizationRange: number;
  140234. /**
  140235. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  140236. */
  140237. separationWeight: number;
  140238. }
  140239. /**
  140240. * Configures the navigation mesh creation
  140241. */
  140242. export interface INavMeshParameters {
  140243. /**
  140244. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  140245. */
  140246. cs: number;
  140247. /**
  140248. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  140249. */
  140250. ch: number;
  140251. /**
  140252. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  140253. */
  140254. walkableSlopeAngle: number;
  140255. /**
  140256. * Minimum floor to 'ceiling' height that will still allow the floor area to
  140257. * be considered walkable. [Limit: >= 3] [Units: vx]
  140258. */
  140259. walkableHeight: number;
  140260. /**
  140261. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  140262. */
  140263. walkableClimb: number;
  140264. /**
  140265. * The distance to erode/shrink the walkable area of the heightfield away from
  140266. * obstructions. [Limit: >=0] [Units: vx]
  140267. */
  140268. walkableRadius: number;
  140269. /**
  140270. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  140271. */
  140272. maxEdgeLen: number;
  140273. /**
  140274. * The maximum distance a simplfied contour's border edges should deviate
  140275. * the original raw contour. [Limit: >=0] [Units: vx]
  140276. */
  140277. maxSimplificationError: number;
  140278. /**
  140279. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  140280. */
  140281. minRegionArea: number;
  140282. /**
  140283. * Any regions with a span count smaller than this value will, if possible,
  140284. * be merged with larger regions. [Limit: >=0] [Units: vx]
  140285. */
  140286. mergeRegionArea: number;
  140287. /**
  140288. * The maximum number of vertices allowed for polygons generated during the
  140289. * contour to polygon conversion process. [Limit: >= 3]
  140290. */
  140291. maxVertsPerPoly: number;
  140292. /**
  140293. * Sets the sampling distance to use when generating the detail mesh.
  140294. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  140295. */
  140296. detailSampleDist: number;
  140297. /**
  140298. * The maximum distance the detail mesh surface should deviate from heightfield
  140299. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  140300. */
  140301. detailSampleMaxError: number;
  140302. }
  140303. }
  140304. declare module BABYLON {
  140305. /**
  140306. * RecastJS navigation plugin
  140307. */
  140308. export class RecastJSPlugin implements INavigationEnginePlugin {
  140309. /**
  140310. * Reference to the Recast library
  140311. */
  140312. bjsRECAST: any;
  140313. /**
  140314. * plugin name
  140315. */
  140316. name: string;
  140317. /**
  140318. * the first navmesh created. We might extend this to support multiple navmeshes
  140319. */
  140320. navMesh: any;
  140321. /**
  140322. * Initializes the recastJS plugin
  140323. * @param recastInjection can be used to inject your own recast reference
  140324. */
  140325. constructor(recastInjection?: any);
  140326. /**
  140327. * Creates a navigation mesh
  140328. * @param meshes array of all the geometry used to compute the navigatio mesh
  140329. * @param parameters bunch of parameters used to filter geometry
  140330. */
  140331. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  140332. /**
  140333. * Create a navigation mesh debug mesh
  140334. * @param scene is where the mesh will be added
  140335. * @returns debug display mesh
  140336. */
  140337. createDebugNavMesh(scene: Scene): Mesh;
  140338. /**
  140339. * Get a navigation mesh constrained position, closest to the parameter position
  140340. * @param position world position
  140341. * @returns the closest point to position constrained by the navigation mesh
  140342. */
  140343. getClosestPoint(position: Vector3): Vector3;
  140344. /**
  140345. * Get a navigation mesh constrained position, closest to the parameter position
  140346. * @param position world position
  140347. * @param result output the closest point to position constrained by the navigation mesh
  140348. */
  140349. getClosestPointToRef(position: Vector3, result: Vector3): void;
  140350. /**
  140351. * Get a navigation mesh constrained position, within a particular radius
  140352. * @param position world position
  140353. * @param maxRadius the maximum distance to the constrained world position
  140354. * @returns the closest point to position constrained by the navigation mesh
  140355. */
  140356. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  140357. /**
  140358. * Get a navigation mesh constrained position, within a particular radius
  140359. * @param position world position
  140360. * @param maxRadius the maximum distance to the constrained world position
  140361. * @param result output the closest point to position constrained by the navigation mesh
  140362. */
  140363. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  140364. /**
  140365. * Compute the final position from a segment made of destination-position
  140366. * @param position world position
  140367. * @param destination world position
  140368. * @returns the resulting point along the navmesh
  140369. */
  140370. moveAlong(position: Vector3, destination: Vector3): Vector3;
  140371. /**
  140372. * Compute the final position from a segment made of destination-position
  140373. * @param position world position
  140374. * @param destination world position
  140375. * @param result output the resulting point along the navmesh
  140376. */
  140377. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  140378. /**
  140379. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  140380. * @param start world position
  140381. * @param end world position
  140382. * @returns array containing world position composing the path
  140383. */
  140384. computePath(start: Vector3, end: Vector3): Vector3[];
  140385. /**
  140386. * Create a new Crowd so you can add agents
  140387. * @param maxAgents the maximum agent count in the crowd
  140388. * @param maxAgentRadius the maximum radius an agent can have
  140389. * @param scene to attach the crowd to
  140390. * @returns the crowd you can add agents to
  140391. */
  140392. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140393. /**
  140394. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140395. * The queries will try to find a solution within those bounds
  140396. * default is (1,1,1)
  140397. * @param extent x,y,z value that define the extent around the queries point of reference
  140398. */
  140399. setDefaultQueryExtent(extent: Vector3): void;
  140400. /**
  140401. * Get the Bounding box extent specified by setDefaultQueryExtent
  140402. * @returns the box extent values
  140403. */
  140404. getDefaultQueryExtent(): Vector3;
  140405. /**
  140406. * build the navmesh from a previously saved state using getNavmeshData
  140407. * @param data the Uint8Array returned by getNavmeshData
  140408. */
  140409. buildFromNavmeshData(data: Uint8Array): void;
  140410. /**
  140411. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140412. * @returns data the Uint8Array that can be saved and reused
  140413. */
  140414. getNavmeshData(): Uint8Array;
  140415. /**
  140416. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140417. * @param result output the box extent values
  140418. */
  140419. getDefaultQueryExtentToRef(result: Vector3): void;
  140420. /**
  140421. * Disposes
  140422. */
  140423. dispose(): void;
  140424. /**
  140425. * If this plugin is supported
  140426. * @returns true if plugin is supported
  140427. */
  140428. isSupported(): boolean;
  140429. }
  140430. /**
  140431. * Recast detour crowd implementation
  140432. */
  140433. export class RecastJSCrowd implements ICrowd {
  140434. /**
  140435. * Recast/detour plugin
  140436. */
  140437. bjsRECASTPlugin: RecastJSPlugin;
  140438. /**
  140439. * Link to the detour crowd
  140440. */
  140441. recastCrowd: any;
  140442. /**
  140443. * One transform per agent
  140444. */
  140445. transforms: TransformNode[];
  140446. /**
  140447. * All agents created
  140448. */
  140449. agents: number[];
  140450. /**
  140451. * Link to the scene is kept to unregister the crowd from the scene
  140452. */
  140453. private _scene;
  140454. /**
  140455. * Observer for crowd updates
  140456. */
  140457. private _onBeforeAnimationsObserver;
  140458. /**
  140459. * Constructor
  140460. * @param plugin recastJS plugin
  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. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  140467. /**
  140468. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140469. * You can attach anything to that node. The node position is updated in the scene update tick.
  140470. * @param pos world position that will be constrained by the navigation mesh
  140471. * @param parameters agent parameters
  140472. * @param transform hooked to the agent that will be update by the scene
  140473. * @returns agent index
  140474. */
  140475. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140476. /**
  140477. * Returns the agent position in world space
  140478. * @param index agent index returned by addAgent
  140479. * @returns world space position
  140480. */
  140481. getAgentPosition(index: number): Vector3;
  140482. /**
  140483. * Returns the agent position result in world space
  140484. * @param index agent index returned by addAgent
  140485. * @param result output world space position
  140486. */
  140487. getAgentPositionToRef(index: number, result: Vector3): void;
  140488. /**
  140489. * Returns the agent velocity in world space
  140490. * @param index agent index returned by addAgent
  140491. * @returns world space velocity
  140492. */
  140493. getAgentVelocity(index: number): Vector3;
  140494. /**
  140495. * Returns the agent velocity result in world space
  140496. * @param index agent index returned by addAgent
  140497. * @param result output world space velocity
  140498. */
  140499. getAgentVelocityToRef(index: number, result: Vector3): void;
  140500. /**
  140501. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140502. * @param index agent index returned by addAgent
  140503. * @param destination targeted world position
  140504. */
  140505. agentGoto(index: number, destination: Vector3): void;
  140506. /**
  140507. * Teleport the agent to a new position
  140508. * @param index agent index returned by addAgent
  140509. * @param destination targeted world position
  140510. */
  140511. agentTeleport(index: number, destination: Vector3): void;
  140512. /**
  140513. * Update agent parameters
  140514. * @param index agent index returned by addAgent
  140515. * @param parameters agent parameters
  140516. */
  140517. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140518. /**
  140519. * remove a particular agent previously created
  140520. * @param index agent index returned by addAgent
  140521. */
  140522. removeAgent(index: number): void;
  140523. /**
  140524. * get the list of all agents attached to this crowd
  140525. * @returns list of agent indices
  140526. */
  140527. getAgents(): number[];
  140528. /**
  140529. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140530. * @param deltaTime in seconds
  140531. */
  140532. update(deltaTime: number): void;
  140533. /**
  140534. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140535. * The queries will try to find a solution within those bounds
  140536. * default is (1,1,1)
  140537. * @param extent x,y,z value that define the extent around the queries point of reference
  140538. */
  140539. setDefaultQueryExtent(extent: Vector3): void;
  140540. /**
  140541. * Get the Bounding box extent specified by setDefaultQueryExtent
  140542. * @returns the box extent values
  140543. */
  140544. getDefaultQueryExtent(): Vector3;
  140545. /**
  140546. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140547. * @param result output the box extent values
  140548. */
  140549. getDefaultQueryExtentToRef(result: Vector3): void;
  140550. /**
  140551. * Release all resources
  140552. */
  140553. dispose(): void;
  140554. }
  140555. }
  140556. declare module BABYLON {
  140557. /**
  140558. * Class used to enable access to IndexedDB
  140559. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  140560. */
  140561. export class Database implements IOfflineProvider {
  140562. private _callbackManifestChecked;
  140563. private _currentSceneUrl;
  140564. private _db;
  140565. private _enableSceneOffline;
  140566. private _enableTexturesOffline;
  140567. private _manifestVersionFound;
  140568. private _mustUpdateRessources;
  140569. private _hasReachedQuota;
  140570. private _isSupported;
  140571. private _idbFactory;
  140572. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  140573. private static IsUASupportingBlobStorage;
  140574. /**
  140575. * Gets a boolean indicating if Database storate is enabled (off by default)
  140576. */
  140577. static IDBStorageEnabled: boolean;
  140578. /**
  140579. * Gets a boolean indicating if scene must be saved in the database
  140580. */
  140581. get enableSceneOffline(): boolean;
  140582. /**
  140583. * Gets a boolean indicating if textures must be saved in the database
  140584. */
  140585. get enableTexturesOffline(): boolean;
  140586. /**
  140587. * Creates a new Database
  140588. * @param urlToScene defines the url to load the scene
  140589. * @param callbackManifestChecked defines the callback to use when manifest is checked
  140590. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  140591. */
  140592. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  140593. private static _ParseURL;
  140594. private static _ReturnFullUrlLocation;
  140595. private _checkManifestFile;
  140596. /**
  140597. * Open the database and make it available
  140598. * @param successCallback defines the callback to call on success
  140599. * @param errorCallback defines the callback to call on error
  140600. */
  140601. open(successCallback: () => void, errorCallback: () => void): void;
  140602. /**
  140603. * Loads an image from the database
  140604. * @param url defines the url to load from
  140605. * @param image defines the target DOM image
  140606. */
  140607. loadImage(url: string, image: HTMLImageElement): void;
  140608. private _loadImageFromDBAsync;
  140609. private _saveImageIntoDBAsync;
  140610. private _checkVersionFromDB;
  140611. private _loadVersionFromDBAsync;
  140612. private _saveVersionIntoDBAsync;
  140613. /**
  140614. * Loads a file from database
  140615. * @param url defines the URL to load from
  140616. * @param sceneLoaded defines a callback to call on success
  140617. * @param progressCallBack defines a callback to call when progress changed
  140618. * @param errorCallback defines a callback to call on error
  140619. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  140620. */
  140621. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  140622. private _loadFileAsync;
  140623. private _saveFileAsync;
  140624. /**
  140625. * Validates if xhr data is correct
  140626. * @param xhr defines the request to validate
  140627. * @param dataType defines the expected data type
  140628. * @returns true if data is correct
  140629. */
  140630. private static _ValidateXHRData;
  140631. }
  140632. }
  140633. declare module BABYLON {
  140634. /** @hidden */
  140635. export var gpuUpdateParticlesPixelShader: {
  140636. name: string;
  140637. shader: string;
  140638. };
  140639. }
  140640. declare module BABYLON {
  140641. /** @hidden */
  140642. export var gpuUpdateParticlesVertexShader: {
  140643. name: string;
  140644. shader: string;
  140645. };
  140646. }
  140647. declare module BABYLON {
  140648. /** @hidden */
  140649. export var clipPlaneFragmentDeclaration2: {
  140650. name: string;
  140651. shader: string;
  140652. };
  140653. }
  140654. declare module BABYLON {
  140655. /** @hidden */
  140656. export var gpuRenderParticlesPixelShader: {
  140657. name: string;
  140658. shader: string;
  140659. };
  140660. }
  140661. declare module BABYLON {
  140662. /** @hidden */
  140663. export var clipPlaneVertexDeclaration2: {
  140664. name: string;
  140665. shader: string;
  140666. };
  140667. }
  140668. declare module BABYLON {
  140669. /** @hidden */
  140670. export var gpuRenderParticlesVertexShader: {
  140671. name: string;
  140672. shader: string;
  140673. };
  140674. }
  140675. declare module BABYLON {
  140676. /**
  140677. * This represents a GPU particle system in Babylon
  140678. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  140679. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  140680. */
  140681. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  140682. /**
  140683. * The layer mask we are rendering the particles through.
  140684. */
  140685. layerMask: number;
  140686. private _capacity;
  140687. private _activeCount;
  140688. private _currentActiveCount;
  140689. private _accumulatedCount;
  140690. private _renderEffect;
  140691. private _updateEffect;
  140692. private _buffer0;
  140693. private _buffer1;
  140694. private _spriteBuffer;
  140695. private _updateVAO;
  140696. private _renderVAO;
  140697. private _targetIndex;
  140698. private _sourceBuffer;
  140699. private _targetBuffer;
  140700. private _engine;
  140701. private _currentRenderId;
  140702. private _started;
  140703. private _stopped;
  140704. private _timeDelta;
  140705. private _randomTexture;
  140706. private _randomTexture2;
  140707. private _attributesStrideSize;
  140708. private _updateEffectOptions;
  140709. private _randomTextureSize;
  140710. private _actualFrame;
  140711. private readonly _rawTextureWidth;
  140712. /**
  140713. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  140714. */
  140715. static get IsSupported(): boolean;
  140716. /**
  140717. * An event triggered when the system is disposed.
  140718. */
  140719. onDisposeObservable: Observable<GPUParticleSystem>;
  140720. /**
  140721. * Gets the maximum number of particles active at the same time.
  140722. * @returns The max number of active particles.
  140723. */
  140724. getCapacity(): number;
  140725. /**
  140726. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  140727. * to override the particles.
  140728. */
  140729. forceDepthWrite: boolean;
  140730. /**
  140731. * Gets or set the number of active particles
  140732. */
  140733. get activeParticleCount(): number;
  140734. set activeParticleCount(value: number);
  140735. private _preWarmDone;
  140736. /**
  140737. * Specifies if the particles are updated in emitter local space or world space.
  140738. */
  140739. isLocal: boolean;
  140740. /**
  140741. * Is this system ready to be used/rendered
  140742. * @return true if the system is ready
  140743. */
  140744. isReady(): boolean;
  140745. /**
  140746. * Gets if the system has been started. (Note: this will still be true after stop is called)
  140747. * @returns True if it has been started, otherwise false.
  140748. */
  140749. isStarted(): boolean;
  140750. /**
  140751. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  140752. * @returns True if it has been stopped, otherwise false.
  140753. */
  140754. isStopped(): boolean;
  140755. /**
  140756. * Gets a boolean indicating that the system is stopping
  140757. * @returns true if the system is currently stopping
  140758. */
  140759. isStopping(): boolean;
  140760. /**
  140761. * Gets the number of particles active at the same time.
  140762. * @returns The number of active particles.
  140763. */
  140764. getActiveCount(): number;
  140765. /**
  140766. * Starts the particle system and begins to emit
  140767. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  140768. */
  140769. start(delay?: number): void;
  140770. /**
  140771. * Stops the particle system.
  140772. */
  140773. stop(): void;
  140774. /**
  140775. * Remove all active particles
  140776. */
  140777. reset(): void;
  140778. /**
  140779. * Returns the string "GPUParticleSystem"
  140780. * @returns a string containing the class name
  140781. */
  140782. getClassName(): string;
  140783. private _colorGradientsTexture;
  140784. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  140785. /**
  140786. * Adds a new color gradient
  140787. * @param gradient defines the gradient to use (between 0 and 1)
  140788. * @param color1 defines the color to affect to the specified gradient
  140789. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  140790. * @returns the current particle system
  140791. */
  140792. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  140793. private _refreshColorGradient;
  140794. /** Force the system to rebuild all gradients that need to be resync */
  140795. forceRefreshGradients(): void;
  140796. /**
  140797. * Remove a specific color gradient
  140798. * @param gradient defines the gradient to remove
  140799. * @returns the current particle system
  140800. */
  140801. removeColorGradient(gradient: number): GPUParticleSystem;
  140802. private _angularSpeedGradientsTexture;
  140803. private _sizeGradientsTexture;
  140804. private _velocityGradientsTexture;
  140805. private _limitVelocityGradientsTexture;
  140806. private _dragGradientsTexture;
  140807. private _addFactorGradient;
  140808. /**
  140809. * Adds a new size gradient
  140810. * @param gradient defines the gradient to use (between 0 and 1)
  140811. * @param factor defines the size factor to affect to the specified gradient
  140812. * @returns the current particle system
  140813. */
  140814. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  140815. /**
  140816. * Remove a specific size gradient
  140817. * @param gradient defines the gradient to remove
  140818. * @returns the current particle system
  140819. */
  140820. removeSizeGradient(gradient: number): GPUParticleSystem;
  140821. private _refreshFactorGradient;
  140822. /**
  140823. * Adds a new angular speed gradient
  140824. * @param gradient defines the gradient to use (between 0 and 1)
  140825. * @param factor defines the angular speed to affect to the specified gradient
  140826. * @returns the current particle system
  140827. */
  140828. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  140829. /**
  140830. * Remove a specific angular speed gradient
  140831. * @param gradient defines the gradient to remove
  140832. * @returns the current particle system
  140833. */
  140834. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  140835. /**
  140836. * Adds a new velocity gradient
  140837. * @param gradient defines the gradient to use (between 0 and 1)
  140838. * @param factor defines the velocity to affect to the specified gradient
  140839. * @returns the current particle system
  140840. */
  140841. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140842. /**
  140843. * Remove a specific velocity gradient
  140844. * @param gradient defines the gradient to remove
  140845. * @returns the current particle system
  140846. */
  140847. removeVelocityGradient(gradient: number): GPUParticleSystem;
  140848. /**
  140849. * Adds a new limit velocity gradient
  140850. * @param gradient defines the gradient to use (between 0 and 1)
  140851. * @param factor defines the limit velocity value to affect to the specified gradient
  140852. * @returns the current particle system
  140853. */
  140854. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140855. /**
  140856. * Remove a specific limit velocity gradient
  140857. * @param gradient defines the gradient to remove
  140858. * @returns the current particle system
  140859. */
  140860. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  140861. /**
  140862. * Adds a new drag gradient
  140863. * @param gradient defines the gradient to use (between 0 and 1)
  140864. * @param factor defines the drag value to affect to the specified gradient
  140865. * @returns the current particle system
  140866. */
  140867. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  140868. /**
  140869. * Remove a specific drag gradient
  140870. * @param gradient defines the gradient to remove
  140871. * @returns the current particle system
  140872. */
  140873. removeDragGradient(gradient: number): GPUParticleSystem;
  140874. /**
  140875. * Not supported by GPUParticleSystem
  140876. * @param gradient defines the gradient to use (between 0 and 1)
  140877. * @param factor defines the emit rate value to affect to the specified gradient
  140878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140879. * @returns the current particle system
  140880. */
  140881. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140882. /**
  140883. * Not supported by GPUParticleSystem
  140884. * @param gradient defines the gradient to remove
  140885. * @returns the current particle system
  140886. */
  140887. removeEmitRateGradient(gradient: number): IParticleSystem;
  140888. /**
  140889. * Not supported by GPUParticleSystem
  140890. * @param gradient defines the gradient to use (between 0 and 1)
  140891. * @param factor defines the start size value to affect to the specified gradient
  140892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140893. * @returns the current particle system
  140894. */
  140895. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140896. /**
  140897. * Not supported by GPUParticleSystem
  140898. * @param gradient defines the gradient to remove
  140899. * @returns the current particle system
  140900. */
  140901. removeStartSizeGradient(gradient: number): IParticleSystem;
  140902. /**
  140903. * Not supported by GPUParticleSystem
  140904. * @param gradient defines the gradient to use (between 0 and 1)
  140905. * @param min defines the color remap minimal range
  140906. * @param max defines the color remap maximal range
  140907. * @returns the current particle system
  140908. */
  140909. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140910. /**
  140911. * Not supported by GPUParticleSystem
  140912. * @param gradient defines the gradient to remove
  140913. * @returns the current particle system
  140914. */
  140915. removeColorRemapGradient(): IParticleSystem;
  140916. /**
  140917. * Not supported by GPUParticleSystem
  140918. * @param gradient defines the gradient to use (between 0 and 1)
  140919. * @param min defines the alpha remap minimal range
  140920. * @param max defines the alpha remap maximal range
  140921. * @returns the current particle system
  140922. */
  140923. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140924. /**
  140925. * Not supported by GPUParticleSystem
  140926. * @param gradient defines the gradient to remove
  140927. * @returns the current particle system
  140928. */
  140929. removeAlphaRemapGradient(): IParticleSystem;
  140930. /**
  140931. * Not supported by GPUParticleSystem
  140932. * @param gradient defines the gradient to use (between 0 and 1)
  140933. * @param color defines the color to affect to the specified gradient
  140934. * @returns the current particle system
  140935. */
  140936. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  140937. /**
  140938. * Not supported by GPUParticleSystem
  140939. * @param gradient defines the gradient to remove
  140940. * @returns the current particle system
  140941. */
  140942. removeRampGradient(): IParticleSystem;
  140943. /**
  140944. * Not supported by GPUParticleSystem
  140945. * @returns the list of ramp gradients
  140946. */
  140947. getRampGradients(): Nullable<Array<Color3Gradient>>;
  140948. /**
  140949. * Not supported by GPUParticleSystem
  140950. * Gets or sets a boolean indicating that ramp gradients must be used
  140951. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  140952. */
  140953. get useRampGradients(): boolean;
  140954. set useRampGradients(value: boolean);
  140955. /**
  140956. * Not supported by GPUParticleSystem
  140957. * @param gradient defines the gradient to use (between 0 and 1)
  140958. * @param factor defines the life time factor to affect to the specified gradient
  140959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140960. * @returns the current particle system
  140961. */
  140962. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140963. /**
  140964. * Not supported by GPUParticleSystem
  140965. * @param gradient defines the gradient to remove
  140966. * @returns the current particle system
  140967. */
  140968. removeLifeTimeGradient(gradient: number): IParticleSystem;
  140969. /**
  140970. * Instantiates a GPU particle system.
  140971. * 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.
  140972. * @param name The name of the particle system
  140973. * @param options The options used to create the system
  140974. * @param scene The scene the particle system belongs to
  140975. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  140976. */
  140977. constructor(name: string, options: Partial<{
  140978. capacity: number;
  140979. randomTextureSize: number;
  140980. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  140981. protected _reset(): void;
  140982. private _createUpdateVAO;
  140983. private _createRenderVAO;
  140984. private _initialize;
  140985. /** @hidden */
  140986. _recreateUpdateEffect(): void;
  140987. /** @hidden */
  140988. _recreateRenderEffect(): void;
  140989. /**
  140990. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  140991. * @param preWarm defines if we are in the pre-warmimg phase
  140992. */
  140993. animate(preWarm?: boolean): void;
  140994. private _createFactorGradientTexture;
  140995. private _createSizeGradientTexture;
  140996. private _createAngularSpeedGradientTexture;
  140997. private _createVelocityGradientTexture;
  140998. private _createLimitVelocityGradientTexture;
  140999. private _createDragGradientTexture;
  141000. private _createColorGradientTexture;
  141001. /**
  141002. * Renders the particle system in its current state
  141003. * @param preWarm defines if the system should only update the particles but not render them
  141004. * @returns the current number of particles
  141005. */
  141006. render(preWarm?: boolean): number;
  141007. /**
  141008. * Rebuilds the particle system
  141009. */
  141010. rebuild(): void;
  141011. private _releaseBuffers;
  141012. private _releaseVAOs;
  141013. /**
  141014. * Disposes the particle system and free the associated resources
  141015. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  141016. */
  141017. dispose(disposeTexture?: boolean): void;
  141018. /**
  141019. * Clones the particle system.
  141020. * @param name The name of the cloned object
  141021. * @param newEmitter The new emitter to use
  141022. * @returns the cloned particle system
  141023. */
  141024. clone(name: string, newEmitter: any): GPUParticleSystem;
  141025. /**
  141026. * Serializes the particle system to a JSON object
  141027. * @param serializeTexture defines if the texture must be serialized as well
  141028. * @returns the JSON object
  141029. */
  141030. serialize(serializeTexture?: boolean): any;
  141031. /**
  141032. * Parses a JSON object to create a GPU particle system.
  141033. * @param parsedParticleSystem The JSON object to parse
  141034. * @param scene The scene to create the particle system in
  141035. * @param rootUrl The root url to use to load external dependencies like texture
  141036. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  141037. * @returns the parsed GPU particle system
  141038. */
  141039. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  141040. }
  141041. }
  141042. declare module BABYLON {
  141043. /**
  141044. * Represents a set of particle systems working together to create a specific effect
  141045. */
  141046. export class ParticleSystemSet implements IDisposable {
  141047. /**
  141048. * Gets or sets base Assets URL
  141049. */
  141050. static BaseAssetsUrl: string;
  141051. private _emitterCreationOptions;
  141052. private _emitterNode;
  141053. /**
  141054. * Gets the particle system list
  141055. */
  141056. systems: IParticleSystem[];
  141057. /**
  141058. * Gets the emitter node used with this set
  141059. */
  141060. get emitterNode(): Nullable<TransformNode>;
  141061. /**
  141062. * Creates a new emitter mesh as a sphere
  141063. * @param options defines the options used to create the sphere
  141064. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  141065. * @param scene defines the hosting scene
  141066. */
  141067. setEmitterAsSphere(options: {
  141068. diameter: number;
  141069. segments: number;
  141070. color: Color3;
  141071. }, renderingGroupId: number, scene: Scene): void;
  141072. /**
  141073. * Starts all particle systems of the set
  141074. * @param emitter defines an optional mesh to use as emitter for the particle systems
  141075. */
  141076. start(emitter?: AbstractMesh): void;
  141077. /**
  141078. * Release all associated resources
  141079. */
  141080. dispose(): void;
  141081. /**
  141082. * Serialize the set into a JSON compatible object
  141083. * @param serializeTexture defines if the texture must be serialized as well
  141084. * @returns a JSON compatible representation of the set
  141085. */
  141086. serialize(serializeTexture?: boolean): any;
  141087. /**
  141088. * Parse a new ParticleSystemSet from a serialized source
  141089. * @param data defines a JSON compatible representation of the set
  141090. * @param scene defines the hosting scene
  141091. * @param gpu defines if we want GPU particles or CPU particles
  141092. * @returns a new ParticleSystemSet
  141093. */
  141094. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  141095. }
  141096. }
  141097. declare module BABYLON {
  141098. /**
  141099. * This class is made for on one-liner static method to help creating particle system set.
  141100. */
  141101. export class ParticleHelper {
  141102. /**
  141103. * Gets or sets base Assets URL
  141104. */
  141105. static BaseAssetsUrl: string;
  141106. /** Define the Url to load snippets */
  141107. static SnippetUrl: string;
  141108. /**
  141109. * Create a default particle system that you can tweak
  141110. * @param emitter defines the emitter to use
  141111. * @param capacity defines the system capacity (default is 500 particles)
  141112. * @param scene defines the hosting scene
  141113. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  141114. * @returns the new Particle system
  141115. */
  141116. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  141117. /**
  141118. * This is the main static method (one-liner) of this helper to create different particle systems
  141119. * @param type This string represents the type to the particle system to create
  141120. * @param scene The scene where the particle system should live
  141121. * @param gpu If the system will use gpu
  141122. * @returns the ParticleSystemSet created
  141123. */
  141124. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  141125. /**
  141126. * Static function used to export a particle system to a ParticleSystemSet variable.
  141127. * Please note that the emitter shape is not exported
  141128. * @param systems defines the particle systems to export
  141129. * @returns the created particle system set
  141130. */
  141131. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  141132. /**
  141133. * Creates a particle system from a snippet saved in a remote file
  141134. * @param name defines the name of the particle system to create
  141135. * @param url defines the url to load from
  141136. * @param scene defines the hosting scene
  141137. * @param gpu If the system will use gpu
  141138. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  141139. * @returns a promise that will resolve to the new particle system
  141140. */
  141141. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  141142. /**
  141143. * Creates a particle system from a snippet saved by the particle system editor
  141144. * @param snippetId defines the snippet to load
  141145. * @param scene defines the hosting scene
  141146. * @param gpu If the system will use gpu
  141147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  141148. * @returns a promise that will resolve to the new particle system
  141149. */
  141150. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  141151. }
  141152. }
  141153. declare module BABYLON {
  141154. interface Engine {
  141155. /**
  141156. * Create an effect to use with particle systems.
  141157. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  141158. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  141159. * @param uniformsNames defines a list of attribute names
  141160. * @param samplers defines an array of string used to represent textures
  141161. * @param defines defines the string containing the defines to use to compile the shaders
  141162. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  141163. * @param onCompiled defines a function to call when the effect creation is successful
  141164. * @param onError defines a function to call when the effect creation has failed
  141165. * @returns the new Effect
  141166. */
  141167. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  141168. }
  141169. interface Mesh {
  141170. /**
  141171. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  141172. * @returns an array of IParticleSystem
  141173. */
  141174. getEmittedParticleSystems(): IParticleSystem[];
  141175. /**
  141176. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  141177. * @returns an array of IParticleSystem
  141178. */
  141179. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  141180. }
  141181. /**
  141182. * @hidden
  141183. */
  141184. export var _IDoNeedToBeInTheBuild: number;
  141185. }
  141186. declare module BABYLON {
  141187. /** Defines the 4 color options */
  141188. export enum PointColor {
  141189. /** color value */
  141190. Color = 2,
  141191. /** uv value */
  141192. UV = 1,
  141193. /** random value */
  141194. Random = 0,
  141195. /** stated value */
  141196. Stated = 3
  141197. }
  141198. /**
  141199. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  141200. * 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.
  141201. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  141202. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  141203. *
  141204. * Full documentation here : TO BE ENTERED
  141205. */
  141206. export class PointsCloudSystem implements IDisposable {
  141207. /**
  141208. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  141209. * Example : var p = SPS.particles[i];
  141210. */
  141211. particles: CloudPoint[];
  141212. /**
  141213. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  141214. */
  141215. nbParticles: number;
  141216. /**
  141217. * This a counter for your own usage. It's not set by any SPS functions.
  141218. */
  141219. counter: number;
  141220. /**
  141221. * The PCS name. This name is also given to the underlying mesh.
  141222. */
  141223. name: string;
  141224. /**
  141225. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  141226. */
  141227. mesh: Mesh;
  141228. /**
  141229. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  141230. * Please read :
  141231. */
  141232. vars: any;
  141233. /**
  141234. * @hidden
  141235. */
  141236. _size: number;
  141237. private _scene;
  141238. private _promises;
  141239. private _positions;
  141240. private _indices;
  141241. private _normals;
  141242. private _colors;
  141243. private _uvs;
  141244. private _indices32;
  141245. private _positions32;
  141246. private _colors32;
  141247. private _uvs32;
  141248. private _updatable;
  141249. private _isVisibilityBoxLocked;
  141250. private _alwaysVisible;
  141251. private _groups;
  141252. private _groupCounter;
  141253. private _computeParticleColor;
  141254. private _computeParticleTexture;
  141255. private _computeParticleRotation;
  141256. private _computeBoundingBox;
  141257. private _isReady;
  141258. /**
  141259. * Creates a PCS (Points Cloud System) object
  141260. * @param name (String) is the PCS name, this will be the underlying mesh name
  141261. * @param pointSize (number) is the size for each point
  141262. * @param scene (Scene) is the scene in which the PCS is added
  141263. * @param options defines the options of the PCS e.g.
  141264. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  141265. */
  141266. constructor(name: string, pointSize: number, scene: Scene, options?: {
  141267. updatable?: boolean;
  141268. });
  141269. /**
  141270. * Builds the PCS underlying mesh. Returns a standard Mesh.
  141271. * If no points were added to the PCS, the returned mesh is just a single point.
  141272. * @returns a promise for the created mesh
  141273. */
  141274. buildMeshAsync(): Promise<Mesh>;
  141275. /**
  141276. * @hidden
  141277. */
  141278. private _buildMesh;
  141279. private _addParticle;
  141280. private _randomUnitVector;
  141281. private _getColorIndicesForCoord;
  141282. private _setPointsColorOrUV;
  141283. private _colorFromTexture;
  141284. private _calculateDensity;
  141285. /**
  141286. * Adds points to the PCS in random positions within a unit sphere
  141287. * @param nb (positive integer) the number of particles to be created from this model
  141288. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  141289. * @returns the number of groups in the system
  141290. */
  141291. addPoints(nb: number, pointFunction?: any): number;
  141292. /**
  141293. * Adds points to the PCS from the surface of the model shape
  141294. * @param mesh is any Mesh object that will be used as a surface model for the points
  141295. * @param nb (positive integer) the number of particles to be created from this model
  141296. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  141297. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  141298. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  141299. * @returns the number of groups in the system
  141300. */
  141301. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  141302. /**
  141303. * Adds points to the PCS inside the model shape
  141304. * @param mesh is any Mesh object that will be used as a surface model for the points
  141305. * @param nb (positive integer) the number of particles to be created from this model
  141306. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  141307. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  141308. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  141309. * @returns the number of groups in the system
  141310. */
  141311. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  141312. /**
  141313. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  141314. * This method calls `updateParticle()` for each particle of the SPS.
  141315. * For an animated SPS, it is usually called within the render loop.
  141316. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  141317. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  141318. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  141319. * @returns the PCS.
  141320. */
  141321. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  141322. /**
  141323. * Disposes the PCS.
  141324. */
  141325. dispose(): void;
  141326. /**
  141327. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  141328. * doc :
  141329. * @returns the PCS.
  141330. */
  141331. refreshVisibleSize(): PointsCloudSystem;
  141332. /**
  141333. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  141334. * @param size the size (float) of the visibility box
  141335. * note : this doesn't lock the PCS mesh bounding box.
  141336. * doc :
  141337. */
  141338. setVisibilityBox(size: number): void;
  141339. /**
  141340. * Gets whether the PCS is always visible or not
  141341. * doc :
  141342. */
  141343. get isAlwaysVisible(): boolean;
  141344. /**
  141345. * Sets the PCS as always visible or not
  141346. * doc :
  141347. */
  141348. set isAlwaysVisible(val: boolean);
  141349. /**
  141350. * Tells to `setParticles()` to compute the particle rotations or not
  141351. * Default value : false. The PCS is faster when it's set to false
  141352. * Note : particle rotations are only applied to parent particles
  141353. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  141354. */
  141355. set computeParticleRotation(val: boolean);
  141356. /**
  141357. * Tells to `setParticles()` to compute the particle colors or not.
  141358. * Default value : true. The PCS is faster when it's set to false.
  141359. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  141360. */
  141361. set computeParticleColor(val: boolean);
  141362. set computeParticleTexture(val: boolean);
  141363. /**
  141364. * Gets if `setParticles()` computes the particle colors or not.
  141365. * Default value : false. The PCS is faster when it's set to false.
  141366. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  141367. */
  141368. get computeParticleColor(): boolean;
  141369. /**
  141370. * Gets if `setParticles()` computes the particle textures or not.
  141371. * Default value : false. The PCS is faster when it's set to false.
  141372. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  141373. */
  141374. get computeParticleTexture(): boolean;
  141375. /**
  141376. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  141377. */
  141378. set computeBoundingBox(val: boolean);
  141379. /**
  141380. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  141381. */
  141382. get computeBoundingBox(): boolean;
  141383. /**
  141384. * This function does nothing. It may be overwritten to set all the particle first values.
  141385. * The PCS doesn't call this function, you may have to call it by your own.
  141386. * doc :
  141387. */
  141388. initParticles(): void;
  141389. /**
  141390. * This function does nothing. It may be overwritten to recycle a particle
  141391. * The PCS doesn't call this function, you can to call it
  141392. * doc :
  141393. * @param particle The particle to recycle
  141394. * @returns the recycled particle
  141395. */
  141396. recycleParticle(particle: CloudPoint): CloudPoint;
  141397. /**
  141398. * Updates a particle : this function should be overwritten by the user.
  141399. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  141400. * doc :
  141401. * @example : just set a particle position or velocity and recycle conditions
  141402. * @param particle The particle to update
  141403. * @returns the updated particle
  141404. */
  141405. updateParticle(particle: CloudPoint): CloudPoint;
  141406. /**
  141407. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  141408. * This does nothing and may be overwritten by the user.
  141409. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141410. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141411. * @param update the boolean update value actually passed to setParticles()
  141412. */
  141413. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141414. /**
  141415. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  141416. * This will be passed three parameters.
  141417. * This does nothing and may be overwritten by the user.
  141418. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141419. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141420. * @param update the boolean update value actually passed to setParticles()
  141421. */
  141422. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141423. }
  141424. }
  141425. declare module BABYLON {
  141426. /**
  141427. * Represents one particle of a points cloud system.
  141428. */
  141429. export class CloudPoint {
  141430. /**
  141431. * particle global index
  141432. */
  141433. idx: number;
  141434. /**
  141435. * The color of the particle
  141436. */
  141437. color: Nullable<Color4>;
  141438. /**
  141439. * The world space position of the particle.
  141440. */
  141441. position: Vector3;
  141442. /**
  141443. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  141444. */
  141445. rotation: Vector3;
  141446. /**
  141447. * The world space rotation quaternion of the particle.
  141448. */
  141449. rotationQuaternion: Nullable<Quaternion>;
  141450. /**
  141451. * The uv of the particle.
  141452. */
  141453. uv: Nullable<Vector2>;
  141454. /**
  141455. * The current speed of the particle.
  141456. */
  141457. velocity: Vector3;
  141458. /**
  141459. * The pivot point in the particle local space.
  141460. */
  141461. pivot: Vector3;
  141462. /**
  141463. * Must the particle be translated from its pivot point in its local space ?
  141464. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  141465. * Default : false
  141466. */
  141467. translateFromPivot: boolean;
  141468. /**
  141469. * Index of this particle in the global "positions" array (Internal use)
  141470. * @hidden
  141471. */
  141472. _pos: number;
  141473. /**
  141474. * @hidden Index of this particle in the global "indices" array (Internal use)
  141475. */
  141476. _ind: number;
  141477. /**
  141478. * Group this particle belongs to
  141479. */
  141480. _group: PointsGroup;
  141481. /**
  141482. * Group id of this particle
  141483. */
  141484. groupId: number;
  141485. /**
  141486. * Index of the particle in its group id (Internal use)
  141487. */
  141488. idxInGroup: number;
  141489. /**
  141490. * @hidden Particle BoundingInfo object (Internal use)
  141491. */
  141492. _boundingInfo: BoundingInfo;
  141493. /**
  141494. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  141495. */
  141496. _pcs: PointsCloudSystem;
  141497. /**
  141498. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  141499. */
  141500. _stillInvisible: boolean;
  141501. /**
  141502. * @hidden Last computed particle rotation matrix
  141503. */
  141504. _rotationMatrix: number[];
  141505. /**
  141506. * Parent particle Id, if any.
  141507. * Default null.
  141508. */
  141509. parentId: Nullable<number>;
  141510. /**
  141511. * @hidden Internal global position in the PCS.
  141512. */
  141513. _globalPosition: Vector3;
  141514. /**
  141515. * Creates a Point Cloud object.
  141516. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  141517. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  141518. * @param group (PointsGroup) is the group the particle belongs to
  141519. * @param groupId (integer) is the group identifier in the PCS.
  141520. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  141521. * @param pcs defines the PCS it is associated to
  141522. */
  141523. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  141524. /**
  141525. * get point size
  141526. */
  141527. get size(): Vector3;
  141528. /**
  141529. * Set point size
  141530. */
  141531. set size(scale: Vector3);
  141532. /**
  141533. * Legacy support, changed quaternion to rotationQuaternion
  141534. */
  141535. get quaternion(): Nullable<Quaternion>;
  141536. /**
  141537. * Legacy support, changed quaternion to rotationQuaternion
  141538. */
  141539. set quaternion(q: Nullable<Quaternion>);
  141540. /**
  141541. * Returns a boolean. True if the particle intersects a mesh, else false
  141542. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  141543. * @param target is the object (point or mesh) what the intersection is computed against
  141544. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  141545. * @returns true if it intersects
  141546. */
  141547. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  141548. /**
  141549. * get the rotation matrix of the particle
  141550. * @hidden
  141551. */
  141552. getRotationMatrix(m: Matrix): void;
  141553. }
  141554. /**
  141555. * Represents a group of points in a points cloud system
  141556. * * PCS internal tool, don't use it manually.
  141557. */
  141558. export class PointsGroup {
  141559. /**
  141560. * The group id
  141561. * @hidden
  141562. */
  141563. groupID: number;
  141564. /**
  141565. * image data for group (internal use)
  141566. * @hidden
  141567. */
  141568. _groupImageData: Nullable<ArrayBufferView>;
  141569. /**
  141570. * Image Width (internal use)
  141571. * @hidden
  141572. */
  141573. _groupImgWidth: number;
  141574. /**
  141575. * Image Height (internal use)
  141576. * @hidden
  141577. */
  141578. _groupImgHeight: number;
  141579. /**
  141580. * Custom position function (internal use)
  141581. * @hidden
  141582. */
  141583. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  141584. /**
  141585. * density per facet for surface points
  141586. * @hidden
  141587. */
  141588. _groupDensity: number[];
  141589. /**
  141590. * Only when points are colored by texture carries pointer to texture list array
  141591. * @hidden
  141592. */
  141593. _textureNb: number;
  141594. /**
  141595. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  141596. * PCS internal tool, don't use it manually.
  141597. * @hidden
  141598. */
  141599. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  141600. }
  141601. }
  141602. declare module BABYLON {
  141603. interface Scene {
  141604. /** @hidden (Backing field) */
  141605. _physicsEngine: Nullable<IPhysicsEngine>;
  141606. /** @hidden */
  141607. _physicsTimeAccumulator: number;
  141608. /**
  141609. * Gets the current physics engine
  141610. * @returns a IPhysicsEngine or null if none attached
  141611. */
  141612. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  141613. /**
  141614. * Enables physics to the current scene
  141615. * @param gravity defines the scene's gravity for the physics engine
  141616. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  141617. * @return a boolean indicating if the physics engine was initialized
  141618. */
  141619. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  141620. /**
  141621. * Disables and disposes the physics engine associated with the scene
  141622. */
  141623. disablePhysicsEngine(): void;
  141624. /**
  141625. * Gets a boolean indicating if there is an active physics engine
  141626. * @returns a boolean indicating if there is an active physics engine
  141627. */
  141628. isPhysicsEnabled(): boolean;
  141629. /**
  141630. * Deletes a physics compound impostor
  141631. * @param compound defines the compound to delete
  141632. */
  141633. deleteCompoundImpostor(compound: any): void;
  141634. /**
  141635. * An event triggered when physic simulation is about to be run
  141636. */
  141637. onBeforePhysicsObservable: Observable<Scene>;
  141638. /**
  141639. * An event triggered when physic simulation has been done
  141640. */
  141641. onAfterPhysicsObservable: Observable<Scene>;
  141642. }
  141643. interface AbstractMesh {
  141644. /** @hidden */
  141645. _physicsImpostor: Nullable<PhysicsImpostor>;
  141646. /**
  141647. * Gets or sets impostor used for physic simulation
  141648. * @see http://doc.babylonjs.com/features/physics_engine
  141649. */
  141650. physicsImpostor: Nullable<PhysicsImpostor>;
  141651. /**
  141652. * Gets the current physics impostor
  141653. * @see http://doc.babylonjs.com/features/physics_engine
  141654. * @returns a physics impostor or null
  141655. */
  141656. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  141657. /** Apply a physic impulse to the mesh
  141658. * @param force defines the force to apply
  141659. * @param contactPoint defines where to apply the force
  141660. * @returns the current mesh
  141661. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  141662. */
  141663. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  141664. /**
  141665. * Creates a physic joint between two meshes
  141666. * @param otherMesh defines the other mesh to use
  141667. * @param pivot1 defines the pivot to use on this mesh
  141668. * @param pivot2 defines the pivot to use on the other mesh
  141669. * @param options defines additional options (can be plugin dependent)
  141670. * @returns the current mesh
  141671. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  141672. */
  141673. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  141674. /** @hidden */
  141675. _disposePhysicsObserver: Nullable<Observer<Node>>;
  141676. }
  141677. /**
  141678. * Defines the physics engine scene component responsible to manage a physics engine
  141679. */
  141680. export class PhysicsEngineSceneComponent implements ISceneComponent {
  141681. /**
  141682. * The component name helpful to identify the component in the list of scene components.
  141683. */
  141684. readonly name: string;
  141685. /**
  141686. * The scene the component belongs to.
  141687. */
  141688. scene: Scene;
  141689. /**
  141690. * Creates a new instance of the component for the given scene
  141691. * @param scene Defines the scene to register the component in
  141692. */
  141693. constructor(scene: Scene);
  141694. /**
  141695. * Registers the component in a given scene
  141696. */
  141697. register(): void;
  141698. /**
  141699. * Rebuilds the elements related to this component in case of
  141700. * context lost for instance.
  141701. */
  141702. rebuild(): void;
  141703. /**
  141704. * Disposes the component and the associated ressources
  141705. */
  141706. dispose(): void;
  141707. }
  141708. }
  141709. declare module BABYLON {
  141710. /**
  141711. * A helper for physics simulations
  141712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141713. */
  141714. export class PhysicsHelper {
  141715. private _scene;
  141716. private _physicsEngine;
  141717. /**
  141718. * Initializes the Physics helper
  141719. * @param scene Babylon.js scene
  141720. */
  141721. constructor(scene: Scene);
  141722. /**
  141723. * Applies a radial explosion impulse
  141724. * @param origin the origin of the explosion
  141725. * @param radiusOrEventOptions the radius or the options of radial explosion
  141726. * @param strength the explosion strength
  141727. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141728. * @returns A physics radial explosion event, or null
  141729. */
  141730. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141731. /**
  141732. * Applies a radial explosion force
  141733. * @param origin the origin of the explosion
  141734. * @param radiusOrEventOptions the radius or the options of radial explosion
  141735. * @param strength the explosion strength
  141736. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141737. * @returns A physics radial explosion event, or null
  141738. */
  141739. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141740. /**
  141741. * Creates a gravitational field
  141742. * @param origin the origin of the explosion
  141743. * @param radiusOrEventOptions the radius or the options of radial explosion
  141744. * @param strength the explosion strength
  141745. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141746. * @returns A physics gravitational field event, or null
  141747. */
  141748. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  141749. /**
  141750. * Creates a physics updraft event
  141751. * @param origin the origin of the updraft
  141752. * @param radiusOrEventOptions the radius or the options of the updraft
  141753. * @param strength the strength of the updraft
  141754. * @param height the height of the updraft
  141755. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  141756. * @returns A physics updraft event, or null
  141757. */
  141758. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  141759. /**
  141760. * Creates a physics vortex event
  141761. * @param origin the of the vortex
  141762. * @param radiusOrEventOptions the radius or the options of the vortex
  141763. * @param strength the strength of the vortex
  141764. * @param height the height of the vortex
  141765. * @returns a Physics vortex event, or null
  141766. * A physics vortex event or null
  141767. */
  141768. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  141769. }
  141770. /**
  141771. * Represents a physics radial explosion event
  141772. */
  141773. class PhysicsRadialExplosionEvent {
  141774. private _scene;
  141775. private _options;
  141776. private _sphere;
  141777. private _dataFetched;
  141778. /**
  141779. * Initializes a radial explosioin event
  141780. * @param _scene BabylonJS scene
  141781. * @param _options The options for the vortex event
  141782. */
  141783. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  141784. /**
  141785. * Returns the data related to the radial explosion event (sphere).
  141786. * @returns The radial explosion event data
  141787. */
  141788. getData(): PhysicsRadialExplosionEventData;
  141789. /**
  141790. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  141791. * @param impostor A physics imposter
  141792. * @param origin the origin of the explosion
  141793. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  141794. */
  141795. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  141796. /**
  141797. * Triggers affecterd impostors callbacks
  141798. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  141799. */
  141800. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  141801. /**
  141802. * Disposes the sphere.
  141803. * @param force Specifies if the sphere should be disposed by force
  141804. */
  141805. dispose(force?: boolean): void;
  141806. /*** Helpers ***/
  141807. private _prepareSphere;
  141808. private _intersectsWithSphere;
  141809. }
  141810. /**
  141811. * Represents a gravitational field event
  141812. */
  141813. class PhysicsGravitationalFieldEvent {
  141814. private _physicsHelper;
  141815. private _scene;
  141816. private _origin;
  141817. private _options;
  141818. private _tickCallback;
  141819. private _sphere;
  141820. private _dataFetched;
  141821. /**
  141822. * Initializes the physics gravitational field event
  141823. * @param _physicsHelper A physics helper
  141824. * @param _scene BabylonJS scene
  141825. * @param _origin The origin position of the gravitational field event
  141826. * @param _options The options for the vortex event
  141827. */
  141828. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  141829. /**
  141830. * Returns the data related to the gravitational field event (sphere).
  141831. * @returns A gravitational field event
  141832. */
  141833. getData(): PhysicsGravitationalFieldEventData;
  141834. /**
  141835. * Enables the gravitational field.
  141836. */
  141837. enable(): void;
  141838. /**
  141839. * Disables the gravitational field.
  141840. */
  141841. disable(): void;
  141842. /**
  141843. * Disposes the sphere.
  141844. * @param force The force to dispose from the gravitational field event
  141845. */
  141846. dispose(force?: boolean): void;
  141847. private _tick;
  141848. }
  141849. /**
  141850. * Represents a physics updraft event
  141851. */
  141852. class PhysicsUpdraftEvent {
  141853. private _scene;
  141854. private _origin;
  141855. private _options;
  141856. private _physicsEngine;
  141857. private _originTop;
  141858. private _originDirection;
  141859. private _tickCallback;
  141860. private _cylinder;
  141861. private _cylinderPosition;
  141862. private _dataFetched;
  141863. /**
  141864. * Initializes the physics updraft event
  141865. * @param _scene BabylonJS scene
  141866. * @param _origin The origin position of the updraft
  141867. * @param _options The options for the updraft event
  141868. */
  141869. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  141870. /**
  141871. * Returns the data related to the updraft event (cylinder).
  141872. * @returns A physics updraft event
  141873. */
  141874. getData(): PhysicsUpdraftEventData;
  141875. /**
  141876. * Enables the updraft.
  141877. */
  141878. enable(): void;
  141879. /**
  141880. * Disables the updraft.
  141881. */
  141882. disable(): void;
  141883. /**
  141884. * Disposes the cylinder.
  141885. * @param force Specifies if the updraft should be disposed by force
  141886. */
  141887. dispose(force?: boolean): void;
  141888. private getImpostorHitData;
  141889. private _tick;
  141890. /*** Helpers ***/
  141891. private _prepareCylinder;
  141892. private _intersectsWithCylinder;
  141893. }
  141894. /**
  141895. * Represents a physics vortex event
  141896. */
  141897. class PhysicsVortexEvent {
  141898. private _scene;
  141899. private _origin;
  141900. private _options;
  141901. private _physicsEngine;
  141902. private _originTop;
  141903. private _tickCallback;
  141904. private _cylinder;
  141905. private _cylinderPosition;
  141906. private _dataFetched;
  141907. /**
  141908. * Initializes the physics vortex event
  141909. * @param _scene The BabylonJS scene
  141910. * @param _origin The origin position of the vortex
  141911. * @param _options The options for the vortex event
  141912. */
  141913. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  141914. /**
  141915. * Returns the data related to the vortex event (cylinder).
  141916. * @returns The physics vortex event data
  141917. */
  141918. getData(): PhysicsVortexEventData;
  141919. /**
  141920. * Enables the vortex.
  141921. */
  141922. enable(): void;
  141923. /**
  141924. * Disables the cortex.
  141925. */
  141926. disable(): void;
  141927. /**
  141928. * Disposes the sphere.
  141929. * @param force
  141930. */
  141931. dispose(force?: boolean): void;
  141932. private getImpostorHitData;
  141933. private _tick;
  141934. /*** Helpers ***/
  141935. private _prepareCylinder;
  141936. private _intersectsWithCylinder;
  141937. }
  141938. /**
  141939. * Options fot the radial explosion event
  141940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141941. */
  141942. export class PhysicsRadialExplosionEventOptions {
  141943. /**
  141944. * The radius of the sphere for the radial explosion.
  141945. */
  141946. radius: number;
  141947. /**
  141948. * The strenth of the explosion.
  141949. */
  141950. strength: number;
  141951. /**
  141952. * The strenght of the force in correspondence to the distance of the affected object
  141953. */
  141954. falloff: PhysicsRadialImpulseFalloff;
  141955. /**
  141956. * Sphere options for the radial explosion.
  141957. */
  141958. sphere: {
  141959. segments: number;
  141960. diameter: number;
  141961. };
  141962. /**
  141963. * Sphere options for the radial explosion.
  141964. */
  141965. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  141966. }
  141967. /**
  141968. * Options fot the updraft event
  141969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141970. */
  141971. export class PhysicsUpdraftEventOptions {
  141972. /**
  141973. * The radius of the cylinder for the vortex
  141974. */
  141975. radius: number;
  141976. /**
  141977. * The strenth of the updraft.
  141978. */
  141979. strength: number;
  141980. /**
  141981. * The height of the cylinder for the updraft.
  141982. */
  141983. height: number;
  141984. /**
  141985. * The mode for the the updraft.
  141986. */
  141987. updraftMode: PhysicsUpdraftMode;
  141988. }
  141989. /**
  141990. * Options fot the vortex event
  141991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141992. */
  141993. export class PhysicsVortexEventOptions {
  141994. /**
  141995. * The radius of the cylinder for the vortex
  141996. */
  141997. radius: number;
  141998. /**
  141999. * The strenth of the vortex.
  142000. */
  142001. strength: number;
  142002. /**
  142003. * The height of the cylinder for the vortex.
  142004. */
  142005. height: number;
  142006. /**
  142007. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  142008. */
  142009. centripetalForceThreshold: number;
  142010. /**
  142011. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  142012. */
  142013. centripetalForceMultiplier: number;
  142014. /**
  142015. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  142016. */
  142017. centrifugalForceMultiplier: number;
  142018. /**
  142019. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  142020. */
  142021. updraftForceMultiplier: number;
  142022. }
  142023. /**
  142024. * The strenght of the force in correspondence to the distance of the affected object
  142025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142026. */
  142027. export enum PhysicsRadialImpulseFalloff {
  142028. /** Defines that impulse is constant in strength across it's whole radius */
  142029. Constant = 0,
  142030. /** Defines that impulse gets weaker if it's further from the origin */
  142031. Linear = 1
  142032. }
  142033. /**
  142034. * The strength of the force in correspondence to the distance of the affected object
  142035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142036. */
  142037. export enum PhysicsUpdraftMode {
  142038. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  142039. Center = 0,
  142040. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  142041. Perpendicular = 1
  142042. }
  142043. /**
  142044. * Interface for a physics hit data
  142045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142046. */
  142047. export interface PhysicsHitData {
  142048. /**
  142049. * The force applied at the contact point
  142050. */
  142051. force: Vector3;
  142052. /**
  142053. * The contact point
  142054. */
  142055. contactPoint: Vector3;
  142056. /**
  142057. * The distance from the origin to the contact point
  142058. */
  142059. distanceFromOrigin: number;
  142060. }
  142061. /**
  142062. * Interface for radial explosion event data
  142063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142064. */
  142065. export interface PhysicsRadialExplosionEventData {
  142066. /**
  142067. * A sphere used for the radial explosion event
  142068. */
  142069. sphere: Mesh;
  142070. }
  142071. /**
  142072. * Interface for gravitational field event data
  142073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142074. */
  142075. export interface PhysicsGravitationalFieldEventData {
  142076. /**
  142077. * A sphere mesh used for the gravitational field event
  142078. */
  142079. sphere: Mesh;
  142080. }
  142081. /**
  142082. * Interface for updraft event data
  142083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142084. */
  142085. export interface PhysicsUpdraftEventData {
  142086. /**
  142087. * A cylinder used for the updraft event
  142088. */
  142089. cylinder: Mesh;
  142090. }
  142091. /**
  142092. * Interface for vortex event data
  142093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142094. */
  142095. export interface PhysicsVortexEventData {
  142096. /**
  142097. * A cylinder used for the vortex event
  142098. */
  142099. cylinder: Mesh;
  142100. }
  142101. /**
  142102. * Interface for an affected physics impostor
  142103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142104. */
  142105. export interface PhysicsAffectedImpostorWithData {
  142106. /**
  142107. * The impostor affected by the effect
  142108. */
  142109. impostor: PhysicsImpostor;
  142110. /**
  142111. * The data about the hit/horce from the explosion
  142112. */
  142113. hitData: PhysicsHitData;
  142114. }
  142115. }
  142116. declare module BABYLON {
  142117. /** @hidden */
  142118. export var blackAndWhitePixelShader: {
  142119. name: string;
  142120. shader: string;
  142121. };
  142122. }
  142123. declare module BABYLON {
  142124. /**
  142125. * Post process used to render in black and white
  142126. */
  142127. export class BlackAndWhitePostProcess extends PostProcess {
  142128. /**
  142129. * Linear about to convert he result to black and white (default: 1)
  142130. */
  142131. degree: number;
  142132. /**
  142133. * Creates a black and white post process
  142134. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  142135. * @param name The name of the effect.
  142136. * @param options The required width/height ratio to downsize to before computing the render pass.
  142137. * @param camera The camera to apply the render pass to.
  142138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142139. * @param engine The engine which the post process will be applied. (default: current engine)
  142140. * @param reusable If the post process can be reused on the same frame. (default: false)
  142141. */
  142142. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142143. }
  142144. }
  142145. declare module BABYLON {
  142146. /**
  142147. * This represents a set of one or more post processes in Babylon.
  142148. * A post process can be used to apply a shader to a texture after it is rendered.
  142149. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142150. */
  142151. export class PostProcessRenderEffect {
  142152. private _postProcesses;
  142153. private _getPostProcesses;
  142154. private _singleInstance;
  142155. private _cameras;
  142156. private _indicesForCamera;
  142157. /**
  142158. * Name of the effect
  142159. * @hidden
  142160. */
  142161. _name: string;
  142162. /**
  142163. * Instantiates a post process render effect.
  142164. * A post process can be used to apply a shader to a texture after it is rendered.
  142165. * @param engine The engine the effect is tied to
  142166. * @param name The name of the effect
  142167. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  142168. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  142169. */
  142170. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  142171. /**
  142172. * Checks if all the post processes in the effect are supported.
  142173. */
  142174. get isSupported(): boolean;
  142175. /**
  142176. * Updates the current state of the effect
  142177. * @hidden
  142178. */
  142179. _update(): void;
  142180. /**
  142181. * Attaches the effect on cameras
  142182. * @param cameras The camera to attach to.
  142183. * @hidden
  142184. */
  142185. _attachCameras(cameras: Camera): void;
  142186. /**
  142187. * Attaches the effect on cameras
  142188. * @param cameras The camera to attach to.
  142189. * @hidden
  142190. */
  142191. _attachCameras(cameras: Camera[]): void;
  142192. /**
  142193. * Detaches the effect on cameras
  142194. * @param cameras The camera to detatch from.
  142195. * @hidden
  142196. */
  142197. _detachCameras(cameras: Camera): void;
  142198. /**
  142199. * Detatches the effect on cameras
  142200. * @param cameras The camera to detatch from.
  142201. * @hidden
  142202. */
  142203. _detachCameras(cameras: Camera[]): void;
  142204. /**
  142205. * Enables the effect on given cameras
  142206. * @param cameras The camera to enable.
  142207. * @hidden
  142208. */
  142209. _enable(cameras: Camera): void;
  142210. /**
  142211. * Enables the effect on given cameras
  142212. * @param cameras The camera to enable.
  142213. * @hidden
  142214. */
  142215. _enable(cameras: Nullable<Camera[]>): void;
  142216. /**
  142217. * Disables the effect on the given cameras
  142218. * @param cameras The camera to disable.
  142219. * @hidden
  142220. */
  142221. _disable(cameras: Camera): void;
  142222. /**
  142223. * Disables the effect on the given cameras
  142224. * @param cameras The camera to disable.
  142225. * @hidden
  142226. */
  142227. _disable(cameras: Nullable<Camera[]>): void;
  142228. /**
  142229. * Gets a list of the post processes contained in the effect.
  142230. * @param camera The camera to get the post processes on.
  142231. * @returns The list of the post processes in the effect.
  142232. */
  142233. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  142234. }
  142235. }
  142236. declare module BABYLON {
  142237. /** @hidden */
  142238. export var extractHighlightsPixelShader: {
  142239. name: string;
  142240. shader: string;
  142241. };
  142242. }
  142243. declare module BABYLON {
  142244. /**
  142245. * 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.
  142246. */
  142247. export class ExtractHighlightsPostProcess extends PostProcess {
  142248. /**
  142249. * The luminance threshold, pixels below this value will be set to black.
  142250. */
  142251. threshold: number;
  142252. /** @hidden */
  142253. _exposure: number;
  142254. /**
  142255. * Post process which has the input texture to be used when performing highlight extraction
  142256. * @hidden
  142257. */
  142258. _inputPostProcess: Nullable<PostProcess>;
  142259. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142260. }
  142261. }
  142262. declare module BABYLON {
  142263. /** @hidden */
  142264. export var bloomMergePixelShader: {
  142265. name: string;
  142266. shader: string;
  142267. };
  142268. }
  142269. declare module BABYLON {
  142270. /**
  142271. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142272. */
  142273. export class BloomMergePostProcess extends PostProcess {
  142274. /** Weight of the bloom to be added to the original input. */
  142275. weight: number;
  142276. /**
  142277. * Creates a new instance of @see BloomMergePostProcess
  142278. * @param name The name of the effect.
  142279. * @param originalFromInput Post process which's input will be used for the merge.
  142280. * @param blurred Blurred highlights post process which's output will be used.
  142281. * @param weight Weight of the bloom to be added to the original input.
  142282. * @param options The required width/height ratio to downsize to before computing the render pass.
  142283. * @param camera The camera to apply the render pass to.
  142284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142285. * @param engine The engine which the post process will be applied. (default: current engine)
  142286. * @param reusable If the post process can be reused on the same frame. (default: false)
  142287. * @param textureType Type of textures used when performing the post process. (default: 0)
  142288. * @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)
  142289. */
  142290. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  142291. /** Weight of the bloom to be added to the original input. */
  142292. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142293. }
  142294. }
  142295. declare module BABYLON {
  142296. /**
  142297. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  142298. */
  142299. export class BloomEffect extends PostProcessRenderEffect {
  142300. private bloomScale;
  142301. /**
  142302. * @hidden Internal
  142303. */
  142304. _effects: Array<PostProcess>;
  142305. /**
  142306. * @hidden Internal
  142307. */
  142308. _downscale: ExtractHighlightsPostProcess;
  142309. private _blurX;
  142310. private _blurY;
  142311. private _merge;
  142312. /**
  142313. * The luminance threshold to find bright areas of the image to bloom.
  142314. */
  142315. get threshold(): number;
  142316. set threshold(value: number);
  142317. /**
  142318. * The strength of the bloom.
  142319. */
  142320. get weight(): number;
  142321. set weight(value: number);
  142322. /**
  142323. * Specifies the size of the bloom blur kernel, relative to the final output size
  142324. */
  142325. get kernel(): number;
  142326. set kernel(value: number);
  142327. /**
  142328. * Creates a new instance of @see BloomEffect
  142329. * @param scene The scene the effect belongs to.
  142330. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  142331. * @param bloomKernel The size of the kernel to be used when applying the blur.
  142332. * @param bloomWeight The the strength of bloom.
  142333. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142334. * @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)
  142335. */
  142336. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  142337. /**
  142338. * Disposes each of the internal effects for a given camera.
  142339. * @param camera The camera to dispose the effect on.
  142340. */
  142341. disposeEffects(camera: Camera): void;
  142342. /**
  142343. * @hidden Internal
  142344. */
  142345. _updateEffects(): void;
  142346. /**
  142347. * Internal
  142348. * @returns if all the contained post processes are ready.
  142349. * @hidden
  142350. */
  142351. _isReady(): boolean;
  142352. }
  142353. }
  142354. declare module BABYLON {
  142355. /** @hidden */
  142356. export var chromaticAberrationPixelShader: {
  142357. name: string;
  142358. shader: string;
  142359. };
  142360. }
  142361. declare module BABYLON {
  142362. /**
  142363. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  142364. */
  142365. export class ChromaticAberrationPostProcess extends PostProcess {
  142366. /**
  142367. * The amount of seperation of rgb channels (default: 30)
  142368. */
  142369. aberrationAmount: number;
  142370. /**
  142371. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  142372. */
  142373. radialIntensity: number;
  142374. /**
  142375. * 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))
  142376. */
  142377. direction: Vector2;
  142378. /**
  142379. * 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))
  142380. */
  142381. centerPosition: Vector2;
  142382. /**
  142383. * Creates a new instance ChromaticAberrationPostProcess
  142384. * @param name The name of the effect.
  142385. * @param screenWidth The width of the screen to apply the effect on.
  142386. * @param screenHeight The height of the screen to apply the effect on.
  142387. * @param options The required width/height ratio to downsize to before computing the render pass.
  142388. * @param camera The camera to apply the render pass to.
  142389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142390. * @param engine The engine which the post process will be applied. (default: current engine)
  142391. * @param reusable If the post process can be reused on the same frame. (default: false)
  142392. * @param textureType Type of textures used when performing the post process. (default: 0)
  142393. * @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)
  142394. */
  142395. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142396. }
  142397. }
  142398. declare module BABYLON {
  142399. /** @hidden */
  142400. export var circleOfConfusionPixelShader: {
  142401. name: string;
  142402. shader: string;
  142403. };
  142404. }
  142405. declare module BABYLON {
  142406. /**
  142407. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  142408. */
  142409. export class CircleOfConfusionPostProcess extends PostProcess {
  142410. /**
  142411. * 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.
  142412. */
  142413. lensSize: number;
  142414. /**
  142415. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142416. */
  142417. fStop: number;
  142418. /**
  142419. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142420. */
  142421. focusDistance: number;
  142422. /**
  142423. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  142424. */
  142425. focalLength: number;
  142426. private _depthTexture;
  142427. /**
  142428. * Creates a new instance CircleOfConfusionPostProcess
  142429. * @param name The name of the effect.
  142430. * @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.
  142431. * @param options The required width/height ratio to downsize to before computing the render pass.
  142432. * @param camera The camera to apply the render pass to.
  142433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142434. * @param engine The engine which the post process will be applied. (default: current engine)
  142435. * @param reusable If the post process can be reused on the same frame. (default: false)
  142436. * @param textureType Type of textures used when performing the post process. (default: 0)
  142437. * @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)
  142438. */
  142439. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142440. /**
  142441. * 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.
  142442. */
  142443. set depthTexture(value: RenderTargetTexture);
  142444. }
  142445. }
  142446. declare module BABYLON {
  142447. /** @hidden */
  142448. export var colorCorrectionPixelShader: {
  142449. name: string;
  142450. shader: string;
  142451. };
  142452. }
  142453. declare module BABYLON {
  142454. /**
  142455. *
  142456. * This post-process allows the modification of rendered colors by using
  142457. * a 'look-up table' (LUT). This effect is also called Color Grading.
  142458. *
  142459. * The object needs to be provided an url to a texture containing the color
  142460. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  142461. * Use an image editing software to tweak the LUT to match your needs.
  142462. *
  142463. * For an example of a color LUT, see here:
  142464. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  142465. * For explanations on color grading, see here:
  142466. * @see http://udn.epicgames.com/Three/ColorGrading.html
  142467. *
  142468. */
  142469. export class ColorCorrectionPostProcess extends PostProcess {
  142470. private _colorTableTexture;
  142471. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142472. }
  142473. }
  142474. declare module BABYLON {
  142475. /** @hidden */
  142476. export var convolutionPixelShader: {
  142477. name: string;
  142478. shader: string;
  142479. };
  142480. }
  142481. declare module BABYLON {
  142482. /**
  142483. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  142484. * input texture to perform effects such as edge detection or sharpening
  142485. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142486. */
  142487. export class ConvolutionPostProcess extends PostProcess {
  142488. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142489. kernel: number[];
  142490. /**
  142491. * Creates a new instance ConvolutionPostProcess
  142492. * @param name The name of the effect.
  142493. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  142494. * @param options The required width/height ratio to downsize to before computing the render pass.
  142495. * @param camera The camera to apply the render pass to.
  142496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142497. * @param engine The engine which the post process will be applied. (default: current engine)
  142498. * @param reusable If the post process can be reused on the same frame. (default: false)
  142499. * @param textureType Type of textures used when performing the post process. (default: 0)
  142500. */
  142501. constructor(name: string,
  142502. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142503. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142504. /**
  142505. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142506. */
  142507. static EdgeDetect0Kernel: number[];
  142508. /**
  142509. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142510. */
  142511. static EdgeDetect1Kernel: number[];
  142512. /**
  142513. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142514. */
  142515. static EdgeDetect2Kernel: number[];
  142516. /**
  142517. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142518. */
  142519. static SharpenKernel: number[];
  142520. /**
  142521. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142522. */
  142523. static EmbossKernel: number[];
  142524. /**
  142525. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142526. */
  142527. static GaussianKernel: number[];
  142528. }
  142529. }
  142530. declare module BABYLON {
  142531. /**
  142532. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  142533. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  142534. * based on samples that have a large difference in distance than the center pixel.
  142535. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  142536. */
  142537. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  142538. direction: Vector2;
  142539. /**
  142540. * Creates a new instance CircleOfConfusionPostProcess
  142541. * @param name The name of the effect.
  142542. * @param scene The scene the effect belongs to.
  142543. * @param direction The direction the blur should be applied.
  142544. * @param kernel The size of the kernel used to blur.
  142545. * @param options The required width/height ratio to downsize to before computing the render pass.
  142546. * @param camera The camera to apply the render pass to.
  142547. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  142548. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  142549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142550. * @param engine The engine which the post process will be applied. (default: current engine)
  142551. * @param reusable If the post process can be reused on the same frame. (default: false)
  142552. * @param textureType Type of textures used when performing the post process. (default: 0)
  142553. * @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)
  142554. */
  142555. 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);
  142556. }
  142557. }
  142558. declare module BABYLON {
  142559. /** @hidden */
  142560. export var depthOfFieldMergePixelShader: {
  142561. name: string;
  142562. shader: string;
  142563. };
  142564. }
  142565. declare module BABYLON {
  142566. /**
  142567. * Options to be set when merging outputs from the default pipeline.
  142568. */
  142569. export class DepthOfFieldMergePostProcessOptions {
  142570. /**
  142571. * The original image to merge on top of
  142572. */
  142573. originalFromInput: PostProcess;
  142574. /**
  142575. * Parameters to perform the merge of the depth of field effect
  142576. */
  142577. depthOfField?: {
  142578. circleOfConfusion: PostProcess;
  142579. blurSteps: Array<PostProcess>;
  142580. };
  142581. /**
  142582. * Parameters to perform the merge of bloom effect
  142583. */
  142584. bloom?: {
  142585. blurred: PostProcess;
  142586. weight: number;
  142587. };
  142588. }
  142589. /**
  142590. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142591. */
  142592. export class DepthOfFieldMergePostProcess extends PostProcess {
  142593. private blurSteps;
  142594. /**
  142595. * Creates a new instance of DepthOfFieldMergePostProcess
  142596. * @param name The name of the effect.
  142597. * @param originalFromInput Post process which's input will be used for the merge.
  142598. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  142599. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  142600. * @param options The required width/height ratio to downsize to before computing the render pass.
  142601. * @param camera The camera to apply the render pass to.
  142602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142603. * @param engine The engine which the post process will be applied. (default: current engine)
  142604. * @param reusable If the post process can be reused on the same frame. (default: false)
  142605. * @param textureType Type of textures used when performing the post process. (default: 0)
  142606. * @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)
  142607. */
  142608. 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);
  142609. /**
  142610. * Updates the effect with the current post process compile time values and recompiles the shader.
  142611. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  142612. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  142613. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  142614. * @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
  142615. * @param onCompiled Called when the shader has been compiled.
  142616. * @param onError Called if there is an error when compiling a shader.
  142617. */
  142618. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  142619. }
  142620. }
  142621. declare module BABYLON {
  142622. /**
  142623. * Specifies the level of max blur that should be applied when using the depth of field effect
  142624. */
  142625. export enum DepthOfFieldEffectBlurLevel {
  142626. /**
  142627. * Subtle blur
  142628. */
  142629. Low = 0,
  142630. /**
  142631. * Medium blur
  142632. */
  142633. Medium = 1,
  142634. /**
  142635. * Large blur
  142636. */
  142637. High = 2
  142638. }
  142639. /**
  142640. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  142641. */
  142642. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  142643. private _circleOfConfusion;
  142644. /**
  142645. * @hidden Internal, blurs from high to low
  142646. */
  142647. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  142648. private _depthOfFieldBlurY;
  142649. private _dofMerge;
  142650. /**
  142651. * @hidden Internal post processes in depth of field effect
  142652. */
  142653. _effects: Array<PostProcess>;
  142654. /**
  142655. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  142656. */
  142657. set focalLength(value: number);
  142658. get focalLength(): number;
  142659. /**
  142660. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142661. */
  142662. set fStop(value: number);
  142663. get fStop(): number;
  142664. /**
  142665. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142666. */
  142667. set focusDistance(value: number);
  142668. get focusDistance(): number;
  142669. /**
  142670. * 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.
  142671. */
  142672. set lensSize(value: number);
  142673. get lensSize(): number;
  142674. /**
  142675. * Creates a new instance DepthOfFieldEffect
  142676. * @param scene The scene the effect belongs to.
  142677. * @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.
  142678. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142679. * @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)
  142680. */
  142681. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  142682. /**
  142683. * Get the current class name of the current effet
  142684. * @returns "DepthOfFieldEffect"
  142685. */
  142686. getClassName(): string;
  142687. /**
  142688. * 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.
  142689. */
  142690. set depthTexture(value: RenderTargetTexture);
  142691. /**
  142692. * Disposes each of the internal effects for a given camera.
  142693. * @param camera The camera to dispose the effect on.
  142694. */
  142695. disposeEffects(camera: Camera): void;
  142696. /**
  142697. * @hidden Internal
  142698. */
  142699. _updateEffects(): void;
  142700. /**
  142701. * Internal
  142702. * @returns if all the contained post processes are ready.
  142703. * @hidden
  142704. */
  142705. _isReady(): boolean;
  142706. }
  142707. }
  142708. declare module BABYLON {
  142709. /** @hidden */
  142710. export var displayPassPixelShader: {
  142711. name: string;
  142712. shader: string;
  142713. };
  142714. }
  142715. declare module BABYLON {
  142716. /**
  142717. * DisplayPassPostProcess which produces an output the same as it's input
  142718. */
  142719. export class DisplayPassPostProcess extends PostProcess {
  142720. /**
  142721. * Creates the DisplayPassPostProcess
  142722. * @param name The name of the effect.
  142723. * @param options The required width/height ratio to downsize to before computing the render pass.
  142724. * @param camera The camera to apply the render pass to.
  142725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142726. * @param engine The engine which the post process will be applied. (default: current engine)
  142727. * @param reusable If the post process can be reused on the same frame. (default: false)
  142728. */
  142729. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142730. }
  142731. }
  142732. declare module BABYLON {
  142733. /** @hidden */
  142734. export var filterPixelShader: {
  142735. name: string;
  142736. shader: string;
  142737. };
  142738. }
  142739. declare module BABYLON {
  142740. /**
  142741. * Applies a kernel filter to the image
  142742. */
  142743. export class FilterPostProcess extends PostProcess {
  142744. /** The matrix to be applied to the image */
  142745. kernelMatrix: Matrix;
  142746. /**
  142747. *
  142748. * @param name The name of the effect.
  142749. * @param kernelMatrix The matrix to be applied to the image
  142750. * @param options The required width/height ratio to downsize to before computing the render pass.
  142751. * @param camera The camera to apply the render pass to.
  142752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142753. * @param engine The engine which the post process will be applied. (default: current engine)
  142754. * @param reusable If the post process can be reused on the same frame. (default: false)
  142755. */
  142756. constructor(name: string,
  142757. /** The matrix to be applied to the image */
  142758. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142759. }
  142760. }
  142761. declare module BABYLON {
  142762. /** @hidden */
  142763. export var fxaaPixelShader: {
  142764. name: string;
  142765. shader: string;
  142766. };
  142767. }
  142768. declare module BABYLON {
  142769. /** @hidden */
  142770. export var fxaaVertexShader: {
  142771. name: string;
  142772. shader: string;
  142773. };
  142774. }
  142775. declare module BABYLON {
  142776. /**
  142777. * Fxaa post process
  142778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  142779. */
  142780. export class FxaaPostProcess extends PostProcess {
  142781. /** @hidden */
  142782. texelWidth: number;
  142783. /** @hidden */
  142784. texelHeight: number;
  142785. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142786. private _getDefines;
  142787. }
  142788. }
  142789. declare module BABYLON {
  142790. /** @hidden */
  142791. export var grainPixelShader: {
  142792. name: string;
  142793. shader: string;
  142794. };
  142795. }
  142796. declare module BABYLON {
  142797. /**
  142798. * The GrainPostProcess adds noise to the image at mid luminance levels
  142799. */
  142800. export class GrainPostProcess extends PostProcess {
  142801. /**
  142802. * The intensity of the grain added (default: 30)
  142803. */
  142804. intensity: number;
  142805. /**
  142806. * If the grain should be randomized on every frame
  142807. */
  142808. animated: boolean;
  142809. /**
  142810. * Creates a new instance of @see GrainPostProcess
  142811. * @param name The name of the effect.
  142812. * @param options The required width/height ratio to downsize to before computing the render pass.
  142813. * @param camera The camera to apply the render pass to.
  142814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142815. * @param engine The engine which the post process will be applied. (default: current engine)
  142816. * @param reusable If the post process can be reused on the same frame. (default: false)
  142817. * @param textureType Type of textures used when performing the post process. (default: 0)
  142818. * @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)
  142819. */
  142820. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142821. }
  142822. }
  142823. declare module BABYLON {
  142824. /** @hidden */
  142825. export var highlightsPixelShader: {
  142826. name: string;
  142827. shader: string;
  142828. };
  142829. }
  142830. declare module BABYLON {
  142831. /**
  142832. * Extracts highlights from the image
  142833. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142834. */
  142835. export class HighlightsPostProcess extends PostProcess {
  142836. /**
  142837. * Extracts highlights from the image
  142838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142839. * @param name The name of the effect.
  142840. * @param options The required width/height ratio to downsize to before computing the render pass.
  142841. * @param camera The camera to apply the render pass to.
  142842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142843. * @param engine The engine which the post process will be applied. (default: current engine)
  142844. * @param reusable If the post process can be reused on the same frame. (default: false)
  142845. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  142846. */
  142847. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142848. }
  142849. }
  142850. declare module BABYLON {
  142851. /** @hidden */
  142852. export var mrtFragmentDeclaration: {
  142853. name: string;
  142854. shader: string;
  142855. };
  142856. }
  142857. declare module BABYLON {
  142858. /** @hidden */
  142859. export var geometryPixelShader: {
  142860. name: string;
  142861. shader: string;
  142862. };
  142863. }
  142864. declare module BABYLON {
  142865. /** @hidden */
  142866. export var geometryVertexShader: {
  142867. name: string;
  142868. shader: string;
  142869. };
  142870. }
  142871. declare module BABYLON {
  142872. /** @hidden */
  142873. interface ISavedTransformationMatrix {
  142874. world: Matrix;
  142875. viewProjection: Matrix;
  142876. }
  142877. /**
  142878. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  142879. */
  142880. export class GeometryBufferRenderer {
  142881. /**
  142882. * Constant used to retrieve the position texture index in the G-Buffer textures array
  142883. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  142884. */
  142885. static readonly POSITION_TEXTURE_TYPE: number;
  142886. /**
  142887. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  142888. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  142889. */
  142890. static readonly VELOCITY_TEXTURE_TYPE: number;
  142891. /**
  142892. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  142893. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  142894. */
  142895. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  142896. /**
  142897. * Dictionary used to store the previous transformation matrices of each rendered mesh
  142898. * in order to compute objects velocities when enableVelocity is set to "true"
  142899. * @hidden
  142900. */
  142901. _previousTransformationMatrices: {
  142902. [index: number]: ISavedTransformationMatrix;
  142903. };
  142904. /**
  142905. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  142906. * in order to compute objects velocities when enableVelocity is set to "true"
  142907. * @hidden
  142908. */
  142909. _previousBonesTransformationMatrices: {
  142910. [index: number]: Float32Array;
  142911. };
  142912. /**
  142913. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  142914. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  142915. */
  142916. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  142917. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  142918. renderTransparentMeshes: boolean;
  142919. private _scene;
  142920. private _multiRenderTarget;
  142921. private _ratio;
  142922. private _enablePosition;
  142923. private _enableVelocity;
  142924. private _enableReflectivity;
  142925. private _positionIndex;
  142926. private _velocityIndex;
  142927. private _reflectivityIndex;
  142928. protected _effect: Effect;
  142929. protected _cachedDefines: string;
  142930. /**
  142931. * Set the render list (meshes to be rendered) used in the G buffer.
  142932. */
  142933. set renderList(meshes: Mesh[]);
  142934. /**
  142935. * Gets wether or not G buffer are supported by the running hardware.
  142936. * This requires draw buffer supports
  142937. */
  142938. get isSupported(): boolean;
  142939. /**
  142940. * Returns the index of the given texture type in the G-Buffer textures array
  142941. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  142942. * @returns the index of the given texture type in the G-Buffer textures array
  142943. */
  142944. getTextureIndex(textureType: number): number;
  142945. /**
  142946. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  142947. */
  142948. get enablePosition(): boolean;
  142949. /**
  142950. * Sets whether or not objects positions are enabled for the G buffer.
  142951. */
  142952. set enablePosition(enable: boolean);
  142953. /**
  142954. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  142955. */
  142956. get enableVelocity(): boolean;
  142957. /**
  142958. * Sets wether or not objects velocities are enabled for the G buffer.
  142959. */
  142960. set enableVelocity(enable: boolean);
  142961. /**
  142962. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  142963. */
  142964. get enableReflectivity(): boolean;
  142965. /**
  142966. * Sets wether or not objects roughness are enabled for the G buffer.
  142967. */
  142968. set enableReflectivity(enable: boolean);
  142969. /**
  142970. * Gets the scene associated with the buffer.
  142971. */
  142972. get scene(): Scene;
  142973. /**
  142974. * Gets the ratio used by the buffer during its creation.
  142975. * How big is the buffer related to the main canvas.
  142976. */
  142977. get ratio(): number;
  142978. /** @hidden */
  142979. static _SceneComponentInitialization: (scene: Scene) => void;
  142980. /**
  142981. * Creates a new G Buffer for the scene
  142982. * @param scene The scene the buffer belongs to
  142983. * @param ratio How big is the buffer related to the main canvas.
  142984. */
  142985. constructor(scene: Scene, ratio?: number);
  142986. /**
  142987. * Checks wether everything is ready to render a submesh to the G buffer.
  142988. * @param subMesh the submesh to check readiness for
  142989. * @param useInstances is the mesh drawn using instance or not
  142990. * @returns true if ready otherwise false
  142991. */
  142992. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142993. /**
  142994. * Gets the current underlying G Buffer.
  142995. * @returns the buffer
  142996. */
  142997. getGBuffer(): MultiRenderTarget;
  142998. /**
  142999. * Gets the number of samples used to render the buffer (anti aliasing).
  143000. */
  143001. get samples(): number;
  143002. /**
  143003. * Sets the number of samples used to render the buffer (anti aliasing).
  143004. */
  143005. set samples(value: number);
  143006. /**
  143007. * Disposes the renderer and frees up associated resources.
  143008. */
  143009. dispose(): void;
  143010. protected _createRenderTargets(): void;
  143011. private _copyBonesTransformationMatrices;
  143012. }
  143013. }
  143014. declare module BABYLON {
  143015. interface Scene {
  143016. /** @hidden (Backing field) */
  143017. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  143018. /**
  143019. * Gets or Sets the current geometry buffer associated to the scene.
  143020. */
  143021. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  143022. /**
  143023. * Enables a GeometryBufferRender and associates it with the scene
  143024. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  143025. * @returns the GeometryBufferRenderer
  143026. */
  143027. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  143028. /**
  143029. * Disables the GeometryBufferRender associated with the scene
  143030. */
  143031. disableGeometryBufferRenderer(): void;
  143032. }
  143033. /**
  143034. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  143035. * in several rendering techniques.
  143036. */
  143037. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  143038. /**
  143039. * The component name helpful to identify the component in the list of scene components.
  143040. */
  143041. readonly name: string;
  143042. /**
  143043. * The scene the component belongs to.
  143044. */
  143045. scene: Scene;
  143046. /**
  143047. * Creates a new instance of the component for the given scene
  143048. * @param scene Defines the scene to register the component in
  143049. */
  143050. constructor(scene: Scene);
  143051. /**
  143052. * Registers the component in a given scene
  143053. */
  143054. register(): void;
  143055. /**
  143056. * Rebuilds the elements related to this component in case of
  143057. * context lost for instance.
  143058. */
  143059. rebuild(): void;
  143060. /**
  143061. * Disposes the component and the associated ressources
  143062. */
  143063. dispose(): void;
  143064. private _gatherRenderTargets;
  143065. }
  143066. }
  143067. declare module BABYLON {
  143068. /** @hidden */
  143069. export var motionBlurPixelShader: {
  143070. name: string;
  143071. shader: string;
  143072. };
  143073. }
  143074. declare module BABYLON {
  143075. /**
  143076. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  143077. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  143078. * As an example, all you have to do is to create the post-process:
  143079. * var mb = new BABYLON.MotionBlurPostProcess(
  143080. * 'mb', // The name of the effect.
  143081. * scene, // The scene containing the objects to blur according to their velocity.
  143082. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  143083. * camera // The camera to apply the render pass to.
  143084. * );
  143085. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  143086. */
  143087. export class MotionBlurPostProcess extends PostProcess {
  143088. /**
  143089. * Defines how much the image is blurred by the movement. Default value is equal to 1
  143090. */
  143091. motionStrength: number;
  143092. /**
  143093. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  143094. */
  143095. get motionBlurSamples(): number;
  143096. /**
  143097. * Sets the number of iterations to be used for motion blur quality
  143098. */
  143099. set motionBlurSamples(samples: number);
  143100. private _motionBlurSamples;
  143101. private _geometryBufferRenderer;
  143102. /**
  143103. * Creates a new instance MotionBlurPostProcess
  143104. * @param name The name of the effect.
  143105. * @param scene The scene containing the objects to blur according to their velocity.
  143106. * @param options The required width/height ratio to downsize to before computing the render pass.
  143107. * @param camera The camera to apply the render pass to.
  143108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143109. * @param engine The engine which the post process will be applied. (default: current engine)
  143110. * @param reusable If the post process can be reused on the same frame. (default: false)
  143111. * @param textureType Type of textures used when performing the post process. (default: 0)
  143112. * @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)
  143113. */
  143114. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143115. /**
  143116. * Excludes the given skinned mesh from computing bones velocities.
  143117. * 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.
  143118. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  143119. */
  143120. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  143121. /**
  143122. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  143123. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  143124. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  143125. */
  143126. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  143127. /**
  143128. * Disposes the post process.
  143129. * @param camera The camera to dispose the post process on.
  143130. */
  143131. dispose(camera?: Camera): void;
  143132. }
  143133. }
  143134. declare module BABYLON {
  143135. /** @hidden */
  143136. export var refractionPixelShader: {
  143137. name: string;
  143138. shader: string;
  143139. };
  143140. }
  143141. declare module BABYLON {
  143142. /**
  143143. * Post process which applies a refractin texture
  143144. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  143145. */
  143146. export class RefractionPostProcess extends PostProcess {
  143147. /** the base color of the refraction (used to taint the rendering) */
  143148. color: Color3;
  143149. /** simulated refraction depth */
  143150. depth: number;
  143151. /** the coefficient of the base color (0 to remove base color tainting) */
  143152. colorLevel: number;
  143153. private _refTexture;
  143154. private _ownRefractionTexture;
  143155. /**
  143156. * Gets or sets the refraction texture
  143157. * Please note that you are responsible for disposing the texture if you set it manually
  143158. */
  143159. get refractionTexture(): Texture;
  143160. set refractionTexture(value: Texture);
  143161. /**
  143162. * Initializes the RefractionPostProcess
  143163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  143164. * @param name The name of the effect.
  143165. * @param refractionTextureUrl Url of the refraction texture to use
  143166. * @param color the base color of the refraction (used to taint the rendering)
  143167. * @param depth simulated refraction depth
  143168. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  143169. * @param camera The camera to apply the render pass to.
  143170. * @param options The required width/height ratio to downsize to before computing the render pass.
  143171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143172. * @param engine The engine which the post process will be applied. (default: current engine)
  143173. * @param reusable If the post process can be reused on the same frame. (default: false)
  143174. */
  143175. constructor(name: string, refractionTextureUrl: string,
  143176. /** the base color of the refraction (used to taint the rendering) */
  143177. color: Color3,
  143178. /** simulated refraction depth */
  143179. depth: number,
  143180. /** the coefficient of the base color (0 to remove base color tainting) */
  143181. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  143182. /**
  143183. * Disposes of the post process
  143184. * @param camera Camera to dispose post process on
  143185. */
  143186. dispose(camera: Camera): void;
  143187. }
  143188. }
  143189. declare module BABYLON {
  143190. /** @hidden */
  143191. export var sharpenPixelShader: {
  143192. name: string;
  143193. shader: string;
  143194. };
  143195. }
  143196. declare module BABYLON {
  143197. /**
  143198. * The SharpenPostProcess applies a sharpen kernel to every pixel
  143199. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  143200. */
  143201. export class SharpenPostProcess extends PostProcess {
  143202. /**
  143203. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  143204. */
  143205. colorAmount: number;
  143206. /**
  143207. * How much sharpness should be applied (default: 0.3)
  143208. */
  143209. edgeAmount: number;
  143210. /**
  143211. * Creates a new instance ConvolutionPostProcess
  143212. * @param name The name of the effect.
  143213. * @param options The required width/height ratio to downsize to before computing the render pass.
  143214. * @param camera The camera to apply the render pass to.
  143215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143216. * @param engine The engine which the post process will be applied. (default: current engine)
  143217. * @param reusable If the post process can be reused on the same frame. (default: false)
  143218. * @param textureType Type of textures used when performing the post process. (default: 0)
  143219. * @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)
  143220. */
  143221. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143222. }
  143223. }
  143224. declare module BABYLON {
  143225. /**
  143226. * PostProcessRenderPipeline
  143227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143228. */
  143229. export class PostProcessRenderPipeline {
  143230. private engine;
  143231. private _renderEffects;
  143232. private _renderEffectsForIsolatedPass;
  143233. /**
  143234. * List of inspectable custom properties (used by the Inspector)
  143235. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  143236. */
  143237. inspectableCustomProperties: IInspectable[];
  143238. /**
  143239. * @hidden
  143240. */
  143241. protected _cameras: Camera[];
  143242. /** @hidden */
  143243. _name: string;
  143244. /**
  143245. * Gets pipeline name
  143246. */
  143247. get name(): string;
  143248. /** Gets the list of attached cameras */
  143249. get cameras(): Camera[];
  143250. /**
  143251. * Initializes a PostProcessRenderPipeline
  143252. * @param engine engine to add the pipeline to
  143253. * @param name name of the pipeline
  143254. */
  143255. constructor(engine: Engine, name: string);
  143256. /**
  143257. * Gets the class name
  143258. * @returns "PostProcessRenderPipeline"
  143259. */
  143260. getClassName(): string;
  143261. /**
  143262. * If all the render effects in the pipeline are supported
  143263. */
  143264. get isSupported(): boolean;
  143265. /**
  143266. * Adds an effect to the pipeline
  143267. * @param renderEffect the effect to add
  143268. */
  143269. addEffect(renderEffect: PostProcessRenderEffect): void;
  143270. /** @hidden */
  143271. _rebuild(): void;
  143272. /** @hidden */
  143273. _enableEffect(renderEffectName: string, cameras: Camera): void;
  143274. /** @hidden */
  143275. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  143276. /** @hidden */
  143277. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  143278. /** @hidden */
  143279. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  143280. /** @hidden */
  143281. _attachCameras(cameras: Camera, unique: boolean): void;
  143282. /** @hidden */
  143283. _attachCameras(cameras: Camera[], unique: boolean): void;
  143284. /** @hidden */
  143285. _detachCameras(cameras: Camera): void;
  143286. /** @hidden */
  143287. _detachCameras(cameras: Nullable<Camera[]>): void;
  143288. /** @hidden */
  143289. _update(): void;
  143290. /** @hidden */
  143291. _reset(): void;
  143292. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  143293. /**
  143294. * Disposes of the pipeline
  143295. */
  143296. dispose(): void;
  143297. }
  143298. }
  143299. declare module BABYLON {
  143300. /**
  143301. * PostProcessRenderPipelineManager class
  143302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143303. */
  143304. export class PostProcessRenderPipelineManager {
  143305. private _renderPipelines;
  143306. /**
  143307. * Initializes a PostProcessRenderPipelineManager
  143308. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143309. */
  143310. constructor();
  143311. /**
  143312. * Gets the list of supported render pipelines
  143313. */
  143314. get supportedPipelines(): PostProcessRenderPipeline[];
  143315. /**
  143316. * Adds a pipeline to the manager
  143317. * @param renderPipeline The pipeline to add
  143318. */
  143319. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  143320. /**
  143321. * Attaches a camera to the pipeline
  143322. * @param renderPipelineName The name of the pipeline to attach to
  143323. * @param cameras the camera to attach
  143324. * @param unique if the camera can be attached multiple times to the pipeline
  143325. */
  143326. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  143327. /**
  143328. * Detaches a camera from the pipeline
  143329. * @param renderPipelineName The name of the pipeline to detach from
  143330. * @param cameras the camera to detach
  143331. */
  143332. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  143333. /**
  143334. * Enables an effect by name on a pipeline
  143335. * @param renderPipelineName the name of the pipeline to enable the effect in
  143336. * @param renderEffectName the name of the effect to enable
  143337. * @param cameras the cameras that the effect should be enabled on
  143338. */
  143339. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  143340. /**
  143341. * Disables an effect by name on a pipeline
  143342. * @param renderPipelineName the name of the pipeline to disable the effect in
  143343. * @param renderEffectName the name of the effect to disable
  143344. * @param cameras the cameras that the effect should be disabled on
  143345. */
  143346. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  143347. /**
  143348. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  143349. */
  143350. update(): void;
  143351. /** @hidden */
  143352. _rebuild(): void;
  143353. /**
  143354. * Disposes of the manager and pipelines
  143355. */
  143356. dispose(): void;
  143357. }
  143358. }
  143359. declare module BABYLON {
  143360. interface Scene {
  143361. /** @hidden (Backing field) */
  143362. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  143363. /**
  143364. * Gets the postprocess render pipeline manager
  143365. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143366. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143367. */
  143368. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  143369. }
  143370. /**
  143371. * Defines the Render Pipeline scene component responsible to rendering pipelines
  143372. */
  143373. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  143374. /**
  143375. * The component name helpfull to identify the component in the list of scene components.
  143376. */
  143377. readonly name: string;
  143378. /**
  143379. * The scene the component belongs to.
  143380. */
  143381. scene: Scene;
  143382. /**
  143383. * Creates a new instance of the component for the given scene
  143384. * @param scene Defines the scene to register the component in
  143385. */
  143386. constructor(scene: Scene);
  143387. /**
  143388. * Registers the component in a given scene
  143389. */
  143390. register(): void;
  143391. /**
  143392. * Rebuilds the elements related to this component in case of
  143393. * context lost for instance.
  143394. */
  143395. rebuild(): void;
  143396. /**
  143397. * Disposes the component and the associated ressources
  143398. */
  143399. dispose(): void;
  143400. private _gatherRenderTargets;
  143401. }
  143402. }
  143403. declare module BABYLON {
  143404. /**
  143405. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  143406. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143407. */
  143408. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143409. private _scene;
  143410. private _camerasToBeAttached;
  143411. /**
  143412. * ID of the sharpen post process,
  143413. */
  143414. private readonly SharpenPostProcessId;
  143415. /**
  143416. * @ignore
  143417. * ID of the image processing post process;
  143418. */
  143419. readonly ImageProcessingPostProcessId: string;
  143420. /**
  143421. * @ignore
  143422. * ID of the Fast Approximate Anti-Aliasing post process;
  143423. */
  143424. readonly FxaaPostProcessId: string;
  143425. /**
  143426. * ID of the chromatic aberration post process,
  143427. */
  143428. private readonly ChromaticAberrationPostProcessId;
  143429. /**
  143430. * ID of the grain post process
  143431. */
  143432. private readonly GrainPostProcessId;
  143433. /**
  143434. * Sharpen post process which will apply a sharpen convolution to enhance edges
  143435. */
  143436. sharpen: SharpenPostProcess;
  143437. private _sharpenEffect;
  143438. private bloom;
  143439. /**
  143440. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  143441. */
  143442. depthOfField: DepthOfFieldEffect;
  143443. /**
  143444. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143445. */
  143446. fxaa: FxaaPostProcess;
  143447. /**
  143448. * Image post processing pass used to perform operations such as tone mapping or color grading.
  143449. */
  143450. imageProcessing: ImageProcessingPostProcess;
  143451. /**
  143452. * Chromatic aberration post process which will shift rgb colors in the image
  143453. */
  143454. chromaticAberration: ChromaticAberrationPostProcess;
  143455. private _chromaticAberrationEffect;
  143456. /**
  143457. * Grain post process which add noise to the image
  143458. */
  143459. grain: GrainPostProcess;
  143460. private _grainEffect;
  143461. /**
  143462. * Glow post process which adds a glow to emissive areas of the image
  143463. */
  143464. private _glowLayer;
  143465. /**
  143466. * Animations which can be used to tweak settings over a period of time
  143467. */
  143468. animations: Animation[];
  143469. private _imageProcessingConfigurationObserver;
  143470. private _sharpenEnabled;
  143471. private _bloomEnabled;
  143472. private _depthOfFieldEnabled;
  143473. private _depthOfFieldBlurLevel;
  143474. private _fxaaEnabled;
  143475. private _imageProcessingEnabled;
  143476. private _defaultPipelineTextureType;
  143477. private _bloomScale;
  143478. private _chromaticAberrationEnabled;
  143479. private _grainEnabled;
  143480. private _buildAllowed;
  143481. /**
  143482. * Gets active scene
  143483. */
  143484. get scene(): Scene;
  143485. /**
  143486. * Enable or disable the sharpen process from the pipeline
  143487. */
  143488. set sharpenEnabled(enabled: boolean);
  143489. get sharpenEnabled(): boolean;
  143490. private _resizeObserver;
  143491. private _hardwareScaleLevel;
  143492. private _bloomKernel;
  143493. /**
  143494. * Specifies the size of the bloom blur kernel, relative to the final output size
  143495. */
  143496. get bloomKernel(): number;
  143497. set bloomKernel(value: number);
  143498. /**
  143499. * Specifies the weight of the bloom in the final rendering
  143500. */
  143501. private _bloomWeight;
  143502. /**
  143503. * Specifies the luma threshold for the area that will be blurred by the bloom
  143504. */
  143505. private _bloomThreshold;
  143506. private _hdr;
  143507. /**
  143508. * The strength of the bloom.
  143509. */
  143510. set bloomWeight(value: number);
  143511. get bloomWeight(): number;
  143512. /**
  143513. * The strength of the bloom.
  143514. */
  143515. set bloomThreshold(value: number);
  143516. get bloomThreshold(): number;
  143517. /**
  143518. * The scale of the bloom, lower value will provide better performance.
  143519. */
  143520. set bloomScale(value: number);
  143521. get bloomScale(): number;
  143522. /**
  143523. * Enable or disable the bloom from the pipeline
  143524. */
  143525. set bloomEnabled(enabled: boolean);
  143526. get bloomEnabled(): boolean;
  143527. private _rebuildBloom;
  143528. /**
  143529. * If the depth of field is enabled.
  143530. */
  143531. get depthOfFieldEnabled(): boolean;
  143532. set depthOfFieldEnabled(enabled: boolean);
  143533. /**
  143534. * Blur level of the depth of field effect. (Higher blur will effect performance)
  143535. */
  143536. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  143537. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  143538. /**
  143539. * If the anti aliasing is enabled.
  143540. */
  143541. set fxaaEnabled(enabled: boolean);
  143542. get fxaaEnabled(): boolean;
  143543. private _samples;
  143544. /**
  143545. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  143546. */
  143547. set samples(sampleCount: number);
  143548. get samples(): number;
  143549. /**
  143550. * If image processing is enabled.
  143551. */
  143552. set imageProcessingEnabled(enabled: boolean);
  143553. get imageProcessingEnabled(): boolean;
  143554. /**
  143555. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  143556. */
  143557. set glowLayerEnabled(enabled: boolean);
  143558. get glowLayerEnabled(): boolean;
  143559. /**
  143560. * Gets the glow layer (or null if not defined)
  143561. */
  143562. get glowLayer(): Nullable<GlowLayer>;
  143563. /**
  143564. * Enable or disable the chromaticAberration process from the pipeline
  143565. */
  143566. set chromaticAberrationEnabled(enabled: boolean);
  143567. get chromaticAberrationEnabled(): boolean;
  143568. /**
  143569. * Enable or disable the grain process from the pipeline
  143570. */
  143571. set grainEnabled(enabled: boolean);
  143572. get grainEnabled(): boolean;
  143573. /**
  143574. * @constructor
  143575. * @param name - The rendering pipeline name (default: "")
  143576. * @param hdr - If high dynamic range textures should be used (default: true)
  143577. * @param scene - The scene linked to this pipeline (default: the last created scene)
  143578. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  143579. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  143580. */
  143581. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  143582. /**
  143583. * Get the class name
  143584. * @returns "DefaultRenderingPipeline"
  143585. */
  143586. getClassName(): string;
  143587. /**
  143588. * Force the compilation of the entire pipeline.
  143589. */
  143590. prepare(): void;
  143591. private _hasCleared;
  143592. private _prevPostProcess;
  143593. private _prevPrevPostProcess;
  143594. private _setAutoClearAndTextureSharing;
  143595. private _depthOfFieldSceneObserver;
  143596. private _buildPipeline;
  143597. private _disposePostProcesses;
  143598. /**
  143599. * Adds a camera to the pipeline
  143600. * @param camera the camera to be added
  143601. */
  143602. addCamera(camera: Camera): void;
  143603. /**
  143604. * Removes a camera from the pipeline
  143605. * @param camera the camera to remove
  143606. */
  143607. removeCamera(camera: Camera): void;
  143608. /**
  143609. * Dispose of the pipeline and stop all post processes
  143610. */
  143611. dispose(): void;
  143612. /**
  143613. * Serialize the rendering pipeline (Used when exporting)
  143614. * @returns the serialized object
  143615. */
  143616. serialize(): any;
  143617. /**
  143618. * Parse the serialized pipeline
  143619. * @param source Source pipeline.
  143620. * @param scene The scene to load the pipeline to.
  143621. * @param rootUrl The URL of the serialized pipeline.
  143622. * @returns An instantiated pipeline from the serialized object.
  143623. */
  143624. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  143625. }
  143626. }
  143627. declare module BABYLON {
  143628. /** @hidden */
  143629. export var lensHighlightsPixelShader: {
  143630. name: string;
  143631. shader: string;
  143632. };
  143633. }
  143634. declare module BABYLON {
  143635. /** @hidden */
  143636. export var depthOfFieldPixelShader: {
  143637. name: string;
  143638. shader: string;
  143639. };
  143640. }
  143641. declare module BABYLON {
  143642. /**
  143643. * BABYLON.JS Chromatic Aberration GLSL Shader
  143644. * Author: Olivier Guyot
  143645. * Separates very slightly R, G and B colors on the edges of the screen
  143646. * Inspired by Francois Tarlier & Martins Upitis
  143647. */
  143648. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  143649. /**
  143650. * @ignore
  143651. * The chromatic aberration PostProcess id in the pipeline
  143652. */
  143653. LensChromaticAberrationEffect: string;
  143654. /**
  143655. * @ignore
  143656. * The highlights enhancing PostProcess id in the pipeline
  143657. */
  143658. HighlightsEnhancingEffect: string;
  143659. /**
  143660. * @ignore
  143661. * The depth-of-field PostProcess id in the pipeline
  143662. */
  143663. LensDepthOfFieldEffect: string;
  143664. private _scene;
  143665. private _depthTexture;
  143666. private _grainTexture;
  143667. private _chromaticAberrationPostProcess;
  143668. private _highlightsPostProcess;
  143669. private _depthOfFieldPostProcess;
  143670. private _edgeBlur;
  143671. private _grainAmount;
  143672. private _chromaticAberration;
  143673. private _distortion;
  143674. private _highlightsGain;
  143675. private _highlightsThreshold;
  143676. private _dofDistance;
  143677. private _dofAperture;
  143678. private _dofDarken;
  143679. private _dofPentagon;
  143680. private _blurNoise;
  143681. /**
  143682. * @constructor
  143683. *
  143684. * Effect parameters are as follow:
  143685. * {
  143686. * chromatic_aberration: number; // from 0 to x (1 for realism)
  143687. * edge_blur: number; // from 0 to x (1 for realism)
  143688. * distortion: number; // from 0 to x (1 for realism)
  143689. * grain_amount: number; // from 0 to 1
  143690. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  143691. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  143692. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  143693. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  143694. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  143695. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  143696. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  143697. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  143698. * }
  143699. * Note: if an effect parameter is unset, effect is disabled
  143700. *
  143701. * @param name The rendering pipeline name
  143702. * @param parameters - An object containing all parameters (see above)
  143703. * @param scene The scene linked to this pipeline
  143704. * @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)
  143705. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143706. */
  143707. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  143708. /**
  143709. * Get the class name
  143710. * @returns "LensRenderingPipeline"
  143711. */
  143712. getClassName(): string;
  143713. /**
  143714. * Gets associated scene
  143715. */
  143716. get scene(): Scene;
  143717. /**
  143718. * Gets or sets the edge blur
  143719. */
  143720. get edgeBlur(): number;
  143721. set edgeBlur(value: number);
  143722. /**
  143723. * Gets or sets the grain amount
  143724. */
  143725. get grainAmount(): number;
  143726. set grainAmount(value: number);
  143727. /**
  143728. * Gets or sets the chromatic aberration amount
  143729. */
  143730. get chromaticAberration(): number;
  143731. set chromaticAberration(value: number);
  143732. /**
  143733. * Gets or sets the depth of field aperture
  143734. */
  143735. get dofAperture(): number;
  143736. set dofAperture(value: number);
  143737. /**
  143738. * Gets or sets the edge distortion
  143739. */
  143740. get edgeDistortion(): number;
  143741. set edgeDistortion(value: number);
  143742. /**
  143743. * Gets or sets the depth of field distortion
  143744. */
  143745. get dofDistortion(): number;
  143746. set dofDistortion(value: number);
  143747. /**
  143748. * Gets or sets the darken out of focus amount
  143749. */
  143750. get darkenOutOfFocus(): number;
  143751. set darkenOutOfFocus(value: number);
  143752. /**
  143753. * Gets or sets a boolean indicating if blur noise is enabled
  143754. */
  143755. get blurNoise(): boolean;
  143756. set blurNoise(value: boolean);
  143757. /**
  143758. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  143759. */
  143760. get pentagonBokeh(): boolean;
  143761. set pentagonBokeh(value: boolean);
  143762. /**
  143763. * Gets or sets the highlight grain amount
  143764. */
  143765. get highlightsGain(): number;
  143766. set highlightsGain(value: number);
  143767. /**
  143768. * Gets or sets the highlight threshold
  143769. */
  143770. get highlightsThreshold(): number;
  143771. set highlightsThreshold(value: number);
  143772. /**
  143773. * Sets the amount of blur at the edges
  143774. * @param amount blur amount
  143775. */
  143776. setEdgeBlur(amount: number): void;
  143777. /**
  143778. * Sets edge blur to 0
  143779. */
  143780. disableEdgeBlur(): void;
  143781. /**
  143782. * Sets the amout of grain
  143783. * @param amount Amount of grain
  143784. */
  143785. setGrainAmount(amount: number): void;
  143786. /**
  143787. * Set grain amount to 0
  143788. */
  143789. disableGrain(): void;
  143790. /**
  143791. * Sets the chromatic aberration amount
  143792. * @param amount amount of chromatic aberration
  143793. */
  143794. setChromaticAberration(amount: number): void;
  143795. /**
  143796. * Sets chromatic aberration amount to 0
  143797. */
  143798. disableChromaticAberration(): void;
  143799. /**
  143800. * Sets the EdgeDistortion amount
  143801. * @param amount amount of EdgeDistortion
  143802. */
  143803. setEdgeDistortion(amount: number): void;
  143804. /**
  143805. * Sets edge distortion to 0
  143806. */
  143807. disableEdgeDistortion(): void;
  143808. /**
  143809. * Sets the FocusDistance amount
  143810. * @param amount amount of FocusDistance
  143811. */
  143812. setFocusDistance(amount: number): void;
  143813. /**
  143814. * Disables depth of field
  143815. */
  143816. disableDepthOfField(): void;
  143817. /**
  143818. * Sets the Aperture amount
  143819. * @param amount amount of Aperture
  143820. */
  143821. setAperture(amount: number): void;
  143822. /**
  143823. * Sets the DarkenOutOfFocus amount
  143824. * @param amount amount of DarkenOutOfFocus
  143825. */
  143826. setDarkenOutOfFocus(amount: number): void;
  143827. private _pentagonBokehIsEnabled;
  143828. /**
  143829. * Creates a pentagon bokeh effect
  143830. */
  143831. enablePentagonBokeh(): void;
  143832. /**
  143833. * Disables the pentagon bokeh effect
  143834. */
  143835. disablePentagonBokeh(): void;
  143836. /**
  143837. * Enables noise blur
  143838. */
  143839. enableNoiseBlur(): void;
  143840. /**
  143841. * Disables noise blur
  143842. */
  143843. disableNoiseBlur(): void;
  143844. /**
  143845. * Sets the HighlightsGain amount
  143846. * @param amount amount of HighlightsGain
  143847. */
  143848. setHighlightsGain(amount: number): void;
  143849. /**
  143850. * Sets the HighlightsThreshold amount
  143851. * @param amount amount of HighlightsThreshold
  143852. */
  143853. setHighlightsThreshold(amount: number): void;
  143854. /**
  143855. * Disables highlights
  143856. */
  143857. disableHighlights(): void;
  143858. /**
  143859. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  143860. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  143861. */
  143862. dispose(disableDepthRender?: boolean): void;
  143863. private _createChromaticAberrationPostProcess;
  143864. private _createHighlightsPostProcess;
  143865. private _createDepthOfFieldPostProcess;
  143866. private _createGrainTexture;
  143867. }
  143868. }
  143869. declare module BABYLON {
  143870. /** @hidden */
  143871. export var ssao2PixelShader: {
  143872. name: string;
  143873. shader: string;
  143874. };
  143875. }
  143876. declare module BABYLON {
  143877. /** @hidden */
  143878. export var ssaoCombinePixelShader: {
  143879. name: string;
  143880. shader: string;
  143881. };
  143882. }
  143883. declare module BABYLON {
  143884. /**
  143885. * Render pipeline to produce ssao effect
  143886. */
  143887. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  143888. /**
  143889. * @ignore
  143890. * The PassPostProcess id in the pipeline that contains the original scene color
  143891. */
  143892. SSAOOriginalSceneColorEffect: string;
  143893. /**
  143894. * @ignore
  143895. * The SSAO PostProcess id in the pipeline
  143896. */
  143897. SSAORenderEffect: string;
  143898. /**
  143899. * @ignore
  143900. * The horizontal blur PostProcess id in the pipeline
  143901. */
  143902. SSAOBlurHRenderEffect: string;
  143903. /**
  143904. * @ignore
  143905. * The vertical blur PostProcess id in the pipeline
  143906. */
  143907. SSAOBlurVRenderEffect: string;
  143908. /**
  143909. * @ignore
  143910. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143911. */
  143912. SSAOCombineRenderEffect: string;
  143913. /**
  143914. * The output strength of the SSAO post-process. Default value is 1.0.
  143915. */
  143916. totalStrength: number;
  143917. /**
  143918. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  143919. */
  143920. maxZ: number;
  143921. /**
  143922. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  143923. */
  143924. minZAspect: number;
  143925. private _samples;
  143926. /**
  143927. * Number of samples used for the SSAO calculations. Default value is 8
  143928. */
  143929. set samples(n: number);
  143930. get samples(): number;
  143931. private _textureSamples;
  143932. /**
  143933. * Number of samples to use for antialiasing
  143934. */
  143935. set textureSamples(n: number);
  143936. get textureSamples(): number;
  143937. /**
  143938. * Ratio object used for SSAO ratio and blur ratio
  143939. */
  143940. private _ratio;
  143941. /**
  143942. * Dynamically generated sphere sampler.
  143943. */
  143944. private _sampleSphere;
  143945. /**
  143946. * Blur filter offsets
  143947. */
  143948. private _samplerOffsets;
  143949. private _expensiveBlur;
  143950. /**
  143951. * If bilateral blur should be used
  143952. */
  143953. set expensiveBlur(b: boolean);
  143954. get expensiveBlur(): boolean;
  143955. /**
  143956. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  143957. */
  143958. radius: number;
  143959. /**
  143960. * The base color of the SSAO post-process
  143961. * The final result is "base + ssao" between [0, 1]
  143962. */
  143963. base: number;
  143964. /**
  143965. * Support test.
  143966. */
  143967. static get IsSupported(): boolean;
  143968. private _scene;
  143969. private _depthTexture;
  143970. private _normalTexture;
  143971. private _randomTexture;
  143972. private _originalColorPostProcess;
  143973. private _ssaoPostProcess;
  143974. private _blurHPostProcess;
  143975. private _blurVPostProcess;
  143976. private _ssaoCombinePostProcess;
  143977. /**
  143978. * Gets active scene
  143979. */
  143980. get scene(): Scene;
  143981. /**
  143982. * @constructor
  143983. * @param name The rendering pipeline name
  143984. * @param scene The scene linked to this pipeline
  143985. * @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 }
  143986. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143987. */
  143988. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  143989. /**
  143990. * Get the class name
  143991. * @returns "SSAO2RenderingPipeline"
  143992. */
  143993. getClassName(): string;
  143994. /**
  143995. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  143996. */
  143997. dispose(disableGeometryBufferRenderer?: boolean): void;
  143998. private _createBlurPostProcess;
  143999. /** @hidden */
  144000. _rebuild(): void;
  144001. private _bits;
  144002. private _radicalInverse_VdC;
  144003. private _hammersley;
  144004. private _hemisphereSample_uniform;
  144005. private _generateHemisphere;
  144006. private _createSSAOPostProcess;
  144007. private _createSSAOCombinePostProcess;
  144008. private _createRandomTexture;
  144009. /**
  144010. * Serialize the rendering pipeline (Used when exporting)
  144011. * @returns the serialized object
  144012. */
  144013. serialize(): any;
  144014. /**
  144015. * Parse the serialized pipeline
  144016. * @param source Source pipeline.
  144017. * @param scene The scene to load the pipeline to.
  144018. * @param rootUrl The URL of the serialized pipeline.
  144019. * @returns An instantiated pipeline from the serialized object.
  144020. */
  144021. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  144022. }
  144023. }
  144024. declare module BABYLON {
  144025. /** @hidden */
  144026. export var ssaoPixelShader: {
  144027. name: string;
  144028. shader: string;
  144029. };
  144030. }
  144031. declare module BABYLON {
  144032. /**
  144033. * Render pipeline to produce ssao effect
  144034. */
  144035. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  144036. /**
  144037. * @ignore
  144038. * The PassPostProcess id in the pipeline that contains the original scene color
  144039. */
  144040. SSAOOriginalSceneColorEffect: string;
  144041. /**
  144042. * @ignore
  144043. * The SSAO PostProcess id in the pipeline
  144044. */
  144045. SSAORenderEffect: string;
  144046. /**
  144047. * @ignore
  144048. * The horizontal blur PostProcess id in the pipeline
  144049. */
  144050. SSAOBlurHRenderEffect: string;
  144051. /**
  144052. * @ignore
  144053. * The vertical blur PostProcess id in the pipeline
  144054. */
  144055. SSAOBlurVRenderEffect: string;
  144056. /**
  144057. * @ignore
  144058. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  144059. */
  144060. SSAOCombineRenderEffect: string;
  144061. /**
  144062. * The output strength of the SSAO post-process. Default value is 1.0.
  144063. */
  144064. totalStrength: number;
  144065. /**
  144066. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  144067. */
  144068. radius: number;
  144069. /**
  144070. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  144071. * Must not be equal to fallOff and superior to fallOff.
  144072. * Default value is 0.0075
  144073. */
  144074. area: number;
  144075. /**
  144076. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  144077. * Must not be equal to area and inferior to area.
  144078. * Default value is 0.000001
  144079. */
  144080. fallOff: number;
  144081. /**
  144082. * The base color of the SSAO post-process
  144083. * The final result is "base + ssao" between [0, 1]
  144084. */
  144085. base: number;
  144086. private _scene;
  144087. private _depthTexture;
  144088. private _randomTexture;
  144089. private _originalColorPostProcess;
  144090. private _ssaoPostProcess;
  144091. private _blurHPostProcess;
  144092. private _blurVPostProcess;
  144093. private _ssaoCombinePostProcess;
  144094. private _firstUpdate;
  144095. /**
  144096. * Gets active scene
  144097. */
  144098. get scene(): Scene;
  144099. /**
  144100. * @constructor
  144101. * @param name - The rendering pipeline name
  144102. * @param scene - The scene linked to this pipeline
  144103. * @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 }
  144104. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  144105. */
  144106. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  144107. /**
  144108. * Get the class name
  144109. * @returns "SSAORenderingPipeline"
  144110. */
  144111. getClassName(): string;
  144112. /**
  144113. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  144114. */
  144115. dispose(disableDepthRender?: boolean): void;
  144116. private _createBlurPostProcess;
  144117. /** @hidden */
  144118. _rebuild(): void;
  144119. private _createSSAOPostProcess;
  144120. private _createSSAOCombinePostProcess;
  144121. private _createRandomTexture;
  144122. }
  144123. }
  144124. declare module BABYLON {
  144125. /** @hidden */
  144126. export var screenSpaceReflectionPixelShader: {
  144127. name: string;
  144128. shader: string;
  144129. };
  144130. }
  144131. declare module BABYLON {
  144132. /**
  144133. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  144134. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  144135. */
  144136. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  144137. /**
  144138. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  144139. */
  144140. threshold: number;
  144141. /**
  144142. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  144143. */
  144144. strength: number;
  144145. /**
  144146. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  144147. */
  144148. reflectionSpecularFalloffExponent: number;
  144149. /**
  144150. * 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]
  144151. */
  144152. step: number;
  144153. /**
  144154. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  144155. */
  144156. roughnessFactor: number;
  144157. private _geometryBufferRenderer;
  144158. private _enableSmoothReflections;
  144159. private _reflectionSamples;
  144160. private _smoothSteps;
  144161. /**
  144162. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  144163. * @param name The name of the effect.
  144164. * @param scene The scene containing the objects to calculate reflections.
  144165. * @param options The required width/height ratio to downsize to before computing the render pass.
  144166. * @param camera The camera to apply the render pass to.
  144167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144168. * @param engine The engine which the post process will be applied. (default: current engine)
  144169. * @param reusable If the post process can be reused on the same frame. (default: false)
  144170. * @param textureType Type of textures used when performing the post process. (default: 0)
  144171. * @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)
  144172. */
  144173. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144174. /**
  144175. * Gets wether or not smoothing reflections is enabled.
  144176. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  144177. */
  144178. get enableSmoothReflections(): boolean;
  144179. /**
  144180. * Sets wether or not smoothing reflections is enabled.
  144181. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  144182. */
  144183. set enableSmoothReflections(enabled: boolean);
  144184. /**
  144185. * Gets the number of samples taken while computing reflections. More samples count is high,
  144186. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  144187. */
  144188. get reflectionSamples(): number;
  144189. /**
  144190. * Sets the number of samples taken while computing reflections. More samples count is high,
  144191. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  144192. */
  144193. set reflectionSamples(samples: number);
  144194. /**
  144195. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  144196. * more the post-process will require GPU power and can generate a drop in FPS.
  144197. * Default value (5.0) work pretty well in all cases but can be adjusted.
  144198. */
  144199. get smoothSteps(): number;
  144200. set smoothSteps(steps: number);
  144201. private _updateEffectDefines;
  144202. }
  144203. }
  144204. declare module BABYLON {
  144205. /** @hidden */
  144206. export var standardPixelShader: {
  144207. name: string;
  144208. shader: string;
  144209. };
  144210. }
  144211. declare module BABYLON {
  144212. /**
  144213. * Standard rendering pipeline
  144214. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144215. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  144216. */
  144217. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  144218. /**
  144219. * Public members
  144220. */
  144221. /**
  144222. * Post-process which contains the original scene color before the pipeline applies all the effects
  144223. */
  144224. originalPostProcess: Nullable<PostProcess>;
  144225. /**
  144226. * Post-process used to down scale an image x4
  144227. */
  144228. downSampleX4PostProcess: Nullable<PostProcess>;
  144229. /**
  144230. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  144231. */
  144232. brightPassPostProcess: Nullable<PostProcess>;
  144233. /**
  144234. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  144235. */
  144236. blurHPostProcesses: PostProcess[];
  144237. /**
  144238. * Post-process array storing all the vertical blur post-processes used by the pipeline
  144239. */
  144240. blurVPostProcesses: PostProcess[];
  144241. /**
  144242. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  144243. */
  144244. textureAdderPostProcess: Nullable<PostProcess>;
  144245. /**
  144246. * Post-process used to create volumetric lighting effect
  144247. */
  144248. volumetricLightPostProcess: Nullable<PostProcess>;
  144249. /**
  144250. * Post-process used to smooth the previous volumetric light post-process on the X axis
  144251. */
  144252. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  144253. /**
  144254. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  144255. */
  144256. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  144257. /**
  144258. * Post-process used to merge the volumetric light effect and the real scene color
  144259. */
  144260. volumetricLightMergePostProces: Nullable<PostProcess>;
  144261. /**
  144262. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  144263. */
  144264. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  144265. /**
  144266. * Base post-process used to calculate the average luminance of the final image for HDR
  144267. */
  144268. luminancePostProcess: Nullable<PostProcess>;
  144269. /**
  144270. * Post-processes used to create down sample post-processes in order to get
  144271. * the average luminance of the final image for HDR
  144272. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  144273. */
  144274. luminanceDownSamplePostProcesses: PostProcess[];
  144275. /**
  144276. * Post-process used to create a HDR effect (light adaptation)
  144277. */
  144278. hdrPostProcess: Nullable<PostProcess>;
  144279. /**
  144280. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  144281. */
  144282. textureAdderFinalPostProcess: Nullable<PostProcess>;
  144283. /**
  144284. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  144285. */
  144286. lensFlareFinalPostProcess: Nullable<PostProcess>;
  144287. /**
  144288. * Post-process used to merge the final HDR post-process and the real scene color
  144289. */
  144290. hdrFinalPostProcess: Nullable<PostProcess>;
  144291. /**
  144292. * Post-process used to create a lens flare effect
  144293. */
  144294. lensFlarePostProcess: Nullable<PostProcess>;
  144295. /**
  144296. * Post-process that merges the result of the lens flare post-process and the real scene color
  144297. */
  144298. lensFlareComposePostProcess: Nullable<PostProcess>;
  144299. /**
  144300. * Post-process used to create a motion blur effect
  144301. */
  144302. motionBlurPostProcess: Nullable<PostProcess>;
  144303. /**
  144304. * Post-process used to create a depth of field effect
  144305. */
  144306. depthOfFieldPostProcess: Nullable<PostProcess>;
  144307. /**
  144308. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  144309. */
  144310. fxaaPostProcess: Nullable<FxaaPostProcess>;
  144311. /**
  144312. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  144313. */
  144314. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  144315. /**
  144316. * Represents the brightness threshold in order to configure the illuminated surfaces
  144317. */
  144318. brightThreshold: number;
  144319. /**
  144320. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  144321. */
  144322. blurWidth: number;
  144323. /**
  144324. * Sets if the blur for highlighted surfaces must be only horizontal
  144325. */
  144326. horizontalBlur: boolean;
  144327. /**
  144328. * Gets the overall exposure used by the pipeline
  144329. */
  144330. get exposure(): number;
  144331. /**
  144332. * Sets the overall exposure used by the pipeline
  144333. */
  144334. set exposure(value: number);
  144335. /**
  144336. * Texture used typically to simulate "dirty" on camera lens
  144337. */
  144338. lensTexture: Nullable<Texture>;
  144339. /**
  144340. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  144341. */
  144342. volumetricLightCoefficient: number;
  144343. /**
  144344. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  144345. */
  144346. volumetricLightPower: number;
  144347. /**
  144348. * Used the set the blur intensity to smooth the volumetric lights
  144349. */
  144350. volumetricLightBlurScale: number;
  144351. /**
  144352. * Light (spot or directional) used to generate the volumetric lights rays
  144353. * The source light must have a shadow generate so the pipeline can get its
  144354. * depth map
  144355. */
  144356. sourceLight: Nullable<SpotLight | DirectionalLight>;
  144357. /**
  144358. * For eye adaptation, represents the minimum luminance the eye can see
  144359. */
  144360. hdrMinimumLuminance: number;
  144361. /**
  144362. * For eye adaptation, represents the decrease luminance speed
  144363. */
  144364. hdrDecreaseRate: number;
  144365. /**
  144366. * For eye adaptation, represents the increase luminance speed
  144367. */
  144368. hdrIncreaseRate: number;
  144369. /**
  144370. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  144371. */
  144372. get hdrAutoExposure(): boolean;
  144373. /**
  144374. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  144375. */
  144376. set hdrAutoExposure(value: boolean);
  144377. /**
  144378. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  144379. */
  144380. lensColorTexture: Nullable<Texture>;
  144381. /**
  144382. * The overall strengh for the lens flare effect
  144383. */
  144384. lensFlareStrength: number;
  144385. /**
  144386. * Dispersion coefficient for lens flare ghosts
  144387. */
  144388. lensFlareGhostDispersal: number;
  144389. /**
  144390. * Main lens flare halo width
  144391. */
  144392. lensFlareHaloWidth: number;
  144393. /**
  144394. * Based on the lens distortion effect, defines how much the lens flare result
  144395. * is distorted
  144396. */
  144397. lensFlareDistortionStrength: number;
  144398. /**
  144399. * Configures the blur intensity used for for lens flare (halo)
  144400. */
  144401. lensFlareBlurWidth: number;
  144402. /**
  144403. * Lens star texture must be used to simulate rays on the flares and is available
  144404. * in the documentation
  144405. */
  144406. lensStarTexture: Nullable<Texture>;
  144407. /**
  144408. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  144409. * flare effect by taking account of the dirt texture
  144410. */
  144411. lensFlareDirtTexture: Nullable<Texture>;
  144412. /**
  144413. * Represents the focal length for the depth of field effect
  144414. */
  144415. depthOfFieldDistance: number;
  144416. /**
  144417. * Represents the blur intensity for the blurred part of the depth of field effect
  144418. */
  144419. depthOfFieldBlurWidth: number;
  144420. /**
  144421. * Gets how much the image is blurred by the movement while using the motion blur post-process
  144422. */
  144423. get motionStrength(): number;
  144424. /**
  144425. * Sets how much the image is blurred by the movement while using the motion blur post-process
  144426. */
  144427. set motionStrength(strength: number);
  144428. /**
  144429. * Gets wether or not the motion blur post-process is object based or screen based.
  144430. */
  144431. get objectBasedMotionBlur(): boolean;
  144432. /**
  144433. * Sets wether or not the motion blur post-process should be object based or screen based
  144434. */
  144435. set objectBasedMotionBlur(value: boolean);
  144436. /**
  144437. * List of animations for the pipeline (IAnimatable implementation)
  144438. */
  144439. animations: Animation[];
  144440. /**
  144441. * Private members
  144442. */
  144443. private _scene;
  144444. private _currentDepthOfFieldSource;
  144445. private _basePostProcess;
  144446. private _fixedExposure;
  144447. private _currentExposure;
  144448. private _hdrAutoExposure;
  144449. private _hdrCurrentLuminance;
  144450. private _motionStrength;
  144451. private _isObjectBasedMotionBlur;
  144452. private _floatTextureType;
  144453. private _camerasToBeAttached;
  144454. private _ratio;
  144455. private _bloomEnabled;
  144456. private _depthOfFieldEnabled;
  144457. private _vlsEnabled;
  144458. private _lensFlareEnabled;
  144459. private _hdrEnabled;
  144460. private _motionBlurEnabled;
  144461. private _fxaaEnabled;
  144462. private _screenSpaceReflectionsEnabled;
  144463. private _motionBlurSamples;
  144464. private _volumetricLightStepsCount;
  144465. private _samples;
  144466. /**
  144467. * @ignore
  144468. * Specifies if the bloom pipeline is enabled
  144469. */
  144470. get BloomEnabled(): boolean;
  144471. set BloomEnabled(enabled: boolean);
  144472. /**
  144473. * @ignore
  144474. * Specifies if the depth of field pipeline is enabed
  144475. */
  144476. get DepthOfFieldEnabled(): boolean;
  144477. set DepthOfFieldEnabled(enabled: boolean);
  144478. /**
  144479. * @ignore
  144480. * Specifies if the lens flare pipeline is enabed
  144481. */
  144482. get LensFlareEnabled(): boolean;
  144483. set LensFlareEnabled(enabled: boolean);
  144484. /**
  144485. * @ignore
  144486. * Specifies if the HDR pipeline is enabled
  144487. */
  144488. get HDREnabled(): boolean;
  144489. set HDREnabled(enabled: boolean);
  144490. /**
  144491. * @ignore
  144492. * Specifies if the volumetric lights scattering effect is enabled
  144493. */
  144494. get VLSEnabled(): boolean;
  144495. set VLSEnabled(enabled: boolean);
  144496. /**
  144497. * @ignore
  144498. * Specifies if the motion blur effect is enabled
  144499. */
  144500. get MotionBlurEnabled(): boolean;
  144501. set MotionBlurEnabled(enabled: boolean);
  144502. /**
  144503. * Specifies if anti-aliasing is enabled
  144504. */
  144505. get fxaaEnabled(): boolean;
  144506. set fxaaEnabled(enabled: boolean);
  144507. /**
  144508. * Specifies if screen space reflections are enabled.
  144509. */
  144510. get screenSpaceReflectionsEnabled(): boolean;
  144511. set screenSpaceReflectionsEnabled(enabled: boolean);
  144512. /**
  144513. * Specifies the number of steps used to calculate the volumetric lights
  144514. * Typically in interval [50, 200]
  144515. */
  144516. get volumetricLightStepsCount(): number;
  144517. set volumetricLightStepsCount(count: number);
  144518. /**
  144519. * Specifies the number of samples used for the motion blur effect
  144520. * Typically in interval [16, 64]
  144521. */
  144522. get motionBlurSamples(): number;
  144523. set motionBlurSamples(samples: number);
  144524. /**
  144525. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  144526. */
  144527. get samples(): number;
  144528. set samples(sampleCount: number);
  144529. /**
  144530. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144531. * @constructor
  144532. * @param name The rendering pipeline name
  144533. * @param scene The scene linked to this pipeline
  144534. * @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)
  144535. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  144536. * @param cameras The array of cameras that the rendering pipeline will be attached to
  144537. */
  144538. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  144539. private _buildPipeline;
  144540. private _createDownSampleX4PostProcess;
  144541. private _createBrightPassPostProcess;
  144542. private _createBlurPostProcesses;
  144543. private _createTextureAdderPostProcess;
  144544. private _createVolumetricLightPostProcess;
  144545. private _createLuminancePostProcesses;
  144546. private _createHdrPostProcess;
  144547. private _createLensFlarePostProcess;
  144548. private _createDepthOfFieldPostProcess;
  144549. private _createMotionBlurPostProcess;
  144550. private _getDepthTexture;
  144551. private _disposePostProcesses;
  144552. /**
  144553. * Dispose of the pipeline and stop all post processes
  144554. */
  144555. dispose(): void;
  144556. /**
  144557. * Serialize the rendering pipeline (Used when exporting)
  144558. * @returns the serialized object
  144559. */
  144560. serialize(): any;
  144561. /**
  144562. * Parse the serialized pipeline
  144563. * @param source Source pipeline.
  144564. * @param scene The scene to load the pipeline to.
  144565. * @param rootUrl The URL of the serialized pipeline.
  144566. * @returns An instantiated pipeline from the serialized object.
  144567. */
  144568. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  144569. /**
  144570. * Luminance steps
  144571. */
  144572. static LuminanceSteps: number;
  144573. }
  144574. }
  144575. declare module BABYLON {
  144576. /** @hidden */
  144577. export var stereoscopicInterlacePixelShader: {
  144578. name: string;
  144579. shader: string;
  144580. };
  144581. }
  144582. declare module BABYLON {
  144583. /**
  144584. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  144585. */
  144586. export class StereoscopicInterlacePostProcessI extends PostProcess {
  144587. private _stepSize;
  144588. private _passedProcess;
  144589. /**
  144590. * Initializes a StereoscopicInterlacePostProcessI
  144591. * @param name The name of the effect.
  144592. * @param rigCameras The rig cameras to be appled to the post process
  144593. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  144594. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  144595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144596. * @param engine The engine which the post process will be applied. (default: current engine)
  144597. * @param reusable If the post process can be reused on the same frame. (default: false)
  144598. */
  144599. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144600. }
  144601. /**
  144602. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  144603. */
  144604. export class StereoscopicInterlacePostProcess extends PostProcess {
  144605. private _stepSize;
  144606. private _passedProcess;
  144607. /**
  144608. * Initializes a StereoscopicInterlacePostProcess
  144609. * @param name The name of the effect.
  144610. * @param rigCameras The rig cameras to be appled to the post process
  144611. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  144612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144613. * @param engine The engine which the post process will be applied. (default: current engine)
  144614. * @param reusable If the post process can be reused on the same frame. (default: false)
  144615. */
  144616. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144617. }
  144618. }
  144619. declare module BABYLON {
  144620. /** @hidden */
  144621. export var tonemapPixelShader: {
  144622. name: string;
  144623. shader: string;
  144624. };
  144625. }
  144626. declare module BABYLON {
  144627. /** Defines operator used for tonemapping */
  144628. export enum TonemappingOperator {
  144629. /** Hable */
  144630. Hable = 0,
  144631. /** Reinhard */
  144632. Reinhard = 1,
  144633. /** HejiDawson */
  144634. HejiDawson = 2,
  144635. /** Photographic */
  144636. Photographic = 3
  144637. }
  144638. /**
  144639. * Defines a post process to apply tone mapping
  144640. */
  144641. export class TonemapPostProcess extends PostProcess {
  144642. private _operator;
  144643. /** Defines the required exposure adjustement */
  144644. exposureAdjustment: number;
  144645. /**
  144646. * Creates a new TonemapPostProcess
  144647. * @param name defines the name of the postprocess
  144648. * @param _operator defines the operator to use
  144649. * @param exposureAdjustment defines the required exposure adjustement
  144650. * @param camera defines the camera to use (can be null)
  144651. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  144652. * @param engine defines the hosting engine (can be ignore if camera is set)
  144653. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144654. */
  144655. constructor(name: string, _operator: TonemappingOperator,
  144656. /** Defines the required exposure adjustement */
  144657. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  144658. }
  144659. }
  144660. declare module BABYLON {
  144661. /** @hidden */
  144662. export var volumetricLightScatteringPixelShader: {
  144663. name: string;
  144664. shader: string;
  144665. };
  144666. }
  144667. declare module BABYLON {
  144668. /** @hidden */
  144669. export var volumetricLightScatteringPassVertexShader: {
  144670. name: string;
  144671. shader: string;
  144672. };
  144673. }
  144674. declare module BABYLON {
  144675. /** @hidden */
  144676. export var volumetricLightScatteringPassPixelShader: {
  144677. name: string;
  144678. shader: string;
  144679. };
  144680. }
  144681. declare module BABYLON {
  144682. /**
  144683. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  144684. */
  144685. export class VolumetricLightScatteringPostProcess extends PostProcess {
  144686. private _volumetricLightScatteringPass;
  144687. private _volumetricLightScatteringRTT;
  144688. private _viewPort;
  144689. private _screenCoordinates;
  144690. private _cachedDefines;
  144691. /**
  144692. * If not undefined, the mesh position is computed from the attached node position
  144693. */
  144694. attachedNode: {
  144695. position: Vector3;
  144696. };
  144697. /**
  144698. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  144699. */
  144700. customMeshPosition: Vector3;
  144701. /**
  144702. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  144703. */
  144704. useCustomMeshPosition: boolean;
  144705. /**
  144706. * If the post-process should inverse the light scattering direction
  144707. */
  144708. invert: boolean;
  144709. /**
  144710. * The internal mesh used by the post-process
  144711. */
  144712. mesh: Mesh;
  144713. /**
  144714. * @hidden
  144715. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  144716. */
  144717. get useDiffuseColor(): boolean;
  144718. set useDiffuseColor(useDiffuseColor: boolean);
  144719. /**
  144720. * Array containing the excluded meshes not rendered in the internal pass
  144721. */
  144722. excludedMeshes: AbstractMesh[];
  144723. /**
  144724. * Controls the overall intensity of the post-process
  144725. */
  144726. exposure: number;
  144727. /**
  144728. * Dissipates each sample's contribution in range [0, 1]
  144729. */
  144730. decay: number;
  144731. /**
  144732. * Controls the overall intensity of each sample
  144733. */
  144734. weight: number;
  144735. /**
  144736. * Controls the density of each sample
  144737. */
  144738. density: number;
  144739. /**
  144740. * @constructor
  144741. * @param name The post-process name
  144742. * @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)
  144743. * @param camera The camera that the post-process will be attached to
  144744. * @param mesh The mesh used to create the light scattering
  144745. * @param samples The post-process quality, default 100
  144746. * @param samplingModeThe post-process filtering mode
  144747. * @param engine The babylon engine
  144748. * @param reusable If the post-process is reusable
  144749. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  144750. */
  144751. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  144752. /**
  144753. * Returns the string "VolumetricLightScatteringPostProcess"
  144754. * @returns "VolumetricLightScatteringPostProcess"
  144755. */
  144756. getClassName(): string;
  144757. private _isReady;
  144758. /**
  144759. * Sets the new light position for light scattering effect
  144760. * @param position The new custom light position
  144761. */
  144762. setCustomMeshPosition(position: Vector3): void;
  144763. /**
  144764. * Returns the light position for light scattering effect
  144765. * @return Vector3 The custom light position
  144766. */
  144767. getCustomMeshPosition(): Vector3;
  144768. /**
  144769. * Disposes the internal assets and detaches the post-process from the camera
  144770. */
  144771. dispose(camera: Camera): void;
  144772. /**
  144773. * Returns the render target texture used by the post-process
  144774. * @return the render target texture used by the post-process
  144775. */
  144776. getPass(): RenderTargetTexture;
  144777. private _meshExcluded;
  144778. private _createPass;
  144779. private _updateMeshScreenCoordinates;
  144780. /**
  144781. * Creates a default mesh for the Volumeric Light Scattering post-process
  144782. * @param name The mesh name
  144783. * @param scene The scene where to create the mesh
  144784. * @return the default mesh
  144785. */
  144786. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  144787. }
  144788. }
  144789. declare module BABYLON {
  144790. interface Scene {
  144791. /** @hidden (Backing field) */
  144792. _boundingBoxRenderer: BoundingBoxRenderer;
  144793. /** @hidden (Backing field) */
  144794. _forceShowBoundingBoxes: boolean;
  144795. /**
  144796. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  144797. */
  144798. forceShowBoundingBoxes: boolean;
  144799. /**
  144800. * Gets the bounding box renderer associated with the scene
  144801. * @returns a BoundingBoxRenderer
  144802. */
  144803. getBoundingBoxRenderer(): BoundingBoxRenderer;
  144804. }
  144805. interface AbstractMesh {
  144806. /** @hidden (Backing field) */
  144807. _showBoundingBox: boolean;
  144808. /**
  144809. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  144810. */
  144811. showBoundingBox: boolean;
  144812. }
  144813. /**
  144814. * Component responsible of rendering the bounding box of the meshes in a scene.
  144815. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  144816. */
  144817. export class BoundingBoxRenderer implements ISceneComponent {
  144818. /**
  144819. * The component name helpfull to identify the component in the list of scene components.
  144820. */
  144821. readonly name: string;
  144822. /**
  144823. * The scene the component belongs to.
  144824. */
  144825. scene: Scene;
  144826. /**
  144827. * Color of the bounding box lines placed in front of an object
  144828. */
  144829. frontColor: Color3;
  144830. /**
  144831. * Color of the bounding box lines placed behind an object
  144832. */
  144833. backColor: Color3;
  144834. /**
  144835. * Defines if the renderer should show the back lines or not
  144836. */
  144837. showBackLines: boolean;
  144838. /**
  144839. * @hidden
  144840. */
  144841. renderList: SmartArray<BoundingBox>;
  144842. private _colorShader;
  144843. private _vertexBuffers;
  144844. private _indexBuffer;
  144845. private _fillIndexBuffer;
  144846. private _fillIndexData;
  144847. /**
  144848. * Instantiates a new bounding box renderer in a scene.
  144849. * @param scene the scene the renderer renders in
  144850. */
  144851. constructor(scene: Scene);
  144852. /**
  144853. * Registers the component in a given scene
  144854. */
  144855. register(): void;
  144856. private _evaluateSubMesh;
  144857. private _activeMesh;
  144858. private _prepareRessources;
  144859. private _createIndexBuffer;
  144860. /**
  144861. * Rebuilds the elements related to this component in case of
  144862. * context lost for instance.
  144863. */
  144864. rebuild(): void;
  144865. /**
  144866. * @hidden
  144867. */
  144868. reset(): void;
  144869. /**
  144870. * Render the bounding boxes of a specific rendering group
  144871. * @param renderingGroupId defines the rendering group to render
  144872. */
  144873. render(renderingGroupId: number): void;
  144874. /**
  144875. * In case of occlusion queries, we can render the occlusion bounding box through this method
  144876. * @param mesh Define the mesh to render the occlusion bounding box for
  144877. */
  144878. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  144879. /**
  144880. * Dispose and release the resources attached to this renderer.
  144881. */
  144882. dispose(): void;
  144883. }
  144884. }
  144885. declare module BABYLON {
  144886. interface Scene {
  144887. /** @hidden (Backing field) */
  144888. _depthRenderer: {
  144889. [id: string]: DepthRenderer;
  144890. };
  144891. /**
  144892. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  144893. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  144894. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  144895. * @returns the created depth renderer
  144896. */
  144897. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  144898. /**
  144899. * Disables a depth renderer for a given camera
  144900. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  144901. */
  144902. disableDepthRenderer(camera?: Nullable<Camera>): void;
  144903. }
  144904. /**
  144905. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  144906. * in several rendering techniques.
  144907. */
  144908. export class DepthRendererSceneComponent implements ISceneComponent {
  144909. /**
  144910. * The component name helpfull to identify the component in the list of scene components.
  144911. */
  144912. readonly name: string;
  144913. /**
  144914. * The scene the component belongs to.
  144915. */
  144916. scene: Scene;
  144917. /**
  144918. * Creates a new instance of the component for the given scene
  144919. * @param scene Defines the scene to register the component in
  144920. */
  144921. constructor(scene: Scene);
  144922. /**
  144923. * Registers the component in a given scene
  144924. */
  144925. register(): void;
  144926. /**
  144927. * Rebuilds the elements related to this component in case of
  144928. * context lost for instance.
  144929. */
  144930. rebuild(): void;
  144931. /**
  144932. * Disposes the component and the associated ressources
  144933. */
  144934. dispose(): void;
  144935. private _gatherRenderTargets;
  144936. private _gatherActiveCameraRenderTargets;
  144937. }
  144938. }
  144939. declare module BABYLON {
  144940. /** @hidden */
  144941. export var outlinePixelShader: {
  144942. name: string;
  144943. shader: string;
  144944. };
  144945. }
  144946. declare module BABYLON {
  144947. /** @hidden */
  144948. export var outlineVertexShader: {
  144949. name: string;
  144950. shader: string;
  144951. };
  144952. }
  144953. declare module BABYLON {
  144954. interface Scene {
  144955. /** @hidden */
  144956. _outlineRenderer: OutlineRenderer;
  144957. /**
  144958. * Gets the outline renderer associated with the scene
  144959. * @returns a OutlineRenderer
  144960. */
  144961. getOutlineRenderer(): OutlineRenderer;
  144962. }
  144963. interface AbstractMesh {
  144964. /** @hidden (Backing field) */
  144965. _renderOutline: boolean;
  144966. /**
  144967. * Gets or sets a boolean indicating if the outline must be rendered as well
  144968. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  144969. */
  144970. renderOutline: boolean;
  144971. /** @hidden (Backing field) */
  144972. _renderOverlay: boolean;
  144973. /**
  144974. * Gets or sets a boolean indicating if the overlay must be rendered as well
  144975. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  144976. */
  144977. renderOverlay: boolean;
  144978. }
  144979. /**
  144980. * This class is responsible to draw bothe outline/overlay of meshes.
  144981. * It should not be used directly but through the available method on mesh.
  144982. */
  144983. export class OutlineRenderer implements ISceneComponent {
  144984. /**
  144985. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  144986. */
  144987. private static _StencilReference;
  144988. /**
  144989. * The name of the component. Each component must have a unique name.
  144990. */
  144991. name: string;
  144992. /**
  144993. * The scene the component belongs to.
  144994. */
  144995. scene: Scene;
  144996. /**
  144997. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  144998. */
  144999. zOffset: number;
  145000. private _engine;
  145001. private _effect;
  145002. private _cachedDefines;
  145003. private _savedDepthWrite;
  145004. /**
  145005. * Instantiates a new outline renderer. (There could be only one per scene).
  145006. * @param scene Defines the scene it belongs to
  145007. */
  145008. constructor(scene: Scene);
  145009. /**
  145010. * Register the component to one instance of a scene.
  145011. */
  145012. register(): void;
  145013. /**
  145014. * Rebuilds the elements related to this component in case of
  145015. * context lost for instance.
  145016. */
  145017. rebuild(): void;
  145018. /**
  145019. * Disposes the component and the associated ressources.
  145020. */
  145021. dispose(): void;
  145022. /**
  145023. * Renders the outline in the canvas.
  145024. * @param subMesh Defines the sumesh to render
  145025. * @param batch Defines the batch of meshes in case of instances
  145026. * @param useOverlay Defines if the rendering is for the overlay or the outline
  145027. */
  145028. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  145029. /**
  145030. * Returns whether or not the outline renderer is ready for a given submesh.
  145031. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  145032. * @param subMesh Defines the submesh to check readyness for
  145033. * @param useInstances Defines wheter wee are trying to render instances or not
  145034. * @returns true if ready otherwise false
  145035. */
  145036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  145037. private _beforeRenderingMesh;
  145038. private _afterRenderingMesh;
  145039. }
  145040. }
  145041. declare module BABYLON {
  145042. /**
  145043. * Defines the basic options interface of a Sprite Frame Source Size.
  145044. */
  145045. export interface ISpriteJSONSpriteSourceSize {
  145046. /**
  145047. * number of the original width of the Frame
  145048. */
  145049. w: number;
  145050. /**
  145051. * number of the original height of the Frame
  145052. */
  145053. h: number;
  145054. }
  145055. /**
  145056. * Defines the basic options interface of a Sprite Frame Data.
  145057. */
  145058. export interface ISpriteJSONSpriteFrameData {
  145059. /**
  145060. * number of the x offset of the Frame
  145061. */
  145062. x: number;
  145063. /**
  145064. * number of the y offset of the Frame
  145065. */
  145066. y: number;
  145067. /**
  145068. * number of the width of the Frame
  145069. */
  145070. w: number;
  145071. /**
  145072. * number of the height of the Frame
  145073. */
  145074. h: number;
  145075. }
  145076. /**
  145077. * Defines the basic options interface of a JSON Sprite.
  145078. */
  145079. export interface ISpriteJSONSprite {
  145080. /**
  145081. * string name of the Frame
  145082. */
  145083. filename: string;
  145084. /**
  145085. * ISpriteJSONSpriteFrame basic object of the frame data
  145086. */
  145087. frame: ISpriteJSONSpriteFrameData;
  145088. /**
  145089. * boolean to flag is the frame was rotated.
  145090. */
  145091. rotated: boolean;
  145092. /**
  145093. * boolean to flag is the frame was trimmed.
  145094. */
  145095. trimmed: boolean;
  145096. /**
  145097. * ISpriteJSONSpriteFrame basic object of the source data
  145098. */
  145099. spriteSourceSize: ISpriteJSONSpriteFrameData;
  145100. /**
  145101. * ISpriteJSONSpriteFrame basic object of the source data
  145102. */
  145103. sourceSize: ISpriteJSONSpriteSourceSize;
  145104. }
  145105. /**
  145106. * Defines the basic options interface of a JSON atlas.
  145107. */
  145108. export interface ISpriteJSONAtlas {
  145109. /**
  145110. * Array of objects that contain the frame data.
  145111. */
  145112. frames: Array<ISpriteJSONSprite>;
  145113. /**
  145114. * object basic object containing the sprite meta data.
  145115. */
  145116. meta?: object;
  145117. }
  145118. }
  145119. declare module BABYLON {
  145120. /** @hidden */
  145121. export var spriteMapPixelShader: {
  145122. name: string;
  145123. shader: string;
  145124. };
  145125. }
  145126. declare module BABYLON {
  145127. /** @hidden */
  145128. export var spriteMapVertexShader: {
  145129. name: string;
  145130. shader: string;
  145131. };
  145132. }
  145133. declare module BABYLON {
  145134. /**
  145135. * Defines the basic options interface of a SpriteMap
  145136. */
  145137. export interface ISpriteMapOptions {
  145138. /**
  145139. * Vector2 of the number of cells in the grid.
  145140. */
  145141. stageSize?: Vector2;
  145142. /**
  145143. * Vector2 of the size of the output plane in World Units.
  145144. */
  145145. outputSize?: Vector2;
  145146. /**
  145147. * Vector3 of the position of the output plane in World Units.
  145148. */
  145149. outputPosition?: Vector3;
  145150. /**
  145151. * Vector3 of the rotation of the output plane.
  145152. */
  145153. outputRotation?: Vector3;
  145154. /**
  145155. * number of layers that the system will reserve in resources.
  145156. */
  145157. layerCount?: number;
  145158. /**
  145159. * number of max animation frames a single cell will reserve in resources.
  145160. */
  145161. maxAnimationFrames?: number;
  145162. /**
  145163. * number cell index of the base tile when the system compiles.
  145164. */
  145165. baseTile?: number;
  145166. /**
  145167. * boolean flip the sprite after its been repositioned by the framing data.
  145168. */
  145169. flipU?: boolean;
  145170. /**
  145171. * Vector3 scalar of the global RGB values of the SpriteMap.
  145172. */
  145173. colorMultiply?: Vector3;
  145174. }
  145175. /**
  145176. * Defines the IDisposable interface in order to be cleanable from resources.
  145177. */
  145178. export interface ISpriteMap extends IDisposable {
  145179. /**
  145180. * String name of the SpriteMap.
  145181. */
  145182. name: string;
  145183. /**
  145184. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  145185. */
  145186. atlasJSON: ISpriteJSONAtlas;
  145187. /**
  145188. * Texture of the SpriteMap.
  145189. */
  145190. spriteSheet: Texture;
  145191. /**
  145192. * The parameters to initialize the SpriteMap with.
  145193. */
  145194. options: ISpriteMapOptions;
  145195. }
  145196. /**
  145197. * Class used to manage a grid restricted sprite deployment on an Output plane.
  145198. */
  145199. export class SpriteMap implements ISpriteMap {
  145200. /** The Name of the spriteMap */
  145201. name: string;
  145202. /** The JSON file with the frame and meta data */
  145203. atlasJSON: ISpriteJSONAtlas;
  145204. /** The systems Sprite Sheet Texture */
  145205. spriteSheet: Texture;
  145206. /** Arguments passed with the Constructor */
  145207. options: ISpriteMapOptions;
  145208. /** Public Sprite Storage array, parsed from atlasJSON */
  145209. sprites: Array<ISpriteJSONSprite>;
  145210. /** Returns the Number of Sprites in the System */
  145211. get spriteCount(): number;
  145212. /** Returns the Position of Output Plane*/
  145213. get position(): Vector3;
  145214. /** Returns the Position of Output Plane*/
  145215. set position(v: Vector3);
  145216. /** Returns the Rotation of Output Plane*/
  145217. get rotation(): Vector3;
  145218. /** Returns the Rotation of Output Plane*/
  145219. set rotation(v: Vector3);
  145220. /** Sets the AnimationMap*/
  145221. get animationMap(): RawTexture;
  145222. /** Sets the AnimationMap*/
  145223. set animationMap(v: RawTexture);
  145224. /** Scene that the SpriteMap was created in */
  145225. private _scene;
  145226. /** Texture Buffer of Float32 that holds tile frame data*/
  145227. private _frameMap;
  145228. /** Texture Buffers of Float32 that holds tileMap data*/
  145229. private _tileMaps;
  145230. /** Texture Buffer of Float32 that holds Animation Data*/
  145231. private _animationMap;
  145232. /** Custom ShaderMaterial Central to the System*/
  145233. private _material;
  145234. /** Custom ShaderMaterial Central to the System*/
  145235. private _output;
  145236. /** Systems Time Ticker*/
  145237. private _time;
  145238. /**
  145239. * Creates a new SpriteMap
  145240. * @param name defines the SpriteMaps Name
  145241. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  145242. * @param spriteSheet is the Texture that the Sprites are on.
  145243. * @param options a basic deployment configuration
  145244. * @param scene The Scene that the map is deployed on
  145245. */
  145246. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  145247. /**
  145248. * Returns tileID location
  145249. * @returns Vector2 the cell position ID
  145250. */
  145251. getTileID(): Vector2;
  145252. /**
  145253. * Gets the UV location of the mouse over the SpriteMap.
  145254. * @returns Vector2 the UV position of the mouse interaction
  145255. */
  145256. getMousePosition(): Vector2;
  145257. /**
  145258. * Creates the "frame" texture Buffer
  145259. * -------------------------------------
  145260. * Structure of frames
  145261. * "filename": "Falling-Water-2.png",
  145262. * "frame": {"x":69,"y":103,"w":24,"h":32},
  145263. * "rotated": true,
  145264. * "trimmed": true,
  145265. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  145266. * "sourceSize": {"w":32,"h":32}
  145267. * @returns RawTexture of the frameMap
  145268. */
  145269. private _createFrameBuffer;
  145270. /**
  145271. * Creates the tileMap texture Buffer
  145272. * @param buffer normally and array of numbers, or a false to generate from scratch
  145273. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  145274. * @returns RawTexture of the tileMap
  145275. */
  145276. private _createTileBuffer;
  145277. /**
  145278. * Modifies the data of the tileMaps
  145279. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  145280. * @param pos is the iVector2 Coordinates of the Tile
  145281. * @param tile The SpriteIndex of the new Tile
  145282. */
  145283. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  145284. /**
  145285. * Creates the animationMap texture Buffer
  145286. * @param buffer normally and array of numbers, or a false to generate from scratch
  145287. * @returns RawTexture of the animationMap
  145288. */
  145289. private _createTileAnimationBuffer;
  145290. /**
  145291. * Modifies the data of the animationMap
  145292. * @param cellID is the Index of the Sprite
  145293. * @param _frame is the target Animation frame
  145294. * @param toCell is the Target Index of the next frame of the animation
  145295. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  145296. * @param speed is a global scalar of the time variable on the map.
  145297. */
  145298. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  145299. /**
  145300. * Exports the .tilemaps file
  145301. */
  145302. saveTileMaps(): void;
  145303. /**
  145304. * Imports the .tilemaps file
  145305. * @param url of the .tilemaps file
  145306. */
  145307. loadTileMaps(url: string): void;
  145308. /**
  145309. * Release associated resources
  145310. */
  145311. dispose(): void;
  145312. }
  145313. }
  145314. declare module BABYLON {
  145315. /**
  145316. * Class used to manage multiple sprites of different sizes on the same spritesheet
  145317. * @see http://doc.babylonjs.com/babylon101/sprites
  145318. */
  145319. export class SpritePackedManager extends SpriteManager {
  145320. /** defines the packed manager's name */
  145321. name: string;
  145322. /**
  145323. * Creates a new sprite manager from a packed sprite sheet
  145324. * @param name defines the manager's name
  145325. * @param imgUrl defines the sprite sheet url
  145326. * @param capacity defines the maximum allowed number of sprites
  145327. * @param scene defines the hosting scene
  145328. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  145329. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  145330. * @param samplingMode defines the smapling mode to use with spritesheet
  145331. * @param fromPacked set to true; do not alter
  145332. */
  145333. constructor(
  145334. /** defines the packed manager's name */
  145335. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  145336. }
  145337. }
  145338. declare module BABYLON {
  145339. /**
  145340. * Defines the list of states available for a task inside a AssetsManager
  145341. */
  145342. export enum AssetTaskState {
  145343. /**
  145344. * Initialization
  145345. */
  145346. INIT = 0,
  145347. /**
  145348. * Running
  145349. */
  145350. RUNNING = 1,
  145351. /**
  145352. * Done
  145353. */
  145354. DONE = 2,
  145355. /**
  145356. * Error
  145357. */
  145358. ERROR = 3
  145359. }
  145360. /**
  145361. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  145362. */
  145363. export abstract class AbstractAssetTask {
  145364. /**
  145365. * Task name
  145366. */ name: string;
  145367. /**
  145368. * Callback called when the task is successful
  145369. */
  145370. onSuccess: (task: any) => void;
  145371. /**
  145372. * Callback called when the task is not successful
  145373. */
  145374. onError: (task: any, message?: string, exception?: any) => void;
  145375. /**
  145376. * Creates a new AssetsManager
  145377. * @param name defines the name of the task
  145378. */
  145379. constructor(
  145380. /**
  145381. * Task name
  145382. */ name: string);
  145383. private _isCompleted;
  145384. private _taskState;
  145385. private _errorObject;
  145386. /**
  145387. * Get if the task is completed
  145388. */
  145389. get isCompleted(): boolean;
  145390. /**
  145391. * Gets the current state of the task
  145392. */
  145393. get taskState(): AssetTaskState;
  145394. /**
  145395. * Gets the current error object (if task is in error)
  145396. */
  145397. get errorObject(): {
  145398. message?: string;
  145399. exception?: any;
  145400. };
  145401. /**
  145402. * Internal only
  145403. * @hidden
  145404. */
  145405. _setErrorObject(message?: string, exception?: any): void;
  145406. /**
  145407. * Execute the current task
  145408. * @param scene defines the scene where you want your assets to be loaded
  145409. * @param onSuccess is a callback called when the task is successfully executed
  145410. * @param onError is a callback called if an error occurs
  145411. */
  145412. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145413. /**
  145414. * Execute the current task
  145415. * @param scene defines the scene where you want your assets to be loaded
  145416. * @param onSuccess is a callback called when the task is successfully executed
  145417. * @param onError is a callback called if an error occurs
  145418. */
  145419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145420. /**
  145421. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  145422. * This can be used with failed tasks that have the reason for failure fixed.
  145423. */
  145424. reset(): void;
  145425. private onErrorCallback;
  145426. private onDoneCallback;
  145427. }
  145428. /**
  145429. * Define the interface used by progress events raised during assets loading
  145430. */
  145431. export interface IAssetsProgressEvent {
  145432. /**
  145433. * Defines the number of remaining tasks to process
  145434. */
  145435. remainingCount: number;
  145436. /**
  145437. * Defines the total number of tasks
  145438. */
  145439. totalCount: number;
  145440. /**
  145441. * Defines the task that was just processed
  145442. */
  145443. task: AbstractAssetTask;
  145444. }
  145445. /**
  145446. * Class used to share progress information about assets loading
  145447. */
  145448. export class AssetsProgressEvent implements IAssetsProgressEvent {
  145449. /**
  145450. * Defines the number of remaining tasks to process
  145451. */
  145452. remainingCount: number;
  145453. /**
  145454. * Defines the total number of tasks
  145455. */
  145456. totalCount: number;
  145457. /**
  145458. * Defines the task that was just processed
  145459. */
  145460. task: AbstractAssetTask;
  145461. /**
  145462. * Creates a AssetsProgressEvent
  145463. * @param remainingCount defines the number of remaining tasks to process
  145464. * @param totalCount defines the total number of tasks
  145465. * @param task defines the task that was just processed
  145466. */
  145467. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  145468. }
  145469. /**
  145470. * Define a task used by AssetsManager to load meshes
  145471. */
  145472. export class MeshAssetTask extends AbstractAssetTask {
  145473. /**
  145474. * Defines the name of the task
  145475. */
  145476. name: string;
  145477. /**
  145478. * Defines the list of mesh's names you want to load
  145479. */
  145480. meshesNames: any;
  145481. /**
  145482. * Defines the root url to use as a base to load your meshes and associated resources
  145483. */
  145484. rootUrl: string;
  145485. /**
  145486. * Defines the filename or File of the scene to load from
  145487. */
  145488. sceneFilename: string | File;
  145489. /**
  145490. * Gets the list of loaded meshes
  145491. */
  145492. loadedMeshes: Array<AbstractMesh>;
  145493. /**
  145494. * Gets the list of loaded particle systems
  145495. */
  145496. loadedParticleSystems: Array<IParticleSystem>;
  145497. /**
  145498. * Gets the list of loaded skeletons
  145499. */
  145500. loadedSkeletons: Array<Skeleton>;
  145501. /**
  145502. * Gets the list of loaded animation groups
  145503. */
  145504. loadedAnimationGroups: Array<AnimationGroup>;
  145505. /**
  145506. * Callback called when the task is successful
  145507. */
  145508. onSuccess: (task: MeshAssetTask) => void;
  145509. /**
  145510. * Callback called when the task is successful
  145511. */
  145512. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  145513. /**
  145514. * Creates a new MeshAssetTask
  145515. * @param name defines the name of the task
  145516. * @param meshesNames defines the list of mesh's names you want to load
  145517. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  145518. * @param sceneFilename defines the filename or File of the scene to load from
  145519. */
  145520. constructor(
  145521. /**
  145522. * Defines the name of the task
  145523. */
  145524. name: string,
  145525. /**
  145526. * Defines the list of mesh's names you want to load
  145527. */
  145528. meshesNames: any,
  145529. /**
  145530. * Defines the root url to use as a base to load your meshes and associated resources
  145531. */
  145532. rootUrl: string,
  145533. /**
  145534. * Defines the filename or File of the scene to load from
  145535. */
  145536. sceneFilename: string | File);
  145537. /**
  145538. * Execute the current task
  145539. * @param scene defines the scene where you want your assets to be loaded
  145540. * @param onSuccess is a callback called when the task is successfully executed
  145541. * @param onError is a callback called if an error occurs
  145542. */
  145543. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145544. }
  145545. /**
  145546. * Define a task used by AssetsManager to load text content
  145547. */
  145548. export class TextFileAssetTask extends AbstractAssetTask {
  145549. /**
  145550. * Defines the name of the task
  145551. */
  145552. name: string;
  145553. /**
  145554. * Defines the location of the file to load
  145555. */
  145556. url: string;
  145557. /**
  145558. * Gets the loaded text string
  145559. */
  145560. text: string;
  145561. /**
  145562. * Callback called when the task is successful
  145563. */
  145564. onSuccess: (task: TextFileAssetTask) => void;
  145565. /**
  145566. * Callback called when the task is successful
  145567. */
  145568. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  145569. /**
  145570. * Creates a new TextFileAssetTask object
  145571. * @param name defines the name of the task
  145572. * @param url defines the location of the file to load
  145573. */
  145574. constructor(
  145575. /**
  145576. * Defines the name of the task
  145577. */
  145578. name: string,
  145579. /**
  145580. * Defines the location of the file to load
  145581. */
  145582. url: string);
  145583. /**
  145584. * Execute the current task
  145585. * @param scene defines the scene where you want your assets to be loaded
  145586. * @param onSuccess is a callback called when the task is successfully executed
  145587. * @param onError is a callback called if an error occurs
  145588. */
  145589. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145590. }
  145591. /**
  145592. * Define a task used by AssetsManager to load binary data
  145593. */
  145594. export class BinaryFileAssetTask extends AbstractAssetTask {
  145595. /**
  145596. * Defines the name of the task
  145597. */
  145598. name: string;
  145599. /**
  145600. * Defines the location of the file to load
  145601. */
  145602. url: string;
  145603. /**
  145604. * Gets the lodaded data (as an array buffer)
  145605. */
  145606. data: ArrayBuffer;
  145607. /**
  145608. * Callback called when the task is successful
  145609. */
  145610. onSuccess: (task: BinaryFileAssetTask) => void;
  145611. /**
  145612. * Callback called when the task is successful
  145613. */
  145614. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  145615. /**
  145616. * Creates a new BinaryFileAssetTask object
  145617. * @param name defines the name of the new task
  145618. * @param url defines the location of the file to load
  145619. */
  145620. constructor(
  145621. /**
  145622. * Defines the name of the task
  145623. */
  145624. name: string,
  145625. /**
  145626. * Defines the location of the file to load
  145627. */
  145628. url: string);
  145629. /**
  145630. * Execute the current task
  145631. * @param scene defines the scene where you want your assets to be loaded
  145632. * @param onSuccess is a callback called when the task is successfully executed
  145633. * @param onError is a callback called if an error occurs
  145634. */
  145635. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145636. }
  145637. /**
  145638. * Define a task used by AssetsManager to load images
  145639. */
  145640. export class ImageAssetTask extends AbstractAssetTask {
  145641. /**
  145642. * Defines the name of the task
  145643. */
  145644. name: string;
  145645. /**
  145646. * Defines the location of the image to load
  145647. */
  145648. url: string;
  145649. /**
  145650. * Gets the loaded images
  145651. */
  145652. image: HTMLImageElement;
  145653. /**
  145654. * Callback called when the task is successful
  145655. */
  145656. onSuccess: (task: ImageAssetTask) => void;
  145657. /**
  145658. * Callback called when the task is successful
  145659. */
  145660. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  145661. /**
  145662. * Creates a new ImageAssetTask
  145663. * @param name defines the name of the task
  145664. * @param url defines the location of the image to load
  145665. */
  145666. constructor(
  145667. /**
  145668. * Defines the name of the task
  145669. */
  145670. name: string,
  145671. /**
  145672. * Defines the location of the image to load
  145673. */
  145674. url: string);
  145675. /**
  145676. * Execute the current task
  145677. * @param scene defines the scene where you want your assets to be loaded
  145678. * @param onSuccess is a callback called when the task is successfully executed
  145679. * @param onError is a callback called if an error occurs
  145680. */
  145681. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145682. }
  145683. /**
  145684. * Defines the interface used by texture loading tasks
  145685. */
  145686. export interface ITextureAssetTask<TEX extends BaseTexture> {
  145687. /**
  145688. * Gets the loaded texture
  145689. */
  145690. texture: TEX;
  145691. }
  145692. /**
  145693. * Define a task used by AssetsManager to load 2D textures
  145694. */
  145695. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  145696. /**
  145697. * Defines the name of the task
  145698. */
  145699. name: string;
  145700. /**
  145701. * Defines the location of the file to load
  145702. */
  145703. url: string;
  145704. /**
  145705. * Defines if mipmap should not be generated (default is false)
  145706. */
  145707. noMipmap?: boolean | undefined;
  145708. /**
  145709. * Defines if texture must be inverted on Y axis (default is true)
  145710. */
  145711. invertY: boolean;
  145712. /**
  145713. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145714. */
  145715. samplingMode: number;
  145716. /**
  145717. * Gets the loaded texture
  145718. */
  145719. texture: Texture;
  145720. /**
  145721. * Callback called when the task is successful
  145722. */
  145723. onSuccess: (task: TextureAssetTask) => void;
  145724. /**
  145725. * Callback called when the task is successful
  145726. */
  145727. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  145728. /**
  145729. * Creates a new TextureAssetTask object
  145730. * @param name defines the name of the task
  145731. * @param url defines the location of the file to load
  145732. * @param noMipmap defines if mipmap should not be generated (default is false)
  145733. * @param invertY defines if texture must be inverted on Y axis (default is true)
  145734. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145735. */
  145736. constructor(
  145737. /**
  145738. * Defines the name of the task
  145739. */
  145740. name: string,
  145741. /**
  145742. * Defines the location of the file to load
  145743. */
  145744. url: string,
  145745. /**
  145746. * Defines if mipmap should not be generated (default is false)
  145747. */
  145748. noMipmap?: boolean | undefined,
  145749. /**
  145750. * Defines if texture must be inverted on Y axis (default is true)
  145751. */
  145752. invertY?: boolean,
  145753. /**
  145754. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145755. */
  145756. samplingMode?: number);
  145757. /**
  145758. * Execute the current task
  145759. * @param scene defines the scene where you want your assets to be loaded
  145760. * @param onSuccess is a callback called when the task is successfully executed
  145761. * @param onError is a callback called if an error occurs
  145762. */
  145763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145764. }
  145765. /**
  145766. * Define a task used by AssetsManager to load cube textures
  145767. */
  145768. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  145769. /**
  145770. * Defines the name of the task
  145771. */
  145772. name: string;
  145773. /**
  145774. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145775. */
  145776. url: string;
  145777. /**
  145778. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145779. */
  145780. extensions?: string[] | undefined;
  145781. /**
  145782. * Defines if mipmaps should not be generated (default is false)
  145783. */
  145784. noMipmap?: boolean | undefined;
  145785. /**
  145786. * Defines the explicit list of files (undefined by default)
  145787. */
  145788. files?: string[] | undefined;
  145789. /**
  145790. * Gets the loaded texture
  145791. */
  145792. texture: CubeTexture;
  145793. /**
  145794. * Callback called when the task is successful
  145795. */
  145796. onSuccess: (task: CubeTextureAssetTask) => void;
  145797. /**
  145798. * Callback called when the task is successful
  145799. */
  145800. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  145801. /**
  145802. * Creates a new CubeTextureAssetTask
  145803. * @param name defines the name of the task
  145804. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145805. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145806. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145807. * @param files defines the explicit list of files (undefined by default)
  145808. */
  145809. constructor(
  145810. /**
  145811. * Defines the name of the task
  145812. */
  145813. name: string,
  145814. /**
  145815. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145816. */
  145817. url: string,
  145818. /**
  145819. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145820. */
  145821. extensions?: string[] | undefined,
  145822. /**
  145823. * Defines if mipmaps should not be generated (default is false)
  145824. */
  145825. noMipmap?: boolean | undefined,
  145826. /**
  145827. * Defines the explicit list of files (undefined by default)
  145828. */
  145829. files?: string[] | undefined);
  145830. /**
  145831. * Execute the current task
  145832. * @param scene defines the scene where you want your assets to be loaded
  145833. * @param onSuccess is a callback called when the task is successfully executed
  145834. * @param onError is a callback called if an error occurs
  145835. */
  145836. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145837. }
  145838. /**
  145839. * Define a task used by AssetsManager to load HDR cube textures
  145840. */
  145841. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  145842. /**
  145843. * Defines the name of the task
  145844. */
  145845. name: string;
  145846. /**
  145847. * Defines the location of the file to load
  145848. */
  145849. url: string;
  145850. /**
  145851. * Defines the desired size (the more it increases the longer the generation will be)
  145852. */
  145853. size: number;
  145854. /**
  145855. * Defines if mipmaps should not be generated (default is false)
  145856. */
  145857. noMipmap: boolean;
  145858. /**
  145859. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145860. */
  145861. generateHarmonics: boolean;
  145862. /**
  145863. * 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)
  145864. */
  145865. gammaSpace: boolean;
  145866. /**
  145867. * Internal Use Only
  145868. */
  145869. reserved: boolean;
  145870. /**
  145871. * Gets the loaded texture
  145872. */
  145873. texture: HDRCubeTexture;
  145874. /**
  145875. * Callback called when the task is successful
  145876. */
  145877. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  145878. /**
  145879. * Callback called when the task is successful
  145880. */
  145881. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  145882. /**
  145883. * Creates a new HDRCubeTextureAssetTask object
  145884. * @param name defines the name of the task
  145885. * @param url defines the location of the file to load
  145886. * @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.
  145887. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145888. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145889. * @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)
  145890. * @param reserved Internal use only
  145891. */
  145892. constructor(
  145893. /**
  145894. * Defines the name of the task
  145895. */
  145896. name: string,
  145897. /**
  145898. * Defines the location of the file to load
  145899. */
  145900. url: string,
  145901. /**
  145902. * Defines the desired size (the more it increases the longer the generation will be)
  145903. */
  145904. size: number,
  145905. /**
  145906. * Defines if mipmaps should not be generated (default is false)
  145907. */
  145908. noMipmap?: boolean,
  145909. /**
  145910. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145911. */
  145912. generateHarmonics?: boolean,
  145913. /**
  145914. * 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)
  145915. */
  145916. gammaSpace?: boolean,
  145917. /**
  145918. * Internal Use Only
  145919. */
  145920. reserved?: boolean);
  145921. /**
  145922. * Execute the current task
  145923. * @param scene defines the scene where you want your assets to be loaded
  145924. * @param onSuccess is a callback called when the task is successfully executed
  145925. * @param onError is a callback called if an error occurs
  145926. */
  145927. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145928. }
  145929. /**
  145930. * Define a task used by AssetsManager to load Equirectangular cube textures
  145931. */
  145932. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  145933. /**
  145934. * Defines the name of the task
  145935. */
  145936. name: string;
  145937. /**
  145938. * Defines the location of the file to load
  145939. */
  145940. url: string;
  145941. /**
  145942. * Defines the desired size (the more it increases the longer the generation will be)
  145943. */
  145944. size: number;
  145945. /**
  145946. * Defines if mipmaps should not be generated (default is false)
  145947. */
  145948. noMipmap: boolean;
  145949. /**
  145950. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145951. * but the standard material would require them in Gamma space) (default is true)
  145952. */
  145953. gammaSpace: boolean;
  145954. /**
  145955. * Gets the loaded texture
  145956. */
  145957. texture: EquiRectangularCubeTexture;
  145958. /**
  145959. * Callback called when the task is successful
  145960. */
  145961. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  145962. /**
  145963. * Callback called when the task is successful
  145964. */
  145965. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  145966. /**
  145967. * Creates a new EquiRectangularCubeTextureAssetTask object
  145968. * @param name defines the name of the task
  145969. * @param url defines the location of the file to load
  145970. * @param size defines the desired size (the more it increases the longer the generation will be)
  145971. * If the size is omitted this implies you are using a preprocessed cubemap.
  145972. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145973. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  145974. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  145975. * (default is true)
  145976. */
  145977. constructor(
  145978. /**
  145979. * Defines the name of the task
  145980. */
  145981. name: string,
  145982. /**
  145983. * Defines the location of the file to load
  145984. */
  145985. url: string,
  145986. /**
  145987. * Defines the desired size (the more it increases the longer the generation will be)
  145988. */
  145989. size: number,
  145990. /**
  145991. * Defines if mipmaps should not be generated (default is false)
  145992. */
  145993. noMipmap?: boolean,
  145994. /**
  145995. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145996. * but the standard material would require them in Gamma space) (default is true)
  145997. */
  145998. gammaSpace?: boolean);
  145999. /**
  146000. * Execute the current task
  146001. * @param scene defines the scene where you want your assets to be loaded
  146002. * @param onSuccess is a callback called when the task is successfully executed
  146003. * @param onError is a callback called if an error occurs
  146004. */
  146005. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  146006. }
  146007. /**
  146008. * This class can be used to easily import assets into a scene
  146009. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  146010. */
  146011. export class AssetsManager {
  146012. private _scene;
  146013. private _isLoading;
  146014. protected _tasks: AbstractAssetTask[];
  146015. protected _waitingTasksCount: number;
  146016. protected _totalTasksCount: number;
  146017. /**
  146018. * Callback called when all tasks are processed
  146019. */
  146020. onFinish: (tasks: AbstractAssetTask[]) => void;
  146021. /**
  146022. * Callback called when a task is successful
  146023. */
  146024. onTaskSuccess: (task: AbstractAssetTask) => void;
  146025. /**
  146026. * Callback called when a task had an error
  146027. */
  146028. onTaskError: (task: AbstractAssetTask) => void;
  146029. /**
  146030. * Callback called when a task is done (whatever the result is)
  146031. */
  146032. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  146033. /**
  146034. * Observable called when all tasks are processed
  146035. */
  146036. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  146037. /**
  146038. * Observable called when a task had an error
  146039. */
  146040. onTaskErrorObservable: Observable<AbstractAssetTask>;
  146041. /**
  146042. * Observable called when all tasks were executed
  146043. */
  146044. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  146045. /**
  146046. * Observable called when a task is done (whatever the result is)
  146047. */
  146048. onProgressObservable: Observable<IAssetsProgressEvent>;
  146049. /**
  146050. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  146051. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  146052. */
  146053. useDefaultLoadingScreen: boolean;
  146054. /**
  146055. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  146056. * when all assets have been downloaded.
  146057. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  146058. */
  146059. autoHideLoadingUI: boolean;
  146060. /**
  146061. * Creates a new AssetsManager
  146062. * @param scene defines the scene to work on
  146063. */
  146064. constructor(scene: Scene);
  146065. /**
  146066. * Add a MeshAssetTask to the list of active tasks
  146067. * @param taskName defines the name of the new task
  146068. * @param meshesNames defines the name of meshes to load
  146069. * @param rootUrl defines the root url to use to locate files
  146070. * @param sceneFilename defines the filename of the scene file
  146071. * @returns a new MeshAssetTask object
  146072. */
  146073. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  146074. /**
  146075. * Add a TextFileAssetTask to the list of active tasks
  146076. * @param taskName defines the name of the new task
  146077. * @param url defines the url of the file to load
  146078. * @returns a new TextFileAssetTask object
  146079. */
  146080. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  146081. /**
  146082. * Add a BinaryFileAssetTask to the list of active tasks
  146083. * @param taskName defines the name of the new task
  146084. * @param url defines the url of the file to load
  146085. * @returns a new BinaryFileAssetTask object
  146086. */
  146087. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  146088. /**
  146089. * Add a ImageAssetTask to the list of active tasks
  146090. * @param taskName defines the name of the new task
  146091. * @param url defines the url of the file to load
  146092. * @returns a new ImageAssetTask object
  146093. */
  146094. addImageTask(taskName: string, url: string): ImageAssetTask;
  146095. /**
  146096. * Add a TextureAssetTask to the list of active tasks
  146097. * @param taskName defines the name of the new task
  146098. * @param url defines the url of the file to load
  146099. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146100. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  146101. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  146102. * @returns a new TextureAssetTask object
  146103. */
  146104. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  146105. /**
  146106. * Add a CubeTextureAssetTask to the list of active tasks
  146107. * @param taskName defines the name of the new task
  146108. * @param url defines the url of the file to load
  146109. * @param extensions defines the extension to use to load the cube map (can be null)
  146110. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146111. * @param files defines the list of files to load (can be null)
  146112. * @returns a new CubeTextureAssetTask object
  146113. */
  146114. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  146115. /**
  146116. *
  146117. * Add a HDRCubeTextureAssetTask to the list of active tasks
  146118. * @param taskName defines the name of the new task
  146119. * @param url defines the url of the file to load
  146120. * @param size defines the size you want for the cubemap (can be null)
  146121. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146122. * @param generateHarmonics defines if you want to automatically generate (true by default)
  146123. * @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)
  146124. * @param reserved Internal use only
  146125. * @returns a new HDRCubeTextureAssetTask object
  146126. */
  146127. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  146128. /**
  146129. *
  146130. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  146131. * @param taskName defines the name of the new task
  146132. * @param url defines the url of the file to load
  146133. * @param size defines the size you want for the cubemap (can be null)
  146134. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146135. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  146136. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  146137. * @returns a new EquiRectangularCubeTextureAssetTask object
  146138. */
  146139. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  146140. /**
  146141. * Remove a task from the assets manager.
  146142. * @param task the task to remove
  146143. */
  146144. removeTask(task: AbstractAssetTask): void;
  146145. private _decreaseWaitingTasksCount;
  146146. private _runTask;
  146147. /**
  146148. * Reset the AssetsManager and remove all tasks
  146149. * @return the current instance of the AssetsManager
  146150. */
  146151. reset(): AssetsManager;
  146152. /**
  146153. * Start the loading process
  146154. * @return the current instance of the AssetsManager
  146155. */
  146156. load(): AssetsManager;
  146157. /**
  146158. * Start the loading process as an async operation
  146159. * @return a promise returning the list of failed tasks
  146160. */
  146161. loadAsync(): Promise<void>;
  146162. }
  146163. }
  146164. declare module BABYLON {
  146165. /**
  146166. * Wrapper class for promise with external resolve and reject.
  146167. */
  146168. export class Deferred<T> {
  146169. /**
  146170. * The promise associated with this deferred object.
  146171. */
  146172. readonly promise: Promise<T>;
  146173. private _resolve;
  146174. private _reject;
  146175. /**
  146176. * The resolve method of the promise associated with this deferred object.
  146177. */
  146178. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  146179. /**
  146180. * The reject method of the promise associated with this deferred object.
  146181. */
  146182. get reject(): (reason?: any) => void;
  146183. /**
  146184. * Constructor for this deferred object.
  146185. */
  146186. constructor();
  146187. }
  146188. }
  146189. declare module BABYLON {
  146190. /**
  146191. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  146192. */
  146193. export class MeshExploder {
  146194. private _centerMesh;
  146195. private _meshes;
  146196. private _meshesOrigins;
  146197. private _toCenterVectors;
  146198. private _scaledDirection;
  146199. private _newPosition;
  146200. private _centerPosition;
  146201. /**
  146202. * Explodes meshes from a center mesh.
  146203. * @param meshes The meshes to explode.
  146204. * @param centerMesh The mesh to be center of explosion.
  146205. */
  146206. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  146207. private _setCenterMesh;
  146208. /**
  146209. * Get class name
  146210. * @returns "MeshExploder"
  146211. */
  146212. getClassName(): string;
  146213. /**
  146214. * "Exploded meshes"
  146215. * @returns Array of meshes with the centerMesh at index 0.
  146216. */
  146217. getMeshes(): Array<Mesh>;
  146218. /**
  146219. * Explodes meshes giving a specific direction
  146220. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  146221. */
  146222. explode(direction?: number): void;
  146223. }
  146224. }
  146225. declare module BABYLON {
  146226. /**
  146227. * Class used to help managing file picking and drag'n'drop
  146228. */
  146229. export class FilesInput {
  146230. /**
  146231. * List of files ready to be loaded
  146232. */
  146233. static get FilesToLoad(): {
  146234. [key: string]: File;
  146235. };
  146236. /**
  146237. * Callback called when a file is processed
  146238. */
  146239. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  146240. private _engine;
  146241. private _currentScene;
  146242. private _sceneLoadedCallback;
  146243. private _progressCallback;
  146244. private _additionalRenderLoopLogicCallback;
  146245. private _textureLoadingCallback;
  146246. private _startingProcessingFilesCallback;
  146247. private _onReloadCallback;
  146248. private _errorCallback;
  146249. private _elementToMonitor;
  146250. private _sceneFileToLoad;
  146251. private _filesToLoad;
  146252. /**
  146253. * Creates a new FilesInput
  146254. * @param engine defines the rendering engine
  146255. * @param scene defines the hosting scene
  146256. * @param sceneLoadedCallback callback called when scene is loaded
  146257. * @param progressCallback callback called to track progress
  146258. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  146259. * @param textureLoadingCallback callback called when a texture is loading
  146260. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  146261. * @param onReloadCallback callback called when a reload is requested
  146262. * @param errorCallback callback call if an error occurs
  146263. */
  146264. 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);
  146265. private _dragEnterHandler;
  146266. private _dragOverHandler;
  146267. private _dropHandler;
  146268. /**
  146269. * Calls this function to listen to drag'n'drop events on a specific DOM element
  146270. * @param elementToMonitor defines the DOM element to track
  146271. */
  146272. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  146273. /**
  146274. * Release all associated resources
  146275. */
  146276. dispose(): void;
  146277. private renderFunction;
  146278. private drag;
  146279. private drop;
  146280. private _traverseFolder;
  146281. private _processFiles;
  146282. /**
  146283. * Load files from a drop event
  146284. * @param event defines the drop event to use as source
  146285. */
  146286. loadFiles(event: any): void;
  146287. private _processReload;
  146288. /**
  146289. * Reload the current scene from the loaded files
  146290. */
  146291. reload(): void;
  146292. }
  146293. }
  146294. declare module BABYLON {
  146295. /**
  146296. * Defines the root class used to create scene optimization to use with SceneOptimizer
  146297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146298. */
  146299. export class SceneOptimization {
  146300. /**
  146301. * Defines the priority of this optimization (0 by default which means first in the list)
  146302. */
  146303. priority: number;
  146304. /**
  146305. * Gets a string describing the action executed by the current optimization
  146306. * @returns description string
  146307. */
  146308. getDescription(): string;
  146309. /**
  146310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146311. * @param scene defines the current scene where to apply this optimization
  146312. * @param optimizer defines the current optimizer
  146313. * @returns true if everything that can be done was applied
  146314. */
  146315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146316. /**
  146317. * Creates the SceneOptimization object
  146318. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146319. * @param desc defines the description associated with the optimization
  146320. */
  146321. constructor(
  146322. /**
  146323. * Defines the priority of this optimization (0 by default which means first in the list)
  146324. */
  146325. priority?: number);
  146326. }
  146327. /**
  146328. * Defines an optimization used to reduce the size of render target textures
  146329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146330. */
  146331. export class TextureOptimization extends SceneOptimization {
  146332. /**
  146333. * Defines the priority of this optimization (0 by default which means first in the list)
  146334. */
  146335. priority: number;
  146336. /**
  146337. * 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
  146338. */
  146339. maximumSize: number;
  146340. /**
  146341. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146342. */
  146343. step: number;
  146344. /**
  146345. * Gets a string describing the action executed by the current optimization
  146346. * @returns description string
  146347. */
  146348. getDescription(): string;
  146349. /**
  146350. * Creates the TextureOptimization object
  146351. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146352. * @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
  146353. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146354. */
  146355. constructor(
  146356. /**
  146357. * Defines the priority of this optimization (0 by default which means first in the list)
  146358. */
  146359. priority?: number,
  146360. /**
  146361. * 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
  146362. */
  146363. maximumSize?: number,
  146364. /**
  146365. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146366. */
  146367. step?: number);
  146368. /**
  146369. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146370. * @param scene defines the current scene where to apply this optimization
  146371. * @param optimizer defines the current optimizer
  146372. * @returns true if everything that can be done was applied
  146373. */
  146374. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146375. }
  146376. /**
  146377. * Defines an optimization used to increase or decrease the rendering resolution
  146378. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146379. */
  146380. export class HardwareScalingOptimization extends SceneOptimization {
  146381. /**
  146382. * Defines the priority of this optimization (0 by default which means first in the list)
  146383. */
  146384. priority: number;
  146385. /**
  146386. * Defines the maximum scale to use (2 by default)
  146387. */
  146388. maximumScale: number;
  146389. /**
  146390. * Defines the step to use between two passes (0.5 by default)
  146391. */
  146392. step: number;
  146393. private _currentScale;
  146394. private _directionOffset;
  146395. /**
  146396. * Gets a string describing the action executed by the current optimization
  146397. * @return description string
  146398. */
  146399. getDescription(): string;
  146400. /**
  146401. * Creates the HardwareScalingOptimization object
  146402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146403. * @param maximumScale defines the maximum scale to use (2 by default)
  146404. * @param step defines the step to use between two passes (0.5 by default)
  146405. */
  146406. constructor(
  146407. /**
  146408. * Defines the priority of this optimization (0 by default which means first in the list)
  146409. */
  146410. priority?: number,
  146411. /**
  146412. * Defines the maximum scale to use (2 by default)
  146413. */
  146414. maximumScale?: number,
  146415. /**
  146416. * Defines the step to use between two passes (0.5 by default)
  146417. */
  146418. step?: number);
  146419. /**
  146420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146421. * @param scene defines the current scene where to apply this optimization
  146422. * @param optimizer defines the current optimizer
  146423. * @returns true if everything that can be done was applied
  146424. */
  146425. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146426. }
  146427. /**
  146428. * Defines an optimization used to remove shadows
  146429. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146430. */
  146431. export class ShadowsOptimization extends SceneOptimization {
  146432. /**
  146433. * Gets a string describing the action executed by the current optimization
  146434. * @return description string
  146435. */
  146436. getDescription(): string;
  146437. /**
  146438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146439. * @param scene defines the current scene where to apply this optimization
  146440. * @param optimizer defines the current optimizer
  146441. * @returns true if everything that can be done was applied
  146442. */
  146443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146444. }
  146445. /**
  146446. * Defines an optimization used to turn post-processes off
  146447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146448. */
  146449. export class PostProcessesOptimization extends SceneOptimization {
  146450. /**
  146451. * Gets a string describing the action executed by the current optimization
  146452. * @return description string
  146453. */
  146454. getDescription(): string;
  146455. /**
  146456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146457. * @param scene defines the current scene where to apply this optimization
  146458. * @param optimizer defines the current optimizer
  146459. * @returns true if everything that can be done was applied
  146460. */
  146461. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146462. }
  146463. /**
  146464. * Defines an optimization used to turn lens flares off
  146465. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146466. */
  146467. export class LensFlaresOptimization extends SceneOptimization {
  146468. /**
  146469. * Gets a string describing the action executed by the current optimization
  146470. * @return description string
  146471. */
  146472. getDescription(): string;
  146473. /**
  146474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146475. * @param scene defines the current scene where to apply this optimization
  146476. * @param optimizer defines the current optimizer
  146477. * @returns true if everything that can be done was applied
  146478. */
  146479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146480. }
  146481. /**
  146482. * Defines an optimization based on user defined callback.
  146483. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146484. */
  146485. export class CustomOptimization extends SceneOptimization {
  146486. /**
  146487. * Callback called to apply the custom optimization.
  146488. */
  146489. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  146490. /**
  146491. * Callback called to get custom description
  146492. */
  146493. onGetDescription: () => string;
  146494. /**
  146495. * Gets a string describing the action executed by the current optimization
  146496. * @returns description string
  146497. */
  146498. getDescription(): string;
  146499. /**
  146500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146501. * @param scene defines the current scene where to apply this optimization
  146502. * @param optimizer defines the current optimizer
  146503. * @returns true if everything that can be done was applied
  146504. */
  146505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146506. }
  146507. /**
  146508. * Defines an optimization used to turn particles off
  146509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146510. */
  146511. export class ParticlesOptimization extends SceneOptimization {
  146512. /**
  146513. * Gets a string describing the action executed by the current optimization
  146514. * @return description string
  146515. */
  146516. getDescription(): string;
  146517. /**
  146518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146519. * @param scene defines the current scene where to apply this optimization
  146520. * @param optimizer defines the current optimizer
  146521. * @returns true if everything that can be done was applied
  146522. */
  146523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146524. }
  146525. /**
  146526. * Defines an optimization used to turn render targets off
  146527. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146528. */
  146529. export class RenderTargetsOptimization extends SceneOptimization {
  146530. /**
  146531. * Gets a string describing the action executed by the current optimization
  146532. * @return description string
  146533. */
  146534. getDescription(): string;
  146535. /**
  146536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146537. * @param scene defines the current scene where to apply this optimization
  146538. * @param optimizer defines the current optimizer
  146539. * @returns true if everything that can be done was applied
  146540. */
  146541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146542. }
  146543. /**
  146544. * Defines an optimization used to merge meshes with compatible materials
  146545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146546. */
  146547. export class MergeMeshesOptimization extends SceneOptimization {
  146548. private static _UpdateSelectionTree;
  146549. /**
  146550. * Gets or sets a boolean which defines if optimization octree has to be updated
  146551. */
  146552. static get UpdateSelectionTree(): boolean;
  146553. /**
  146554. * Gets or sets a boolean which defines if optimization octree has to be updated
  146555. */
  146556. static set UpdateSelectionTree(value: boolean);
  146557. /**
  146558. * Gets a string describing the action executed by the current optimization
  146559. * @return description string
  146560. */
  146561. getDescription(): string;
  146562. private _canBeMerged;
  146563. /**
  146564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146565. * @param scene defines the current scene where to apply this optimization
  146566. * @param optimizer defines the current optimizer
  146567. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  146568. * @returns true if everything that can be done was applied
  146569. */
  146570. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  146571. }
  146572. /**
  146573. * Defines a list of options used by SceneOptimizer
  146574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146575. */
  146576. export class SceneOptimizerOptions {
  146577. /**
  146578. * Defines the target frame rate to reach (60 by default)
  146579. */
  146580. targetFrameRate: number;
  146581. /**
  146582. * Defines the interval between two checkes (2000ms by default)
  146583. */
  146584. trackerDuration: number;
  146585. /**
  146586. * Gets the list of optimizations to apply
  146587. */
  146588. optimizations: SceneOptimization[];
  146589. /**
  146590. * Creates a new list of options used by SceneOptimizer
  146591. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  146592. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  146593. */
  146594. constructor(
  146595. /**
  146596. * Defines the target frame rate to reach (60 by default)
  146597. */
  146598. targetFrameRate?: number,
  146599. /**
  146600. * Defines the interval between two checkes (2000ms by default)
  146601. */
  146602. trackerDuration?: number);
  146603. /**
  146604. * Add a new optimization
  146605. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  146606. * @returns the current SceneOptimizerOptions
  146607. */
  146608. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  146609. /**
  146610. * Add a new custom optimization
  146611. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  146612. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  146613. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146614. * @returns the current SceneOptimizerOptions
  146615. */
  146616. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  146617. /**
  146618. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  146619. * @param targetFrameRate defines the target frame rate (60 by default)
  146620. * @returns a SceneOptimizerOptions object
  146621. */
  146622. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146623. /**
  146624. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  146625. * @param targetFrameRate defines the target frame rate (60 by default)
  146626. * @returns a SceneOptimizerOptions object
  146627. */
  146628. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146629. /**
  146630. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  146631. * @param targetFrameRate defines the target frame rate (60 by default)
  146632. * @returns a SceneOptimizerOptions object
  146633. */
  146634. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146635. }
  146636. /**
  146637. * Class used to run optimizations in order to reach a target frame rate
  146638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146639. */
  146640. export class SceneOptimizer implements IDisposable {
  146641. private _isRunning;
  146642. private _options;
  146643. private _scene;
  146644. private _currentPriorityLevel;
  146645. private _targetFrameRate;
  146646. private _trackerDuration;
  146647. private _currentFrameRate;
  146648. private _sceneDisposeObserver;
  146649. private _improvementMode;
  146650. /**
  146651. * Defines an observable called when the optimizer reaches the target frame rate
  146652. */
  146653. onSuccessObservable: Observable<SceneOptimizer>;
  146654. /**
  146655. * Defines an observable called when the optimizer enables an optimization
  146656. */
  146657. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  146658. /**
  146659. * Defines an observable called when the optimizer is not able to reach the target frame rate
  146660. */
  146661. onFailureObservable: Observable<SceneOptimizer>;
  146662. /**
  146663. * Gets a boolean indicating if the optimizer is in improvement mode
  146664. */
  146665. get isInImprovementMode(): boolean;
  146666. /**
  146667. * Gets the current priority level (0 at start)
  146668. */
  146669. get currentPriorityLevel(): number;
  146670. /**
  146671. * Gets the current frame rate checked by the SceneOptimizer
  146672. */
  146673. get currentFrameRate(): number;
  146674. /**
  146675. * Gets or sets the current target frame rate (60 by default)
  146676. */
  146677. get targetFrameRate(): number;
  146678. /**
  146679. * Gets or sets the current target frame rate (60 by default)
  146680. */
  146681. set targetFrameRate(value: number);
  146682. /**
  146683. * Gets or sets the current interval between two checks (every 2000ms by default)
  146684. */
  146685. get trackerDuration(): number;
  146686. /**
  146687. * Gets or sets the current interval between two checks (every 2000ms by default)
  146688. */
  146689. set trackerDuration(value: number);
  146690. /**
  146691. * Gets the list of active optimizations
  146692. */
  146693. get optimizations(): SceneOptimization[];
  146694. /**
  146695. * Creates a new SceneOptimizer
  146696. * @param scene defines the scene to work on
  146697. * @param options defines the options to use with the SceneOptimizer
  146698. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  146699. * @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)
  146700. */
  146701. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  146702. /**
  146703. * Stops the current optimizer
  146704. */
  146705. stop(): void;
  146706. /**
  146707. * Reset the optimizer to initial step (current priority level = 0)
  146708. */
  146709. reset(): void;
  146710. /**
  146711. * Start the optimizer. By default it will try to reach a specific framerate
  146712. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  146713. */
  146714. start(): void;
  146715. private _checkCurrentState;
  146716. /**
  146717. * Release all resources
  146718. */
  146719. dispose(): void;
  146720. /**
  146721. * Helper function to create a SceneOptimizer with one single line of code
  146722. * @param scene defines the scene to work on
  146723. * @param options defines the options to use with the SceneOptimizer
  146724. * @param onSuccess defines a callback to call on success
  146725. * @param onFailure defines a callback to call on failure
  146726. * @returns the new SceneOptimizer object
  146727. */
  146728. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  146729. }
  146730. }
  146731. declare module BABYLON {
  146732. /**
  146733. * Class used to serialize a scene into a string
  146734. */
  146735. export class SceneSerializer {
  146736. /**
  146737. * Clear cache used by a previous serialization
  146738. */
  146739. static ClearCache(): void;
  146740. /**
  146741. * Serialize a scene into a JSON compatible object
  146742. * @param scene defines the scene to serialize
  146743. * @returns a JSON compatible object
  146744. */
  146745. static Serialize(scene: Scene): any;
  146746. /**
  146747. * Serialize a mesh into a JSON compatible object
  146748. * @param toSerialize defines the mesh to serialize
  146749. * @param withParents defines if parents must be serialized as well
  146750. * @param withChildren defines if children must be serialized as well
  146751. * @returns a JSON compatible object
  146752. */
  146753. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  146754. }
  146755. }
  146756. declare module BABYLON {
  146757. /**
  146758. * Class used to host texture specific utilities
  146759. */
  146760. export class TextureTools {
  146761. /**
  146762. * Uses the GPU to create a copy texture rescaled at a given size
  146763. * @param texture Texture to copy from
  146764. * @param width defines the desired width
  146765. * @param height defines the desired height
  146766. * @param useBilinearMode defines if bilinear mode has to be used
  146767. * @return the generated texture
  146768. */
  146769. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  146770. }
  146771. }
  146772. declare module BABYLON {
  146773. /**
  146774. * This represents the different options available for the video capture.
  146775. */
  146776. export interface VideoRecorderOptions {
  146777. /** Defines the mime type of the video. */
  146778. mimeType: string;
  146779. /** Defines the FPS the video should be recorded at. */
  146780. fps: number;
  146781. /** Defines the chunk size for the recording data. */
  146782. recordChunckSize: number;
  146783. /** The audio tracks to attach to the recording. */
  146784. audioTracks?: MediaStreamTrack[];
  146785. }
  146786. /**
  146787. * This can help with recording videos from BabylonJS.
  146788. * This is based on the available WebRTC functionalities of the browser.
  146789. *
  146790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  146791. */
  146792. export class VideoRecorder {
  146793. private static readonly _defaultOptions;
  146794. /**
  146795. * Returns whether or not the VideoRecorder is available in your browser.
  146796. * @param engine Defines the Babylon Engine.
  146797. * @returns true if supported otherwise false.
  146798. */
  146799. static IsSupported(engine: Engine): boolean;
  146800. private readonly _options;
  146801. private _canvas;
  146802. private _mediaRecorder;
  146803. private _recordedChunks;
  146804. private _fileName;
  146805. private _resolve;
  146806. private _reject;
  146807. /**
  146808. * True when a recording is already in progress.
  146809. */
  146810. get isRecording(): boolean;
  146811. /**
  146812. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  146813. * @param engine Defines the BabylonJS Engine you wish to record.
  146814. * @param options Defines options that can be used to customize the capture.
  146815. */
  146816. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  146817. /**
  146818. * Stops the current recording before the default capture timeout passed in the startRecording function.
  146819. */
  146820. stopRecording(): void;
  146821. /**
  146822. * Starts recording the canvas for a max duration specified in parameters.
  146823. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  146824. * If null no automatic download will start and you can rely on the promise to get the data back.
  146825. * @param maxDuration Defines the maximum recording time in seconds.
  146826. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  146827. * @return A promise callback at the end of the recording with the video data in Blob.
  146828. */
  146829. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  146830. /**
  146831. * Releases internal resources used during the recording.
  146832. */
  146833. dispose(): void;
  146834. private _handleDataAvailable;
  146835. private _handleError;
  146836. private _handleStop;
  146837. }
  146838. }
  146839. declare module BABYLON {
  146840. /**
  146841. * Class containing a set of static utilities functions for screenshots
  146842. */
  146843. export class ScreenshotTools {
  146844. /**
  146845. * Captures a screenshot of the current rendering
  146846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146847. * @param engine defines the rendering engine
  146848. * @param camera defines the source camera
  146849. * @param size This parameter can be set to a single number or to an object with the
  146850. * following (optional) properties: precision, width, height. If a single number is passed,
  146851. * it will be used for both width and height. If an object is passed, the screenshot size
  146852. * will be derived from the parameters. The precision property is a multiplier allowing
  146853. * rendering at a higher or lower resolution
  146854. * @param successCallback defines the callback receives a single parameter which contains the
  146855. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146856. * src parameter of an <img> to display it
  146857. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146858. * Check your browser for supported MIME types
  146859. */
  146860. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  146861. /**
  146862. * Captures a screenshot of the current rendering
  146863. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146864. * @param engine defines the rendering engine
  146865. * @param camera defines the source camera
  146866. * @param size This parameter can be set to a single number or to an object with the
  146867. * following (optional) properties: precision, width, height. If a single number is passed,
  146868. * it will be used for both width and height. If an object is passed, the screenshot size
  146869. * will be derived from the parameters. The precision property is a multiplier allowing
  146870. * rendering at a higher or lower resolution
  146871. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146872. * Check your browser for supported MIME types
  146873. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146874. * to the src parameter of an <img> to display it
  146875. */
  146876. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  146877. /**
  146878. * Generates an image screenshot from the specified camera.
  146879. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146880. * @param engine The engine to use for rendering
  146881. * @param camera The camera to use for rendering
  146882. * @param size This parameter can be set to a single number or to an object with the
  146883. * following (optional) properties: precision, width, height. If a single number is passed,
  146884. * it will be used for both width and height. If an object is passed, the screenshot size
  146885. * will be derived from the parameters. The precision property is a multiplier allowing
  146886. * rendering at a higher or lower resolution
  146887. * @param successCallback The callback receives a single parameter which contains the
  146888. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146889. * src parameter of an <img> to display it
  146890. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146891. * Check your browser for supported MIME types
  146892. * @param samples Texture samples (default: 1)
  146893. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146894. * @param fileName A name for for the downloaded file.
  146895. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146896. */
  146897. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  146898. /**
  146899. * Generates an image screenshot from the specified camera.
  146900. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146901. * @param engine The engine to use for rendering
  146902. * @param camera The camera to use for rendering
  146903. * @param size This parameter can be set to a single number or to an object with the
  146904. * following (optional) properties: precision, width, height. If a single number is passed,
  146905. * it will be used for both width and height. If an object is passed, the screenshot size
  146906. * will be derived from the parameters. The precision property is a multiplier allowing
  146907. * rendering at a higher or lower resolution
  146908. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146909. * Check your browser for supported MIME types
  146910. * @param samples Texture samples (default: 1)
  146911. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146912. * @param fileName A name for for the downloaded file.
  146913. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146914. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146915. * to the src parameter of an <img> to display it
  146916. */
  146917. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  146918. /**
  146919. * Gets height and width for screenshot size
  146920. * @private
  146921. */
  146922. private static _getScreenshotSize;
  146923. }
  146924. }
  146925. declare module BABYLON {
  146926. /**
  146927. * Interface for a data buffer
  146928. */
  146929. export interface IDataBuffer {
  146930. /**
  146931. * Reads bytes from the data buffer.
  146932. * @param byteOffset The byte offset to read
  146933. * @param byteLength The byte length to read
  146934. * @returns A promise that resolves when the bytes are read
  146935. */
  146936. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  146937. /**
  146938. * The byte length of the buffer.
  146939. */
  146940. readonly byteLength: number;
  146941. }
  146942. /**
  146943. * Utility class for reading from a data buffer
  146944. */
  146945. export class DataReader {
  146946. /**
  146947. * The data buffer associated with this data reader.
  146948. */
  146949. readonly buffer: IDataBuffer;
  146950. /**
  146951. * The current byte offset from the beginning of the data buffer.
  146952. */
  146953. byteOffset: number;
  146954. private _dataView;
  146955. private _dataByteOffset;
  146956. /**
  146957. * Constructor
  146958. * @param buffer The buffer to read
  146959. */
  146960. constructor(buffer: IDataBuffer);
  146961. /**
  146962. * Loads the given byte length.
  146963. * @param byteLength The byte length to load
  146964. * @returns A promise that resolves when the load is complete
  146965. */
  146966. loadAsync(byteLength: number): Promise<void>;
  146967. /**
  146968. * Read a unsigned 32-bit integer from the currently loaded data range.
  146969. * @returns The 32-bit integer read
  146970. */
  146971. readUint32(): number;
  146972. /**
  146973. * Read a byte array from the currently loaded data range.
  146974. * @param byteLength The byte length to read
  146975. * @returns The byte array read
  146976. */
  146977. readUint8Array(byteLength: number): Uint8Array;
  146978. /**
  146979. * Read a string from the currently loaded data range.
  146980. * @param byteLength The byte length to read
  146981. * @returns The string read
  146982. */
  146983. readString(byteLength: number): string;
  146984. /**
  146985. * Skips the given byte length the currently loaded data range.
  146986. * @param byteLength The byte length to skip
  146987. */
  146988. skipBytes(byteLength: number): void;
  146989. }
  146990. }
  146991. declare module BABYLON {
  146992. /**
  146993. * Class for storing data to local storage if available or in-memory storage otherwise
  146994. */
  146995. export class DataStorage {
  146996. private static _Storage;
  146997. private static _GetStorage;
  146998. /**
  146999. * Reads a string from the data storage
  147000. * @param key The key to read
  147001. * @param defaultValue The value if the key doesn't exist
  147002. * @returns The string value
  147003. */
  147004. static ReadString(key: string, defaultValue: string): string;
  147005. /**
  147006. * Writes a string to the data storage
  147007. * @param key The key to write
  147008. * @param value The value to write
  147009. */
  147010. static WriteString(key: string, value: string): void;
  147011. /**
  147012. * Reads a boolean from the data storage
  147013. * @param key The key to read
  147014. * @param defaultValue The value if the key doesn't exist
  147015. * @returns The boolean value
  147016. */
  147017. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  147018. /**
  147019. * Writes a boolean to the data storage
  147020. * @param key The key to write
  147021. * @param value The value to write
  147022. */
  147023. static WriteBoolean(key: string, value: boolean): void;
  147024. /**
  147025. * Reads a number from the data storage
  147026. * @param key The key to read
  147027. * @param defaultValue The value if the key doesn't exist
  147028. * @returns The number value
  147029. */
  147030. static ReadNumber(key: string, defaultValue: number): number;
  147031. /**
  147032. * Writes a number to the data storage
  147033. * @param key The key to write
  147034. * @param value The value to write
  147035. */
  147036. static WriteNumber(key: string, value: number): void;
  147037. }
  147038. }
  147039. declare module BABYLON {
  147040. /**
  147041. * Options used for hit testing
  147042. */
  147043. export interface IWebXRLegacyHitTestOptions {
  147044. /**
  147045. * Only test when user interacted with the scene. Default - hit test every frame
  147046. */
  147047. testOnPointerDownOnly?: boolean;
  147048. /**
  147049. * The node to use to transform the local results to world coordinates
  147050. */
  147051. worldParentNode?: TransformNode;
  147052. }
  147053. /**
  147054. * Interface defining the babylon result of raycasting/hit-test
  147055. */
  147056. export interface IWebXRLegacyHitResult {
  147057. /**
  147058. * Transformation matrix that can be applied to a node that will put it in the hit point location
  147059. */
  147060. transformationMatrix: Matrix;
  147061. /**
  147062. * The native hit test result
  147063. */
  147064. xrHitResult: XRHitResult | XRHitTestResult;
  147065. }
  147066. /**
  147067. * The currently-working hit-test module.
  147068. * Hit test (or Ray-casting) is used to interact with the real world.
  147069. * For further information read here - https://github.com/immersive-web/hit-test
  147070. */
  147071. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  147072. /**
  147073. * options to use when constructing this feature
  147074. */
  147075. readonly options: IWebXRLegacyHitTestOptions;
  147076. private _direction;
  147077. private _mat;
  147078. private _onSelectEnabled;
  147079. private _origin;
  147080. /**
  147081. * The module's name
  147082. */
  147083. static readonly Name: string;
  147084. /**
  147085. * The (Babylon) version of this module.
  147086. * This is an integer representing the implementation version.
  147087. * This number does not correspond to the WebXR specs version
  147088. */
  147089. static readonly Version: number;
  147090. /**
  147091. * Populated with the last native XR Hit Results
  147092. */
  147093. lastNativeXRHitResults: XRHitResult[];
  147094. /**
  147095. * Triggered when new babylon (transformed) hit test results are available
  147096. */
  147097. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  147098. /**
  147099. * Creates a new instance of the (legacy version) hit test feature
  147100. * @param _xrSessionManager an instance of WebXRSessionManager
  147101. * @param options options to use when constructing this feature
  147102. */
  147103. constructor(_xrSessionManager: WebXRSessionManager,
  147104. /**
  147105. * options to use when constructing this feature
  147106. */
  147107. options?: IWebXRLegacyHitTestOptions);
  147108. /**
  147109. * execute a hit test with an XR Ray
  147110. *
  147111. * @param xrSession a native xrSession that will execute this hit test
  147112. * @param xrRay the ray (position and direction) to use for ray-casting
  147113. * @param referenceSpace native XR reference space to use for the hit-test
  147114. * @param filter filter function that will filter the results
  147115. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  147116. */
  147117. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  147118. /**
  147119. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  147120. * @param event the (select) event to use to select with
  147121. * @param referenceSpace the reference space to use for this hit test
  147122. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  147123. */
  147124. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  147125. /**
  147126. * attach this feature
  147127. * Will usually be called by the features manager
  147128. *
  147129. * @returns true if successful.
  147130. */
  147131. attach(): boolean;
  147132. /**
  147133. * detach this feature.
  147134. * Will usually be called by the features manager
  147135. *
  147136. * @returns true if successful.
  147137. */
  147138. detach(): boolean;
  147139. /**
  147140. * Dispose this feature and all of the resources attached
  147141. */
  147142. dispose(): void;
  147143. protected _onXRFrame(frame: XRFrame): void;
  147144. private _onHitTestResults;
  147145. private _onSelect;
  147146. }
  147147. }
  147148. declare module BABYLON {
  147149. /**
  147150. * Options used in the plane detector module
  147151. */
  147152. export interface IWebXRPlaneDetectorOptions {
  147153. /**
  147154. * The node to use to transform the local results to world coordinates
  147155. */
  147156. worldParentNode?: TransformNode;
  147157. }
  147158. /**
  147159. * A babylon interface for a WebXR plane.
  147160. * A Plane is actually a polygon, built from N points in space
  147161. *
  147162. * Supported in chrome 79, not supported in canary 81 ATM
  147163. */
  147164. export interface IWebXRPlane {
  147165. /**
  147166. * a babylon-assigned ID for this polygon
  147167. */
  147168. id: number;
  147169. /**
  147170. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  147171. */
  147172. polygonDefinition: Array<Vector3>;
  147173. /**
  147174. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  147175. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  147176. */
  147177. transformationMatrix: Matrix;
  147178. /**
  147179. * the native xr-plane object
  147180. */
  147181. xrPlane: XRPlane;
  147182. }
  147183. /**
  147184. * The plane detector is used to detect planes in the real world when in AR
  147185. * For more information see https://github.com/immersive-web/real-world-geometry/
  147186. */
  147187. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  147188. private _options;
  147189. private _detectedPlanes;
  147190. private _enabled;
  147191. private _lastFrameDetected;
  147192. /**
  147193. * The module's name
  147194. */
  147195. static readonly Name: string;
  147196. /**
  147197. * The (Babylon) version of this module.
  147198. * This is an integer representing the implementation version.
  147199. * This number does not correspond to the WebXR specs version
  147200. */
  147201. static readonly Version: number;
  147202. /**
  147203. * Observers registered here will be executed when a new plane was added to the session
  147204. */
  147205. onPlaneAddedObservable: Observable<IWebXRPlane>;
  147206. /**
  147207. * Observers registered here will be executed when a plane is no longer detected in the session
  147208. */
  147209. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  147210. /**
  147211. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  147212. * This can execute N times every frame
  147213. */
  147214. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  147215. /**
  147216. * construct a new Plane Detector
  147217. * @param _xrSessionManager an instance of xr Session manager
  147218. * @param _options configuration to use when constructing this feature
  147219. */
  147220. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  147221. /**
  147222. * Dispose this feature and all of the resources attached
  147223. */
  147224. dispose(): void;
  147225. protected _onXRFrame(frame: XRFrame): void;
  147226. private _init;
  147227. private _updatePlaneWithXRPlane;
  147228. /**
  147229. * avoiding using Array.find for global support.
  147230. * @param xrPlane the plane to find in the array
  147231. */
  147232. private findIndexInPlaneArray;
  147233. }
  147234. }
  147235. declare module BABYLON {
  147236. /**
  147237. * Configuration options of the anchor system
  147238. */
  147239. export interface IWebXRAnchorSystemOptions {
  147240. /**
  147241. * Should a new anchor be added every time a select event is triggered
  147242. */
  147243. addAnchorOnSelect?: boolean;
  147244. /**
  147245. * should the anchor system use plane detection.
  147246. * If set to true, the plane-detection feature should be set using setPlaneDetector
  147247. */
  147248. usePlaneDetection?: boolean;
  147249. /**
  147250. * a node that will be used to convert local to world coordinates
  147251. */
  147252. worldParentNode?: TransformNode;
  147253. }
  147254. /**
  147255. * A babylon container for an XR Anchor
  147256. */
  147257. export interface IWebXRAnchor {
  147258. /**
  147259. * A babylon-assigned ID for this anchor
  147260. */
  147261. id: number;
  147262. /**
  147263. * Transformation matrix to apply to an object attached to this anchor
  147264. */
  147265. transformationMatrix: Matrix;
  147266. /**
  147267. * The native anchor object
  147268. */
  147269. xrAnchor: XRAnchor;
  147270. }
  147271. /**
  147272. * An implementation of the anchor system of WebXR.
  147273. * Note that the current documented implementation is not available in any browser. Future implementations
  147274. * will use the frame to create an anchor and not the session or a detected plane
  147275. * For further information see https://github.com/immersive-web/anchors/
  147276. */
  147277. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  147278. private _options;
  147279. private _enabled;
  147280. private _hitTestModule;
  147281. private _lastFrameDetected;
  147282. private _onSelect;
  147283. private _planeDetector;
  147284. private _trackedAnchors;
  147285. /**
  147286. * The module's name
  147287. */
  147288. static readonly Name: string;
  147289. /**
  147290. * The (Babylon) version of this module.
  147291. * This is an integer representing the implementation version.
  147292. * This number does not correspond to the WebXR specs version
  147293. */
  147294. static readonly Version: number;
  147295. /**
  147296. * Observers registered here will be executed when a new anchor was added to the session
  147297. */
  147298. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  147299. /**
  147300. * Observers registered here will be executed when an anchor was removed from the session
  147301. */
  147302. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  147303. /**
  147304. * Observers registered here will be executed when an existing anchor updates
  147305. * This can execute N times every frame
  147306. */
  147307. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  147308. /**
  147309. * constructs a new anchor system
  147310. * @param _xrSessionManager an instance of WebXRSessionManager
  147311. * @param _options configuration object for this feature
  147312. */
  147313. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  147314. /**
  147315. * Add anchor at a specific XR point.
  147316. *
  147317. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  147318. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  147319. * @returns a promise the fulfills when the anchor was created
  147320. */
  147321. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  147322. /**
  147323. * attach this feature
  147324. * Will usually be called by the features manager
  147325. *
  147326. * @returns true if successful.
  147327. */
  147328. attach(): boolean;
  147329. /**
  147330. * detach this feature.
  147331. * Will usually be called by the features manager
  147332. *
  147333. * @returns true if successful.
  147334. */
  147335. detach(): boolean;
  147336. /**
  147337. * Dispose this feature and all of the resources attached
  147338. */
  147339. dispose(): void;
  147340. /**
  147341. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  147342. * @param hitTestModule the hit-test module to use.
  147343. */
  147344. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  147345. /**
  147346. * set the plane detector to use in order to create anchors from frames
  147347. * @param planeDetector the plane-detector module to use
  147348. * @param enable enable plane-anchors. default is true
  147349. */
  147350. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  147351. protected _onXRFrame(frame: XRFrame): void;
  147352. /**
  147353. * avoiding using Array.find for global support.
  147354. * @param xrAnchor the plane to find in the array
  147355. */
  147356. private _findIndexInAnchorArray;
  147357. private _updateAnchorWithXRFrame;
  147358. }
  147359. }
  147360. declare module BABYLON {
  147361. /**
  147362. * Options interface for the background remover plugin
  147363. */
  147364. export interface IWebXRBackgroundRemoverOptions {
  147365. /**
  147366. * Further background meshes to disable when entering AR
  147367. */
  147368. backgroundMeshes?: AbstractMesh[];
  147369. /**
  147370. * flags to configure the removal of the environment helper.
  147371. * If not set, the entire background will be removed. If set, flags should be set as well.
  147372. */
  147373. environmentHelperRemovalFlags?: {
  147374. /**
  147375. * Should the skybox be removed (default false)
  147376. */
  147377. skyBox?: boolean;
  147378. /**
  147379. * Should the ground be removed (default false)
  147380. */
  147381. ground?: boolean;
  147382. };
  147383. /**
  147384. * don't disable the environment helper
  147385. */
  147386. ignoreEnvironmentHelper?: boolean;
  147387. }
  147388. /**
  147389. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  147390. */
  147391. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  147392. /**
  147393. * read-only options to be used in this module
  147394. */
  147395. readonly options: IWebXRBackgroundRemoverOptions;
  147396. /**
  147397. * The module's name
  147398. */
  147399. static readonly Name: string;
  147400. /**
  147401. * The (Babylon) version of this module.
  147402. * This is an integer representing the implementation version.
  147403. * This number does not correspond to the WebXR specs version
  147404. */
  147405. static readonly Version: number;
  147406. /**
  147407. * registered observers will be triggered when the background state changes
  147408. */
  147409. onBackgroundStateChangedObservable: Observable<boolean>;
  147410. /**
  147411. * constructs a new background remover module
  147412. * @param _xrSessionManager the session manager for this module
  147413. * @param options read-only options to be used in this module
  147414. */
  147415. constructor(_xrSessionManager: WebXRSessionManager,
  147416. /**
  147417. * read-only options to be used in this module
  147418. */
  147419. options?: IWebXRBackgroundRemoverOptions);
  147420. /**
  147421. * attach this feature
  147422. * Will usually be called by the features manager
  147423. *
  147424. * @returns true if successful.
  147425. */
  147426. attach(): boolean;
  147427. /**
  147428. * detach this feature.
  147429. * Will usually be called by the features manager
  147430. *
  147431. * @returns true if successful.
  147432. */
  147433. detach(): boolean;
  147434. /**
  147435. * Dispose this feature and all of the resources attached
  147436. */
  147437. dispose(): void;
  147438. protected _onXRFrame(_xrFrame: XRFrame): void;
  147439. private _setBackgroundState;
  147440. }
  147441. }
  147442. declare module BABYLON {
  147443. /**
  147444. * Options for the controller physics feature
  147445. */
  147446. export class IWebXRControllerPhysicsOptions {
  147447. /**
  147448. * Should the headset get its own impostor
  147449. */
  147450. enableHeadsetImpostor?: boolean;
  147451. /**
  147452. * Optional parameters for the headset impostor
  147453. */
  147454. headsetImpostorParams?: {
  147455. /**
  147456. * The type of impostor to create. Default is sphere
  147457. */
  147458. impostorType: number;
  147459. /**
  147460. * the size of the impostor. Defaults to 10cm
  147461. */
  147462. impostorSize?: number | {
  147463. width: number;
  147464. height: number;
  147465. depth: number;
  147466. };
  147467. /**
  147468. * Friction definitions
  147469. */
  147470. friction?: number;
  147471. /**
  147472. * Restitution
  147473. */
  147474. restitution?: number;
  147475. };
  147476. /**
  147477. * The physics properties of the future impostors
  147478. */
  147479. physicsProperties?: {
  147480. /**
  147481. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  147482. * Note that this requires a physics engine that supports mesh impostors!
  147483. */
  147484. useControllerMesh?: boolean;
  147485. /**
  147486. * The type of impostor to create. Default is sphere
  147487. */
  147488. impostorType?: number;
  147489. /**
  147490. * the size of the impostor. Defaults to 10cm
  147491. */
  147492. impostorSize?: number | {
  147493. width: number;
  147494. height: number;
  147495. depth: number;
  147496. };
  147497. /**
  147498. * Friction definitions
  147499. */
  147500. friction?: number;
  147501. /**
  147502. * Restitution
  147503. */
  147504. restitution?: number;
  147505. };
  147506. /**
  147507. * the xr input to use with this pointer selection
  147508. */
  147509. xrInput: WebXRInput;
  147510. }
  147511. /**
  147512. * Add physics impostor to your webxr controllers,
  147513. * including naive calculation of their linear and angular velocity
  147514. */
  147515. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  147516. private readonly _options;
  147517. private _attachController;
  147518. private _controllers;
  147519. private _debugMode;
  147520. private _delta;
  147521. private _headsetImpostor?;
  147522. private _headsetMesh?;
  147523. private _lastTimestamp;
  147524. private _tmpQuaternion;
  147525. private _tmpVector;
  147526. /**
  147527. * The module's name
  147528. */
  147529. static readonly Name: string;
  147530. /**
  147531. * The (Babylon) version of this module.
  147532. * This is an integer representing the implementation version.
  147533. * This number does not correspond to the webxr specs version
  147534. */
  147535. static readonly Version: number;
  147536. /**
  147537. * Construct a new Controller Physics Feature
  147538. * @param _xrSessionManager the corresponding xr session manager
  147539. * @param _options options to create this feature with
  147540. */
  147541. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  147542. /**
  147543. * @hidden
  147544. * enable debugging - will show console outputs and the impostor mesh
  147545. */
  147546. _enablePhysicsDebug(): void;
  147547. /**
  147548. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  147549. * @param xrController the controller to add
  147550. */
  147551. addController(xrController: WebXRInputSource): void;
  147552. /**
  147553. * attach this feature
  147554. * Will usually be called by the features manager
  147555. *
  147556. * @returns true if successful.
  147557. */
  147558. attach(): boolean;
  147559. /**
  147560. * detach this feature.
  147561. * Will usually be called by the features manager
  147562. *
  147563. * @returns true if successful.
  147564. */
  147565. detach(): boolean;
  147566. /**
  147567. * Get the headset impostor, if enabled
  147568. * @returns the impostor
  147569. */
  147570. getHeadsetImpostor(): PhysicsImpostor | undefined;
  147571. /**
  147572. * Get the physics impostor of a specific controller.
  147573. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  147574. * @param controller the controller or the controller id of which to get the impostor
  147575. * @returns the impostor or null
  147576. */
  147577. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  147578. /**
  147579. * Update the physics properties provided in the constructor
  147580. * @param newProperties the new properties object
  147581. */
  147582. setPhysicsProperties(newProperties: {
  147583. impostorType?: number;
  147584. impostorSize?: number | {
  147585. width: number;
  147586. height: number;
  147587. depth: number;
  147588. };
  147589. friction?: number;
  147590. restitution?: number;
  147591. }): void;
  147592. protected _onXRFrame(_xrFrame: any): void;
  147593. private _detachController;
  147594. }
  147595. }
  147596. declare module BABYLON {
  147597. /**
  147598. * Options used for hit testing (version 2)
  147599. */
  147600. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  147601. /**
  147602. * Do not create a permanent hit test. Will usually be used when only
  147603. * transient inputs are needed.
  147604. */
  147605. disablePermanentHitTest?: boolean;
  147606. /**
  147607. * Enable transient (for example touch-based) hit test inspections
  147608. */
  147609. enableTransientHitTest?: boolean;
  147610. /**
  147611. * Offset ray for the permanent hit test
  147612. */
  147613. offsetRay?: Vector3;
  147614. /**
  147615. * Offset ray for the transient hit test
  147616. */
  147617. transientOffsetRay?: Vector3;
  147618. /**
  147619. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  147620. */
  147621. useReferenceSpace?: boolean;
  147622. }
  147623. /**
  147624. * Interface defining the babylon result of hit-test
  147625. */
  147626. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  147627. /**
  147628. * The input source that generated this hit test (if transient)
  147629. */
  147630. inputSource?: XRInputSource;
  147631. /**
  147632. * Is this a transient hit test
  147633. */
  147634. isTransient?: boolean;
  147635. /**
  147636. * Position of the hit test result
  147637. */
  147638. position: Vector3;
  147639. /**
  147640. * Rotation of the hit test result
  147641. */
  147642. rotationQuaternion: Quaternion;
  147643. }
  147644. /**
  147645. * The currently-working hit-test module.
  147646. * Hit test (or Ray-casting) is used to interact with the real world.
  147647. * For further information read here - https://github.com/immersive-web/hit-test
  147648. *
  147649. * Tested on chrome (mobile) 80.
  147650. */
  147651. export class WebXRHitTest extends WebXRAbstractFeature {
  147652. /**
  147653. * options to use when constructing this feature
  147654. */
  147655. readonly options: IWebXRHitTestOptions;
  147656. private _tmpMat;
  147657. private _tmpPos;
  147658. private _tmpQuat;
  147659. private _transientXrHitTestSource;
  147660. private _xrHitTestSource;
  147661. private initHitTestSource;
  147662. /**
  147663. * The module's name
  147664. */
  147665. static readonly Name: string;
  147666. /**
  147667. * The (Babylon) version of this module.
  147668. * This is an integer representing the implementation version.
  147669. * This number does not correspond to the WebXR specs version
  147670. */
  147671. static readonly Version: number;
  147672. /**
  147673. * When set to true, each hit test will have its own position/rotation objects
  147674. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  147675. * the developers will clone them or copy them as they see fit.
  147676. */
  147677. autoCloneTransformation: boolean;
  147678. /**
  147679. * Populated with the last native XR Hit Results
  147680. */
  147681. lastNativeXRHitResults: XRHitResult[];
  147682. /**
  147683. * Triggered when new babylon (transformed) hit test results are available
  147684. */
  147685. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  147686. /**
  147687. * Use this to temporarily pause hit test checks.
  147688. */
  147689. paused: boolean;
  147690. /**
  147691. * Creates a new instance of the hit test feature
  147692. * @param _xrSessionManager an instance of WebXRSessionManager
  147693. * @param options options to use when constructing this feature
  147694. */
  147695. constructor(_xrSessionManager: WebXRSessionManager,
  147696. /**
  147697. * options to use when constructing this feature
  147698. */
  147699. options?: IWebXRHitTestOptions);
  147700. /**
  147701. * attach this feature
  147702. * Will usually be called by the features manager
  147703. *
  147704. * @returns true if successful.
  147705. */
  147706. attach(): boolean;
  147707. /**
  147708. * detach this feature.
  147709. * Will usually be called by the features manager
  147710. *
  147711. * @returns true if successful.
  147712. */
  147713. detach(): boolean;
  147714. /**
  147715. * Dispose this feature and all of the resources attached
  147716. */
  147717. dispose(): void;
  147718. protected _onXRFrame(frame: XRFrame): void;
  147719. private _processWebXRHitTestResult;
  147720. }
  147721. }
  147722. declare module BABYLON {
  147723. /**
  147724. * The motion controller class for all microsoft mixed reality controllers
  147725. */
  147726. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  147727. protected readonly _mapping: {
  147728. defaultButton: {
  147729. valueNodeName: string;
  147730. unpressedNodeName: string;
  147731. pressedNodeName: string;
  147732. };
  147733. defaultAxis: {
  147734. valueNodeName: string;
  147735. minNodeName: string;
  147736. maxNodeName: string;
  147737. };
  147738. buttons: {
  147739. "xr-standard-trigger": {
  147740. rootNodeName: string;
  147741. componentProperty: string;
  147742. states: string[];
  147743. };
  147744. "xr-standard-squeeze": {
  147745. rootNodeName: string;
  147746. componentProperty: string;
  147747. states: string[];
  147748. };
  147749. "xr-standard-touchpad": {
  147750. rootNodeName: string;
  147751. labelAnchorNodeName: string;
  147752. touchPointNodeName: string;
  147753. };
  147754. "xr-standard-thumbstick": {
  147755. rootNodeName: string;
  147756. componentProperty: string;
  147757. states: string[];
  147758. };
  147759. };
  147760. axes: {
  147761. "xr-standard-touchpad": {
  147762. "x-axis": {
  147763. rootNodeName: string;
  147764. };
  147765. "y-axis": {
  147766. rootNodeName: string;
  147767. };
  147768. };
  147769. "xr-standard-thumbstick": {
  147770. "x-axis": {
  147771. rootNodeName: string;
  147772. };
  147773. "y-axis": {
  147774. rootNodeName: string;
  147775. };
  147776. };
  147777. };
  147778. };
  147779. /**
  147780. * The base url used to load the left and right controller models
  147781. */
  147782. static MODEL_BASE_URL: string;
  147783. /**
  147784. * The name of the left controller model file
  147785. */
  147786. static MODEL_LEFT_FILENAME: string;
  147787. /**
  147788. * The name of the right controller model file
  147789. */
  147790. static MODEL_RIGHT_FILENAME: string;
  147791. profileId: string;
  147792. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147793. protected _getFilenameAndPath(): {
  147794. filename: string;
  147795. path: string;
  147796. };
  147797. protected _getModelLoadingConstraints(): boolean;
  147798. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147799. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147800. protected _updateModel(): void;
  147801. }
  147802. }
  147803. declare module BABYLON {
  147804. /**
  147805. * The motion controller class for oculus touch (quest, rift).
  147806. * This class supports legacy mapping as well the standard xr mapping
  147807. */
  147808. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  147809. private _forceLegacyControllers;
  147810. private _modelRootNode;
  147811. /**
  147812. * The base url used to load the left and right controller models
  147813. */
  147814. static MODEL_BASE_URL: string;
  147815. /**
  147816. * The name of the left controller model file
  147817. */
  147818. static MODEL_LEFT_FILENAME: string;
  147819. /**
  147820. * The name of the right controller model file
  147821. */
  147822. static MODEL_RIGHT_FILENAME: string;
  147823. /**
  147824. * Base Url for the Quest controller model.
  147825. */
  147826. static QUEST_MODEL_BASE_URL: string;
  147827. profileId: string;
  147828. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  147829. protected _getFilenameAndPath(): {
  147830. filename: string;
  147831. path: string;
  147832. };
  147833. protected _getModelLoadingConstraints(): boolean;
  147834. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147835. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147836. protected _updateModel(): void;
  147837. /**
  147838. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  147839. * between the touch and touch 2.
  147840. */
  147841. private _isQuest;
  147842. }
  147843. }
  147844. declare module BABYLON {
  147845. /**
  147846. * The motion controller class for the standard HTC-Vive controllers
  147847. */
  147848. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  147849. private _modelRootNode;
  147850. /**
  147851. * The base url used to load the left and right controller models
  147852. */
  147853. static MODEL_BASE_URL: string;
  147854. /**
  147855. * File name for the controller model.
  147856. */
  147857. static MODEL_FILENAME: string;
  147858. profileId: string;
  147859. /**
  147860. * Create a new Vive motion controller object
  147861. * @param scene the scene to use to create this controller
  147862. * @param gamepadObject the corresponding gamepad object
  147863. * @param handedness the handedness of the controller
  147864. */
  147865. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147866. protected _getFilenameAndPath(): {
  147867. filename: string;
  147868. path: string;
  147869. };
  147870. protected _getModelLoadingConstraints(): boolean;
  147871. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147872. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147873. protected _updateModel(): void;
  147874. }
  147875. }
  147876. declare module BABYLON {
  147877. /**
  147878. * A cursor which tracks a point on a path
  147879. */
  147880. export class PathCursor {
  147881. private path;
  147882. /**
  147883. * Stores path cursor callbacks for when an onchange event is triggered
  147884. */
  147885. private _onchange;
  147886. /**
  147887. * The value of the path cursor
  147888. */
  147889. value: number;
  147890. /**
  147891. * The animation array of the path cursor
  147892. */
  147893. animations: Animation[];
  147894. /**
  147895. * Initializes the path cursor
  147896. * @param path The path to track
  147897. */
  147898. constructor(path: Path2);
  147899. /**
  147900. * Gets the cursor point on the path
  147901. * @returns A point on the path cursor at the cursor location
  147902. */
  147903. getPoint(): Vector3;
  147904. /**
  147905. * Moves the cursor ahead by the step amount
  147906. * @param step The amount to move the cursor forward
  147907. * @returns This path cursor
  147908. */
  147909. moveAhead(step?: number): PathCursor;
  147910. /**
  147911. * Moves the cursor behind by the step amount
  147912. * @param step The amount to move the cursor back
  147913. * @returns This path cursor
  147914. */
  147915. moveBack(step?: number): PathCursor;
  147916. /**
  147917. * Moves the cursor by the step amount
  147918. * If the step amount is greater than one, an exception is thrown
  147919. * @param step The amount to move the cursor
  147920. * @returns This path cursor
  147921. */
  147922. move(step: number): PathCursor;
  147923. /**
  147924. * Ensures that the value is limited between zero and one
  147925. * @returns This path cursor
  147926. */
  147927. private ensureLimits;
  147928. /**
  147929. * Runs onchange callbacks on change (used by the animation engine)
  147930. * @returns This path cursor
  147931. */
  147932. private raiseOnChange;
  147933. /**
  147934. * Executes a function on change
  147935. * @param f A path cursor onchange callback
  147936. * @returns This path cursor
  147937. */
  147938. onchange(f: (cursor: PathCursor) => void): PathCursor;
  147939. }
  147940. }
  147941. declare module BABYLON {
  147942. /** @hidden */
  147943. export var blurPixelShader: {
  147944. name: string;
  147945. shader: string;
  147946. };
  147947. }
  147948. declare module BABYLON {
  147949. /** @hidden */
  147950. export var pointCloudVertexDeclaration: {
  147951. name: string;
  147952. shader: string;
  147953. };
  147954. }
  147955. // Mixins
  147956. interface Window {
  147957. mozIndexedDB: IDBFactory;
  147958. webkitIndexedDB: IDBFactory;
  147959. msIndexedDB: IDBFactory;
  147960. webkitURL: typeof URL;
  147961. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  147962. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  147963. WebGLRenderingContext: WebGLRenderingContext;
  147964. MSGesture: MSGesture;
  147965. CANNON: any;
  147966. AudioContext: AudioContext;
  147967. webkitAudioContext: AudioContext;
  147968. PointerEvent: any;
  147969. Math: Math;
  147970. Uint8Array: Uint8ArrayConstructor;
  147971. Float32Array: Float32ArrayConstructor;
  147972. mozURL: typeof URL;
  147973. msURL: typeof URL;
  147974. VRFrameData: any; // WebVR, from specs 1.1
  147975. DracoDecoderModule: any;
  147976. setImmediate(handler: (...args: any[]) => void): number;
  147977. }
  147978. interface HTMLCanvasElement {
  147979. requestPointerLock(): void;
  147980. msRequestPointerLock?(): void;
  147981. mozRequestPointerLock?(): void;
  147982. webkitRequestPointerLock?(): void;
  147983. /** Track wether a record is in progress */
  147984. isRecording: boolean;
  147985. /** Capture Stream method defined by some browsers */
  147986. captureStream(fps?: number): MediaStream;
  147987. }
  147988. interface CanvasRenderingContext2D {
  147989. msImageSmoothingEnabled: boolean;
  147990. }
  147991. interface MouseEvent {
  147992. mozMovementX: number;
  147993. mozMovementY: number;
  147994. webkitMovementX: number;
  147995. webkitMovementY: number;
  147996. msMovementX: number;
  147997. msMovementY: number;
  147998. }
  147999. interface Navigator {
  148000. mozGetVRDevices: (any: any) => any;
  148001. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  148002. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  148003. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  148004. webkitGetGamepads(): Gamepad[];
  148005. msGetGamepads(): Gamepad[];
  148006. webkitGamepads(): Gamepad[];
  148007. }
  148008. interface HTMLVideoElement {
  148009. mozSrcObject: any;
  148010. }
  148011. interface Math {
  148012. fround(x: number): number;
  148013. imul(a: number, b: number): number;
  148014. }
  148015. interface WebGLRenderingContext {
  148016. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  148017. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  148018. vertexAttribDivisor(index: number, divisor: number): void;
  148019. createVertexArray(): any;
  148020. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  148021. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  148022. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  148023. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  148024. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  148025. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  148026. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  148027. // Queries
  148028. createQuery(): WebGLQuery;
  148029. deleteQuery(query: WebGLQuery): void;
  148030. beginQuery(target: number, query: WebGLQuery): void;
  148031. endQuery(target: number): void;
  148032. getQueryParameter(query: WebGLQuery, pname: number): any;
  148033. getQuery(target: number, pname: number): any;
  148034. MAX_SAMPLES: number;
  148035. RGBA8: number;
  148036. READ_FRAMEBUFFER: number;
  148037. DRAW_FRAMEBUFFER: number;
  148038. UNIFORM_BUFFER: number;
  148039. HALF_FLOAT_OES: number;
  148040. RGBA16F: number;
  148041. RGBA32F: number;
  148042. R32F: number;
  148043. RG32F: number;
  148044. RGB32F: number;
  148045. R16F: number;
  148046. RG16F: number;
  148047. RGB16F: number;
  148048. RED: number;
  148049. RG: number;
  148050. R8: number;
  148051. RG8: number;
  148052. UNSIGNED_INT_24_8: number;
  148053. DEPTH24_STENCIL8: number;
  148054. MIN: number;
  148055. MAX: number;
  148056. /* Multiple Render Targets */
  148057. drawBuffers(buffers: number[]): void;
  148058. readBuffer(src: number): void;
  148059. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  148060. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  148061. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  148062. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  148063. // Occlusion Query
  148064. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  148065. ANY_SAMPLES_PASSED: number;
  148066. QUERY_RESULT_AVAILABLE: number;
  148067. QUERY_RESULT: number;
  148068. }
  148069. interface WebGLProgram {
  148070. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  148071. }
  148072. interface EXT_disjoint_timer_query {
  148073. QUERY_COUNTER_BITS_EXT: number;
  148074. TIME_ELAPSED_EXT: number;
  148075. TIMESTAMP_EXT: number;
  148076. GPU_DISJOINT_EXT: number;
  148077. QUERY_RESULT_EXT: number;
  148078. QUERY_RESULT_AVAILABLE_EXT: number;
  148079. queryCounterEXT(query: WebGLQuery, target: number): void;
  148080. createQueryEXT(): WebGLQuery;
  148081. beginQueryEXT(target: number, query: WebGLQuery): void;
  148082. endQueryEXT(target: number): void;
  148083. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  148084. deleteQueryEXT(query: WebGLQuery): void;
  148085. }
  148086. interface WebGLUniformLocation {
  148087. _currentState: any;
  148088. }
  148089. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  148090. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  148091. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  148092. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  148093. interface WebGLRenderingContext {
  148094. readonly RASTERIZER_DISCARD: number;
  148095. readonly DEPTH_COMPONENT24: number;
  148096. readonly TEXTURE_3D: number;
  148097. readonly TEXTURE_2D_ARRAY: number;
  148098. readonly TEXTURE_COMPARE_FUNC: number;
  148099. readonly TEXTURE_COMPARE_MODE: number;
  148100. readonly COMPARE_REF_TO_TEXTURE: number;
  148101. readonly TEXTURE_WRAP_R: number;
  148102. readonly HALF_FLOAT: number;
  148103. readonly RGB8: number;
  148104. readonly RED_INTEGER: number;
  148105. readonly RG_INTEGER: number;
  148106. readonly RGB_INTEGER: number;
  148107. readonly RGBA_INTEGER: number;
  148108. readonly R8_SNORM: number;
  148109. readonly RG8_SNORM: number;
  148110. readonly RGB8_SNORM: number;
  148111. readonly RGBA8_SNORM: number;
  148112. readonly R8I: number;
  148113. readonly RG8I: number;
  148114. readonly RGB8I: number;
  148115. readonly RGBA8I: number;
  148116. readonly R8UI: number;
  148117. readonly RG8UI: number;
  148118. readonly RGB8UI: number;
  148119. readonly RGBA8UI: number;
  148120. readonly R16I: number;
  148121. readonly RG16I: number;
  148122. readonly RGB16I: number;
  148123. readonly RGBA16I: number;
  148124. readonly R16UI: number;
  148125. readonly RG16UI: number;
  148126. readonly RGB16UI: number;
  148127. readonly RGBA16UI: number;
  148128. readonly R32I: number;
  148129. readonly RG32I: number;
  148130. readonly RGB32I: number;
  148131. readonly RGBA32I: number;
  148132. readonly R32UI: number;
  148133. readonly RG32UI: number;
  148134. readonly RGB32UI: number;
  148135. readonly RGBA32UI: number;
  148136. readonly RGB10_A2UI: number;
  148137. readonly R11F_G11F_B10F: number;
  148138. readonly RGB9_E5: number;
  148139. readonly RGB10_A2: number;
  148140. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  148141. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  148142. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  148143. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  148144. readonly DEPTH_COMPONENT32F: number;
  148145. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  148146. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  148147. 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;
  148148. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  148149. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  148150. readonly TRANSFORM_FEEDBACK: number;
  148151. readonly INTERLEAVED_ATTRIBS: number;
  148152. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  148153. createTransformFeedback(): WebGLTransformFeedback;
  148154. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  148155. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  148156. beginTransformFeedback(primitiveMode: number): void;
  148157. endTransformFeedback(): void;
  148158. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  148159. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148160. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148161. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148162. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  148163. }
  148164. interface ImageBitmap {
  148165. readonly width: number;
  148166. readonly height: number;
  148167. close(): void;
  148168. }
  148169. interface WebGLQuery extends WebGLObject {
  148170. }
  148171. declare var WebGLQuery: {
  148172. prototype: WebGLQuery;
  148173. new(): WebGLQuery;
  148174. };
  148175. interface WebGLSampler extends WebGLObject {
  148176. }
  148177. declare var WebGLSampler: {
  148178. prototype: WebGLSampler;
  148179. new(): WebGLSampler;
  148180. };
  148181. interface WebGLSync extends WebGLObject {
  148182. }
  148183. declare var WebGLSync: {
  148184. prototype: WebGLSync;
  148185. new(): WebGLSync;
  148186. };
  148187. interface WebGLTransformFeedback extends WebGLObject {
  148188. }
  148189. declare var WebGLTransformFeedback: {
  148190. prototype: WebGLTransformFeedback;
  148191. new(): WebGLTransformFeedback;
  148192. };
  148193. interface WebGLVertexArrayObject extends WebGLObject {
  148194. }
  148195. declare var WebGLVertexArrayObject: {
  148196. prototype: WebGLVertexArrayObject;
  148197. new(): WebGLVertexArrayObject;
  148198. };
  148199. // Type definitions for WebVR API
  148200. // Project: https://w3c.github.io/webvr/
  148201. // Definitions by: six a <https://github.com/lostfictions>
  148202. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  148203. interface VRDisplay extends EventTarget {
  148204. /**
  148205. * Dictionary of capabilities describing the VRDisplay.
  148206. */
  148207. readonly capabilities: VRDisplayCapabilities;
  148208. /**
  148209. * z-depth defining the far plane of the eye view frustum
  148210. * enables mapping of values in the render target depth
  148211. * attachment to scene coordinates. Initially set to 10000.0.
  148212. */
  148213. depthFar: number;
  148214. /**
  148215. * z-depth defining the near plane of the eye view frustum
  148216. * enables mapping of values in the render target depth
  148217. * attachment to scene coordinates. Initially set to 0.01.
  148218. */
  148219. depthNear: number;
  148220. /**
  148221. * An identifier for this distinct VRDisplay. Used as an
  148222. * association point in the Gamepad API.
  148223. */
  148224. readonly displayId: number;
  148225. /**
  148226. * A display name, a user-readable name identifying it.
  148227. */
  148228. readonly displayName: string;
  148229. readonly isConnected: boolean;
  148230. readonly isPresenting: boolean;
  148231. /**
  148232. * If this VRDisplay supports room-scale experiences, the optional
  148233. * stage attribute contains details on the room-scale parameters.
  148234. */
  148235. readonly stageParameters: VRStageParameters | null;
  148236. /**
  148237. * Passing the value returned by `requestAnimationFrame` to
  148238. * `cancelAnimationFrame` will unregister the callback.
  148239. * @param handle Define the hanle of the request to cancel
  148240. */
  148241. cancelAnimationFrame(handle: number): void;
  148242. /**
  148243. * Stops presenting to the VRDisplay.
  148244. * @returns a promise to know when it stopped
  148245. */
  148246. exitPresent(): Promise<void>;
  148247. /**
  148248. * Return the current VREyeParameters for the given eye.
  148249. * @param whichEye Define the eye we want the parameter for
  148250. * @returns the eye parameters
  148251. */
  148252. getEyeParameters(whichEye: string): VREyeParameters;
  148253. /**
  148254. * Populates the passed VRFrameData with the information required to render
  148255. * the current frame.
  148256. * @param frameData Define the data structure to populate
  148257. * @returns true if ok otherwise false
  148258. */
  148259. getFrameData(frameData: VRFrameData): boolean;
  148260. /**
  148261. * Get the layers currently being presented.
  148262. * @returns the list of VR layers
  148263. */
  148264. getLayers(): VRLayer[];
  148265. /**
  148266. * Return a VRPose containing the future predicted pose of the VRDisplay
  148267. * when the current frame will be presented. The value returned will not
  148268. * change until JavaScript has returned control to the browser.
  148269. *
  148270. * The VRPose will contain the position, orientation, velocity,
  148271. * and acceleration of each of these properties.
  148272. * @returns the pose object
  148273. */
  148274. getPose(): VRPose;
  148275. /**
  148276. * Return the current instantaneous pose of the VRDisplay, with no
  148277. * prediction applied.
  148278. * @returns the current instantaneous pose
  148279. */
  148280. getImmediatePose(): VRPose;
  148281. /**
  148282. * The callback passed to `requestAnimationFrame` will be called
  148283. * any time a new frame should be rendered. When the VRDisplay is
  148284. * presenting the callback will be called at the native refresh
  148285. * rate of the HMD. When not presenting this function acts
  148286. * identically to how window.requestAnimationFrame acts. Content should
  148287. * make no assumptions of frame rate or vsync behavior as the HMD runs
  148288. * asynchronously from other displays and at differing refresh rates.
  148289. * @param callback Define the eaction to run next frame
  148290. * @returns the request handle it
  148291. */
  148292. requestAnimationFrame(callback: FrameRequestCallback): number;
  148293. /**
  148294. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  148295. * Repeat calls while already presenting will update the VRLayers being displayed.
  148296. * @param layers Define the list of layer to present
  148297. * @returns a promise to know when the request has been fulfilled
  148298. */
  148299. requestPresent(layers: VRLayer[]): Promise<void>;
  148300. /**
  148301. * Reset the pose for this display, treating its current position and
  148302. * orientation as the "origin/zero" values. VRPose.position,
  148303. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  148304. * updated when calling resetPose(). This should be called in only
  148305. * sitting-space experiences.
  148306. */
  148307. resetPose(): void;
  148308. /**
  148309. * The VRLayer provided to the VRDisplay will be captured and presented
  148310. * in the HMD. Calling this function has the same effect on the source
  148311. * canvas as any other operation that uses its source image, and canvases
  148312. * created without preserveDrawingBuffer set to true will be cleared.
  148313. * @param pose Define the pose to submit
  148314. */
  148315. submitFrame(pose?: VRPose): void;
  148316. }
  148317. declare var VRDisplay: {
  148318. prototype: VRDisplay;
  148319. new(): VRDisplay;
  148320. };
  148321. interface VRLayer {
  148322. leftBounds?: number[] | Float32Array | null;
  148323. rightBounds?: number[] | Float32Array | null;
  148324. source?: HTMLCanvasElement | null;
  148325. }
  148326. interface VRDisplayCapabilities {
  148327. readonly canPresent: boolean;
  148328. readonly hasExternalDisplay: boolean;
  148329. readonly hasOrientation: boolean;
  148330. readonly hasPosition: boolean;
  148331. readonly maxLayers: number;
  148332. }
  148333. interface VREyeParameters {
  148334. /** @deprecated */
  148335. readonly fieldOfView: VRFieldOfView;
  148336. readonly offset: Float32Array;
  148337. readonly renderHeight: number;
  148338. readonly renderWidth: number;
  148339. }
  148340. interface VRFieldOfView {
  148341. readonly downDegrees: number;
  148342. readonly leftDegrees: number;
  148343. readonly rightDegrees: number;
  148344. readonly upDegrees: number;
  148345. }
  148346. interface VRFrameData {
  148347. readonly leftProjectionMatrix: Float32Array;
  148348. readonly leftViewMatrix: Float32Array;
  148349. readonly pose: VRPose;
  148350. readonly rightProjectionMatrix: Float32Array;
  148351. readonly rightViewMatrix: Float32Array;
  148352. readonly timestamp: number;
  148353. }
  148354. interface VRPose {
  148355. readonly angularAcceleration: Float32Array | null;
  148356. readonly angularVelocity: Float32Array | null;
  148357. readonly linearAcceleration: Float32Array | null;
  148358. readonly linearVelocity: Float32Array | null;
  148359. readonly orientation: Float32Array | null;
  148360. readonly position: Float32Array | null;
  148361. readonly timestamp: number;
  148362. }
  148363. interface VRStageParameters {
  148364. sittingToStandingTransform?: Float32Array;
  148365. sizeX?: number;
  148366. sizeY?: number;
  148367. }
  148368. interface Navigator {
  148369. getVRDisplays(): Promise<VRDisplay[]>;
  148370. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  148371. }
  148372. interface Window {
  148373. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  148374. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  148375. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  148376. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  148377. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  148378. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  148379. }
  148380. interface Gamepad {
  148381. readonly displayId: number;
  148382. }
  148383. type XRSessionMode =
  148384. | "inline"
  148385. | "immersive-vr"
  148386. | "immersive-ar";
  148387. type XRReferenceSpaceType =
  148388. | "viewer"
  148389. | "local"
  148390. | "local-floor"
  148391. | "bounded-floor"
  148392. | "unbounded";
  148393. type XREnvironmentBlendMode =
  148394. | "opaque"
  148395. | "additive"
  148396. | "alpha-blend";
  148397. type XRVisibilityState =
  148398. | "visible"
  148399. | "visible-blurred"
  148400. | "hidden";
  148401. type XRHandedness =
  148402. | "none"
  148403. | "left"
  148404. | "right";
  148405. type XRTargetRayMode =
  148406. | "gaze"
  148407. | "tracked-pointer"
  148408. | "screen";
  148409. type XREye =
  148410. | "none"
  148411. | "left"
  148412. | "right";
  148413. type XREventType =
  148414. | "devicechange"
  148415. | "visibilitychange"
  148416. | "end"
  148417. | "inputsourceschange"
  148418. | "select"
  148419. | "selectstart"
  148420. | "selectend"
  148421. | "squeeze"
  148422. | "squeezestart"
  148423. | "squeezeend"
  148424. | "reset";
  148425. interface XRSpace extends EventTarget {
  148426. }
  148427. interface XRRenderState {
  148428. depthNear?: number;
  148429. depthFar?: number;
  148430. inlineVerticalFieldOfView?: number;
  148431. baseLayer?: XRWebGLLayer;
  148432. }
  148433. interface XRInputSource {
  148434. handedness: XRHandedness;
  148435. targetRayMode: XRTargetRayMode;
  148436. targetRaySpace: XRSpace;
  148437. gripSpace: XRSpace | undefined;
  148438. gamepad: Gamepad | undefined;
  148439. profiles: Array<string>;
  148440. }
  148441. interface XRSessionInit {
  148442. optionalFeatures?: string[];
  148443. requiredFeatures?: string[];
  148444. }
  148445. interface XRSession extends XRAnchorCreator {
  148446. addEventListener: Function;
  148447. removeEventListener: Function;
  148448. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  148449. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  148450. requestAnimationFrame: Function;
  148451. end(): Promise<void>;
  148452. renderState: XRRenderState;
  148453. inputSources: Array<XRInputSource>;
  148454. // hit test
  148455. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  148456. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  148457. // legacy AR hit test
  148458. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  148459. // legacy plane detection
  148460. updateWorldTrackingState(options: {
  148461. planeDetectionState?: { enabled: boolean; }
  148462. }): void;
  148463. }
  148464. interface XRReferenceSpace extends XRSpace {
  148465. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  148466. onreset: any;
  148467. }
  148468. type XRPlaneSet = Set<XRPlane>;
  148469. type XRAnchorSet = Set<XRAnchor>;
  148470. interface XRFrame {
  148471. session: XRSession;
  148472. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  148473. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  148474. // AR
  148475. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  148476. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  148477. // Anchors
  148478. trackedAnchors?: XRAnchorSet;
  148479. // Planes
  148480. worldInformation: {
  148481. detectedPlanes?: XRPlaneSet;
  148482. };
  148483. }
  148484. interface XRViewerPose extends XRPose {
  148485. views: Array<XRView>;
  148486. }
  148487. interface XRPose {
  148488. transform: XRRigidTransform;
  148489. emulatedPosition: boolean;
  148490. }
  148491. interface XRWebGLLayerOptions {
  148492. antialias?: boolean;
  148493. depth?: boolean;
  148494. stencil?: boolean;
  148495. alpha?: boolean;
  148496. multiview?: boolean;
  148497. framebufferScaleFactor?: number;
  148498. }
  148499. declare var XRWebGLLayer: {
  148500. prototype: XRWebGLLayer;
  148501. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  148502. };
  148503. interface XRWebGLLayer {
  148504. framebuffer: WebGLFramebuffer;
  148505. framebufferWidth: number;
  148506. framebufferHeight: number;
  148507. getViewport: Function;
  148508. }
  148509. declare class XRRigidTransform {
  148510. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  148511. position: DOMPointReadOnly;
  148512. orientation: DOMPointReadOnly;
  148513. matrix: Float32Array;
  148514. inverse: XRRigidTransform;
  148515. }
  148516. interface XRView {
  148517. eye: XREye;
  148518. projectionMatrix: Float32Array;
  148519. transform: XRRigidTransform;
  148520. }
  148521. interface XRInputSourceChangeEvent {
  148522. session: XRSession;
  148523. removed: Array<XRInputSource>;
  148524. added: Array<XRInputSource>;
  148525. }
  148526. interface XRInputSourceEvent extends Event {
  148527. readonly frame: XRFrame;
  148528. readonly inputSource: XRInputSource;
  148529. }
  148530. // Experimental(er) features
  148531. declare class XRRay {
  148532. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  148533. origin: DOMPointReadOnly;
  148534. direction: DOMPointReadOnly;
  148535. matrix: Float32Array;
  148536. }
  148537. declare enum XRHitTestTrackableType {
  148538. "point",
  148539. "plane"
  148540. }
  148541. interface XRHitResult {
  148542. hitMatrix: Float32Array;
  148543. }
  148544. interface XRTransientInputHitTestResult {
  148545. readonly inputSource: XRInputSource;
  148546. readonly results: Array<XRHitTestResult>;
  148547. }
  148548. interface XRHitTestResult {
  148549. getPose(baseSpace: XRSpace): XRPose | undefined;
  148550. }
  148551. interface XRHitTestSource {
  148552. cancel(): void;
  148553. }
  148554. interface XRTransientInputHitTestSource {
  148555. cancel(): void;
  148556. }
  148557. interface XRHitTestOptionsInit {
  148558. space: XRSpace;
  148559. entityTypes?: Array<XRHitTestTrackableType>;
  148560. offsetRay?: XRRay;
  148561. }
  148562. interface XRTransientInputHitTestOptionsInit {
  148563. profile: string;
  148564. entityTypes?: Array<XRHitTestTrackableType>;
  148565. offsetRay?: XRRay;
  148566. }
  148567. interface XRAnchor {
  148568. // remove?
  148569. id?: string;
  148570. anchorSpace: XRSpace;
  148571. lastChangedTime: number;
  148572. detach(): void;
  148573. }
  148574. interface XRPlane extends XRAnchorCreator {
  148575. orientation: "Horizontal" | "Vertical";
  148576. planeSpace: XRSpace;
  148577. polygon: Array<DOMPointReadOnly>;
  148578. lastChangedTime: number;
  148579. }
  148580. interface XRAnchorCreator {
  148581. // AR Anchors
  148582. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  148583. }